blob: cbc7f496ca665e660e22c5c77625f88b9c51b1dd [file] [log] [blame]
Leo Repp58b9f112021-11-22 11:57:47 +01001'use strict';
2
3// TODO: Use rest/spread when targeting Node.js 6
4
5module.exports = function (input) {
6 const args = Array.isArray(input) ? input : arguments;
7
8 if (args.length === 0) {
9 return Promise.reject(new Error('Expected at least one argument'));
10 }
11
12 return [].slice.call(args, 1).reduce((a, b) => {
13 return function () {
14 return Promise.resolve(a.apply(null, arguments)).then(b);
15 };
16 }, args[0]);
17};