MCPcopy Create free account
hub / github.com/compiler-explorer/compiler-explorer / remove

Function remove

shared/common-utils.ts:48–50  ·  view source on GitHub ↗
(arr: U[], v: V)

Source from the content-addressed store, hash-verified

46// Apparently the idiomatic solution is arr.filter((x): x is T => x !== null), but this is shorter (and the type
47// predicate also isn't type checked so it doesn't seem safe to me)
48export function remove<U, V extends U>(arr: U[], v: V) {
49 return arr.filter(item => item !== v) as Exclude<U, V extends null | undefined ? V : never>[];
50}
51
52// https://www.typescriptlang.org/play?#code/KYDwDg9gTgLgBAMwK4DsDGMCWEVysAWwgDdgAeAVQBo4A1OUGYFAEwGc4KA+ACgEMoUAFycA2gF0axEbQCUcAN4AoOKrzAYSKLgFQAdAkwAbJlB6YmBOAF4ucC4TgBCa9bjF5fDgFEQaI0gs5NR0DCBMrBwoSEZGcAA+cKhBhijALHAA-KEiaaRQXBIA3EoAvkpKQf4CwHBoOGzwuiI8jVCYKADmCXDRsbLFFfUojXAgNupEpPyCNH1GsiUA9EtqcAB6mUMN8ACeE-hTwDNQNABECBAQZ4tKK2ubFUA
53

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected