UNPKG

conductor

Version:

A modern & functional JavaScript utility library

26 lines (21 loc) 531 B
const compose = require('./src/compose') const apply = fn => args => fn(...args) const parseFnDef = def => { const limit = def.indexOf('=') const output = def.substring(limit) return eval( def.substring(0, limit) + output.replace('(', '[').replace(')', ']') ) } const wrap = fn => new Proxy(fn, { get(obj, transformation) { const definition = transformation.toString() const tf = parseFnDef(definition) return compose( apply(fn), tf ) }, }) module.exports = wrap