Immutable Js Tools
Installation
Test Version 0.0.5
npm install --save immutable-js-tools
What Is Immutable Js ?
if you are in the beginning with immutable, you have to go here to understanding it.
What Is Immutable Js Tools ?
Do you always diving in immutable hell ? This maybe help you to use it clearly.
- only use the
setIn
andgetIn
cursor with this tools.
Quick Start
;;const obj = items: id: 1 item: 'bar' selected: const _D = Im;let _O;/* * basic to getIn key */_O = _D; // Map { "id": 1, "item": "bar" } /* * addList(cursor, value); * handle add list method */_O = _D; // Map { "items": List [ Map { "id": 1, "item": "bar" } ], "selected": List [ "foo" ] } /* * reverse(cursor); * reverse the boolean */_O = _D; // Map { "items": List [ Map { "id": 1, "item": "bar" } ], "selected": List [ "foo", true ] }_O = _D; // Map { "items": List [ Map { "id": 1, "item": "bar" } ], "selected": List [ "foo", false ] } /* * auto bind Functions of Sugar * selected => getSelected(); */console; // List [ "foo", false ]
Document
API
- Immutable.Map
- setEmptyMap(cursor)
- mergeInMap(cursor, data)
- Immutable.List
- addList(cursor, value)
- removeList(cursor, index)
- clearList(cursor - will rename to setEmptyList, version 1.0.0)
- setEmptyList() or setEmptyList(cursor)
- Immutable.Set
- clearSet(cursor)
- little helper
- reverse(cursor)
- basic getter & setter
- getIn(cursor)
- setIn(cursor, data)
- hasIn(cursor)
- getJS(cursor)
- basic validation: static method
- isMap
- isList
- auto bind Functions of Sugar method helper
const _D = Im;const obj = items: id: 1 item: 'bar' selected: 1 2 3//Functions of Sugarconsole; // => [ { id: 1, item: 'bar' } ]console; // => [1, 2, 3]
TODO
- To support much method
- Documentation
License
MIT