namespace · packages/metakit/src/ops/set.ts:14
export * as Sets from './ops/set.js' Set operations over scalar sets (held as arrays of finite numbers or
NUL-free strings): union, intersect, difference (core primitives) plus
derived helpers (subset, disjoint, has, include, exclude, count,
isEmpty, nonEmpty, superset, equal, properSubset, overlaps,
symDiff).
Set-producing operations (union, intersect, difference, symDiff)
canonicalize to ascending unique order (matching arr.include/arr.exclude),
normalize -0 to 0 and lone surrogates to U+FFFD, refuse NUL bytes
(unportable), non-finite numbers (non-finite), and mixed scalar kinds
(ill-typed), and are null-strict.
Members Sets.count# const · packages/metakit/src/ops/set.ts:220
const count: {
< A extends Arr . NullableItems >(
items: A ,
) : Expr < EnvOfInput < A >, number | NullOf < A >>
< L extends Arr . NullableItems , R extends ExprInput < never , boolean | null >>(
list: L ,
test : ( each: Arr . Each < Arr . ElementOf < L >>) => R ,
) : Expr < EnvOfInput < L > & EnvOfInput < R >, number | NullOf < L >>
} Cardinality of s (|S|).
Sets.difference# function · packages/metakit/src/ops/set.ts:163
function difference < A extends NullableSet , B extends MatchingSet < A >>(
a: A ,
b: B ,
) : Expr <
EnvOfInput < A > & EnvOfInput < B >,
ReadonlyArray < MergedElement < A , B >> | NullOf < A > | NullOf < B >
> Set difference A \ B in canonical ascending unique order.
Sets.differenceOp# const · packages/metakit/src/ops/set.ts:123
const differenceOp = { id, returns, nulls, refuses, evaluate } Sets.disjoint# function · packages/metakit/src/ops/set.ts:181
function disjoint < A extends NullableSet , B extends MatchingSet < A >>(
a: A ,
b: B ,
) : Expr < EnvOfInput < A > & EnvOfInput < B >, boolean | NullOf < A > | NullOf < B >> True when a and b share no elements (A ∩ B = ∅): Arr.isEmpty(Sets.intersect(a, b)).
Sets.equal# function · packages/metakit/src/ops/set.ts:235
function equal < A extends NullableSet , B extends MatchingSet < A >>(
a: A ,
b: B ,
) : Expr < EnvOfInput < A > & EnvOfInput < B >, boolean | NullOf < A > | NullOf < B >> Derived helper: extensional set equality A = B (A ⊆ B ∧ B ⊆ A).
Sets.exclude# function · packages/metakit/src/ops/set.ts:204
function exclude <
S extends NullableSet ,
V extends ExprInput <
never ,
([SetElementOf < S > ] extends [never ] ? SetElement : SetElementOf < S > ) | null
>,
>(
s: S ,
value: V ,
) : Expr <
EnvOfInput < S > & EnvOfInput < V >,
ReadonlyArray < SetElementOf < S >> | NullOf < S >
> Remove value from set s (S \ {x}), canonical ascending unique order.
Sets.has# const · packages/metakit/src/ops/set.ts:217
const has : <
L extends Arr . NullableItems ,
V extends ExprInput < never , number | string | boolean | null >,
> (
items: L ,
value: V ,
) => Expr < EnvOfInput < L > & EnvOfInput < V >, boolean | NullOf < L > | NullOf < V >> True when value is a member of s (x ∈ S).
Sets.include# function · packages/metakit/src/ops/set.ts:188
function include <
S extends NullableSet ,
V extends ExprInput <
never ,
([SetElementOf < S > ] extends [never ] ? SetElement : SetElementOf < S > ) | null
>,
>(
s: S ,
value: V ,
) : Expr <
EnvOfInput < S > & EnvOfInput < V >,
| ReadonlyArray <
| SetElementOf < S >
| Exclude < V extends ExprInput < never , infer X > ? X : never , null >
>
| NullOf < S >
> Show all 17 lines Insert value into set s (S ∪ {x}), canonical ascending unique order.
Sets.intersect# function · packages/metakit/src/ops/set.ts:154
function intersect < A extends NullableSet , B extends MatchingSet < A >>(
a: A ,
b: B ,
) : Expr <
EnvOfInput < A > & EnvOfInput < B >,
ReadonlyArray < MergedElement < A , B >> | NullOf < A > | NullOf < B >
> Set intersection A ∩ B in canonical ascending unique order.
Sets.intersectOp# const · packages/metakit/src/ops/set.ts:109
const intersectOp = { id, returns, nulls, refuses, evaluate } Sets.isEmpty# const · packages/metakit/src/ops/set.ts:223
const isEmpty : < A extends Arr . NullableItems > (
items: A ,
) => Expr < EnvOfInput < A >, boolean | NullOf < A >> True when s is empty (S = ∅).
Sets.nonEmpty# const · packages/metakit/src/ops/set.ts:226
const nonEmpty : < A extends Arr . NullableItems > (
items: A ,
) => Expr < EnvOfInput < A >, boolean | NullOf < A >> True when s is non-empty (S ≠ ∅).
Sets.NullableSet# type · packages/metakit/src/ops/set.ts:25
type NullableSet < E extends SetElement = SetElement > = ExprInput <
never ,
ReadonlyArray < E > | null
> A set expression: an array of numbers or strings, possibly null.
Sets.overlaps# function · packages/metakit/src/ops/set.ts:249
function overlaps < A extends NullableSet , B extends MatchingSet < A >>(
a: A ,
b: B ,
) : Expr < EnvOfInput < A > & EnvOfInput < B >, boolean | NullOf < A > | NullOf < B >> Derived helper: A and b share at least one element (A ∩ B ≠ ∅).
Sets.properSubset# function · packages/metakit/src/ops/set.ts:242
function properSubset < A extends NullableSet , B extends MatchingSet < A >>(
a: A ,
b: B ,
) : Expr < EnvOfInput < A > & EnvOfInput < B >, boolean | NullOf < A > | NullOf < B >> Derived helper: strict subset A ⊂ B (A ⊆ B ∧ ¬(B ⊆ A)).
Sets.SetElement# type · packages/metakit/src/ops/set.ts:22
type SetElement = number | string A scalar element a set may hold.
Sets.SetElementOf# type · packages/metakit/src/ops/set.ts:31
type SetElementOf < S > =
S extends ExprInput < never , ReadonlyArray < infer E > | null >
? Extract < E , SetElement >
: S extends ReadonlyArray < infer E >
? Extract < E , SetElement >
: SetElement Element type of a set expression.
Sets.subset# function · packages/metakit/src/ops/set.ts:175
function subset < A extends NullableSet , B extends MatchingSet < A >>(
a: A ,
b: B ,
) : Expr < EnvOfInput < A > & EnvOfInput < B >, boolean | NullOf < A > | NullOf < B >> True when every element of a is in b (A ⊆ B): Arr.isEmpty(Sets.difference(a, b)).
Sets.superset# function · packages/metakit/src/ops/set.ts:229
function superset < A extends NullableSet , B extends MatchingSet < A >>(
a: A ,
b: B ,
) : Expr < EnvOfInput < A > & EnvOfInput < B >, boolean | NullOf < A > | NullOf < B >> Derived helper: A ⊇ B (subset(b, a)).
Sets.symDiff# function · packages/metakit/src/ops/set.ts:256
function symDiff < A extends NullableSet , B extends MatchingSet < A >>(
a: A ,
b: B ,
) : Expr <
EnvOfInput < A > & EnvOfInput < B >,
ReadonlyArray < MergedElement < A , B >> | NullOf < A > | NullOf < B >
> Derived helper: symmetric difference A △ B = (A \ B) ∪ (B \ A).
Sets.union# function · packages/metakit/src/ops/set.ts:145
function union < A extends NullableSet , B extends MatchingSet < A >>(
a: A ,
b: B ,
) : Expr <
EnvOfInput < A > & EnvOfInput < B >,
ReadonlyArray < MergedElement < A , B >> | NullOf < A > | NullOf < B >
> Set union A ∪ B in canonical ascending unique order.
Sets.unionOp# const · packages/metakit/src/ops/set.ts:96
const unionOp = { id, returns, nulls, refuses, evaluate }