MCPcopy Create free account
hub / github.com/antfu/utils / filterInPlace

Function filterInPlace

src/array.ts:215–221  ·  view source on GitHub ↗
(array: T[], predicate: (item: T, index: number, arr: T[]) => unknown)

Source from the content-addressed store, hash-verified

213 * @category Array
214 */
215export function filterInPlace<T>(array: T[], predicate: (item: T, index: number, arr: T[]) => unknown) {
216 for (let i = array.length; i--; i >= 0) {
217 if (!predicate(array[i], i, array))
218 array.splice(i, 1)
219 }
220 return array
221}

Callers 1

array.test.tsFile · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected