A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/madeinfree/immutable-js-tools below:

madeinfree/immutable-js-tools: util tools for immutable.js

Test Version 0.0.5

npm install --save immutable-js-tools

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.

import Im from 'immutable';
import ImUtil from './src/';
const obj = {
  items: [
    {
      id: 1,
      item: 'bar'
    }
  ],
  selected: []
}
const _D = new ImUtil(Im.fromJS(obj));
let _O;
/*
 * basic to getIn key
 */
_O = _D.getIn(['items', 0]); // Map { "id": 1, "item": "bar" }

/*
 * addList(cursor, value);
 * handle add list method
 */
_O = _D.addList(['selected'], 'foo'); // Map { "items": List [ Map { "id": 1, "item": "bar" } ], "selected": List [ "foo" ] }

/*
 * reverse(cursor);
 * reverse the boolean
 */
_O = _D.addList(['selected'], true); // Map { "items": List [ Map { "id": 1, "item": "bar" } ], "selected": List [ "foo", true ] }
_O = _D.reverse(['selected', 1]); // Map { "items": List [ Map { "id": 1, "item": "bar" } ], "selected": List [ "foo", false ] }

/*
 * auto bind Functions of Sugar
 * selected => getSelected();
 */
console.log(_O.getSelected()); // List [ "foo", false ]

Immutable.js document

- basic validation: static method - auto bind Functions of Sugar method helper
const _D = new ImUtil(Im.fromJS(obj));
const obj = {
  items: [
    {
      id: 1,
      item: 'bar'
    }
  ],
  selected: [1, 2, 3]
}
//Functions of Sugar
console.log(_D.getItems().toJS()); // => [ { id: 1, item: 'bar' } ]
console.log(_D.getSelected().toJS()); // => [1, 2, 3]

MIT


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4