modern-ts 0.8.0
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/LICENSE +201 -0
- package/README.md +223 -0
- package/README.zh-CN.md +223 -0
- package/dist/chunks/Errors-BWEYu-AB.cjs +2 -0
- package/dist/chunks/Errors-BWEYu-AB.cjs.map +1 -0
- package/dist/chunks/Errors-DwUAvFIF.mjs +63 -0
- package/dist/chunks/Errors-DwUAvFIF.mjs.map +1 -0
- package/dist/chunks/Math-CGEH1ClN.mjs +68 -0
- package/dist/chunks/Math-CGEH1ClN.mjs.map +1 -0
- package/dist/chunks/Math-CWZVxSF-.cjs +2 -0
- package/dist/chunks/Math-CWZVxSF-.cjs.map +1 -0
- package/dist/chunks/base-B9k8Lqvf.mjs +56 -0
- package/dist/chunks/base-B9k8Lqvf.mjs.map +1 -0
- package/dist/chunks/base-BTXL1y_I.cjs +2 -0
- package/dist/chunks/base-BTXL1y_I.cjs.map +1 -0
- package/dist/chunks/base-BpECeKwU.mjs +19 -0
- package/dist/chunks/base-BpECeKwU.mjs.map +1 -0
- package/dist/chunks/base-BvHqpP_s.cjs +2 -0
- package/dist/chunks/base-BvHqpP_s.cjs.map +1 -0
- package/dist/chunks/base-K-RHLZ-S.mjs +46 -0
- package/dist/chunks/base-K-RHLZ-S.mjs.map +1 -0
- package/dist/chunks/base-r6kn0B0D.cjs +2 -0
- package/dist/chunks/base-r6kn0B0D.cjs.map +1 -0
- package/dist/chunks/combine-async-DcG-3p8i.cjs +2 -0
- package/dist/chunks/combine-async-DcG-3p8i.cjs.map +1 -0
- package/dist/chunks/combine-async-Dcg4ya1R.mjs +236 -0
- package/dist/chunks/combine-async-Dcg4ya1R.mjs.map +1 -0
- package/dist/chunks/delay-CG3cD7bk.cjs +2 -0
- package/dist/chunks/delay-CG3cD7bk.cjs.map +1 -0
- package/dist/chunks/delay-CKIXpP71.mjs +32 -0
- package/dist/chunks/delay-CKIXpP71.mjs.map +1 -0
- package/dist/chunks/helper-BVabbpmX.mjs +165 -0
- package/dist/chunks/helper-BVabbpmX.mjs.map +1 -0
- package/dist/chunks/helper-tsqZMRHW.cjs +3 -0
- package/dist/chunks/helper-tsqZMRHW.cjs.map +1 -0
- package/dist/chunks/local-8JVtLN0O.mjs +10 -0
- package/dist/chunks/local-8JVtLN0O.mjs.map +1 -0
- package/dist/chunks/local-Da4yU-nE.cjs +2 -0
- package/dist/chunks/local-Da4yU-nE.cjs.map +1 -0
- package/dist/chunks/types-B7X_LBjM.cjs +2 -0
- package/dist/chunks/types-B7X_LBjM.cjs.map +1 -0
- package/dist/chunks/types-DE2SnSbz.mjs +5 -0
- package/dist/chunks/types-DE2SnSbz.mjs.map +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.mjs +759 -0
- package/dist/index.mjs.map +1 -0
- package/dist/subpath/Arr.cjs +2 -0
- package/dist/subpath/Arr.cjs.map +1 -0
- package/dist/subpath/Arr.mjs +539 -0
- package/dist/subpath/Arr.mjs.map +1 -0
- package/dist/subpath/Concurrent.cjs +15 -0
- package/dist/subpath/Concurrent.cjs.map +1 -0
- package/dist/subpath/Concurrent.mjs +4044 -0
- package/dist/subpath/Concurrent.mjs.map +1 -0
- package/dist/subpath/FetchQ.cjs +2 -0
- package/dist/subpath/FetchQ.cjs.map +1 -0
- package/dist/subpath/FetchQ.mjs +519 -0
- package/dist/subpath/FetchQ.mjs.map +1 -0
- package/dist/subpath/Fit.cjs +2 -0
- package/dist/subpath/Fit.cjs.map +1 -0
- package/dist/subpath/Fit.mjs +914 -0
- package/dist/subpath/Fit.mjs.map +1 -0
- package/dist/subpath/Lazy.cjs +2 -0
- package/dist/subpath/Lazy.cjs.map +1 -0
- package/dist/subpath/Lazy.mjs +72 -0
- package/dist/subpath/Lazy.mjs.map +1 -0
- package/dist/subpath/Maps.cjs +2 -0
- package/dist/subpath/Maps.cjs.map +1 -0
- package/dist/subpath/Maps.mjs +123 -0
- package/dist/subpath/Maps.mjs.map +1 -0
- package/dist/subpath/Maybe.cjs +2 -0
- package/dist/subpath/Maybe.cjs.map +1 -0
- package/dist/subpath/Maybe.mjs +329 -0
- package/dist/subpath/Maybe.mjs.map +1 -0
- package/dist/subpath/Reactive.cjs +2 -0
- package/dist/subpath/Reactive.cjs.map +1 -0
- package/dist/subpath/Reactive.mjs +1204 -0
- package/dist/subpath/Reactive.mjs.map +1 -0
- package/dist/subpath/Reader.cjs +2 -0
- package/dist/subpath/Reader.cjs.map +1 -0
- package/dist/subpath/Reader.mjs +75 -0
- package/dist/subpath/Reader.mjs.map +1 -0
- package/dist/subpath/ReaderT.cjs +2 -0
- package/dist/subpath/ReaderT.cjs.map +1 -0
- package/dist/subpath/ReaderT.mjs +148 -0
- package/dist/subpath/ReaderT.mjs.map +1 -0
- package/dist/subpath/Resource.cjs +2 -0
- package/dist/subpath/Resource.cjs.map +1 -0
- package/dist/subpath/Resource.mjs +150 -0
- package/dist/subpath/Resource.mjs.map +1 -0
- package/dist/subpath/Result.cjs +2 -0
- package/dist/subpath/Result.cjs.map +1 -0
- package/dist/subpath/Result.mjs +337 -0
- package/dist/subpath/Result.mjs.map +1 -0
- package/dist/subpath/Sets.cjs +2 -0
- package/dist/subpath/Sets.cjs.map +1 -0
- package/dist/subpath/Sets.mjs +92 -0
- package/dist/subpath/Sets.mjs.map +1 -0
- package/dist/subpath/Str.cjs +2 -0
- package/dist/subpath/Str.cjs.map +1 -0
- package/dist/subpath/Str.mjs +114 -0
- package/dist/subpath/Str.mjs.map +1 -0
- package/dist/subpath/TxScope.cjs +2 -0
- package/dist/subpath/TxScope.cjs.map +1 -0
- package/dist/subpath/TxScope.mjs +138 -0
- package/dist/subpath/TxScope.mjs.map +1 -0
- package/dist/subpath/TypeTool.cjs +2 -0
- package/dist/subpath/TypeTool.cjs.map +1 -0
- package/dist/subpath/TypeTool.mjs +9 -0
- package/dist/subpath/TypeTool.mjs.map +1 -0
- package/dist/subpath/Utils.cjs +2 -0
- package/dist/subpath/Utils.cjs.map +1 -0
- package/dist/subpath/Utils.mjs +835 -0
- package/dist/subpath/Utils.mjs.map +1 -0
- package/dist/subpath/VirtualTime.cjs +2 -0
- package/dist/subpath/VirtualTime.cjs.map +1 -0
- package/dist/subpath/VirtualTime.mjs +1186 -0
- package/dist/subpath/VirtualTime.mjs.map +1 -0
- package/dist/types/Arr.d.ts +2 -0
- package/dist/types/Concurrent/Lock/condition_variable.d.ts +138 -0
- package/dist/types/Concurrent/Lock/mutex.d.ts +185 -0
- package/dist/types/Concurrent/Lock/rwlock.d.ts +253 -0
- package/dist/types/Concurrent/Lock/semaphore.d.ts +208 -0
- package/dist/types/Concurrent/Valve/__export__.d.ts +5 -0
- package/dist/types/Concurrent/Valve/circuit-breaker.d.ts +146 -0
- package/dist/types/Concurrent/Valve/leaky-bucket.d.ts +115 -0
- package/dist/types/Concurrent/Valve/sliding-window.d.ts +91 -0
- package/dist/types/Concurrent/Valve/token-bucket.d.ts +68 -0
- package/dist/types/Concurrent/__export__.d.ts +15 -0
- package/dist/types/Concurrent/barrier.d.ts +255 -0
- package/dist/types/Concurrent/channel.d.ts +239 -0
- package/dist/types/Concurrent/delay.d.ts +42 -0
- package/dist/types/Concurrent/ext/map.d.ts +82 -0
- package/dist/types/Concurrent/ext/other.d.ts +113 -0
- package/dist/types/Concurrent/ext/race.d.ts +31 -0
- package/dist/types/Concurrent/ext/some.d.ts +64 -0
- package/dist/types/Concurrent/limiter.d.ts +131 -0
- package/dist/types/Concurrent/scheduler.d.ts +171 -0
- package/dist/types/Concurrent/task-scope.d.ts +282 -0
- package/dist/types/Concurrent.d.ts +2 -0
- package/dist/types/Errors.d.ts +66 -0
- package/dist/types/FetchQ.d.ts +2 -0
- package/dist/types/Fit/__export__.d.ts +5 -0
- package/dist/types/Fit/base.d.ts +325 -0
- package/dist/types/Fit/parser.d.ts +110 -0
- package/dist/types/Fit/standard-schema.d.ts +127 -0
- package/dist/types/Fit/sugar.d.ts +274 -0
- package/dist/types/Fit/tool.d.ts +585 -0
- package/dist/types/Fit.d.ts +2 -0
- package/dist/types/Lazy.d.ts +2 -0
- package/dist/types/Maps.d.ts +2 -0
- package/dist/types/Maybe/__export__.d.ts +6 -0
- package/dist/types/Maybe/base.d.ts +62 -0
- package/dist/types/Maybe/consumers-async.d.ts +58 -0
- package/dist/types/Maybe/consumers.d.ts +63 -0
- package/dist/types/Maybe/operators-async.d.ts +145 -0
- package/dist/types/Maybe/operators.d.ts +177 -0
- package/dist/types/Maybe/types.d.ts +12 -0
- package/dist/types/Maybe.d.ts +2 -0
- package/dist/types/MockClock/Timeline.d.ts +392 -0
- package/dist/types/MockClock/TimerHandle.d.ts +159 -0
- package/dist/types/MockClock/TimerHeap.d.ts +21 -0
- package/dist/types/MockClock/VirtualTimeManager.d.ts +23 -0
- package/dist/types/MockClock/__export__.d.ts +104 -0
- package/dist/types/MockClock/hooks/__export__.d.ts +9 -0
- package/dist/types/MockClock/hooks/hookAbortSignal.d.ts +3 -0
- package/dist/types/MockClock/hooks/hookDate.d.ts +3 -0
- package/dist/types/MockClock/hooks/hookIntl.d.ts +3 -0
- package/dist/types/MockClock/hooks/hookMessageChannel.d.ts +3 -0
- package/dist/types/MockClock/hooks/hookMicrotasks.d.ts +3 -0
- package/dist/types/MockClock/hooks/hookOs.d.ts +3 -0
- package/dist/types/MockClock/hooks/hookPerformance.d.ts +3 -0
- package/dist/types/MockClock/hooks/hookProcess.d.ts +3 -0
- package/dist/types/MockClock/hooks/hookTimers.d.ts +3 -0
- package/dist/types/MockClock/types.d.ts +103 -0
- package/dist/types/Other/FetchQ.d.ts +320 -0
- package/dist/types/Other/deque.d.ts +59 -0
- package/dist/types/Other/disjointSet.d.ts +53 -0
- package/dist/types/Other/heap.d.ts +41 -0
- package/dist/types/Other/lazy.d.ts +127 -0
- package/dist/types/Other/queue.d.ts +42 -0
- package/dist/types/Other/secret.d.ts +111 -0
- package/dist/types/Other/stack.d.ts +40 -0
- package/dist/types/Reactive/__export__.d.ts +4 -0
- package/dist/types/Reactive/event_emitter.d.ts +195 -0
- package/dist/types/Reactive/flow-combination.d.ts +74 -0
- package/dist/types/Reactive/flow.d.ts +180 -0
- package/dist/types/Reactive/pace.d.ts +80 -0
- package/dist/types/Reactive.d.ts +2 -0
- package/dist/types/Reader/__export-readerT__.d.ts +4 -0
- package/dist/types/Reader/__export-reader__.d.ts +4 -0
- package/dist/types/Reader/local.d.ts +39 -0
- package/dist/types/Reader/reader-async.d.ts +84 -0
- package/dist/types/Reader/reader.d.ts +96 -0
- package/dist/types/Reader/readerT-async.d.ts +186 -0
- package/dist/types/Reader/readerT.d.ts +178 -0
- package/dist/types/Reader/types.d.ts +37 -0
- package/dist/types/Reader.d.ts +2 -0
- package/dist/types/ReaderT.d.ts +2 -0
- package/dist/types/Resource/TxScope-async.d.ts +86 -0
- package/dist/types/Resource/TxScope.d.ts +85 -0
- package/dist/types/Resource/__export-TxScope__.d.ts +2 -0
- package/dist/types/Resource/__export-resource__.d.ts +2 -0
- package/dist/types/Resource/resource-async.d.ts +79 -0
- package/dist/types/Resource/resource.d.ts +78 -0
- package/dist/types/Resource/types.d.ts +79 -0
- package/dist/types/Resource.d.ts +2 -0
- package/dist/types/Result/Consumers/branch-async.d.ts +77 -0
- package/dist/types/Result/Consumers/branch.d.ts +70 -0
- package/dist/types/Result/Consumers/inspect.d.ts +66 -0
- package/dist/types/Result/Operators/Async/combine-async.d.ts +69 -0
- package/dist/types/Result/Operators/Async/partition-async.d.ts +29 -0
- package/dist/types/Result/Operators/Async/reduce-async.d.ts +15 -0
- package/dist/types/Result/Operators/Async/transform-async.d.ts +90 -0
- package/dist/types/Result/Operators/combine.d.ts +60 -0
- package/dist/types/Result/Operators/flatten.d.ts +26 -0
- package/dist/types/Result/Operators/partition.d.ts +25 -0
- package/dist/types/Result/Operators/reduce.d.ts +12 -0
- package/dist/types/Result/Operators/transform.d.ts +70 -0
- package/dist/types/Result/__export__.d.ts +14 -0
- package/dist/types/Result/base.d.ts +115 -0
- package/dist/types/Result/types.d.ts +34 -0
- package/dist/types/Result.d.ts +2 -0
- package/dist/types/Sets.d.ts +2 -0
- package/dist/types/Str.d.ts +2 -0
- package/dist/types/TxScope.d.ts +2 -0
- package/dist/types/TypeTool.d.ts +2 -0
- package/dist/types/Utils/Array/__export__.d.ts +10 -0
- package/dist/types/Utils/Array/filtering.d.ts +89 -0
- package/dist/types/Utils/Array/flatten.d.ts +45 -0
- package/dist/types/Utils/Array/grouping.d.ts +44 -0
- package/dist/types/Utils/Array/iteration.d.ts +86 -0
- package/dist/types/Utils/Array/operators.d.ts +62 -0
- package/dist/types/Utils/Array/randomization.d.ts +76 -0
- package/dist/types/Utils/Array/set.d.ts +108 -0
- package/dist/types/Utils/Array/slice.d.ts +189 -0
- package/dist/types/Utils/Array/sorting.d.ts +55 -0
- package/dist/types/Utils/Array/zip.d.ts +93 -0
- package/dist/types/Utils/Functions/__export__.d.ts +5 -0
- package/dist/types/Utils/Functions/base.d.ts +157 -0
- package/dist/types/Utils/Functions/curry.d.ts +73 -0
- package/dist/types/Utils/Functions/debounce.d.ts +240 -0
- package/dist/types/Utils/Functions/defer.d.ts +43 -0
- package/dist/types/Utils/Functions/pipe.d.ts +205 -0
- package/dist/types/Utils/Map.d.ts +284 -0
- package/dist/types/Utils/Math.d.ts +225 -0
- package/dist/types/Utils/Object/__export__.d.ts +2 -0
- package/dist/types/Utils/Object/base.d.ts +131 -0
- package/dist/types/Utils/Object/clone.d.ts +81 -0
- package/dist/types/Utils/Predicates.d.ts +361 -0
- package/dist/types/Utils/Set.d.ts +105 -0
- package/dist/types/Utils/String.d.ts +217 -0
- package/dist/types/Utils/__export__.d.ts +9 -0
- package/dist/types/Utils/type-tool.d.ts +168 -0
- package/dist/types/Utils.d.ts +2 -0
- package/dist/types/VirtualTime.d.ts +2 -0
- package/dist/types/helper.d.ts +71 -0
- package/dist/types/index.d.ts +21 -0
- package/dist/types/unknown-error.d.ts +98 -0
- package/package.json +179 -0
|
@@ -0,0 +1,585 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type guard that checks if a value is a string.
|
|
3
|
+
* @param x - The value to check
|
|
4
|
+
* @returns True if the value is a string
|
|
5
|
+
*/
|
|
6
|
+
declare const _string: (x: unknown) => x is string;
|
|
7
|
+
/**
|
|
8
|
+
* Type guard that checks if a value is a number.
|
|
9
|
+
* @param x - The value to check
|
|
10
|
+
* @returns True if the value is a number
|
|
11
|
+
*/
|
|
12
|
+
declare const _number: (x: unknown) => x is number;
|
|
13
|
+
/**
|
|
14
|
+
* Type guard that checks if a value is a boolean.
|
|
15
|
+
* @param x - The value to check
|
|
16
|
+
* @returns True if the value is a boolean
|
|
17
|
+
*/
|
|
18
|
+
declare const _boolean: (x: unknown) => x is boolean;
|
|
19
|
+
/**
|
|
20
|
+
* Type guard that checks if a value is a symbol.
|
|
21
|
+
* @param x - The value to check
|
|
22
|
+
* @returns True if the value is a symbol
|
|
23
|
+
*/
|
|
24
|
+
declare const _symbol: (x: unknown) => x is symbol;
|
|
25
|
+
/**
|
|
26
|
+
* Type guard that checks if a value is a bigint.
|
|
27
|
+
* @param x - The value to check
|
|
28
|
+
* @returns True if the value is a bigint
|
|
29
|
+
*/
|
|
30
|
+
declare const _bigint: (x: unknown) => x is bigint;
|
|
31
|
+
/**
|
|
32
|
+
* Type guard that checks if a value is a function.
|
|
33
|
+
* @param x - The value to check
|
|
34
|
+
* @returns True if the value is a function
|
|
35
|
+
*/
|
|
36
|
+
declare const _function: (x: unknown) => x is (...args: unknown[]) => unknown;
|
|
37
|
+
/**
|
|
38
|
+
* Type guard that checks if a value is a non-null object.
|
|
39
|
+
* @param x - The value to check
|
|
40
|
+
* @returns True if the value is a non-null object
|
|
41
|
+
*/
|
|
42
|
+
declare const _object: (x: unknown) => x is Record<string, unknown>;
|
|
43
|
+
/**
|
|
44
|
+
* Type guard that checks if a value is an array.
|
|
45
|
+
* @param x - The value to check
|
|
46
|
+
* @returns True if the value is an array
|
|
47
|
+
*/
|
|
48
|
+
declare const _array: (x: unknown) => x is unknown[];
|
|
49
|
+
/**
|
|
50
|
+
* Type guard that checks if a value is undefined.
|
|
51
|
+
* @param x - The value to check
|
|
52
|
+
* @returns True if the value is undefined
|
|
53
|
+
*/
|
|
54
|
+
declare const _undefined: (x: unknown) => x is undefined;
|
|
55
|
+
/**
|
|
56
|
+
* Type guard that checks if a value is null.
|
|
57
|
+
* @param x - The value to check
|
|
58
|
+
* @returns True if the value is null
|
|
59
|
+
*/
|
|
60
|
+
declare const _null: (x: unknown) => x is null;
|
|
61
|
+
/**
|
|
62
|
+
* Type guard that checks if a value is null or undefined.
|
|
63
|
+
* @param x - The value to check
|
|
64
|
+
* @returns True if the value is null or undefined
|
|
65
|
+
*/
|
|
66
|
+
declare const _nullish: (x: unknown) => x is null | undefined;
|
|
67
|
+
/**
|
|
68
|
+
* Type guard that checks if a value is a primitive type.
|
|
69
|
+
* @param x - The value to check
|
|
70
|
+
* @returns True if the value is string, number, boolean, null, undefined, symbol, or bigint
|
|
71
|
+
*/
|
|
72
|
+
declare const _primitive: (x: unknown) => x is string | number | boolean | null | undefined | symbol | bigint;
|
|
73
|
+
/**
|
|
74
|
+
* Type guard that checks if a value is a Date object.
|
|
75
|
+
* @param x - The value to check
|
|
76
|
+
* @returns True if the value is a Date instance
|
|
77
|
+
*/
|
|
78
|
+
declare const _date: (x: unknown) => x is Date;
|
|
79
|
+
/**
|
|
80
|
+
* Type guard that checks if a value is a RegExp object.
|
|
81
|
+
* @param x - The value to check
|
|
82
|
+
* @returns True if the value is a RegExp instance
|
|
83
|
+
*/
|
|
84
|
+
declare const _regexp: (x: unknown) => x is RegExp;
|
|
85
|
+
/**
|
|
86
|
+
* Type guard that checks if a value is an Error object.
|
|
87
|
+
* @param x - The value to check
|
|
88
|
+
* @returns True if the value is an Error instance
|
|
89
|
+
*/
|
|
90
|
+
declare const _error: (x: unknown) => x is Error;
|
|
91
|
+
/**
|
|
92
|
+
* Type guard that checks if a value is a Map object.
|
|
93
|
+
* @template K - The map key type (default: unknown)
|
|
94
|
+
* @template V - The map value type (default: unknown)
|
|
95
|
+
* @param x - The value to check
|
|
96
|
+
* @returns True if the value is a Map instance
|
|
97
|
+
*/
|
|
98
|
+
declare const _map: <K = unknown, V = unknown>(x: unknown) => x is Map<K, V>;
|
|
99
|
+
/**
|
|
100
|
+
* Type guard that checks if a value is a Set object.
|
|
101
|
+
* @template T - The set element type (default: unknown)
|
|
102
|
+
* @param x - The value to check
|
|
103
|
+
* @returns True if the value is a Set instance
|
|
104
|
+
*/
|
|
105
|
+
declare const _set: <T = unknown>(x: unknown) => x is Set<T>;
|
|
106
|
+
/**
|
|
107
|
+
* Type guard that checks if a value is a WeakMap object.
|
|
108
|
+
* @template K - The weak map key type (must extend object, default: object)
|
|
109
|
+
* @template V - The weak map value type (default: unknown)
|
|
110
|
+
* @param x - The value to check
|
|
111
|
+
* @returns True if the value is a WeakMap instance
|
|
112
|
+
*/
|
|
113
|
+
declare const _weakMap: <K extends object, V = unknown>(x: unknown) => x is WeakMap<K, V>;
|
|
114
|
+
/**
|
|
115
|
+
* Type guard that checks if a value is a WeakSet object.
|
|
116
|
+
* @template T - The weak set element type (must extend object, default: object)
|
|
117
|
+
* @param x - The value to check
|
|
118
|
+
* @returns True if the value is a WeakSet instance
|
|
119
|
+
*/
|
|
120
|
+
declare const _weakSet: <T extends object>(x: unknown) => x is WeakSet<T>;
|
|
121
|
+
/**
|
|
122
|
+
* Type guard that checks if a value is a plain object (non-null object that is not an array).
|
|
123
|
+
* @param x - The value to check
|
|
124
|
+
* @returns True if the value is a plain object
|
|
125
|
+
*/
|
|
126
|
+
declare const _plainObject: (x: unknown) => x is Record<string, unknown>;
|
|
127
|
+
/**
|
|
128
|
+
* Type guard that checks if a value is iterable (has Symbol.iterator).
|
|
129
|
+
* @param x - The value to check
|
|
130
|
+
* @returns True if the value implements the Iterable protocol
|
|
131
|
+
*/
|
|
132
|
+
declare const _iterable: (x: unknown) => x is Iterable<unknown>;
|
|
133
|
+
/**
|
|
134
|
+
* Type guard that checks if a value is async iterable (has Symbol.asyncIterator).
|
|
135
|
+
* @param x - The value to check
|
|
136
|
+
* @returns True if the value implements the AsyncIterable protocol
|
|
137
|
+
*/
|
|
138
|
+
declare const _asyncIterable: (x: unknown) => x is AsyncIterable<unknown>;
|
|
139
|
+
/**
|
|
140
|
+
* Creates a type guard that checks if a value is a Record with specific key and value types.
|
|
141
|
+
* @template K - The record key type (must extend PropertyKey)
|
|
142
|
+
* @template V - The record value type
|
|
143
|
+
* @param key_guard - The type guard for keys
|
|
144
|
+
* @param value_guard - The type guard for values
|
|
145
|
+
* @returns A type guard that returns true if all enumerable own properties pass both guards
|
|
146
|
+
*/
|
|
147
|
+
declare const _record: <K extends PropertyKey, V>(key_guard: (k: unknown) => k is K, value_guard: (v: unknown) => v is V) => (x: unknown) => x is Record<K, V>;
|
|
148
|
+
/**
|
|
149
|
+
* Type guard that checks if a value is truthy (coerces to true in boolean context).
|
|
150
|
+
* @template T - The expected truthy type
|
|
151
|
+
* @param x - The value to check
|
|
152
|
+
* @returns True if the value is truthy (excludes null, undefined, false, 0, '', 0n)
|
|
153
|
+
*/
|
|
154
|
+
declare const _truthy: <T>(x: T | null | undefined | false | 0 | "" | 0n) => x is T;
|
|
155
|
+
/**
|
|
156
|
+
* Type guard that checks if a value is falsy (coerces to false in boolean context).
|
|
157
|
+
* @param x - The value to check
|
|
158
|
+
* @returns True if the value is null, undefined, false, 0, '', or 0n
|
|
159
|
+
*/
|
|
160
|
+
declare const _falsy: (x: unknown) => x is null | undefined | false | 0 | "" | 0n;
|
|
161
|
+
/**
|
|
162
|
+
* Checks if a value is empty (nullish, empty string/array, empty Map/Set, or object with no keys).
|
|
163
|
+
* @param x - The value to check
|
|
164
|
+
* @returns True if the value is considered empty
|
|
165
|
+
*/
|
|
166
|
+
declare const _empty: (x: unknown) => boolean;
|
|
167
|
+
/**
|
|
168
|
+
* Checks if a value is non-empty (not nullish, has content).
|
|
169
|
+
* @param x - The value to check
|
|
170
|
+
* @returns True if the value is considered non-empty
|
|
171
|
+
*/
|
|
172
|
+
declare const _nonEmpty: (x: unknown) => boolean;
|
|
173
|
+
/**
|
|
174
|
+
* Creates a type guard that checks if a value equals a specific value (strict equality).
|
|
175
|
+
* @template T - The expected value type
|
|
176
|
+
* @param val - The value to compare against
|
|
177
|
+
* @returns A type guard that returns true if the value === val
|
|
178
|
+
*/
|
|
179
|
+
declare const _eq: <T>(val: T) => (x: unknown) => x is T;
|
|
180
|
+
/**
|
|
181
|
+
* Creates a predicate that checks if a value does not equal a specific value.
|
|
182
|
+
* @template T - The comparison value type
|
|
183
|
+
* @param val - The value to compare against
|
|
184
|
+
* @returns A predicate that returns true if the value !== val
|
|
185
|
+
*/
|
|
186
|
+
declare const _neq: <T>(val: T) => (x: unknown) => boolean;
|
|
187
|
+
/**
|
|
188
|
+
* Creates a predicate that checks if a number is greater than a value.
|
|
189
|
+
* @param val - The comparison value
|
|
190
|
+
* @returns A predicate that returns true if the number > val
|
|
191
|
+
*/
|
|
192
|
+
declare const _gt: (val: number) => (x: number) => boolean;
|
|
193
|
+
/**
|
|
194
|
+
* Creates a predicate that checks if a number is greater than or equal to a value.
|
|
195
|
+
* @param val - The comparison value
|
|
196
|
+
* @returns A predicate that returns true if the number >= val
|
|
197
|
+
*/
|
|
198
|
+
declare const _gte: (val: number) => (x: number) => boolean;
|
|
199
|
+
/**
|
|
200
|
+
* Creates a predicate that checks if a number is less than a value.
|
|
201
|
+
* @param val - The comparison value
|
|
202
|
+
* @returns A predicate that returns true if the number < val
|
|
203
|
+
*/
|
|
204
|
+
declare const _lt: (val: number) => (x: number) => boolean;
|
|
205
|
+
/**
|
|
206
|
+
* Creates a predicate that checks if a number is less than or equal to a value.
|
|
207
|
+
* @param val - The comparison value
|
|
208
|
+
* @returns A predicate that returns true if the number <= val
|
|
209
|
+
*/
|
|
210
|
+
declare const _lte: (val: number) => (x: number) => boolean;
|
|
211
|
+
/**
|
|
212
|
+
* Creates a predicate that checks if a number is strictly between two values (exclusive).
|
|
213
|
+
* @param min_val - The minimum value (exclusive)
|
|
214
|
+
* @param max_val - The maximum value (exclusive)
|
|
215
|
+
* @returns A predicate that returns true if min_val < number < max_val
|
|
216
|
+
*/
|
|
217
|
+
declare const _between: (min_val: number, max_val: number) => (x: number) => boolean;
|
|
218
|
+
/**
|
|
219
|
+
* Creates a predicate that checks if a number is between two values (inclusive).
|
|
220
|
+
* @param min_val - The minimum value (inclusive)
|
|
221
|
+
* @param max_val - The maximum value (inclusive)
|
|
222
|
+
* @returns A predicate that returns true if min_val <= number <= max_val
|
|
223
|
+
*/
|
|
224
|
+
declare const _betweenInclusive: (min_val: number, max_val: number) => (x: number) => boolean;
|
|
225
|
+
/**
|
|
226
|
+
* Creates a type guard that checks if a value is one of the specified values.
|
|
227
|
+
* @template T - The tuple of allowed values
|
|
228
|
+
* @param vals - The values to check against
|
|
229
|
+
* @returns A type guard that returns true if the value is in the list
|
|
230
|
+
*/
|
|
231
|
+
declare const _oneOf: <const T extends readonly [unknown, ...unknown[]]>(...vals: T) => (x: unknown) => x is T[number];
|
|
232
|
+
/**
|
|
233
|
+
* Creates a predicate that checks if a value is not one of the specified values.
|
|
234
|
+
* @template T - The tuple of excluded values
|
|
235
|
+
* @param vals - The values to exclude
|
|
236
|
+
* @returns A predicate that returns true if the value is not in the list
|
|
237
|
+
*/
|
|
238
|
+
declare const _notOneOf: <const T extends readonly [unknown, ...unknown[]]>(...vals: T) => (x: unknown) => boolean;
|
|
239
|
+
/**
|
|
240
|
+
* Creates a type guard that checks if a value is an instance of a class.
|
|
241
|
+
* @template T - The constructor type
|
|
242
|
+
* @param cls - The class constructor to check against
|
|
243
|
+
* @returns A type guard that returns true if the value is an instance of cls
|
|
244
|
+
*/
|
|
245
|
+
declare const _instanceOf: <T extends abstract new (...args: any[]) => unknown>(cls: T) => (x: unknown) => x is InstanceType<T>;
|
|
246
|
+
/**
|
|
247
|
+
* Creates a predicate that checks if a string has at least the specified length.
|
|
248
|
+
* @param len - The minimum required length
|
|
249
|
+
* @returns A predicate function that returns true if the string length is >= len
|
|
250
|
+
*/
|
|
251
|
+
export declare const min_len: (len: number) => (x: string) => boolean;
|
|
252
|
+
/**
|
|
253
|
+
* Creates a predicate that checks if a string has at most the specified length.
|
|
254
|
+
* @param len - The maximum allowed length
|
|
255
|
+
* @returns A predicate function that returns true if the string length is <= len
|
|
256
|
+
*/
|
|
257
|
+
export declare const max_len: (len: number) => (x: string) => boolean;
|
|
258
|
+
/**
|
|
259
|
+
* Creates a predicate that checks if a string length falls within a specified range.
|
|
260
|
+
* @param min - The minimum required length (inclusive)
|
|
261
|
+
* @param max - The maximum allowed length (inclusive)
|
|
262
|
+
* @returns A predicate function that returns true if the string length is within [min, max]
|
|
263
|
+
*/
|
|
264
|
+
export declare const len_range: (min: number, max: number) => (x: string) => boolean;
|
|
265
|
+
/**
|
|
266
|
+
* Creates a predicate that checks if a string matches a regular expression.
|
|
267
|
+
* @param reg - The regular expression to test against
|
|
268
|
+
* @returns A predicate function that returns true if the string matches the regex
|
|
269
|
+
*/
|
|
270
|
+
export declare const matches: (reg: RegExp) => (x: string) => boolean;
|
|
271
|
+
/**
|
|
272
|
+
* Creates a predicate that checks if a string starts with the specified prefix.
|
|
273
|
+
* @param prefix - The prefix to check for
|
|
274
|
+
* @returns A predicate function that returns true if the string starts with the prefix
|
|
275
|
+
*/
|
|
276
|
+
export declare const starts_with: (prefix: string) => (x: string) => boolean;
|
|
277
|
+
/**
|
|
278
|
+
* Creates a predicate that checks if a string ends with the specified suffix.
|
|
279
|
+
* @param suffix - The suffix to check for
|
|
280
|
+
* @returns A predicate function that returns true if the string ends with the suffix
|
|
281
|
+
*/
|
|
282
|
+
export declare const ends_with: (suffix: string) => (x: string) => boolean;
|
|
283
|
+
/**
|
|
284
|
+
* Creates a predicate that checks if a string contains the specified substring.
|
|
285
|
+
* @param substr - The substring to search for
|
|
286
|
+
* @returns A predicate function that returns true if the string contains the substring
|
|
287
|
+
*/
|
|
288
|
+
export declare const includes: (substr: string) => (x: string) => boolean;
|
|
289
|
+
/**
|
|
290
|
+
* Checks if a string is equal to its trimmed version (no leading/trailing whitespace).
|
|
291
|
+
* @param x - The string to check
|
|
292
|
+
* @returns True if the string has no leading or trailing whitespace
|
|
293
|
+
*/
|
|
294
|
+
export declare const trimmed: (x: string) => boolean;
|
|
295
|
+
/**
|
|
296
|
+
* Checks if a string has at least one character.
|
|
297
|
+
* @param x - The string to check
|
|
298
|
+
* @returns True if the string length is greater than 0
|
|
299
|
+
*/
|
|
300
|
+
export declare const non_empty_string: (x: string) => boolean;
|
|
301
|
+
/**
|
|
302
|
+
* Checks if a string consists only of numeric digits.
|
|
303
|
+
* @param x - The string to check
|
|
304
|
+
* @returns True if the string matches /^\d+$/
|
|
305
|
+
*/
|
|
306
|
+
export declare const numeric_string: (x: string) => boolean;
|
|
307
|
+
/**
|
|
308
|
+
* Checks if a string consists only of alphabetic characters (a-z, A-Z).
|
|
309
|
+
* @param x - The string to check
|
|
310
|
+
* @returns True if the string matches /^[a-zA-Z]+$/
|
|
311
|
+
*/
|
|
312
|
+
export declare const alpha_string: (x: string) => boolean;
|
|
313
|
+
/**
|
|
314
|
+
* Checks if a string consists only of alphanumeric characters (a-z, A-Z, 0-9).
|
|
315
|
+
* @param x - The string to check
|
|
316
|
+
* @returns True if the string matches /^[a-zA-Z0-9]+$/
|
|
317
|
+
*/
|
|
318
|
+
export declare const alphanumeric_string: (x: string) => boolean;
|
|
319
|
+
/**
|
|
320
|
+
* Checks if a string matches ISO 8601 datetime format.
|
|
321
|
+
* @param x - The string to check
|
|
322
|
+
* @returns True if the string matches ISO datetime format (YYYY-MM-DDTHH:mm:ss)
|
|
323
|
+
*/
|
|
324
|
+
export declare const iso_datetime: (x: string) => boolean;
|
|
325
|
+
/**
|
|
326
|
+
* Validates an email address according to RFC 5321.
|
|
327
|
+
* @param email_str - The email string to validate
|
|
328
|
+
* @returns True if the string is a valid email address (max 254 characters per RFC 5321)
|
|
329
|
+
*/
|
|
330
|
+
export declare const email: (email_str: string) => boolean;
|
|
331
|
+
/**
|
|
332
|
+
* Checks if a string is a valid URL.
|
|
333
|
+
* @param x - The string to check
|
|
334
|
+
* @returns True if the string can be parsed as a valid URL
|
|
335
|
+
*/
|
|
336
|
+
export declare const url: (x: string) => boolean;
|
|
337
|
+
/**
|
|
338
|
+
* Checks if a string is a valid UUID format.
|
|
339
|
+
* @param x - The string to check
|
|
340
|
+
* @returns True if the string matches UUID format (8-4-4-4-12 hexadecimal)
|
|
341
|
+
*/
|
|
342
|
+
export declare const uuid: (x: string) => boolean;
|
|
343
|
+
/**
|
|
344
|
+
* Checks if a string is a valid hexadecimal color code.
|
|
345
|
+
* @param x - The string to check
|
|
346
|
+
* @returns True if the string matches #RGB, #RRGGBB, or #RRGGBBAA format
|
|
347
|
+
*/
|
|
348
|
+
export declare const hex_color: (x: string) => boolean;
|
|
349
|
+
/**
|
|
350
|
+
* Creates a predicate that checks if a number is greater than or equal to a minimum value.
|
|
351
|
+
* @param val - The minimum value (inclusive)
|
|
352
|
+
* @returns A predicate function that returns true if the number >= val
|
|
353
|
+
*/
|
|
354
|
+
export declare const min: (val: number) => (x: number) => boolean;
|
|
355
|
+
/**
|
|
356
|
+
* Creates a predicate that checks if a number is less than or equal to a maximum value.
|
|
357
|
+
* @param val - The maximum value (inclusive)
|
|
358
|
+
* @returns A predicate function that returns true if the number <= val
|
|
359
|
+
*/
|
|
360
|
+
export declare const max: (val: number) => (x: number) => boolean;
|
|
361
|
+
/**
|
|
362
|
+
* Creates a predicate that checks if a number falls within a specified range.
|
|
363
|
+
* @param min_val - The minimum value (inclusive)
|
|
364
|
+
* @param max_val - The maximum value (inclusive)
|
|
365
|
+
* @returns A predicate function that returns true if the number is within [min_val, max_val]
|
|
366
|
+
*/
|
|
367
|
+
export declare const range: (min_val: number, max_val: number) => (x: number) => boolean;
|
|
368
|
+
/**
|
|
369
|
+
* Checks if a number is an integer (no fractional part).
|
|
370
|
+
* @param x - The number to check
|
|
371
|
+
* @returns True if the number is an integer
|
|
372
|
+
*/
|
|
373
|
+
export declare const integer: (x: number) => boolean;
|
|
374
|
+
/**
|
|
375
|
+
* Checks if a number is a safe integer (within IEEE-754 safe integer range).
|
|
376
|
+
* @param x - The number to check
|
|
377
|
+
* @returns True if the number is a safe integer (-(2^53 - 1) to 2^53 - 1)
|
|
378
|
+
*/
|
|
379
|
+
export declare const safe_integer: (x: number) => boolean;
|
|
380
|
+
/**
|
|
381
|
+
* Checks if a number is positive (greater than 0).
|
|
382
|
+
* @param x - The number to check
|
|
383
|
+
* @returns True if the number > 0
|
|
384
|
+
*/
|
|
385
|
+
export declare const positive: (x: number) => boolean;
|
|
386
|
+
/**
|
|
387
|
+
* Checks if a number is negative (less than 0).
|
|
388
|
+
* @param x - The number to check
|
|
389
|
+
* @returns True if the number < 0
|
|
390
|
+
*/
|
|
391
|
+
export declare const negative: (x: number) => boolean;
|
|
392
|
+
/**
|
|
393
|
+
* Checks if a number is non-positive (less than or equal to 0).
|
|
394
|
+
* @param x - The number to check
|
|
395
|
+
* @returns True if the number <= 0
|
|
396
|
+
*/
|
|
397
|
+
export declare const non_positive: (x: number) => boolean;
|
|
398
|
+
/**
|
|
399
|
+
* Checks if a number is non-negative (greater than or equal to 0).
|
|
400
|
+
* @param x - The number to check
|
|
401
|
+
* @returns True if the number >= 0
|
|
402
|
+
*/
|
|
403
|
+
export declare const non_negative: (x: number) => boolean;
|
|
404
|
+
/**
|
|
405
|
+
* Checks if a number is finite (not Infinity or -Infinity).
|
|
406
|
+
* @param x - The number to check
|
|
407
|
+
* @returns True if the number is finite
|
|
408
|
+
*/
|
|
409
|
+
export declare const finite: (x: number) => boolean;
|
|
410
|
+
/**
|
|
411
|
+
* Type guard that checks if a value is NaN (Not a Number).
|
|
412
|
+
* @param x - The value to check
|
|
413
|
+
* @returns True if the value is NaN
|
|
414
|
+
*/
|
|
415
|
+
export declare const nan: (x: unknown) => x is number;
|
|
416
|
+
/**
|
|
417
|
+
* Checks if a number is even (divisible by 2).
|
|
418
|
+
* @param x - The number to check
|
|
419
|
+
* @returns True if the number is even
|
|
420
|
+
*/
|
|
421
|
+
export declare const even: (x: number) => boolean;
|
|
422
|
+
/**
|
|
423
|
+
* Checks if a number is odd (not divisible by 2).
|
|
424
|
+
* @param x - The number to check
|
|
425
|
+
* @returns True if the number is odd
|
|
426
|
+
*/
|
|
427
|
+
export declare const odd: (x: number) => boolean;
|
|
428
|
+
/**
|
|
429
|
+
* Creates a predicate that checks if a number is divisible by a given divisor.
|
|
430
|
+
* @param divisor - The divisor to check divisibility against
|
|
431
|
+
* @returns A predicate function that returns true if the number is divisible by divisor
|
|
432
|
+
*/
|
|
433
|
+
export declare const multiple_of: (divisor: number) => (x: number) => boolean;
|
|
434
|
+
/**
|
|
435
|
+
* Creates a predicate that checks if an array has at least the specified length.
|
|
436
|
+
* @template T - The array element type
|
|
437
|
+
* @param len - The minimum required length
|
|
438
|
+
* @returns A predicate function that returns true if the array length >= len
|
|
439
|
+
*/
|
|
440
|
+
export declare const arr_min_len: <T>(len: number) => (x: T[]) => boolean;
|
|
441
|
+
/**
|
|
442
|
+
* Creates a predicate that checks if an array has at most the specified length.
|
|
443
|
+
* @template T - The array element type
|
|
444
|
+
* @param len - The maximum allowed length
|
|
445
|
+
* @returns A predicate function that returns true if the array length <= len
|
|
446
|
+
*/
|
|
447
|
+
export declare const arr_max_len: <T>(len: number) => (x: T[]) => boolean;
|
|
448
|
+
/**
|
|
449
|
+
* Creates a predicate that checks if an array length falls within a specified range.
|
|
450
|
+
* @template T - The array element type
|
|
451
|
+
* @param min - The minimum required length (inclusive)
|
|
452
|
+
* @param max - The maximum allowed length (inclusive)
|
|
453
|
+
* @returns A predicate function that returns true if the array length is within [min, max]
|
|
454
|
+
*/
|
|
455
|
+
export declare const arr_len_range: <T>(min: number, max: number) => (x: T[]) => boolean;
|
|
456
|
+
/**
|
|
457
|
+
* Creates a predicate that checks if an array has exactly the specified length.
|
|
458
|
+
* @template T - The array element type
|
|
459
|
+
* @param len - The exact required length
|
|
460
|
+
* @returns A predicate function that returns true if the array length === len
|
|
461
|
+
*/
|
|
462
|
+
export declare const arr_len: <T>(len: number) => (x: T[]) => boolean;
|
|
463
|
+
/**
|
|
464
|
+
* Type guard that checks if an array is non-empty.
|
|
465
|
+
* @template T - The array element type
|
|
466
|
+
* @param x - The array to check
|
|
467
|
+
* @returns True if the array has at least one element, narrowing type to [T, ...T[]]
|
|
468
|
+
*/
|
|
469
|
+
export declare const non_empty_array: <T>(x: T[]) => x is [T, ...T[]];
|
|
470
|
+
/**
|
|
471
|
+
* Checks if an array contains only unique elements (no duplicates).
|
|
472
|
+
* @template T - The array element type
|
|
473
|
+
* @param x - The array to check
|
|
474
|
+
* @returns True if all elements in the array are unique
|
|
475
|
+
*/
|
|
476
|
+
export declare const unique: <T>(x: T[]) => boolean;
|
|
477
|
+
/**
|
|
478
|
+
* Creates a predicate that checks if an array is sorted.
|
|
479
|
+
* @template T - The array element type
|
|
480
|
+
* @param compare - Optional comparison function for sorting
|
|
481
|
+
* @returns A predicate function that returns true if the array is sorted
|
|
482
|
+
*/
|
|
483
|
+
export declare const sorted: <T>(compare?: (a: T, b: T) => number) => (x: T[]) => boolean;
|
|
484
|
+
/**
|
|
485
|
+
* Creates a predicate that checks if all array elements satisfy a condition.
|
|
486
|
+
* @template T - The array element type
|
|
487
|
+
* @param pred - The predicate function to test each element
|
|
488
|
+
* @returns A predicate function that returns true if every element passes the predicate
|
|
489
|
+
*/
|
|
490
|
+
export declare const every: <T>(pred: (val: T) => boolean) => (x: T[]) => boolean;
|
|
491
|
+
/**
|
|
492
|
+
* Creates a predicate that checks if at least one array element satisfies a condition.
|
|
493
|
+
* @template T - The array element type
|
|
494
|
+
* @param pred - The predicate function to test each element
|
|
495
|
+
* @returns A predicate function that returns true if at least one element passes the predicate
|
|
496
|
+
*/
|
|
497
|
+
export declare const some: <T>(pred: (val: T) => boolean) => (x: T[]) => boolean;
|
|
498
|
+
/**
|
|
499
|
+
* Creates a predicate that checks if an object has a specific key (own or inherited).
|
|
500
|
+
* @param key - The key to check for (string, number, or symbol)
|
|
501
|
+
* @returns A predicate function that returns true if the key exists in the object
|
|
502
|
+
*/
|
|
503
|
+
export declare const has_key: (key: string | number | symbol) => (x: object) => boolean;
|
|
504
|
+
/**
|
|
505
|
+
* Creates a predicate that checks if an object has a specific own property.
|
|
506
|
+
* @param key - The property key to check for
|
|
507
|
+
* @returns A predicate function that returns true if the object has the own property
|
|
508
|
+
*/
|
|
509
|
+
export declare const has_own: (key: string | number | symbol) => (x: object) => boolean;
|
|
510
|
+
/**
|
|
511
|
+
* Creates a type guard that checks if an object has all specified keys.
|
|
512
|
+
* @template T - The tuple of required key names
|
|
513
|
+
* @param keys - The keys that must be present in the object
|
|
514
|
+
* @returns A type guard function that narrows the type to include the specified keys
|
|
515
|
+
*/
|
|
516
|
+
export declare const keys: <const T extends readonly string[]>(...keys: T) => <U extends Record<string, unknown>>(x: U) => x is U & Record<T[number], unknown>;
|
|
517
|
+
/**
|
|
518
|
+
* Creates a predicate that checks if an object has exactly the specified keys (no more, no less).
|
|
519
|
+
* @template T - The tuple of expected key names
|
|
520
|
+
* @param keys - The exact keys the object should have
|
|
521
|
+
* @returns A predicate function that returns true if the object has exactly these keys
|
|
522
|
+
*/
|
|
523
|
+
export declare const exact_keys: <const T extends readonly string[]>(...keys: T) => (x: object) => boolean;
|
|
524
|
+
type Predicate = (v: unknown) => boolean;
|
|
525
|
+
type TypeGuard<T> = (v: unknown) => v is T;
|
|
526
|
+
type ExtractGuardUnion<T extends readonly unknown[]> = T extends readonly [
|
|
527
|
+
infer H,
|
|
528
|
+
...infer R
|
|
529
|
+
] ? (H extends (v: unknown) => v is infer U ? U : never) | ExtractGuardUnion<R> : never;
|
|
530
|
+
type ExtractGuardIntersection<T extends readonly unknown[]> = T extends readonly [infer H, ...infer R] ? H extends (v: unknown) => v is infer U ? U & ExtractGuardIntersection<R> : ExtractGuardIntersection<R> : unknown;
|
|
531
|
+
/**
|
|
532
|
+
* Creates a type guard that is the union of multiple type guards.
|
|
533
|
+
* The resulting guard returns true if any of the input guards return true.
|
|
534
|
+
* @template T - The tuple of predicates or type guards
|
|
535
|
+
* @param guards - The type guards to combine with OR logic
|
|
536
|
+
* @returns A type guard that returns true if any guard passes
|
|
537
|
+
*/
|
|
538
|
+
export declare function union<T extends readonly (Predicate | TypeGuard<unknown>)[]>(...guards: T): (v: unknown) => v is ExtractGuardUnion<T>;
|
|
539
|
+
/**
|
|
540
|
+
* Creates a type guard that is the intersection of multiple type guards.
|
|
541
|
+
* The resulting guard returns true only if all of the input guards return true.
|
|
542
|
+
* @template T - The tuple of predicates or type guards
|
|
543
|
+
* @param guards - The type guards to combine with AND logic
|
|
544
|
+
* @returns A type guard that returns true only if all guards pass
|
|
545
|
+
*/
|
|
546
|
+
export declare function and<T extends readonly (Predicate | TypeGuard<unknown>)[]>(...guards: T): (v: unknown) => v is ExtractGuardIntersection<T>;
|
|
547
|
+
type ExtractDiscriminated<_K extends PropertyKey, T extends Record<PropertyKey, (v: unknown) => v is unknown>> = T[keyof T] extends (v: unknown) => v is infer R ? R : never;
|
|
548
|
+
/**
|
|
549
|
+
* Creates a type guard for a discriminated union based on a discriminator key.
|
|
550
|
+
* @template K - The discriminator key type
|
|
551
|
+
* @template T - The record mapping discriminator values to type guards
|
|
552
|
+
* @param key - The property key used as the discriminator
|
|
553
|
+
* @param guards - A record mapping discriminator values to their corresponding type guards
|
|
554
|
+
* @returns A type guard that checks the discriminator value and applies the appropriate guard
|
|
555
|
+
*/
|
|
556
|
+
export declare const discriminatedUnion: <K extends PropertyKey, T extends Record<PropertyKey, (v: unknown) => v is unknown>>(key: K, guards: T) => (v: unknown) => v is ExtractDiscriminated<K, T>;
|
|
557
|
+
/**
|
|
558
|
+
* Creates a type guard that checks if a value is an array where all elements pass the element guard.
|
|
559
|
+
* @template T - The element type
|
|
560
|
+
* @param element_guard - The type guard to apply to each element
|
|
561
|
+
* @returns A type guard that returns true if the value is an array of T
|
|
562
|
+
*/
|
|
563
|
+
export declare const arrayOf: <T>(element_guard: (v: unknown) => v is T) => (v: unknown) => v is T[];
|
|
564
|
+
/**
|
|
565
|
+
* Creates a type guard that checks if an object matches a specific shape.
|
|
566
|
+
* @template T - The expected object shape type
|
|
567
|
+
* @param shape - A record of type guards for each property
|
|
568
|
+
* @returns A type guard that returns true if the object matches the shape
|
|
569
|
+
*/
|
|
570
|
+
export declare const objectShape: <T extends Record<string, unknown>>(shape: { [K in keyof T]: (v: unknown) => v is T[K]; }) => (v: unknown) => v is T;
|
|
571
|
+
/**
|
|
572
|
+
* Creates a type guard that checks if a value is a number within a specified range.
|
|
573
|
+
* @param min_val - The minimum value (inclusive)
|
|
574
|
+
* @param max_val - The maximum value (inclusive)
|
|
575
|
+
* @param int - Whether the number must be an integer (default: false)
|
|
576
|
+
* @returns A type guard that returns true if the value is a number within the range
|
|
577
|
+
*/
|
|
578
|
+
export declare const numRange: (min_val: number, max_val: number, int?: boolean) => (v: unknown) => v is number;
|
|
579
|
+
/**
|
|
580
|
+
* Type guard that checks if a value is a non-negative integer (0, 1, 2, ...).
|
|
581
|
+
* @param v - The value to check
|
|
582
|
+
* @returns True if the value is an integer >= 0
|
|
583
|
+
*/
|
|
584
|
+
export declare const nonNegativeInt: (v: unknown) => v is number;
|
|
585
|
+
export { _string as string, _number as number, _boolean as boolean, _symbol as symbol, _bigint as bigint, _function as function, _object as object, _array as array, _undefined as undefined, _null as null, _nullish as nullish, _primitive as primitive, _date as date, _regexp as regexp, _error as error, _map as map, _set as set, _weakMap as weakMap, _weakSet as weakSet, _plainObject as plainObject, _iterable as iterable, _asyncIterable as asyncIterable, _record as record, _truthy as truthy, _falsy as falsy, _empty as empty, _nonEmpty as nonEmpty, _eq as eq, _oneOf as oneOf, _neq as neq, _notOneOf as notOneOf, _gt as gt, _gte as gte, _lt as lt, _lte as lte, _between as between, _betweenInclusive as betweenInclusive, _instanceOf as instanceOf, };
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Result } from '../Result/types';
|
|
2
|
+
import { AsyncMaybe, Maybe } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Constructs a `Some` value containing a non-null, non-undefined value.
|
|
5
|
+
* @param value - The value to wrap in a Maybe.
|
|
6
|
+
* @returns A Maybe containing the value.
|
|
7
|
+
*/
|
|
8
|
+
export declare const Some: <T>(value: T) => Maybe<T>;
|
|
9
|
+
/**
|
|
10
|
+
* Constructs a `None` value representing absence of a value.
|
|
11
|
+
* @returns An empty Maybe (undefined).
|
|
12
|
+
*/
|
|
13
|
+
export declare const None: () => Maybe<never>;
|
|
14
|
+
/**
|
|
15
|
+
* Type guard checking if a Maybe contains a value (`Some`).
|
|
16
|
+
* @param m - The Maybe to inspect.
|
|
17
|
+
* @returns True if the Maybe contains a value.
|
|
18
|
+
*/
|
|
19
|
+
export declare const isSome: <T>(m: Maybe<T>) => m is T;
|
|
20
|
+
/**
|
|
21
|
+
* Type guard checking if a Maybe is empty (`None`).
|
|
22
|
+
* @param m - The Maybe to inspect.
|
|
23
|
+
* @returns True if the Maybe is null or undefined.
|
|
24
|
+
*/
|
|
25
|
+
export declare const isNone: (m: Maybe<unknown>) => m is null | undefined;
|
|
26
|
+
/**
|
|
27
|
+
* Converts nullable value to a Maybe.
|
|
28
|
+
* @param value - Possibly null/undefined value.
|
|
29
|
+
* @returns Some(value) if value exists, None otherwise.
|
|
30
|
+
*/
|
|
31
|
+
export declare const fromNullable: <T>(value: T | null | undefined) => Maybe<T>;
|
|
32
|
+
/**
|
|
33
|
+
* Converts falsy value to a Maybe.
|
|
34
|
+
* @param value - Possibly falsy value.
|
|
35
|
+
* @returns Some(value) if truthy, None otherwise.
|
|
36
|
+
*/
|
|
37
|
+
export declare const fromFalsy: <T>(value: T | null | undefined | false | 0 | "") => Maybe<T>;
|
|
38
|
+
/**
|
|
39
|
+
* Converts Maybe to nullable value.
|
|
40
|
+
* @param maybe - Maybe value.
|
|
41
|
+
* @returns The value if Some, null if None.
|
|
42
|
+
*/
|
|
43
|
+
export declare const toNullable: <T>(maybe: Maybe<T>) => T | null;
|
|
44
|
+
/**
|
|
45
|
+
* Converts Maybe to Result type.
|
|
46
|
+
* @param maybe - Maybe value.
|
|
47
|
+
* @param errorFn - Error generator for None case.
|
|
48
|
+
* @returns Ok(value) if Some, Err(errorFn()) if None.
|
|
49
|
+
*/
|
|
50
|
+
export declare const toResult: <T, E>(maybe: Maybe<T>, errorFn: () => E) => Result<T, E>;
|
|
51
|
+
/**
|
|
52
|
+
* Converts Maybe to array representation.
|
|
53
|
+
* @param val - Maybe value.
|
|
54
|
+
* @returns Singleton array if Some, empty array if None.
|
|
55
|
+
*/
|
|
56
|
+
export declare const toArray: <T>(val: Maybe<T>) => T[];
|
|
57
|
+
/**
|
|
58
|
+
* Transposes a Maybe containing a Promise to an AsyncMaybe.
|
|
59
|
+
* @param val - Maybe wrapping a Promise.
|
|
60
|
+
* @returns Promise resolving to Some(value) if input was Some, None otherwise.
|
|
61
|
+
*/
|
|
62
|
+
export declare function transpose<T>(val: Maybe<Promise<T>>): AsyncMaybe<T>;
|