0.1.5 • Published 5 years ago

@higherorder/shinju v0.1.5

Weekly downloads
-
License
MIT
Repository
github
Last release
5 years ago

Shinju

Helps in maintaining and manipulating your application State

Build Status Coverage Status

Examples

import Shinju from '@higherorder/shinju';

const MutableTree = Shinju();
MutableTree.add(35, 'rollNo');
console.log(MutableTree.getTree().get('rollNo')); //=> 35;
import Shinju from '@higherorder/shinju';

const ImmutableTree = Shinju();

const NewTree = ImmutableTree.addChain(35, 'rollNo').addChain(
  500023356,
  'sapId',
);
console.log(NewTree.getTree()); //=> { sapId: 500023356, rollNo: 35 }
console.log(ImmutableTree.getTree()); //=> {}

Available Functions

  • add
import Shinju from '@higherorder/shinju';

const StateTree = Shinju();
StateTree.add(35, 'rollno');
  • get
StateTree.get('rollno'); //=> 35
  • getTree
StateTree.getTree(); //=> { rollno: 35 }
  • subscribe
StateTree.subscribe(_ => console.log(StateTree.getTree()));

StateTree.add('Rajat Sharma', 'name');
//=> { rollNo: 35, name:'Rajat Sharma' }
  • addChain
const NewStateTree = StateTree.addChain(500023356, 'sapId')
  .addChain('CSEOG', 'branch')
  .getTree(''); //=> { rollno: 35, sapId: '50023356', branch: 'CSEOG' }

Install

npm version