const stream = (log, ...args) => args.reduce((a, f) => a.then(_ => new Promise(f)).then(log), Promise.resolve()); const stream = (log, ...args) => args.shift()(s => (log(s), args.length && stream(log, ...args)))