# model-chainify

> Converts a bunch of functions into a method-chainable calss with a shared data model.

Latest version **0.1.1** (published 2015-12-23) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install model-chainify
pnpm add model-chainify
yarn add model-chainify
bun add model-chainify
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.1.1 |
| Published | 2015-12-23 |
| First published | 2015-12-23 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Amobiz |
| Maintainers | amobiz |
| Keywords | model, data centric, data model, class, classify, mixin, mix-in, chain, chainable |

## Links

- npm: https://www.npmjs.com/package/model-chainify
- npm.io page: https://npm.io/package/model-chainify

## Recent versions

- 0.1.1 (latest) — 2015-12-23
- 0.1.0 — 2015-12-23

## README

# model-chainify

Converts a bunch of functions into a method-chainable calss with a shared data model.

## Install
``` bash
$ npm install model-chainify
```

## API

### `chainify(functions ...)`
Converts a bunch of functions into a method-chainable calss with a shared data model.

#### Context
Don't care.
#### Parameters
##### `functions/mix-ins`
Any number of named functions or objects with methods.
Note that functions can't be anonymous or will throw Error.
All functions must take first argument as a data model object (or so called "[object-based](https://en.wikipedia.org/wiki/Object-based_language)" functions) and return a (new) data model object.
#### Returns
A constructor with signature `function (model)`. That can be invoked with `new` operator to create an object with given model object. Objects created via the contructor owns all the mix-in functions plus a `get()` method that returns the shared data model object.
#### Example

Pass named functions:
``` javascript
var _ = require('lodash');
var chainify = require('model-chainify');
var Collection = chainify(_.flatten, _.uniq, _.sortBy);
var collection = new Collection([1, 2, [4, 3, 2]]);
collection.flatten().uniq().sortBy().get(); // => [1, 2, 3, 4]
```

Pass mix-ins Object:
``` javascript
var _ = require('lodash');
var chainify = require('model-chainify');
var Collection = chainify({
	flatten: _.flatten,
	unique: _.uniq,
	sort: _.sortBy
});
var collection = new Collection([1, 2, [4, 3, 2]]);
collection.flatten().unique().sort().get(); // => [1, 2, 3, 4]
```

## Test
``` baseh
$ npm test
```

## License
MIT

## Author
[Amobiz](https://github.com/amobiz)

---
_Source: https://npm.io/package/model-chainify · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
