UNPKG

@rimbu/common

Version:

Common types and objects used in many other Rimbu packages

20 lines 642 B
/** * 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 * ``` */ export function Update(value, update) { if (typeof update === 'function') { return update(value); } return update; } //# sourceMappingURL=update.mjs.map