index.js 343 B

1234567891011121314151617
  1. 'use strict';
  2. module.exports = (...functions) => {
  3. if (functions.length === 0) {
  4. throw new Error('Expected at least one argument');
  5. }
  6. return async input => {
  7. let currentValue = input;
  8. for (const fn of functions) {
  9. currentValue = await fn(currentValue); // eslint-disable-line no-await-in-loop
  10. }
  11. return currentValue;
  12. };
  13. };