@axtk/memory-storage

1.0.3 • Public • Published

npm browser node

An in-memory storage with a customizable capacity and with a localStorage-like API

class MemoryStorage

const MemoryStorage = require('@axtk/memory-storage');

const storage = new MemoryStorage(10);

storage.setItem('x', 1);

let x = storage.getItem('x');

new MemoryStorage(capacity?)

Creates an in-memory storage instance with the given capacity.

  • capacity?: number
    • A maximum number of entries to be stored. When the number of entries reaches this value adding a new entry to the storage will cause the first added entry to be removed from the storage to maintain the capacity.
    • Default: Infinity.

The methods of the MemoryStorage class are in line with the Storage interface.

Package Sidebar

Install

npm i @axtk/memory-storage

Weekly Downloads

0

Version

1.0.3

License

MIT

Unpacked Size

4.89 kB

Total Files

4

Last publish

Collaborators

  • axtk