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.

26 lines 749 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.arrayRemoveMany = void 0; /** * @public * Removes each item in `itemsToRemove` from `items` (including any repeated items). * * @returns The number of items that were removed. * * @remarks * See {@link arrayRemoveMany}. */ function arrayRemoveMany(items, itemsToRemove) { const setOfItemsToRemove = new Set(itemsToRemove); let index = items.length; let removedItems = 0; while (index-- > 0) { if (setOfItemsToRemove.has(items[index])) { items.splice(index, 1); ++removedItems; } } return removedItems; } exports.arrayRemoveMany = arrayRemoveMany; //# sourceMappingURL=array-remove-many.js.map