@orkestrel/contract 0.0.19 → 0.0.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/core/index.cjs +1286 -1274
- package/dist/src/core/index.cjs.map +1 -1
- package/dist/src/core/index.d.cts +363 -10
- package/dist/src/core/index.d.ts +363 -10
- package/dist/src/core/index.js +1268 -1274
- package/dist/src/core/index.js.map +1 -1
- package/package.json +14 -14
|
@@ -199,7 +199,7 @@ export declare interface ArrayShapeOptions {
|
|
|
199
199
|
* @example
|
|
200
200
|
* ```ts
|
|
201
201
|
* const outcome = attempt(() => predicate(value))
|
|
202
|
-
* return outcome
|
|
202
|
+
* return isSuccess(outcome) && outcome.value
|
|
203
203
|
* ```
|
|
204
204
|
*/
|
|
205
205
|
export declare function attempt<T>(callback: () => T): Result<T>;
|
|
@@ -340,6 +340,19 @@ export declare function buildArrayFaults(shape: ArrayShape, length: number, path
|
|
|
340
340
|
*/
|
|
341
341
|
export declare function buildNumberFaults(shape: NumberShape, value: number, path: readonly string[]): readonly Fault[];
|
|
342
342
|
|
|
343
|
+
/**
|
|
344
|
+
* Builds a null-prototype lookup from names to their last index.
|
|
345
|
+
*
|
|
346
|
+
* @param names - Names in declaration order
|
|
347
|
+
* @returns The indexed lookup
|
|
348
|
+
*
|
|
349
|
+
* @example
|
|
350
|
+
* ```ts
|
|
351
|
+
* buildPositions(['id', '__proto__']).id // 0
|
|
352
|
+
* ```
|
|
353
|
+
*/
|
|
354
|
+
export declare function buildPositions(names: readonly string[]): Readonly<Record<string, number>>;
|
|
355
|
+
|
|
343
356
|
/**
|
|
344
357
|
* Builds one empty {@link SampleMemo} node.
|
|
345
358
|
*
|
|
@@ -463,6 +476,20 @@ export declare function buildStringFaults(shape: StringShape, value: string, pat
|
|
|
463
476
|
*/
|
|
464
477
|
export declare function canonicalStringify(value: unknown): string | undefined;
|
|
465
478
|
|
|
479
|
+
/**
|
|
480
|
+
* Caps at `1024` the number of choices one schema field may offer, frozen.
|
|
481
|
+
*
|
|
482
|
+
* @remarks
|
|
483
|
+
* A retention limit that a declaring package, such as a form or table schema
|
|
484
|
+
* package, enforces; this package enforces none of the retention limits itself.
|
|
485
|
+
*
|
|
486
|
+
* @example
|
|
487
|
+
* ```ts
|
|
488
|
+
* CHOICE_LIMIT // 1024
|
|
489
|
+
* ```
|
|
490
|
+
*/
|
|
491
|
+
export declare const CHOICE_LIMIT = 1024;
|
|
492
|
+
|
|
466
493
|
/**
|
|
467
494
|
* Classifies an already-bounded string against the pattern-only and
|
|
468
495
|
* calendar-checked {@link SchemaFormat} vocabulary.
|
|
@@ -633,7 +660,7 @@ export declare function cloneShape(shape: ContractShape): ContractShape;
|
|
|
633
660
|
*
|
|
634
661
|
* @remarks
|
|
635
662
|
* Extracted rather than written inline for the same reason
|
|
636
|
-
* {@link
|
|
663
|
+
* {@link comparePrimitives} is: `Reflect.apply` takes its arguments as a LIST, so an
|
|
637
664
|
* inline collector is a function expression inside an array literal rather than
|
|
638
665
|
* one passed directly as an argument — a hidden function assignment this
|
|
639
666
|
* repository forbids wherever it appears. Returned directly from a factory it is
|
|
@@ -670,6 +697,8 @@ export declare function collectEntries(target: unknown[][]): EntryCollectorFunct
|
|
|
670
697
|
* `new Set(values)` reads `Symbol.iterator` off the argument and `add` off the
|
|
671
698
|
* instance, so building from an iterable would reintroduce two replaceable
|
|
672
699
|
* dispatches to remove one.
|
|
700
|
+
* A captured native union consumes the owned indexed snapshot through a cursor
|
|
701
|
+
* whose `next` is bound to the captured array advance operation.
|
|
673
702
|
*
|
|
674
703
|
* @param values - The members to collect, read by index
|
|
675
704
|
* @returns A collection no caller holds a reference to
|
|
@@ -703,10 +732,10 @@ export declare function collectMembers(values: readonly unknown[]): Set<unknown>
|
|
|
703
732
|
*
|
|
704
733
|
* @example
|
|
705
734
|
* ```ts
|
|
706
|
-
*
|
|
735
|
+
* comparePrimitives('a', 'b') // -1
|
|
707
736
|
* ```
|
|
708
737
|
*/
|
|
709
|
-
export declare function
|
|
738
|
+
export declare function comparePrimitives<T extends string | number>(left: T, right: T): number;
|
|
710
739
|
|
|
711
740
|
/**
|
|
712
741
|
* Caps at `512` the supported nesting depth of a compiled contract shape, frozen.
|
|
@@ -1295,7 +1324,7 @@ export declare interface ContractCompilerInterface<S extends ContractShape> {
|
|
|
1295
1324
|
* ```
|
|
1296
1325
|
*/
|
|
1297
1326
|
export declare class ContractError extends Error {
|
|
1298
|
-
readonly name
|
|
1327
|
+
readonly name: string;
|
|
1299
1328
|
readonly code: ContractCode;
|
|
1300
1329
|
readonly context: ContractErrorContext | undefined;
|
|
1301
1330
|
/**
|
|
@@ -1601,6 +1630,21 @@ export declare function drawRandom(random: RandomFunction, shape: string): numbe
|
|
|
1601
1630
|
*/
|
|
1602
1631
|
export declare function encodeLeaf(value: unknown): string | undefined;
|
|
1603
1632
|
|
|
1633
|
+
/**
|
|
1634
|
+
* Encodes ordered members, stopping before the first unencodable member.
|
|
1635
|
+
*
|
|
1636
|
+
* @param members - The owned members in source order
|
|
1637
|
+
* @param keys - Object keys, or undefined for an array
|
|
1638
|
+
* @param encodings - Encodings already computed for child containers
|
|
1639
|
+
* @returns The encoded prefix
|
|
1640
|
+
*
|
|
1641
|
+
* @example
|
|
1642
|
+
* ```ts
|
|
1643
|
+
* Array.from(encodeParts([1, undefined, 2], undefined, new WeakMap())) // ['1']
|
|
1644
|
+
* ```
|
|
1645
|
+
*/
|
|
1646
|
+
export declare function encodeParts(members: readonly unknown[], keys: readonly string[] | undefined, encodings: WeakMap<object, string>): Generator<string, void, unknown>;
|
|
1647
|
+
|
|
1604
1648
|
/**
|
|
1605
1649
|
* Represents the collector a captured `forEach` sweep invokes per entry.
|
|
1606
1650
|
*
|
|
@@ -1679,6 +1723,54 @@ export declare function enumerableSymbolCount(value: object): number;
|
|
|
1679
1723
|
*/
|
|
1680
1724
|
export declare function enumOf<const E extends Record<string, string | number>>(enumeration: E): Guard<E[keyof E]>;
|
|
1681
1725
|
|
|
1726
|
+
/**
|
|
1727
|
+
* Renders a thrown value as a non-empty message.
|
|
1728
|
+
*
|
|
1729
|
+
* @remarks
|
|
1730
|
+
* Reads an `Error`'s `message` and converts any other value with the `String`
|
|
1731
|
+
* function {@link INTRINSICS} captured at load, so a symbol renders as
|
|
1732
|
+
* `Symbol(description)` and a caller that replaces the global `String` does not
|
|
1733
|
+
* change the result. Returns `'unknown failure'` when
|
|
1734
|
+
* that read throws, as a throwing `message` getter or `toString` method does,
|
|
1735
|
+
* when an `Error`'s `message` is not a string, and when the rendered text is
|
|
1736
|
+
* empty. Never throws.
|
|
1737
|
+
*
|
|
1738
|
+
* @param error - The caught value, of any shape
|
|
1739
|
+
* @returns The rendered message, never empty
|
|
1740
|
+
*
|
|
1741
|
+
* @example
|
|
1742
|
+
* ```ts
|
|
1743
|
+
* errorToMessage(new Error('boom')) // 'boom'
|
|
1744
|
+
* errorToMessage('') // 'unknown failure'
|
|
1745
|
+
* ```
|
|
1746
|
+
*/
|
|
1747
|
+
export declare function errorToMessage(error: unknown): string;
|
|
1748
|
+
|
|
1749
|
+
/**
|
|
1750
|
+
* Escapes every regular-expression metacharacter in a text, so the text
|
|
1751
|
+
* matches literally inside a larger `RegExp` source.
|
|
1752
|
+
*
|
|
1753
|
+
* @remarks
|
|
1754
|
+
* Prefixes each of `\ ^ $ . * + ? ( ) [ ] { } |` with a backslash and leaves
|
|
1755
|
+
* every other character, `-` and `/` included, unchanged; the empty string
|
|
1756
|
+
* returns unchanged. The escape is an INDEXED character map rather than
|
|
1757
|
+
* `String.prototype.replace`, which dispatches through the caller-writable
|
|
1758
|
+
* `RegExp.prototype[Symbol.replace]` and `exec` members.
|
|
1759
|
+
*
|
|
1760
|
+
* @param value - The literal text to escape
|
|
1761
|
+
* @returns The text with every metacharacter backslash-escaped
|
|
1762
|
+
*
|
|
1763
|
+
* @example
|
|
1764
|
+
* ```ts
|
|
1765
|
+
* escapeRegExp('a.b*c') // 'a\\.b\\*c'
|
|
1766
|
+
* new RegExp(`^${escapeRegExp('a.b')}$`).test('axb') // false
|
|
1767
|
+
* ```
|
|
1768
|
+
*/
|
|
1769
|
+
export declare function escapeRegExp(value: string): string;
|
|
1770
|
+
|
|
1771
|
+
/** Evaluates a compiled node at one diagnostic path. */
|
|
1772
|
+
export declare type EvaluationFunction<T> = (value: unknown, path: readonly string[]) => T;
|
|
1773
|
+
|
|
1682
1774
|
/**
|
|
1683
1775
|
* Represents a key present on a value that its closed object shape does not declare.
|
|
1684
1776
|
*
|
|
@@ -1702,6 +1794,19 @@ export declare interface Failure<E> {
|
|
|
1702
1794
|
readonly error: E;
|
|
1703
1795
|
}
|
|
1704
1796
|
|
|
1797
|
+
/**
|
|
1798
|
+
* Boxes an error as the {@link Failure} branch of a {@link Result}.
|
|
1799
|
+
*
|
|
1800
|
+
* @param error - The error to box, retained exactly
|
|
1801
|
+
* @returns A fresh `{ success: false, error }` record
|
|
1802
|
+
*
|
|
1803
|
+
* @example
|
|
1804
|
+
* ```ts
|
|
1805
|
+
* failure('offline') // { success: false, error: 'offline' }
|
|
1806
|
+
* ```
|
|
1807
|
+
*/
|
|
1808
|
+
export declare function failure<E>(error: E): Failure<E>;
|
|
1809
|
+
|
|
1705
1810
|
/**
|
|
1706
1811
|
* Represents a single structured parse-failure diagnostic — one entry of an
|
|
1707
1812
|
* {@link ContractInterface.explain} report.
|
|
@@ -2269,10 +2374,14 @@ export declare const INTRINSICS: Readonly<{
|
|
|
2269
2374
|
(o: object | null): any;
|
|
2270
2375
|
(o: object | null, properties: PropertyDescriptorMap & ThisType<any>): any;
|
|
2271
2376
|
};
|
|
2377
|
+
/** Captures `Proxy` for non-array indexed views. */
|
|
2378
|
+
proxy: ProxyConstructor;
|
|
2272
2379
|
/** Captures `Object.getOwnPropertyDescriptor` — value observation that runs no accessor. */
|
|
2273
2380
|
describe: (o: any, p: PropertyKey) => PropertyDescriptor | undefined;
|
|
2274
2381
|
/** Captures `Object.defineProperty` — exact placement of an own data property. */
|
|
2275
2382
|
define: <T>(o: T, p: PropertyKey, attributes: PropertyDescriptor & ThisType<any>) => T;
|
|
2383
|
+
/** Captures `Object.defineProperties` — sparse snapshot construction. */
|
|
2384
|
+
definitions: <T>(o: T, properties: PropertyDescriptorMap & ThisType<any>) => T;
|
|
2276
2385
|
/** Captures `Object.getPrototypeOf` — the record-brand observation. */
|
|
2277
2386
|
prototype: (o: any) => any;
|
|
2278
2387
|
/** Captures `Object.getOwnPropertySymbols` — the own-symbol population. */
|
|
@@ -2365,6 +2474,61 @@ export declare const INTRINSICS: Readonly<{
|
|
|
2365
2474
|
list: ArrayConstructor;
|
|
2366
2475
|
/** Captures `Array.prototype.sort` — the deterministic ordering every published schema is emitted in, dispatched through `apply`. */
|
|
2367
2476
|
order: (compareFn?: ((a: any, b: any) => number) | undefined) => any[];
|
|
2477
|
+
/** Captures `Array.prototype.some` for short-circuit membership checks. */
|
|
2478
|
+
some: (predicate: (value: any, index: number, array: any[]) => unknown, thisArg?: any) => boolean;
|
|
2479
|
+
/** Captures `Array.prototype.findIndex`, including reads of sparse positions. */
|
|
2480
|
+
find: (predicate: (value: any, index: number, obj: any[]) => unknown, thisArg?: any) => number;
|
|
2481
|
+
/** Captures `Array.prototype.forEach` for indexed visits of owned arrays. */
|
|
2482
|
+
each: (callbackfn: (value: any, index: number, array: any[]) => void, thisArg?: any) => void;
|
|
2483
|
+
/** Captures `Array.from` for ordered array construction. */
|
|
2484
|
+
from: {
|
|
2485
|
+
<T>(arrayLike: ArrayLike<T>): T[];
|
|
2486
|
+
<T, U>(arrayLike: ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[];
|
|
2487
|
+
<T>(iterable: Iterable<T> | ArrayLike<T>): T[];
|
|
2488
|
+
<T, U>(iterable: Iterable<T> | ArrayLike<T>, mapfn: (v: T, k: number) => U, thisArg?: any): U[];
|
|
2489
|
+
};
|
|
2490
|
+
/** Captures `Array.prototype.reduce` for derived aggregate values. */
|
|
2491
|
+
fold: {
|
|
2492
|
+
(callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: any[]) => any): any;
|
|
2493
|
+
(callbackfn: (previousValue: any, currentValue: any, currentIndex: number, array: any[]) => any, initialValue: any): any;
|
|
2494
|
+
<U>(callbackfn: (previousValue: U, currentValue: any, currentIndex: number, array: any[]) => U, initialValue: U): U;
|
|
2495
|
+
};
|
|
2496
|
+
/** Captures `Iterator.prototype.reduce` — ordered lazy reduction. */
|
|
2497
|
+
reduce: {
|
|
2498
|
+
(callbackfn: (previousValue: any, currentValue: any, currentIndex: number) => any): any;
|
|
2499
|
+
(callbackfn: (previousValue: any, currentValue: any, currentIndex: number) => any, initialValue: any): any;
|
|
2500
|
+
<U>(callbackfn: (previousValue: U, currentValue: any, currentIndex: number) => U, initialValue: U): U;
|
|
2501
|
+
};
|
|
2502
|
+
/** Captures `Array.prototype.filter` for derived selections. */
|
|
2503
|
+
select: {
|
|
2504
|
+
<S extends any>(predicate: (value: any, index: number, array: any[]) => value is S, thisArg?: any): S[];
|
|
2505
|
+
(predicate: (value: any, index: number, array: any[]) => unknown, thisArg?: any): any[];
|
|
2506
|
+
};
|
|
2507
|
+
/** Captures `Array.prototype.map` for derived projections. */
|
|
2508
|
+
project: <U>(callbackfn: (value: any, index: number, array: any[]) => U, thisArg?: any) => U[];
|
|
2509
|
+
/** Captures `Array.prototype.flatMap` — ordered list expansion. */
|
|
2510
|
+
expand: <U, This = undefined>(callback: (this: This, value: any, index: number, array: any[]) => U | readonly U[], thisArg?: This | undefined) => U[];
|
|
2511
|
+
/** Captures `Array.prototype.toReversed` — reverse-order derivation. */
|
|
2512
|
+
flip: () => any[];
|
|
2513
|
+
/** Captures `Array.prototype.values` for owned iterable construction. */
|
|
2514
|
+
iterator: () => ArrayIterator<any>;
|
|
2515
|
+
/** Captures `Array.prototype.keys` — an indexed cursor that reads length per step. */
|
|
2516
|
+
indices: () => ArrayIterator<number>;
|
|
2517
|
+
/** Captures the native array iterator advance operation. */
|
|
2518
|
+
advance: any;
|
|
2519
|
+
/** Captures `Array.prototype.join` — text assembly from derived parts. */
|
|
2520
|
+
join: (separator?: string) => string;
|
|
2521
|
+
/** Captures `Function.prototype.bind` for a receiver-bound host operation. */
|
|
2522
|
+
bind: (this: Function, thisArg: any, ...argArray: any[]) => any;
|
|
2523
|
+
/** Captures `Object.fromEntries` for derived records. */
|
|
2524
|
+
record: {
|
|
2525
|
+
<T = any>(entries: Iterable<readonly [PropertyKey, T]>): {
|
|
2526
|
+
[k: string]: T;
|
|
2527
|
+
};
|
|
2528
|
+
(entries: Iterable<readonly any[]>): any;
|
|
2529
|
+
};
|
|
2530
|
+
/** Captures `Object.setPrototypeOf` for owned record prototypes. */
|
|
2531
|
+
rebase: (o: any, proto: object | null) => any;
|
|
2368
2532
|
/** Captures `Map` — keyed working state. */
|
|
2369
2533
|
map: MapConstructor;
|
|
2370
2534
|
/** Captures `Map.prototype.get` — a memo read whose answer a published graph embeds, dispatched through `apply`. */
|
|
@@ -2377,12 +2541,16 @@ export declare const INTRINSICS: Readonly<{
|
|
|
2377
2541
|
pairs: (callbackfn: (value: any, key: any, map: Map<any, any>) => void, thisArg?: any) => void;
|
|
2378
2542
|
/** Captures `Set` — membership working state. */
|
|
2379
2543
|
set: SetConstructor;
|
|
2544
|
+
/** Captures `Set.prototype.union` — construction without a live `add` dispatch. */
|
|
2545
|
+
union: <U>(other: ReadonlySetLike<U>) => Set<any>;
|
|
2380
2546
|
/** Captures `Set.prototype.has` — THE membership answer every published verdict rests on, dispatched through `apply`. */
|
|
2381
2547
|
member: (value: any) => boolean;
|
|
2382
2548
|
/** Captures `Set.prototype.add` — collection of one more member, dispatched through `apply`. */
|
|
2383
2549
|
admit: (value: any) => Set<any>;
|
|
2384
2550
|
/** Captures `Set.prototype.forEach` — the only full view of a caller's `Set` that runs no iterator, dispatched through `apply`. */
|
|
2385
2551
|
sweep: (callbackfn: (value: any, value2: any, set: Set<any>) => void, thisArg?: any) => void;
|
|
2552
|
+
/** Captures `Set.prototype.delete` — settlement of an active operation. */
|
|
2553
|
+
remove: (value: any) => boolean;
|
|
2386
2554
|
/** Captures `WeakMap` — object-keyed working state. */
|
|
2387
2555
|
weakMap: WeakMapConstructor;
|
|
2388
2556
|
/** Captures `WeakMap.prototype.get` — an object-keyed memo read a published graph embeds, dispatched through `apply`. */
|
|
@@ -2619,7 +2787,10 @@ export declare function isConstructor(value: unknown): value is AnyConstructor<o
|
|
|
2619
2787
|
*
|
|
2620
2788
|
* @remarks
|
|
2621
2789
|
* Recognition combines a global own-property brand with the native `Error`
|
|
2622
|
-
* base, a subclass prototype,
|
|
2790
|
+
* base, a subclass prototype, an own declared contract code, and valid context.
|
|
2791
|
+
* Context may be a class instance or callable object; paths are checked by index.
|
|
2792
|
+
* Optional context fields are read only when owned; inherited fields are ignored.
|
|
2793
|
+
* A subclass may replace its name without changing recognition.
|
|
2623
2794
|
* The brand stores the error itself and recognition requires that exact
|
|
2624
2795
|
* identity. A transparent proxy is therefore refused because its forwarded
|
|
2625
2796
|
* descriptor still stores the target, not the proxy.
|
|
@@ -2767,6 +2938,19 @@ export declare function isEmptyString(value: unknown): value is '';
|
|
|
2767
2938
|
*/
|
|
2768
2939
|
export declare function isError(value: unknown): value is Error;
|
|
2769
2940
|
|
|
2941
|
+
/**
|
|
2942
|
+
* Narrows a {@link Result} to its {@link Failure} branch.
|
|
2943
|
+
*
|
|
2944
|
+
* @param result - The result to narrow
|
|
2945
|
+
* @returns True if the result failed; false otherwise
|
|
2946
|
+
*
|
|
2947
|
+
* @example
|
|
2948
|
+
* ```ts
|
|
2949
|
+
* isFailure(failure('offline')) // true
|
|
2950
|
+
* ```
|
|
2951
|
+
*/
|
|
2952
|
+
export declare function isFailure<T, E>(result: Result<T, E>): result is Failure<E>;
|
|
2953
|
+
|
|
2770
2954
|
/** Determines whether a value is exactly `false`.
|
|
2771
2955
|
*
|
|
2772
2956
|
* @param value - The value to inspect
|
|
@@ -3366,6 +3550,19 @@ export declare function isSharedArrayBuffer(value: unknown): value is SharedArra
|
|
|
3366
3550
|
*/
|
|
3367
3551
|
export declare function isString(value: unknown): value is string;
|
|
3368
3552
|
|
|
3553
|
+
/**
|
|
3554
|
+
* Narrows a {@link Result} to its {@link Success} branch.
|
|
3555
|
+
*
|
|
3556
|
+
* @param result - The result to narrow
|
|
3557
|
+
* @returns True if the result succeeded; false otherwise
|
|
3558
|
+
*
|
|
3559
|
+
* @example
|
|
3560
|
+
* ```ts
|
|
3561
|
+
* isSuccess(success(1)) // true
|
|
3562
|
+
* ```
|
|
3563
|
+
*/
|
|
3564
|
+
export declare function isSuccess<T, E>(result: Result<T, E>): result is Success<T>;
|
|
3565
|
+
|
|
3369
3566
|
/** Determines whether a value is a symbol.
|
|
3370
3567
|
*
|
|
3371
3568
|
* @param value - The value to inspect
|
|
@@ -3535,6 +3732,23 @@ export declare function isZeroArgAsyncGenerator(value: unknown): value is () =>
|
|
|
3535
3732
|
*/
|
|
3536
3733
|
export declare function isZeroArgGenerator(value: unknown): value is () => Generator<unknown, unknown, unknown>;
|
|
3537
3734
|
|
|
3735
|
+
/**
|
|
3736
|
+
* Iterates indices while rereading the upper bound before every step.
|
|
3737
|
+
*
|
|
3738
|
+
* @remarks
|
|
3739
|
+
* Uses a captured native cursor and never reads an element or a caller's
|
|
3740
|
+
* iterator. Fractional bounds include the last index below the bound.
|
|
3741
|
+
*
|
|
3742
|
+
* @param read - Reads the current upper bound
|
|
3743
|
+
* @returns The indices below each observed bound
|
|
3744
|
+
*
|
|
3745
|
+
* @example
|
|
3746
|
+
* ```ts
|
|
3747
|
+
* Array.from(iterateIndices(() => 3)) // [0, 1, 2]
|
|
3748
|
+
* ```
|
|
3749
|
+
*/
|
|
3750
|
+
export declare function iterateIndices(read: LengthReader): Generator<number, void, unknown>;
|
|
3751
|
+
|
|
3538
3752
|
/**
|
|
3539
3753
|
* Lists the seven standard JSON Schema `type` names, frozen.
|
|
3540
3754
|
*
|
|
@@ -3787,13 +4001,18 @@ export declare function keyOf<const O extends Readonly<Record<PropertyKey, unkno
|
|
|
3787
4001
|
*
|
|
3788
4002
|
* @example
|
|
3789
4003
|
* ```ts
|
|
3790
|
-
* type Tree = { value: number; children: Tree[] }
|
|
3791
|
-
*
|
|
3792
|
-
*
|
|
4004
|
+
* type Tree = { readonly value: number; readonly children: readonly Tree[] }
|
|
4005
|
+
* const isTree: Guard<Tree> = recordOf({
|
|
4006
|
+
* value: isNumber,
|
|
4007
|
+
* children: arrayOf(lazyOf(() => isTree)),
|
|
4008
|
+
* })
|
|
3793
4009
|
* ```
|
|
3794
4010
|
*/
|
|
3795
4011
|
export declare function lazyOf<T>(thunk: () => Guard<T>): Guard<T>;
|
|
3796
4012
|
|
|
4013
|
+
/** Reads the current upper bound of an indexed walk. */
|
|
4014
|
+
export declare type LengthReader = () => number;
|
|
4015
|
+
|
|
3797
4016
|
/**
|
|
3798
4017
|
* Takes at most `limit` leading elements of an array, by index.
|
|
3799
4018
|
*
|
|
@@ -4149,6 +4368,34 @@ export declare function matchesVisited(visited: WeakSet<object>, value: object):
|
|
|
4149
4368
|
*/
|
|
4150
4369
|
export declare function matchOf(pattern: RegExp): Guard<string>;
|
|
4151
4370
|
|
|
4371
|
+
/**
|
|
4372
|
+
* Caps at `128` the length, in UTF-16 code units, of one name a schema declares, frozen:
|
|
4373
|
+
* a schema, group, or field name, or a column key.
|
|
4374
|
+
*
|
|
4375
|
+
* @remarks
|
|
4376
|
+
* A retention limit that a declaring package enforces, as {@link CHOICE_LIMIT} states.
|
|
4377
|
+
*
|
|
4378
|
+
* @example
|
|
4379
|
+
* ```ts
|
|
4380
|
+
* NAME_LIMIT // 128
|
|
4381
|
+
* ```
|
|
4382
|
+
*/
|
|
4383
|
+
export declare const NAME_LIMIT = 128;
|
|
4384
|
+
|
|
4385
|
+
/**
|
|
4386
|
+
* Caps at `16384` the total number of records, arrays, and leaves one schema retains,
|
|
4387
|
+
* frozen.
|
|
4388
|
+
*
|
|
4389
|
+
* @remarks
|
|
4390
|
+
* A retention limit that a declaring package enforces, as {@link CHOICE_LIMIT} states.
|
|
4391
|
+
*
|
|
4392
|
+
* @example
|
|
4393
|
+
* ```ts
|
|
4394
|
+
* NODE_LIMIT // 16384
|
|
4395
|
+
* ```
|
|
4396
|
+
*/
|
|
4397
|
+
export declare const NODE_LIMIT = 16384;
|
|
4398
|
+
|
|
4152
4399
|
/**
|
|
4153
4400
|
* Negates a guard or predicate — passes when `guard` returns `false`.
|
|
4154
4401
|
*
|
|
@@ -4669,6 +4916,20 @@ export declare function parseEnum(value: unknown, allowed: readonly LiteralValue
|
|
|
4669
4916
|
*/
|
|
4670
4917
|
export declare function parseEnumField<const T extends LiteralValue>(record: Record<string, unknown>, path: FieldPath, allowed: readonly T[]): T | undefined;
|
|
4671
4918
|
|
|
4919
|
+
/**
|
|
4920
|
+
* Parses indexed enum members, ending after the first undefined result.
|
|
4921
|
+
*
|
|
4922
|
+
* @param values - The source array, read by index
|
|
4923
|
+
* @param allowed - The accepted literal vocabulary
|
|
4924
|
+
* @returns Parsed members, including the first invalid member's undefined result
|
|
4925
|
+
*
|
|
4926
|
+
* @example
|
|
4927
|
+
* ```ts
|
|
4928
|
+
* Array.from(parseEnumValues(['a', 'x', 'b'], ['a', 'b'])) // ['a', undefined]
|
|
4929
|
+
* ```
|
|
4930
|
+
*/
|
|
4931
|
+
export declare function parseEnumValues<const T extends LiteralValue>(values: readonly unknown[], allowed: readonly T[]): Generator<T | undefined, void, unknown>;
|
|
4932
|
+
|
|
4672
4933
|
/**
|
|
4673
4934
|
* Parses an unknown value to a finite integer.
|
|
4674
4935
|
*
|
|
@@ -5090,6 +5351,22 @@ export declare function preview(value: unknown): string;
|
|
|
5090
5351
|
*/
|
|
5091
5352
|
export declare const PREVIEW_LIMIT = 64;
|
|
5092
5353
|
|
|
5354
|
+
/**
|
|
5355
|
+
* Builds bounded escaped preview parts without splitting a surrogate pair.
|
|
5356
|
+
*
|
|
5357
|
+
* @param source - The source text
|
|
5358
|
+
* @param index - The next UTF-16 offset
|
|
5359
|
+
* @param capacity - The unused preview width
|
|
5360
|
+
* @param quoted - Whether the final part closes a string quote
|
|
5361
|
+
* @returns The escaped parts with their closing quote or truncation mark
|
|
5362
|
+
*
|
|
5363
|
+
* @example
|
|
5364
|
+
* ```ts
|
|
5365
|
+
* previewParts('abc', 0, 2, false) // ['a', 'b', '…']
|
|
5366
|
+
* ```
|
|
5367
|
+
*/
|
|
5368
|
+
export declare function previewParts(source: string, index: number, capacity: number, quoted: boolean): readonly string[];
|
|
5369
|
+
|
|
5093
5370
|
/**
|
|
5094
5371
|
* Represents a deterministic random source returning a value in `[0, 1)`.
|
|
5095
5372
|
*
|
|
@@ -5204,6 +5481,27 @@ export declare function readArrayEntries<T>(value: readonly T[]): Result<ArrayRe
|
|
|
5204
5481
|
*/
|
|
5205
5482
|
export declare function readGuardShape(shape: GuardsShape, optional: readonly string[] | true | undefined, reader: string): GuardShapeRead;
|
|
5206
5483
|
|
|
5484
|
+
/**
|
|
5485
|
+
* Exposes indexed reads through a non-array receiver without species dispatch.
|
|
5486
|
+
*
|
|
5487
|
+
* @remarks
|
|
5488
|
+
* Captured array methods read length, membership, and elements lazily through
|
|
5489
|
+
* the source receiver. The view is not an array, so native map, filter, and
|
|
5490
|
+
* flatMap never consult its constructor or species. Their callback's collection
|
|
5491
|
+
* argument is this view. No source element is observed while constructing it.
|
|
5492
|
+
*
|
|
5493
|
+
* @param values - The array whose live indexed reads and membership are forwarded
|
|
5494
|
+
* @returns A non-array receiver for captured array methods
|
|
5495
|
+
*
|
|
5496
|
+
* @example
|
|
5497
|
+
* ```ts
|
|
5498
|
+
* INTRINSICS.reflect.apply(INTRINSICS.project, readIndexView([1, 2]), [
|
|
5499
|
+
* (value: number) => value * 2,
|
|
5500
|
+
* ]) // [2, 4]
|
|
5501
|
+
* ```
|
|
5502
|
+
*/
|
|
5503
|
+
export declare function readIndexView(values: readonly unknown[]): object;
|
|
5504
|
+
|
|
5207
5505
|
/**
|
|
5208
5506
|
* Snapshots the genuine entries of a caller's `Map` without running an iterator.
|
|
5209
5507
|
*
|
|
@@ -5315,6 +5613,20 @@ export declare function readPatternFlags(pattern: unknown): string | undefined;
|
|
|
5315
5613
|
*/
|
|
5316
5614
|
export declare function readPatternSource(pattern: unknown): string | undefined;
|
|
5317
5615
|
|
|
5616
|
+
/**
|
|
5617
|
+
* Derives the bit mask of names present in an indexed lookup.
|
|
5618
|
+
*
|
|
5619
|
+
* @param names - Names to observe in order
|
|
5620
|
+
* @param positions - The bit position of each declared name
|
|
5621
|
+
* @returns The combined signed 32-bit mask
|
|
5622
|
+
*
|
|
5623
|
+
* @example
|
|
5624
|
+
* ```ts
|
|
5625
|
+
* readPresence(['id'], buildPositions(['id', 'name'])) // 1
|
|
5626
|
+
* ```
|
|
5627
|
+
*/
|
|
5628
|
+
export declare function readPresence(names: readonly string[], positions: Readonly<Record<string, number>>): number;
|
|
5629
|
+
|
|
5318
5630
|
/**
|
|
5319
5631
|
* Checks that a value really is a {@link SampleMemo} before a walk stores a
|
|
5320
5632
|
* published schema in it.
|
|
@@ -6213,7 +6525,7 @@ export declare interface ShapeValidatorInterface {
|
|
|
6213
6525
|
* `valueToSchema({ b: 1, a: 2 })` publish `{"type":"object","additionalProperties":false}`
|
|
6214
6526
|
* — a successful answer with the caller's properties silently gone. The copy is
|
|
6215
6527
|
* taken first so a caller-owned array is never reordered in place, and the order
|
|
6216
|
-
* is decided by {@link
|
|
6528
|
+
* is decided by {@link comparePrimitives}, whose `<` / `>` comparison dispatches
|
|
6217
6529
|
* through nothing.
|
|
6218
6530
|
*
|
|
6219
6531
|
* @param values - The keys or indices to order
|
|
@@ -6226,6 +6538,20 @@ export declare interface ShapeValidatorInterface {
|
|
|
6226
6538
|
*/
|
|
6227
6539
|
export declare function sortValues<T extends string | number>(values: readonly T[]): readonly T[];
|
|
6228
6540
|
|
|
6541
|
+
/**
|
|
6542
|
+
* Caps at `65536` the length, in UTF-16 code units, of any single string one schema
|
|
6543
|
+
* retains, frozen.
|
|
6544
|
+
*
|
|
6545
|
+
* @remarks
|
|
6546
|
+
* A retention limit that a declaring package enforces, as {@link CHOICE_LIMIT} states.
|
|
6547
|
+
*
|
|
6548
|
+
* @example
|
|
6549
|
+
* ```ts
|
|
6550
|
+
* STRING_LIMIT // 65536
|
|
6551
|
+
* ```
|
|
6552
|
+
*/
|
|
6553
|
+
export declare const STRING_LIMIT = 65536;
|
|
6554
|
+
|
|
6229
6555
|
/**
|
|
6230
6556
|
* Groups the options for the `stringOf` guard builder.
|
|
6231
6557
|
*
|
|
@@ -6346,6 +6672,33 @@ export declare interface Success<T> {
|
|
|
6346
6672
|
readonly value: T;
|
|
6347
6673
|
}
|
|
6348
6674
|
|
|
6675
|
+
/**
|
|
6676
|
+
* Boxes a value as the {@link Success} branch of a {@link Result}.
|
|
6677
|
+
*
|
|
6678
|
+
* @param value - The value to box, retained exactly
|
|
6679
|
+
* @returns A fresh `{ success: true, value }` record
|
|
6680
|
+
*
|
|
6681
|
+
* @example
|
|
6682
|
+
* ```ts
|
|
6683
|
+
* success(42) // { success: true, value: 42 }
|
|
6684
|
+
* ```
|
|
6685
|
+
*/
|
|
6686
|
+
export declare function success<T>(value: T): Success<T>;
|
|
6687
|
+
|
|
6688
|
+
/**
|
|
6689
|
+
* Caps at `1048576` the total length, in UTF-16 code units, of every string one schema
|
|
6690
|
+
* retains, frozen.
|
|
6691
|
+
*
|
|
6692
|
+
* @remarks
|
|
6693
|
+
* A retention limit that a declaring package enforces, as {@link CHOICE_LIMIT} states.
|
|
6694
|
+
*
|
|
6695
|
+
* @example
|
|
6696
|
+
* ```ts
|
|
6697
|
+
* TEXT_LIMIT // 1048576
|
|
6698
|
+
* ```
|
|
6699
|
+
*/
|
|
6700
|
+
export declare const TEXT_LIMIT = 1048576;
|
|
6701
|
+
|
|
6349
6702
|
/**
|
|
6350
6703
|
* Builds a guard that passes when the base passes AND the projection of the value
|
|
6351
6704
|
* satisfies the target guard. Still narrows to `T` (the base type) — the target
|