foop
Version:
interfaces that describe their intentions.
149 lines (128 loc) ⢠7.55 kB
Markdown
# ā chain-able
[![NPM version][chain-able-npm-image]][chain-able-npm-url]
[](https://github.com/fluents/chain-able/wiki)
[![Dependencies][david-deps-img]][david-deps-url]
[![fliphub][gitter-badge]][gitter-url]
[](https://travis-ci.org/fluents/awesome-fluents)
[](https://coveralls.io/github/fluents/chain-able?branch=master)
[](https://www.codacy.com/app/aretecode/chain-able?utm_source=github.com&utm_medium=referral&utm_content=fluents/chain-able&utm_campaign=Badge_Grade)
[](https://unpkg.com/chain-able@4.0.6)
[](https://github.com/fluents/awesome-fluents)
[](https://aretecode.github.io/chain-able-playground/)
[david-deps-img]: https://img.shields.io/badge/0-dependencies-blue.svg
[david-deps-url]: https://david-dm.org/fluents/chain-able
[chain-able-npm-image]: https://img.shields.io/npm/v/chain-able.svg
[chain-able-npm-url]: https://npmjs.org/package/chain-able
[license-image]: http://img.shields.io/badge/license-MIT-blue.svg?style=flat
[license-url]: https://spdx.org/licenses/MIT
[gitter-badge]: https://img.shields.io/gitter/room/fliphub/pink.svg
[gitter-url]: https://gitter.im/fliphub/Lobby
[wiki]: https://github.com/fluents/chain-able/wiki
[deps]: https://github.com/fluents/chain-able/wiki/deps
[parent]: https://github.com/fluents/chain-able/wiki/parent
[analogy]: https://github.com/fluents/chain-able/wiki/analogy
[Observe]: https://github.com/fluents/chain-able/wiki/Observe
[DotProp]: https://github.com/fluents/chain-able/wiki/DotProp
[Schema]: https://github.com/fluents/chain-able/wiki/Schema
[Transform]: https://github.com/fluents/chain-able/wiki/Transform
[Shorthand]: https://github.com/fluents/chain-able/wiki/Shorthand
[API]: https://github.com/fluents/chain-able/wiki/api
[compose]: https://github.com/fluents/chain-able/wiki/Compose
[Chainable]: https://github.com/fluents/chain-able/wiki/Chainable
[ChainedMap]: https://github.com/fluents/chain-able/wiki/ChainedMap
[ChainedSet]: https://github.com/fluents/chain-able/wiki/ChainedSet
[FactoryChain]: https://github.com/fluents/chain-able/wiki/FactoryChain
[MergeChain]: https://github.com/fluents/chain-able/wiki/MergeChain
[MethodChain]: https://github.com/fluents/chain-able/wiki/MethodChain
[TraverseChain]: https://github.com/fluents/chain-able/wiki/TraverseChain
[CHANGELOG]: https://github.com/fluents/chain-able/blob/master/docs/CHANGELOG.md
[Snippet]: https://github.com/fluents/chain-able/wiki/Snippet
[Examples]: https://github.com/fluents/chain-able/wiki/Examples
[ExamplesPrimitives]: https://github.com/fluents/chain-able/wiki/Primitives
[ExamplesLocalStorage]: https://github.com/fluents/chain-able/wiki/LocalStorage
[ExamplesExpressive]: https://github.com/fluents/chain-able/wiki/LocalStorage
[ExamplesComparison]: https://github.com/fluents/chain-able/wiki/Comparison
[ExamplesIteratable]: https://github.com/fluents/chain-able/wiki/Iteratable
[TypeDefs]: https://github.com/fluents/chain-able/tree/master/typings
[Tests]: https://github.com/fluents/chain-able/tree/master/test
[Src]: https://github.com/fluents/chain-able/tree/master/src
[map]: https://ponyfoo.com/articles/es6-maps-in-depth
[set]: https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Set
[cov]: https://coveralls.io/github/fluents/chain-able?branch=master
> interfaces that describe their intentions
ā chain-able now has a website!
[š chain-able.js.org](https://chain-able.js.org)
### š¦ install
```bash
yarn add chain-able
npm i chain-able --save
```
#### cdn
- _dev_ `<script src="https://unpkg.com/chain-able@beta/dists/dev/index.js"></script>`
- _min_ `<script src="https://unpkg.com/chain-able@beta/dists/umd/index.js"></script>`
# š° benefits
writing an api using chain-able means:
- write **1** api
- get **3** apis as a result!
- š persistable, rehydratable, & transferrable configurations
- ā fluent/chainable api
- š¦ vanilla object syntax
# š features
- [expressive, clearly communicative code][wiki]
- [runtime type validation][Schema]
- [š¬ 300+ tests][Tests] with [96%+ code coverage][cov]
- ā” [performant & tiny][Src] `~8kb` _(gzip)_ [_300 byte_ minimal version available as snippet][snippet]
<details><summary><em><b>more...</b></em></summary>
- [š api][API]
- [ā Chainable][Chainable]
- [šŗ ChainedMap][ChainedMap]
- [š¢ ChainedSet][ChainedSet]
- [š“ extends Map & Set, same transparent api][map]
- [š£ symbols to make usage even easier][Chainable]
- [š iteratable][ExamplesIteratable]
- [š£ expressive][ExamplesExpressive]
- [š¾ makes solving complex problems simple][Examples]
- [š seamless native integration][ExamplesPrimitives]
- [š¼ compose & decorate][compose]
- [š observe with Wildcard/Glob, RegExp, Functions][Observe]
- [š¤ transform][Transform]
- [šµ debug][Shorthand]
- [š£ traverse **any** data][TraverseChain]
- [āļø fast deepEquals][Transform]
- [šŗ remap][Transform]
- [š tap][ChainedMap]
- [š toggleable dot.prop][DotProp]
- [š shorthands, wrap, return, setIfEmpty][Shorthand]
- [š types, schemas, validation][Schema]
- [š method builder][MethodChain]
- [`onCall`][MethodChain]
- [`onSet`][MethodChain]
- [`onGet`][MethodChain]
- [`type`][MethodChain]
- [`define`][MethodChain]
- [`getSet`][MethodChain]
- [`default`][MethodChain]
- [`initial`][MethodChain]
- [`bind`][MethodChain]
- [`camelCase`][MethodChain]
- [`autoIncrement`][MethodChain]
- [`factory`][MethodChain]
- [`returns`][MethodChain]
- [`callReturns`][MethodChain]
- [`decorate (any object!)`][MethodChain]
- [š infinitely nestable understandable factories][FactoryChain]
- [ā¶ļøāļø easy deep merging][MergeChain]
- [ā®ļø compatibility - typescript, nodejs, webpack, rollup, fusebox, babel, buble, amd][API]
</details>
-----
### š related
- [šā awesome fluents](https://github.com/fluents/awesome-fluents)
- many thanks to [Eli Perelman](https://github.com/eliperelman) for all the chainable goodness
- thanks to [James Halliday](https://github.com/substack) for the tremendous [traversals](https://github.com/substack/js-traverse)
- thanks to [Sindre Sorhus](https://github.com/sindresorhus) for the simple [dot-prop](https://github.com/sindresorhus/dot-prop) access
- thanks to [Josh Duff](https://github.com/KyleAMathews) for [deep merging](https://github.com/KyleAMathews/deepmerge)
- based on [webpack-chain](https://github.com/mozilla-rpweb/webpack-chain), but not webpack-specific.
- thanks to [Jon Schlinkert](https://github.com/jonschlinkert/kind-of) & [inferno](https://github.com/infernojs/inferno/blob/master/packages/inferno-shared/src/index.ts) for type checking inspirations
- transpiled with [buble](https://gitlab.com/Rich-Harris/buble)
- [Martin Fowler on FluentInterface](https://www.martinfowler.com/bliki/FluentInterface.html)
- [ramda](https://github.com/ramda/ramda) & [lodash](https://github.com/lodash/lodash) for some well tested & documented utilities (currying, mapping)