rl-store
TypeScript icon, indicating that this package has built-in type declarations

0.1.1 • Public • Published

rl-store

A map which be limited size of storage for catching.

Rin&Len store.

const RlStroe = require('rl-store');

const store = new RlStroe(1000); // Limite the store only retain 1000 length of string.

// to test the key exist
'key0' in store.data
// or
store.has('key0')

// to set
store.data['key1'] = 'value1';
store.dispatch('set', {key: 'key1'});
// or
store.set('key1', 'value1')

// to get
let value1 = store.data['key2'];
store.dispatch('get', {key: 'key2'});
// or
store.get('key2')

// to remove a key maunally
store.delete('key1');

And, you can extend RLStore to get the event when store be called into get(), set() and delete().

const RlStroe = require('rl-store');

class MyRlStroe extends RlStroe {
    onGet(payload :any){
        console.log('got!');
        super.onGet(payload);
    }
}

Readme

Keywords

none

Package Sidebar

Install

npm i rl-store

Weekly Downloads

2

Version

0.1.1

License

MPL-2.0

Unpacked Size

8.9 kB

Total Files

7

Last publish

Collaborators

  • pea3nut