deno.land / std@0.224.0 / collections / without_all.ts

without_all.ts
View Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.// This module is browser compatible.
/** * Returns an array excluding all given values. * * @example * ```ts * import { withoutAll } from "https://deno.land/std@$STD_VERSION/collections/without_all.ts"; * import { assertEquals } from "https://deno.land/std@$STD_VERSION/assert/assert_equals.ts"; * * const withoutList = withoutAll([2, 1, 2, 3], [1, 2]); * * assertEquals(withoutList, [3]); * ``` */export function withoutAll<T>(array: readonly T[], values: readonly T[]): T[] { const toExclude = new Set(values); return array.filter((it) => !toExclude.has(it));}
std

Version Info

Tagged at
6 months ago