defuss-runtime 1.0.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.
@@ -0,0 +1,238 @@
1
+ declare const _BASE64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
2
+ declare let _base64LookupMap: Record<string, number> | null;
3
+ declare function _getBase64LookupMap(): Record<string, number>;
4
+ declare function binaryToBase64(buffer: ArrayBufferLike): string;
5
+ declare function base64ToBinary(base64: string): ArrayBufferLike;
6
+
7
+ declare const _HEX_PREFIX = "hex:";
8
+ declare function binaryToHex(buffer: ArrayBufferLike): string;
9
+ declare function hexToBinary(hexString: string): ArrayBufferLike;
10
+ declare function textToBinary(text: string): ArrayBufferLike;
11
+ declare function binaryToText(buffer: ArrayBufferLike): string;
12
+
13
+ declare const getAllKeysFromPath: (path: string) => Array<string | number>;
14
+ declare const ensureKey: (obj: Record<string, any>, key: string | number, nextKey?: string | number) => void;
15
+ declare const getByPath: (obj: any, path: string) => any;
16
+ declare const setByPath: (obj: any, path: string, value: any) => any;
17
+
18
+ /**
19
+ * Return a new array with unique values from the input array.
20
+ * @param a - The array to dedupe
21
+ * @returns Array of unique values
22
+ */
23
+ declare function unique<T>(a: readonly T[]): T[];
24
+
25
+ /**
26
+ * Pick specific keys from an object.
27
+ * @param o - The source object
28
+ * @param keys - Array of keys to pick
29
+ * @returns New object with only the picked keys
30
+ */
31
+ declare function pick<T extends object, K extends keyof T>(o: T, keys: readonly K[]): Pick<T, K>;
32
+
33
+ /**
34
+ * Omit specific keys from an object.
35
+ * @param o - The source object
36
+ * @param keys - Array of keys to omit
37
+ * @returns New object without the omitted keys
38
+ */
39
+ declare function omit<T extends object, K extends keyof T>(o: T, keys: readonly K[]): Omit<T, K>;
40
+
41
+ /**
42
+ * Check deep equality of two values via JSON serialization.
43
+ * Non-serializable values (functions, undefined) are omitted.
44
+ * @param a - First value to compare
45
+ * @param b - Second value to compare
46
+ * @returns True if the serialized values are identical, false otherwise
47
+ */
48
+ declare function equalsJSON<T>(a: T, b: T): boolean;
49
+
50
+ /**
51
+ * Unique symbol to identify path accessor objects
52
+ */
53
+ declare const PATH_ACCESSOR_SYMBOL: unique symbol;
54
+ /**
55
+ * Type helper for access accessor that returns string paths
56
+ * This type allows chaining property access while maintaining type safety
57
+ * and ultimately returning a string representation of the access
58
+ */
59
+ type PathAccessor<T> = T extends object ? {
60
+ [K in keyof T]: T[K] extends object ? PathAccessor<T[K]> & string : string;
61
+ } & {
62
+ [K in number]: T extends readonly (infer U)[] ? PathAccessor<U> & string : T extends Record<number, infer U> ? PathAccessor<U> & string : PathAccessor<Dynamic> & string;
63
+ } & string : string;
64
+ /**
65
+ * Dynamic type for untyped object property access
66
+ * Use this with access<Dynamic>() to enable arbitrary property access
67
+ */
68
+ type Dynamic = {
69
+ [key: string]: Dynamic;
70
+ [key: number]: Dynamic;
71
+ };
72
+ /**
73
+ * Creates a type-safe access accessor that returns string representations of property paths
74
+ *
75
+ * @example
76
+ * ```typescript
77
+ * interface User {
78
+ * profile: {
79
+ * preferences: {
80
+ * theme: string;
81
+ * };
82
+ * };
83
+ * }
84
+ *
85
+ * const themePath = access<User>().profile.preferences.theme;
86
+ * console.log(String(themePath)); // "profile.preferences.theme"
87
+ *
88
+ * // For dynamic usage without types:
89
+ * const dynamicPath = access<Dynamic>().some.dynamic.path;
90
+ * console.log(String(dynamicPath)); // "some.dynamic.path"
91
+ * ```
92
+ */
93
+ declare const access: <T = any>() => PathAccessor<T>;
94
+ /**
95
+ * Checks if an object is a path accessor created by the access() function
96
+ *
97
+ * @param obj - The object to check
98
+ * @returns True if the object is a path accessor, false otherwise
99
+ *
100
+ * @example
101
+ * ```typescript
102
+ * const path = access<User>().profile.theme;
103
+ * const regularString = "profile.theme";
104
+ *
105
+ * console.log(isPathAccessor(path)); // true
106
+ * console.log(isPathAccessor(regularString)); // false
107
+ * ```
108
+ */
109
+ declare const isPathAccessor: (obj: any) => obj is PathAccessor<any>;
110
+
111
+ /**
112
+ * Debounce a function: delays invoking `fn` until after `wait` ms have elapsed
113
+ * since the last time the debounced function was called.
114
+ * @param fn - The function to debounce
115
+ * @param wait - Milliseconds to wait
116
+ * @returns Debounced function
117
+ */
118
+ declare function debounce<F extends (...args: any[]) => any>(fn: F, wait: number): (...args: Parameters<F>) => void;
119
+
120
+ /**
121
+ * Throttle a function: ensures that `fn` is called at most once every `wait` ms.
122
+ * @param fn - The function to throttle
123
+ * @param wait - Milliseconds to wait
124
+ * @returns Throttled function
125
+ */
126
+ declare function throttle<F extends (...args: any[]) => any>(fn: F, wait: number): (...args: Parameters<F>) => void;
127
+
128
+ /**
129
+ * Wait for a specified amount of time.
130
+ * @param ms - Milliseconds to wait
131
+ * @returns A promise that resolves after the specified time
132
+ */
133
+ declare function wait(ms: number): Promise<void>;
134
+ declare function createTimeoutPromise<T>(timeoutMs: number, operation: () => Promise<T> | T, timeoutCallback?: (ms: number) => void): Promise<T>;
135
+ declare function waitForWithPolling<T>(check: () => T | null | undefined, timeout: number, interval?: number): Promise<T>;
136
+ declare function waitForRef<T>(ref: {
137
+ current: T | null;
138
+ }, timeout: number): Promise<T>;
139
+
140
+ declare const asString: (value: any) => string;
141
+
142
+ declare const asNumber: (value: any) => number;
143
+
144
+ declare const asBoolean: (value: any) => boolean;
145
+
146
+ declare const asArray: (value: any, transformerFn: (value: any) => any) => any[];
147
+
148
+ declare const asDate: (value: any) => Date;
149
+
150
+ declare const asInteger: (value: any) => number;
151
+
152
+ declare const isAfter: (value: Date | undefined, minDate: Date, inclusive?: boolean) => value is Date;
153
+
154
+ type ValidationMessage = string | number | boolean | null | undefined;
155
+ type ValidationFnResult = true | ValidationMessage;
156
+ type ValidatorPrimitiveFn<T = unknown> = (value: T) => boolean | Promise<boolean>;
157
+ interface SingleValidationResult {
158
+ message?: ValidationMessage;
159
+ isValid: boolean;
160
+ }
161
+ type ValidatorFn<T extends unknown[] = unknown[]> = (...args: T) => boolean | string;
162
+ type ValidationStep<T extends unknown[] = unknown[]> = {
163
+ fn: ValidatorFn<T>;
164
+ args: T;
165
+ };
166
+
167
+ declare const isArray: ValidatorPrimitiveFn;
168
+
169
+ declare const isBefore: (value: Date | undefined, maxDate: Date, inclusive?: boolean) => value is Date;
170
+
171
+ declare const isBoolean: ValidatorPrimitiveFn;
172
+
173
+ declare const isDate: ValidatorPrimitiveFn;
174
+
175
+ declare const isDefined: ValidatorPrimitiveFn;
176
+
177
+ declare const isEmail: ValidatorPrimitiveFn;
178
+
179
+ declare const isEmpty: ValidatorPrimitiveFn;
180
+
181
+ declare const is: (value: any, valueB: any) => boolean;
182
+
183
+ declare const isGreaterThan: (value: any, minValue: number, includeEqual?: boolean) => boolean;
184
+
185
+ /**
186
+ * Checks if a value is a safe number (not NaN and finite).
187
+ * @param value - The value to check
188
+ * @returns True if the value is a safe number, false otherwise
189
+ */
190
+ declare const isSafeNumber: ValidatorPrimitiveFn;
191
+
192
+ /**
193
+ * Checks if a value (number or string) is a numeric and a safe number.
194
+ * @param value - The value to check
195
+ * @returns True if the value is numeric, false otherwise
196
+ */
197
+ declare const isSafeNumeric: ValidatorPrimitiveFn;
198
+
199
+ declare const isObject: ValidatorPrimitiveFn;
200
+
201
+ declare const isOneOf: (value: any, options: Array<string | number>) => boolean;
202
+
203
+ declare const isPhoneNumber: ValidatorPrimitiveFn;
204
+
205
+ declare const isRequired: ValidatorPrimitiveFn;
206
+
207
+ declare const isSlug: ValidatorPrimitiveFn;
208
+
209
+ declare const isLessThan: (value: any, maxValue: number, includeEqual?: boolean) => boolean;
210
+
211
+ declare const isString: ValidatorPrimitiveFn;
212
+
213
+ declare const isUrl: ValidatorPrimitiveFn;
214
+
215
+ declare const isUrlPath: ValidatorPrimitiveFn;
216
+
217
+ interface DateValue {
218
+ month: number;
219
+ year: number;
220
+ date: number;
221
+ hour: number;
222
+ minute: number;
223
+ second: number;
224
+ millisecond: number;
225
+ }
226
+ declare const getDateValue: (date: Date) => DateValue;
227
+
228
+ declare const isLongerThan: (value: any, minLength: number, includeEqual?: boolean) => boolean;
229
+
230
+ declare const isShorterThan: (value: any, maxLength: number, includeEqual?: boolean) => boolean;
231
+
232
+ declare const hasPattern: (value: any, pattern: RegExp) => boolean;
233
+
234
+ declare const isInteger: ValidatorPrimitiveFn;
235
+
236
+ declare const isEqual: (value: any, valueB: any) => boolean;
237
+
238
+ export { type DateValue, type Dynamic, PATH_ACCESSOR_SYMBOL, type PathAccessor, type SingleValidationResult, type ValidationFnResult, type ValidationMessage, type ValidationStep, type ValidatorFn, type ValidatorPrimitiveFn, _BASE64_CHARS, _HEX_PREFIX, _base64LookupMap, _getBase64LookupMap, access, asArray, asBoolean, asDate, asInteger, asNumber, asString, base64ToBinary, binaryToBase64, binaryToHex, binaryToText, createTimeoutPromise, debounce, ensureKey, equalsJSON, getAllKeysFromPath, getByPath, getDateValue, hasPattern, hexToBinary, is, isAfter, isArray, isBefore, isBoolean, isDate, isDefined, isEmail, isEmpty, isEqual, isGreaterThan, isInteger, isLessThan, isLongerThan, isObject, isOneOf, isPathAccessor, isPhoneNumber, isRequired, isSafeNumber, isSafeNumeric, isShorterThan, isSlug, isString, isUrl, isUrlPath, omit, pick, setByPath, textToBinary, throttle, unique, wait, waitForRef, waitForWithPolling };
@@ -0,0 +1,238 @@
1
+ declare const _BASE64_CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
2
+ declare let _base64LookupMap: Record<string, number> | null;
3
+ declare function _getBase64LookupMap(): Record<string, number>;
4
+ declare function binaryToBase64(buffer: ArrayBufferLike): string;
5
+ declare function base64ToBinary(base64: string): ArrayBufferLike;
6
+
7
+ declare const _HEX_PREFIX = "hex:";
8
+ declare function binaryToHex(buffer: ArrayBufferLike): string;
9
+ declare function hexToBinary(hexString: string): ArrayBufferLike;
10
+ declare function textToBinary(text: string): ArrayBufferLike;
11
+ declare function binaryToText(buffer: ArrayBufferLike): string;
12
+
13
+ declare const getAllKeysFromPath: (path: string) => Array<string | number>;
14
+ declare const ensureKey: (obj: Record<string, any>, key: string | number, nextKey?: string | number) => void;
15
+ declare const getByPath: (obj: any, path: string) => any;
16
+ declare const setByPath: (obj: any, path: string, value: any) => any;
17
+
18
+ /**
19
+ * Return a new array with unique values from the input array.
20
+ * @param a - The array to dedupe
21
+ * @returns Array of unique values
22
+ */
23
+ declare function unique<T>(a: readonly T[]): T[];
24
+
25
+ /**
26
+ * Pick specific keys from an object.
27
+ * @param o - The source object
28
+ * @param keys - Array of keys to pick
29
+ * @returns New object with only the picked keys
30
+ */
31
+ declare function pick<T extends object, K extends keyof T>(o: T, keys: readonly K[]): Pick<T, K>;
32
+
33
+ /**
34
+ * Omit specific keys from an object.
35
+ * @param o - The source object
36
+ * @param keys - Array of keys to omit
37
+ * @returns New object without the omitted keys
38
+ */
39
+ declare function omit<T extends object, K extends keyof T>(o: T, keys: readonly K[]): Omit<T, K>;
40
+
41
+ /**
42
+ * Check deep equality of two values via JSON serialization.
43
+ * Non-serializable values (functions, undefined) are omitted.
44
+ * @param a - First value to compare
45
+ * @param b - Second value to compare
46
+ * @returns True if the serialized values are identical, false otherwise
47
+ */
48
+ declare function equalsJSON<T>(a: T, b: T): boolean;
49
+
50
+ /**
51
+ * Unique symbol to identify path accessor objects
52
+ */
53
+ declare const PATH_ACCESSOR_SYMBOL: unique symbol;
54
+ /**
55
+ * Type helper for access accessor that returns string paths
56
+ * This type allows chaining property access while maintaining type safety
57
+ * and ultimately returning a string representation of the access
58
+ */
59
+ type PathAccessor<T> = T extends object ? {
60
+ [K in keyof T]: T[K] extends object ? PathAccessor<T[K]> & string : string;
61
+ } & {
62
+ [K in number]: T extends readonly (infer U)[] ? PathAccessor<U> & string : T extends Record<number, infer U> ? PathAccessor<U> & string : PathAccessor<Dynamic> & string;
63
+ } & string : string;
64
+ /**
65
+ * Dynamic type for untyped object property access
66
+ * Use this with access<Dynamic>() to enable arbitrary property access
67
+ */
68
+ type Dynamic = {
69
+ [key: string]: Dynamic;
70
+ [key: number]: Dynamic;
71
+ };
72
+ /**
73
+ * Creates a type-safe access accessor that returns string representations of property paths
74
+ *
75
+ * @example
76
+ * ```typescript
77
+ * interface User {
78
+ * profile: {
79
+ * preferences: {
80
+ * theme: string;
81
+ * };
82
+ * };
83
+ * }
84
+ *
85
+ * const themePath = access<User>().profile.preferences.theme;
86
+ * console.log(String(themePath)); // "profile.preferences.theme"
87
+ *
88
+ * // For dynamic usage without types:
89
+ * const dynamicPath = access<Dynamic>().some.dynamic.path;
90
+ * console.log(String(dynamicPath)); // "some.dynamic.path"
91
+ * ```
92
+ */
93
+ declare const access: <T = any>() => PathAccessor<T>;
94
+ /**
95
+ * Checks if an object is a path accessor created by the access() function
96
+ *
97
+ * @param obj - The object to check
98
+ * @returns True if the object is a path accessor, false otherwise
99
+ *
100
+ * @example
101
+ * ```typescript
102
+ * const path = access<User>().profile.theme;
103
+ * const regularString = "profile.theme";
104
+ *
105
+ * console.log(isPathAccessor(path)); // true
106
+ * console.log(isPathAccessor(regularString)); // false
107
+ * ```
108
+ */
109
+ declare const isPathAccessor: (obj: any) => obj is PathAccessor<any>;
110
+
111
+ /**
112
+ * Debounce a function: delays invoking `fn` until after `wait` ms have elapsed
113
+ * since the last time the debounced function was called.
114
+ * @param fn - The function to debounce
115
+ * @param wait - Milliseconds to wait
116
+ * @returns Debounced function
117
+ */
118
+ declare function debounce<F extends (...args: any[]) => any>(fn: F, wait: number): (...args: Parameters<F>) => void;
119
+
120
+ /**
121
+ * Throttle a function: ensures that `fn` is called at most once every `wait` ms.
122
+ * @param fn - The function to throttle
123
+ * @param wait - Milliseconds to wait
124
+ * @returns Throttled function
125
+ */
126
+ declare function throttle<F extends (...args: any[]) => any>(fn: F, wait: number): (...args: Parameters<F>) => void;
127
+
128
+ /**
129
+ * Wait for a specified amount of time.
130
+ * @param ms - Milliseconds to wait
131
+ * @returns A promise that resolves after the specified time
132
+ */
133
+ declare function wait(ms: number): Promise<void>;
134
+ declare function createTimeoutPromise<T>(timeoutMs: number, operation: () => Promise<T> | T, timeoutCallback?: (ms: number) => void): Promise<T>;
135
+ declare function waitForWithPolling<T>(check: () => T | null | undefined, timeout: number, interval?: number): Promise<T>;
136
+ declare function waitForRef<T>(ref: {
137
+ current: T | null;
138
+ }, timeout: number): Promise<T>;
139
+
140
+ declare const asString: (value: any) => string;
141
+
142
+ declare const asNumber: (value: any) => number;
143
+
144
+ declare const asBoolean: (value: any) => boolean;
145
+
146
+ declare const asArray: (value: any, transformerFn: (value: any) => any) => any[];
147
+
148
+ declare const asDate: (value: any) => Date;
149
+
150
+ declare const asInteger: (value: any) => number;
151
+
152
+ declare const isAfter: (value: Date | undefined, minDate: Date, inclusive?: boolean) => value is Date;
153
+
154
+ type ValidationMessage = string | number | boolean | null | undefined;
155
+ type ValidationFnResult = true | ValidationMessage;
156
+ type ValidatorPrimitiveFn<T = unknown> = (value: T) => boolean | Promise<boolean>;
157
+ interface SingleValidationResult {
158
+ message?: ValidationMessage;
159
+ isValid: boolean;
160
+ }
161
+ type ValidatorFn<T extends unknown[] = unknown[]> = (...args: T) => boolean | string;
162
+ type ValidationStep<T extends unknown[] = unknown[]> = {
163
+ fn: ValidatorFn<T>;
164
+ args: T;
165
+ };
166
+
167
+ declare const isArray: ValidatorPrimitiveFn;
168
+
169
+ declare const isBefore: (value: Date | undefined, maxDate: Date, inclusive?: boolean) => value is Date;
170
+
171
+ declare const isBoolean: ValidatorPrimitiveFn;
172
+
173
+ declare const isDate: ValidatorPrimitiveFn;
174
+
175
+ declare const isDefined: ValidatorPrimitiveFn;
176
+
177
+ declare const isEmail: ValidatorPrimitiveFn;
178
+
179
+ declare const isEmpty: ValidatorPrimitiveFn;
180
+
181
+ declare const is: (value: any, valueB: any) => boolean;
182
+
183
+ declare const isGreaterThan: (value: any, minValue: number, includeEqual?: boolean) => boolean;
184
+
185
+ /**
186
+ * Checks if a value is a safe number (not NaN and finite).
187
+ * @param value - The value to check
188
+ * @returns True if the value is a safe number, false otherwise
189
+ */
190
+ declare const isSafeNumber: ValidatorPrimitiveFn;
191
+
192
+ /**
193
+ * Checks if a value (number or string) is a numeric and a safe number.
194
+ * @param value - The value to check
195
+ * @returns True if the value is numeric, false otherwise
196
+ */
197
+ declare const isSafeNumeric: ValidatorPrimitiveFn;
198
+
199
+ declare const isObject: ValidatorPrimitiveFn;
200
+
201
+ declare const isOneOf: (value: any, options: Array<string | number>) => boolean;
202
+
203
+ declare const isPhoneNumber: ValidatorPrimitiveFn;
204
+
205
+ declare const isRequired: ValidatorPrimitiveFn;
206
+
207
+ declare const isSlug: ValidatorPrimitiveFn;
208
+
209
+ declare const isLessThan: (value: any, maxValue: number, includeEqual?: boolean) => boolean;
210
+
211
+ declare const isString: ValidatorPrimitiveFn;
212
+
213
+ declare const isUrl: ValidatorPrimitiveFn;
214
+
215
+ declare const isUrlPath: ValidatorPrimitiveFn;
216
+
217
+ interface DateValue {
218
+ month: number;
219
+ year: number;
220
+ date: number;
221
+ hour: number;
222
+ minute: number;
223
+ second: number;
224
+ millisecond: number;
225
+ }
226
+ declare const getDateValue: (date: Date) => DateValue;
227
+
228
+ declare const isLongerThan: (value: any, minLength: number, includeEqual?: boolean) => boolean;
229
+
230
+ declare const isShorterThan: (value: any, maxLength: number, includeEqual?: boolean) => boolean;
231
+
232
+ declare const hasPattern: (value: any, pattern: RegExp) => boolean;
233
+
234
+ declare const isInteger: ValidatorPrimitiveFn;
235
+
236
+ declare const isEqual: (value: any, valueB: any) => boolean;
237
+
238
+ export { type DateValue, type Dynamic, PATH_ACCESSOR_SYMBOL, type PathAccessor, type SingleValidationResult, type ValidationFnResult, type ValidationMessage, type ValidationStep, type ValidatorFn, type ValidatorPrimitiveFn, _BASE64_CHARS, _HEX_PREFIX, _base64LookupMap, _getBase64LookupMap, access, asArray, asBoolean, asDate, asInteger, asNumber, asString, base64ToBinary, binaryToBase64, binaryToHex, binaryToText, createTimeoutPromise, debounce, ensureKey, equalsJSON, getAllKeysFromPath, getByPath, getDateValue, hasPattern, hexToBinary, is, isAfter, isArray, isBefore, isBoolean, isDate, isDefined, isEmail, isEmpty, isEqual, isGreaterThan, isInteger, isLessThan, isLongerThan, isObject, isOneOf, isPathAccessor, isPhoneNumber, isRequired, isSafeNumber, isSafeNumeric, isShorterThan, isSlug, isString, isUrl, isUrlPath, omit, pick, setByPath, textToBinary, throttle, unique, wait, waitForRef, waitForWithPolling };