-
Notifications
You must be signed in to change notification settings - Fork 8
Transform
James edited this page Jun 24, 2017
·
3 revisions
🤖 transform
🎼
class TransformChain extends Composable, Chain {
// stored in .meta
public transform(key: Primitive, value: any): ChainAble
// remaps a key from 1 to another
public remap(from: string, to: string): ChainAble
// returns traverser using this.entries()
public traverse(useThis?: boolean): TraverseChain
// returns traverser using obj
public traverse(obj: Traversable): TraverseChain
}
const chain = new Chain()
.remap('dis', 'dat')
.from({dis: 1, other: true})
.get('dat') === 1
- [source][transformsrc] [tests][transformtests] [transformsrc]: https://github.com/fluents/chain-able/blob/4.0.2/src/compose/Transform.js [transformtests]: https://github.com/fluents/chain-able/blob/4.0.2/test/MobX.js [MethodChain]: https://github.com/fluents/chain-able/wiki/MethodChain
works for all other [MethodChain][] extensions as well
import {format} from 'date-fns/esm'
import {Chain} from 'chain-able'
const chain = new Chain()
chain.transform('created_at', date => format(date))
chain.set('created_at', new Date())
// is formatted human-readable pretty!
const {created_at} = chain.entries()
- [source][traversesrc] [tests][traversetests] [dep tests][traversetestsdep] [traversesrc]: https://github.com/fluents/chain-able/blob/4.0.2/src/TraverseChain.js [traversetests]: https://github.com/fluents/chain-able/blob/4.0.2/test/traverse.js [traversetestsdep]: https://github.com/fluents/chain-able/tree/4.0.2/test/traverse
- js-traverse extends this!
- map-factory
- tappable-webpack
- awesome-tap