deno.land / x / froebel@v0.23.2 / partition.test.ts

partition.test.ts
نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
import partition from "./partition.ts";import { assertEquals } from "testing/asserts.ts";
Deno.test("partition", () => { const isStr = (v: unknown): v is string => typeof v === "string";
{ const res: [["a", "b"], [1, 2]] = partition( ["a", 1, "b", 2] as const, isStr, ); assertEquals(res[0], ["a", "b"]); assertEquals(res[1], [1, 2]); }
{ const _res = partition(["a", 1, "b", 2], isStr); // @ts-expect-error const _: [[], []] = partition(["a", 1, "b", 2], isStr); }
{ const _: [(string | number)[], (string | number)[]] = partition( ["a", 1, "b", 2], (v) => typeof v === "string", ); }});
froebel

Version Info

Tagged at
a year ago