@storagebus/memory
v1.0.0
Published
[](https://www.npmjs.com/package/@storagebus/memory) [](https://opensource.org/licenses/MIT)
Readme
@storagebus/memory
In-memory Adapter for StorageBus.
Installation
npm install @storagebus/storage @storagebus/memory
pnpm add @storagebus/storage @storagebus/memory
yarn add @storagebus/storage @storagebus/memoryUsage
import { createAdapter } from '@storagebus/memory'
import { Storage } from '@storagebus/storage'
const storage = new Storage(createAdapter())
const objectKey = await storage.write('notes/hello.txt', 'Hello, world!')
const file = await storage.file(objectKey)
console.log(await file.text())
console.log(file.size)
console.log(file.lastModified)
await storage.write(objectKey, null)API
createAdapter() creates an isolated in-memory Adapter. Each Adapter instance has its own in-memory Storage Backend.
Storage options such as debug, logger, and sanitizeKey are passed to new Storage(adapter, options) from @storagebus/storage.
Migration to v1
Before v1:
import { createStorage } from '@storagebus/storage/memory'
const storage = createStorage()In v1:
import { createAdapter } from '@storagebus/memory'
import { Storage } from '@storagebus/storage'
const storage = new Storage(createAdapter())License
MIT
