@hrimsoft/state-store

1.1.0 • Public • Published

state-store.js

GitHub npm npm

This is a centralized object store that works in the browser and nodejs.

installing

npm install @hrimsoft/state-store --save or yarn add @hrimsoft/state-store

usage

Putting value into the storage:

import stateStore from '@hrimsoft/state-store';

stateStore.register('key', 10);

Getting value from the storage

import stateStore from '@hrimsoft/state-store';

// getting a value by key
let value = stateStore.resolve('key');

// setting a new  a value in the store
stateStore.register('key', value + 1);

Optimizations

To make searching process faster use period-separated delimeter in the key. The storage is optimized by using a tree structure to store objects. Key splits by a period '.' on parts and each part becomes a node of the tree structure; therefore, the complexity of searching algorithm becomes O(Log(n)).

Readme

Keywords

none

Package Sidebar

Install

npm i @hrimsoft/state-store

Weekly Downloads

1

Version

1.1.0

License

MIT

Unpacked Size

23.8 kB

Total Files

11

Last publish

Collaborators

  • basim-hrimsoft