* Removes items from the list-value where the predicate returns `truthy` value. \ * Dispatches a new copy of the value, without mutating the current-value. \ * It modifies the length of the list as these indices are not deleted, * rather removed using `Array.prototype.splice`. *
(predicate: (item: Item, index: number) => boolean)
| 233 | * @category Custom ListUnit |
| 234 | */ |
| 235 | removeIf(predicate: (item: Item, index: number) => boolean): Item[] { |
| 236 | if (this.isFrozen || typeof predicate !== 'function' || this.isEmpty) { |
| 237 | return []; |
| 238 | } |
| 239 | |
| 240 | const indicesToBeRemoved = []; |
| 241 | this.value().forEach((item, index) => { |
| 242 | if (predicate(item, index)) { |
| 243 | indicesToBeRemoved.push(index); |
| 244 | } |
| 245 | }); |
| 246 | return this.remove(...(indicesToBeRemoved as [number, ...number[]])); |
| 247 | } |
| 248 | |
| 249 | /** |
| 250 | * Deletes items at given indices in the list-{@link value}. \ |
no test coverage detected