UNPKG

conductor

Version:

A modern & functional JavaScript utility library

38 lines (27 loc) 784 B
const reduce = require('./src/reduce') const compose = require('./src/compose') const get = require('./src/get') const obj1 = { abc: { balance: 1000, }, bcd: { balance: 1883, }, cde: { balance: 2727 }, } const _ = x => x // => [10.00, 18.83, 27.27] const toMainCurrency = x => x / 100 const balanceToMainCurrency = compose( toMainCurrency, get('balance') ) const t = (...args) => fn => (...args2) => fn(...args2.map((arg, index) => args[index](arg))) const append = (acc, item) => [...acc, item] reduce((acc, item) => append(acc, balanceToMainCurrency(item)), [], obj1) //reduce(t(_, balanceToMainCurrency)(append), [], obj1) //reduce(t((a, b) => [a + b])(append), [], obj1) reduce(append[(a, b) => (b, a)], [], obj1) //const bite = x => (0,1,733,0)