function/pipe.jsjavascript
/**
 * 从左到右串联多个函数。
 * @function pipe
 * @memberof module:function
 * @param {...Function} functions 要串联的函数
 * @returns {Function} 串联后的函数
 * @throws {TypeError} 任一参数不是函数时抛出
 */
function pipe(...functions) {
  if (functions.some(fn => typeof fn !== 'function')) throw new TypeError('all arguments must be functions')
  return (value, ...args) => functions.reduce((result, fn, index) => index === 0 ? fn(result, ...args) : fn(result), value)
}

export default pipe