by MathMonkeyMan · 3y ago · 0 comments
const thrush = (value, func, ...funcs) =>
func ? thrush(func(value), ...funcs) : value;
// no new syntax required
thrush(
envars,
Object.entries,
x => x.map(([key, val]) => `${key}=${val}`),
x => x.join(' '),
x => chalk.dim('$ ' + x, 'node', args.join(' ')),
console.log);
[1]: http://www.davidgoffredo.com/thrush.html const thrush2 = (value, ...funcs) => funcs.reduce((value, func) => func(value), value);
const thrush3 = (value, ...funcs) => { for (const func of funcs) value = func(value); return value }