Transform - fluents/chain-able GitHub Wiki
🤖 transform 🎼
definitions
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
}
🗺 remap
const chain = new Chain()
.remap('dis', 'dat')
.from({dis: 1, other: true})
.get('dat') === 1
🤖 transform
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()