-
Notifications
You must be signed in to change notification settings - Fork 8
Home
James edited this page Jun 24, 2017
·
12 revisions
interfaces that describe their intentions
class Traditional {
constructor() {
this.data = {}
}
build(index, name, object) {
this.data.index = index
this.data.name = name
this.data.object = object
}
}
const classico = new Traditional()
classico.build(1, 'string', {object: true})
class Fluent extends Chain {
constructor(parent) {
super(parent)
this.extend(['index', 'name', 'object'])
}
}
const chain = new Chain()
.index(1)
.name('string')
.object(true)
yarn add chain-able
npm i chain-able --save
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
- api
- transformable
- observable
- easy deep merging
- runtime types & schema
-
.method()
- dot-prop
- shorthand
- nestable factories
- compose & decorators
- ⚡ performant & tiny
~7kb
(gzip) 300 byte minimal version available as snippet
- 😎⛓ awesome fluents
- many thanks to Eli Perelman for all the chainable goodness
- thanks to James Halliday for the tremendous traversals
- thanks to Sindre Sorhus for the simple dot-prop access
- thanks to Josh Duff for deep merging
- based on webpack-chain, but not webpack-specific.
- transpiled with buble
- Martin Fowler on FluentInterface