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.
20 lines • 524 B
JavaScript
/**
* @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}.
*/
export function arrayRemoveOne(items, itemToRemove) {
const index = items.indexOf(itemToRemove);
if (index === -1) {
return false;
}
items.splice(index, 1);
return true;
}
//# sourceMappingURL=array-remove-one.js.map