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.

22 lines 586 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.arrayReplaceOne = void 0; /** * @public * Replaces the first match of itemToRemove with replaceWith. * * @returns true if an element was replaced. * * @remarks * See {@link arrayReplaceOne}. */ function arrayReplaceOne(items, itemToRemove, replaceWith) { const index = items.indexOf(itemToRemove); if (index === -1) { return false; } items[index] = replaceWith; return true; } exports.arrayReplaceOne = arrayReplaceOne; //# sourceMappingURL=array-replace-one.js.map