UNPKG

@rimbu/common

Version:

Common types and objects used in many other Rimbu packages

24 lines 762 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.Update = void 0; /** * Returns the result of given `update` parameter, where it can either directly give a new value, * or it is a function receiving the given `value`, and returns a new value. * @param value - the current value * @param update - an `Update` value, either a new value or a function receiving the old value * and returning a new one. * @example * ```ts * Update(1, 2) // => 2 * Update(1, () => 10) // => 10 * Update(1, v => v + 1) // => 2 * ``` */ function Update(value, update) { if (typeof update === 'function') { return update(value); } return update; } exports.Update = Update; //# sourceMappingURL=update.cjs.map