TBD
Usage
create
; const store = ; console /*{ user: { name: 'Yevhenii', skills: ['HTML', 'JS'], family: { mother: 'mom', father: 'dad' } }}*/
set
; const store = ; // {} const nextStore = store; // { key: { value: 3 } } store === nextStore // false const store2 = ;const nextStore2 = store2 // { ley: 1 } // { ley: 1, key2: 2 } ; // { ley: 1, key2: 2, key3: 3 }
setIn
; const store = ; // {} /*String or array could be used as a path.All numbers in path will be interpreted as a array indexes.*/ const pathAsAString = 'some.like.string';const nextStore = store; // { some: { like: { string: 1 } } } const pathAsArray = 'some' 'like' 'string';const nextStore2 = store; // { some: { like: { string: 1 } } } const pathWithNumbers = 'some' 1 'string';const nextStore3 = store; // { some: [undefined, { string: 1 }] } const pathWithNumbers2 = 'some.0.string';const nextStore3 = store; // { some: [{ string: 1 }] }
get / getInOr
; const store = ; // {} const nextStore = store ; // { user: { name: 'Yevhenii', age: 26, skills: ['HTML'] } } const user = nextStore; // { name: 'Yevhenii', age: 26, skills: ['HTML'] } /*String or array could be used as a path.All numbers in path will be interpreted as a array indexes.*/ // you can use either string or array as a pathconst name = nextStore; // Yevheniiconst name2 = nextStore; // Yevhenii // return either undefined or default value const surname = nextStore; // undefinedconst surnameWithDefault = nextStore; // Hurynets // getting value from array by indexconst firstSkill = nextStore; // HTML
merge
; const store = ; // { surname: 'Hurynets' }const data = user: name: 'Yevhenii' skills: 'HTML' 'JS' const nextStore = store console /*{ surname: 'Hurynets', user: { name: 'Yevhenii', skills: ['HTML', 'JS'] }}*/ const store2 = ; // recursively merge same propertiesconst nextStore2 = ; console /*{ user: { name: 'Yevhenii Hurynets', skills: ['HTML', 'JS', 'CSS'], family: { mother: 'mom', father: 'dad', brother: 'bro' } }}*/