-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNot.ts
22 lines (19 loc) · 784 Bytes
/
Not.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
import { baseZBoolean, ZBoolean } from "./ZBoolean.js";
export type Not<value extends ZBoolean> = value extends ZBoolean<never>
? ZBoolean<never>
: value extends ZBoolean<true>
? ZBoolean<false>
: value extends ZBoolean<false>
? ZBoolean<true>
: ZBoolean;
export const Not = <value extends ZBoolean>(value: value): Not<value> =>
("sample" in value && value.sample !== undefined
? value.sample /**/.length === 0
? baseZBoolean.create([])
: value.sample.every((sample) => sample === true)
? baseZBoolean.create([false])
: value.sample.every((sample) => sample === false)
? baseZBoolean.create([true])
: baseZBoolean
: baseZBoolean) as any;
// const justaconstant = 5