immutable-short-string-notation

2.1.2 • Public • Published

immutable-short-string-notation

Allows you to set paths directly in strings instead of passing arrays

How to use

The requirement must appear in the app before other immutable actions (a good idea would be to place in the root of the app if uncertain)

require('immutable-short-string-notation');

Somewhere else in the application you may use the string syntax

state.setIn('a.b.c.d.e', 42);
state.getIn('a.b.c.d.e'); // 42
 
// All other ways still work
state.setIn('a.b.c.d.e'.split('.'), 42);
state.setIn(['a', 'b', 'c', 'd', 'e'], 42);
state.getIn('a.b.c.d.e'); // still 42

Why ?

because writing state.getIn(['node1', 'node23', 'node67']) could be shorter and state.getIn('node1.node23.node67'.split('.')) feel wrong when it's been repeaded a tousand times

so let's just remove the split as anyway we are sure we want to pass an array here

Installation (available on npm)

npm install --save immutable-short-string-notation

or

yarn add immutable-short-string-notation --save

/immutable-short-string-notation/

    Package Sidebar

    Install

    npm i immutable-short-string-notation

    Weekly Downloads

    1

    Version

    2.1.2

    License

    MIT

    Last publish

    Collaborators

    • zeachco