UNPKG

ramda-extension

Version:

Helpful functions built on top of the mighty Ramda

34 lines (31 loc) 922 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.default = void 0; var _ramda = require("ramda"); /** * Creates a new function that, when invoked, caches the result of calling `fn` * for a given argument and returns the result. Subsequent calls to the * memoized `fn` with the same argument will not result in an additional * call to `fn`; instead, the cached result for that argument will be returned * * @func * @category Function * * @example * * let count = 0; * const factorial = R_.memoizeWithIdentity(n => { * count += 1; * return R.product(R.range(1, n + 1)); * }); * factorial(5); // 120 * factorial(5); // 120 * factorial(5); // 120 * count; // 1 * */ var memoizeWithIdentity = (0, _ramda.memoizeWith)(_ramda.identity); var _default = memoizeWithIdentity; exports.default = _default;