1.2.1 • Published 6 years ago

normalize-list v1.2.1

Weekly downloads
1
License
MIT
Repository
-
Last release
6 years ago

Normalize-List

Allows you convert array to normalized object with keys of specified field and back to array About normalized state : http://redux.js.org/docs/recipes/reducers/NormalizingStateShape.html

Normalize

    const {normalize}=require("normalize-list")
    ...
    // array = [ { id : 1 , value : 1 }, { id : 2 , value : 2 } ]
    const object=normalize(array,"id")// object = { '1' : { id : 1 , value : 1 } , '2' : { id : 2 , value : 2 } }
    // -> use in state 

Denormalize

    const {denormalize}=require("normalize-list")
    ...
    // normalizedObject = { '1' : { id : 1 , value : 1 } , '2' : { id : 2 , value : 2 } }
    const array=denormalize(normalizedObject)// array = [ { id : 1 , value : 1 }, { id : 2 , value : 2 } ]
    // -> list items / make a request
1.2.1

6 years ago

1.1.1

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago