Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/emersonlaurentino/simple-redux-normalizr

:space_invader: Normalizes and denormalizes Arrays for Redux
https://github.com/emersonlaurentino/simple-redux-normalizr

api denormalize flux json normalize normalizr redux

Last synced: 11 days ago
JSON representation

:space_invader: Normalizes and denormalizes Arrays for Redux

Awesome Lists containing this project

README

        

# simple-redux-normalizr

## Get Started
```
npm install simple-redux-normalizr --save
```

## Example

```js
import { normalize, denormalize, getItem } from 'simple-redux-normalizr';

const arr = [
{ id: '32o8wafe', name: 'mark', company: 'facebook' },
{ id: 'oaiwefjo', name: 'musk', company: 'tesla' },
{ id: '3oij2e3c', name: 'jobs', company: 'apple' },
];

// {32o8wafe: Object, oaiwefjo: Object, 3oij2e3c: Object}
const normalized = normalize(arr, 'id');

// [Object, Object, Object]
const denormalized = denormalize(normalized);

// {id: "oaiwefjo", name: "musk", company: "tesla"}
const getFullObj = getItem(normalized, 'oaiwefjo');

// tesla
const getItemOfObj = getItem(normalized, 'oaiwefjo', 'company');
```