Denzel
======

[![npm version](https://badge.fury.io/js/denzel.svg)](https://badge.fury.io/js/denzel) [![Build Status](https://travis-ci.org/JustinBeaudry/denzel.svg?branch=master)](https://travis-ci.org/JustinBeaudry/denzel) [![Coverage Status](https://coveralls.io/repos/github/JustinBeaudry/denzel/badge.svg?branch=master)](https://coveralls.io/github/JustinBeaudry/denzel?branch=master) [![Maintainability](https://api.codeclimate.com/v1/badges/8573b69add63f7c41c66/maintainability)](https://codeclimate.com/github/JustinBeaudry/denzel/maintainability)

Share Data Representations (Models, Collections) between Node and the Browser

Read the [DOCS](https://justinbeaudry.github.io/denzel/)

![Denzel](https://media.giphy.com/media/VJ2B0I6t2HEUE/giphy.gif)

## Why?

Denzel is a toolkit for consistency with the representations of your data between Browsers and Node Servers. It provides methods for creating these
representations and for indexing these representations.

## Installation

Denzel is available via `npm` for Node, and `bower` for the Browser

### Node
```shell
npm i -S denzel
```

### Browser
Denzel has 3 bundles for your convenience:

#### Minified
```javascript
const {Model, Collection, Enum} = require('denzel/dist/denzel.min.js');
```

#### Un-minified
```javascript
const {Model, Collection, Enum} = require('denzel/dist/denzel.js');
```

#### CommonJS
```javascript
const {Model, Collection, Enum} = require('denzel/dist/denzel.cjs.js');
```

You can install denzel via bower with:
```shell
bower install denzel
```

## Usage

Read the [DOCS](https://justinbeaudry.github.io/denzel/)

### Using in Redux

Classes as state really don't play too well with redux. SEE: [Why Not to Store Objects In Redux](https://medium.com/collaborne-engineering/why-not-to-store-objects-in-redux-7f41243020fc) 

### In ReactRedux/Vuex
```javascript
  // inside a reducer
  switch(action.type) {
    case 'LOAD_USERS': {
      return new PersonCollection(action.users, User).toArray(); 
    }
    default: {
      return state
    }
  }
``` 
