@axtk/memory-storage
v1.0.3
Published
An in-memory storage with a customizable capacity and with a localStorage-like API
Downloads
6
Maintainers
Readme
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.