-
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
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()