import { ensureRxStorageInstanceParamsAreCorrect } from 'nxdb-old/src/rx-storage-helper'; import type { RxStorageInstanceCreationParams } from 'nxdb-old/src/types'; import type { RxStorageMemory, RxStorageMemoryInstanceCreationOptions, RxStorageMemorySettings } from 'nxdb-old/src/plugins/storage-memory/memory-types'; import { createMemoryStorageInstance, RxStorageInstanceMemory } from 'nxdb-old/src/plugins/storage-memory/rx-storage-instance-memory'; import { RxStorageDefaultStatics } from 'nxdb-old/src/rx-storage-statics'; /** * Keep the state even when the storage instance is closed. * This makes it easier to use the memory storage * to test filesystem-like and multiInstance behaviors. */ const COLLECTION_STATES = new Map(); export function getRxStorageMemory( settings: RxStorageMemorySettings = {} ): RxStorageMemory { const storage: RxStorageMemory = { name: 'memory', statics: RxStorageDefaultStatics, collectionStates: COLLECTION_STATES, createStorageInstance( params: RxStorageInstanceCreationParams ): Promise> { ensureRxStorageInstanceParamsAreCorrect(params); const useSettings = Object.assign( {}, settings, params.options ); return createMemoryStorageInstance(this, params, useSettings); } }; return storage; } export * from 'nxdb-old/src/plugins/storage-memory/memory-helper'; export * from 'nxdb-old/src/plugins/storage-memory/binary-search-bounds'; export * from 'nxdb-old/src/plugins/storage-memory/memory-types'; export * from 'nxdb-old/src/plugins/storage-memory/memory-indexes'; export * from 'nxdb-old/src/plugins/storage-memory/rx-storage-instance-memory';