@newdash/newdash
Version:
javascript/typescript utility library
34 lines (33 loc) • 864 B
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.flowRight = void 0;
const flow_1 = __importDefault(require("./flow"));
/**
* This method is like `flow` except that it composes a function that
* invokes the given functions from right to left.
*
* @since 5.18.0
* @category Util
* @param funcs The functions to invoke.
* @returns Returns the new composite function.
* @see flow
* @example
*
* ```ts
* function square(n) {
* return n * n
* }
*
* const addSquare = flowRight(square, add)
* addSquare(1, 2)
* // => 9
* ```
*/
function flowRight(...funcs) {
return (0, flow_1.default)(...funcs.reverse());
}
exports.flowRight = flowRight;
exports.default = flowRight;