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.
24 lines • 668 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.arrayRemoveOne = void 0;
/**
* @public
* Removes either 0 or one item from items, even if itemToRemove appears more than once.
*
* @returns true if an item was removed.
*
* @remarks
* The lowest indexed item will be removed where there is more than one match.
*
* See {@link arrayRemoveOne}.
*/
function arrayRemoveOne(items, itemToRemove) {
const index = items.indexOf(itemToRemove);
if (index === -1) {
return false;
}
items.splice(index, 1);
return true;
}
exports.arrayRemoveOne = arrayRemoveOne;
//# sourceMappingURL=array-remove-one.js.map