UNPKG

rc-js-util

Version:

A collection of TS and C++ utilities to help writing performant and correct applications, achieved through strict typing and (removable) invariant checking.

18 lines 439 B
/** * @public * Replaces the first match of itemToRemove with replaceWith. * * @returns true if an element was replaced. * * @remarks * See {@link arrayReplaceOne}. */ export function arrayReplaceOne(items, itemToRemove, replaceWith) { const index = items.indexOf(itemToRemove); if (index === -1) { return false; } items[index] = replaceWith; return true; } //# sourceMappingURL=array-replace-one.js.map