@tinysorcerer/tinyjson
v0.1.0
Published
State database without dependencies.
Downloads
10
Readme
TinyJson
State database without dependencies.
How to
Setup
Import class
import TinyJson from './path/to';
Or
import TinyJson from '@tinysorcerer/tinyjson';
Use
The class makes push
, pop
, and update
available to interact with the object.
const t = new TinyJson();
t.push({ value: true });
t.push({ value: false });
t.push({ value: 'lorem' });
/**
* Initial Value:
* [
* { value: true, _id: "dyt-ezpzg" },
* { value: false, _id: "gek-xyyxp" },
* { value: "lorem", _id: "eei-vfsmi" }
* ]
*/
t.pop('gek-xyyxp');
/**
* Remove 2nd Entry:
* [
* { value: true, _id: "dyt-ezpzg" },
* { value: "lorem", _id: "eei-vfsmi" }
* ]
*/
t.update('eei-vfsmi', { value: false });
/**
* Update Last Entry:
* [
* { value: true, _id: "dyt-ezpzg" },
* { value: false, _id: "eei-vfsmi" }
* ]
*/
console.log(t.find('dyt-ezpzg'));
/**
* Find 1st Entry:
* [
* { value: true, _id: 'dyt-ezpzg' }
* ]
*/
console.log(t.get);
/**
* Final Value: [{"value":true,"_id":"dyt-ezpzg"},{"value":false,"_id":"eei-vfsmi"}]
*/
yarn test
to see this in action.