• File: index.js
  • Full Path: /var/www/imalireports/node_modules/p-pipe/index.js
  • Date Modified: 11/01/2022 10:15 PM
  • File size: 343 bytes
  • MIME-type: text/plain
  • Charset: utf-8
'use strict';

module.exports = (...functions) => {
	if (functions.length === 0) {
		throw new Error('Expected at least one argument');
	}

	return async input => {
		let currentValue = input;

		for (const fn of functions) {
			currentValue = await fn(currentValue); // eslint-disable-line no-await-in-loop
		}

		return currentValue;
	};
};