import { comlink } from '@neo-one/worker' ; import PouchDB from 'pouchdb' ; import { PouchDBFileSystem , PouchDBFileSystemDoc } from './PouchDBFileSystem' ; import { workerPouch } from './worker/workerPouch' ; ( PouchDB as any ) . adapter ( 'worker' , workerPouch ) ; export const createEndpointPouchDB = < Doc extends { } > ( dbID , endpoint ) => { const db = new PouchDB < Doc > ( dbID , { adapter : 'worker' , endpoint : ( ) => endpoint } as any ) ; db . setMaxListeners ( 20 ) ; return db ; } ; export const createPouchDBFileSystem = async ( dbID , endpoint ) : Promise < PouchDBFileSystem > => PouchDBFileSystem . create ( createEndpointPouchDB < PouchDBFileSystemDoc > ( dbID , endpoint ) ) ;