1n-broadutils 0.0.1
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 +21 -0
- package/README.md +161 -0
- package/dist/browser/broadutils.d.ts +9 -0
- package/dist/browser/broadutils.d.ts.map +1 -0
- package/dist/browser/broadutils.js +3 -0
- package/dist/browser/broadutils.js.map +10 -0
- package/dist/browser/canvas/canvas.d.ts +66 -0
- package/dist/browser/canvas/canvas.d.ts.map +1 -0
- package/dist/browser/canvas/canvas.js +3 -0
- package/dist/browser/canvas/canvas.js.map +10 -0
- package/dist/browser/canvas/types.d.ts +35 -0
- package/dist/browser/canvas/types.d.ts.map +1 -0
- package/dist/browser/chunk-2h1wek3q.js +4 -0
- package/dist/browser/chunk-2h1wek3q.js.map +10 -0
- package/dist/browser/chunk-3p7c1apf.js +4 -0
- package/dist/browser/chunk-3p7c1apf.js.map +10 -0
- package/dist/browser/chunk-8r5jmymq.js +4 -0
- package/dist/browser/chunk-8r5jmymq.js.map +9 -0
- package/dist/browser/chunk-te4pbrw5.js +4 -0
- package/dist/browser/chunk-te4pbrw5.js.map +10 -0
- package/dist/browser/data/data.d.ts +11 -0
- package/dist/browser/data/data.d.ts.map +1 -0
- package/dist/browser/data/data.js +3 -0
- package/dist/browser/data/data.js.map +9 -0
- package/dist/browser/data/types.d.ts +178 -0
- package/dist/browser/data/types.d.ts.map +1 -0
- package/dist/browser/math/math.d.ts +11 -0
- package/dist/browser/math/math.d.ts.map +1 -0
- package/dist/browser/math/math.js +3 -0
- package/dist/browser/math/math.js.map +10 -0
- package/dist/browser/math/types.d.ts +134 -0
- package/dist/browser/math/types.d.ts.map +1 -0
- package/dist/browser/misc/misc.d.ts +7 -0
- package/dist/browser/misc/misc.d.ts.map +1 -0
- package/dist/browser/misc/misc.js +3 -0
- package/dist/browser/misc/misc.js.map +10 -0
- package/dist/browser/misc/types.d.ts +44 -0
- package/dist/browser/misc/types.d.ts.map +1 -0
- package/dist/browser/network/network.d.ts +4 -0
- package/dist/browser/network/network.d.ts.map +1 -0
- package/dist/browser/network/network.js +3 -0
- package/dist/browser/network/network.js.map +9 -0
- package/dist/browser/network/types.d.ts +32 -0
- package/dist/browser/network/types.d.ts.map +1 -0
- package/dist/browser/timing/timing.d.ts +7 -0
- package/dist/browser/timing/timing.d.ts.map +1 -0
- package/dist/browser/timing/timing.js +3 -0
- package/dist/browser/timing/timing.js.map +10 -0
- package/dist/browser/timing/types.d.ts +112 -0
- package/dist/browser/timing/types.d.ts.map +1 -0
- package/dist/browser/types/types.d.ts +129 -0
- package/dist/browser/types/types.d.ts.map +1 -0
- package/dist/browser/validate/types.d.ts +93 -0
- package/dist/browser/validate/types.d.ts.map +1 -0
- package/dist/browser/validate/validate.d.ts +7 -0
- package/dist/browser/validate/validate.d.ts.map +1 -0
- package/dist/browser/validate/validate.js +3 -0
- package/dist/browser/validate/validate.js.map +9 -0
- package/dist/node/broadutils.d.ts +8 -0
- package/dist/node/broadutils.d.ts.map +1 -0
- package/dist/node/broadutils.js +3 -0
- package/dist/node/broadutils.js.map +10 -0
- package/dist/node/chunk-hwenktbz.js +4 -0
- package/dist/node/chunk-hwenktbz.js.map +9 -0
- package/dist/node/data/data.d.ts +11 -0
- package/dist/node/data/data.d.ts.map +1 -0
- package/dist/node/data/data.js +3 -0
- package/dist/node/data/data.js.map +10 -0
- package/dist/node/data/types.d.ts +178 -0
- package/dist/node/data/types.d.ts.map +1 -0
- package/dist/node/filesystem/filesystem.d.ts +5 -0
- package/dist/node/filesystem/filesystem.d.ts.map +1 -0
- package/dist/node/filesystem/filesystem.js +3 -0
- package/dist/node/filesystem/filesystem.js.map +10 -0
- package/dist/node/filesystem/types.d.ts +76 -0
- package/dist/node/filesystem/types.d.ts.map +1 -0
- package/dist/node/math/math.d.ts +11 -0
- package/dist/node/math/math.d.ts.map +1 -0
- package/dist/node/math/math.js +3 -0
- package/dist/node/math/math.js.map +10 -0
- package/dist/node/math/types.d.ts +134 -0
- package/dist/node/math/types.d.ts.map +1 -0
- package/dist/node/misc/misc.d.ts +7 -0
- package/dist/node/misc/misc.d.ts.map +1 -0
- package/dist/node/misc/misc.js +3 -0
- package/dist/node/misc/misc.js.map +10 -0
- package/dist/node/misc/types.d.ts +44 -0
- package/dist/node/misc/types.d.ts.map +1 -0
- package/dist/node/timing/timing.d.ts +5 -0
- package/dist/node/timing/timing.d.ts.map +1 -0
- package/dist/node/timing/timing.js +3 -0
- package/dist/node/timing/timing.js.map +10 -0
- package/dist/node/timing/types.d.ts +70 -0
- package/dist/node/timing/types.d.ts.map +1 -0
- package/dist/node/types/types.d.ts +129 -0
- package/dist/node/types/types.d.ts.map +1 -0
- package/dist/node/validate/types.d.ts +93 -0
- package/dist/node/validate/types.d.ts.map +1 -0
- package/dist/node/validate/validate.d.ts +7 -0
- package/dist/node/validate/validate.d.ts.map +1 -0
- package/dist/node/validate/validate.js +3 -0
- package/dist/node/validate/validate.js.map +10 -0
- package/package.json +120 -0
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { CallbackFunctionOne } from "../types/types.ts";
|
|
2
|
+
export interface Deferred<T> {
|
|
3
|
+
/** The promise associated with this deferred object. */
|
|
4
|
+
promise: Promise<T>;
|
|
5
|
+
/** The resolve function for the promise referenced by this deferred object. */
|
|
6
|
+
resolve: CallbackFunctionOne<T>;
|
|
7
|
+
/** The reject function for the promise referenced by this deferred object. */
|
|
8
|
+
reject: CallbackFunctionOne<unknown>;
|
|
9
|
+
}
|
|
10
|
+
export interface CreateDeferred {
|
|
11
|
+
/**
|
|
12
|
+
* Creates a deferred object that contains a promise and its associated resolve and reject
|
|
13
|
+
* functions. The promise is initialized asynchronously to ensure that the resolve and reject
|
|
14
|
+
* functions are properly assigned before the promise is used.
|
|
15
|
+
*/
|
|
16
|
+
<T>(): Promise<Deferred<T>>;
|
|
17
|
+
}
|
|
18
|
+
export interface GCUtils {
|
|
19
|
+
/**
|
|
20
|
+
* Allows the garbage collector to collect the specified value by removing it from the internal
|
|
21
|
+
* preservation set. This is useful for managing memory and ensuring that objects are not kept
|
|
22
|
+
* alive unnecessarily.
|
|
23
|
+
*
|
|
24
|
+
* @param value - The value to allow for garbage collection.
|
|
25
|
+
*
|
|
26
|
+
* @warning This function only removes the value from its internal preservation set. Other
|
|
27
|
+
* references to the value elsewhere in the code may still prevent it from being collected by the
|
|
28
|
+
* garbage collector. Use with caution to avoid unintended memory leaks.
|
|
29
|
+
*/
|
|
30
|
+
allowGC(value: any): null;
|
|
31
|
+
/**
|
|
32
|
+
* Prevents the garbage collector from collecting the specified value by adding it to an internal
|
|
33
|
+
* preservation set. This is useful for keeping objects alive that are still needed, even if they
|
|
34
|
+
* are not referenced elsewhere in the code.
|
|
35
|
+
*
|
|
36
|
+
* @param value - The value to prevent from garbage collection.
|
|
37
|
+
*
|
|
38
|
+
* @warning This function adds the value to an internal preservation set, which may lead to memory
|
|
39
|
+
* leaks if not used carefully. Ensure that you call `allowGC` for the same value when it is no
|
|
40
|
+
* longer needed to allow it to be collected by the garbage collector.
|
|
41
|
+
*/
|
|
42
|
+
preventGC(value: any): null;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/node/misc/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAE7D,MAAM,WAAW,QAAQ,CAAC,CAAC;IACzB,wDAAwD;IACxD,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IACpB,+EAA+E;IAC/E,OAAO,EAAE,mBAAmB,CAAC,CAAC,CAAC,CAAC;IAChC,8EAA8E;IAC9E,MAAM,EAAE,mBAAmB,CAAC,OAAO,CAAC,CAAC;CACtC;AAED,MAAM,WAAW,cAAc;IAC7B;;;;OAIG;IACH,CAAC,CAAC,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC;CAC7B;AAED,MAAM,WAAW,OAAO;IACtB;;;;;;;;;;OAUG;IACH,OAAO,CAAC,KAAK,EAAE,GAAG,GAAG,IAAI,CAAC;IAE1B;;;;;;;;;;OAUG;IACH,SAAS,CAAC,KAAK,EAAE,GAAG,GAAG,IAAI,CAAC;CAC7B"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"timing.d.ts","sourceRoot":"","sources":["../../../src/node/timing/timing.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,YAAY,CAAC;AAE9C,eAAO,MAAM,IAAI,EAAE,IAYlB,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,KAyBnB,CAAC;AAEF,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import"../chunk-hwenktbz.js";var j=(F,A=0,y=1)=>{for(let N=0;N<A;N++)F();let p,P=performance.now();for(let N=0;N<y;N++)p=F();return[(performance.now()-P)/y,p]},O=Object.assign((F)=>{let A=performance.now(),y=Number.isFinite(+F)?+F:0;return y<0&&(y=0),y>2147483647&&(y=0),new Promise((p)=>{setTimeout(()=>p(performance.now()-A),y)})},{sync:(F)=>{let A=performance.now(),y=Number.isFinite(+F)?+F:0,p=0;y<0&&(y=0),y>2147483647&&(y=0);while((p=performance.now()-A)<y);return p}});export{j as time,O as sleep};
|
|
2
|
+
|
|
3
|
+
//# debugId=AA36F383FF1C111464756E2164756E21
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["..\\..\\src\\node\\timing\\timing.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import type { AnyFunction } from \"../types/types.ts\";\nimport type { Sleep, Time } from \"./types.ts\";\n\nexport const time: Time = <T extends AnyFunction>(\n func: T,\n warmupCount: number = 0,\n runCount: number = 1,\n): [duration: number, result: ReturnType<T>] => {\n for (let i = 0; i < warmupCount; i++) func();\n\n let result!: ReturnType<T>;\n const startTime = performance.now();\n for (let i = 0; i < runCount; i++) result = func();\n\n return [(performance.now() - startTime) / runCount, result];\n};\n\nexport const sleep: Sleep = Object.assign(\n (duration: number): Promise<number> => {\n const scheduledAt = performance.now();\n let resolvedDuration = Number.isFinite(+duration) ? +duration : 0;\n\n resolvedDuration < 0 && (resolvedDuration = 0);\n resolvedDuration > 2 ** 31 - 1 && (resolvedDuration = 0);\n\n return new Promise((resolve) => {\n setTimeout(() => resolve(performance.now() - scheduledAt), resolvedDuration);\n });\n },\n {\n sync: (duration: number): number => {\n const scheduledAt = performance.now();\n let resolvedDuration = Number.isFinite(+duration) ? +duration : 0;\n let _duration = 0;\n\n resolvedDuration < 0 && (resolvedDuration = 0);\n resolvedDuration > 2 ** 31 - 1 && (resolvedDuration = 0);\n\n while ((_duration = performance.now() - scheduledAt) < resolvedDuration);\n return _duration;\n },\n },\n);\n\nexport * from \"./types.ts\";\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": "6BAGO,IAAM,EAAa,CACxB,EACA,EAAsB,EACtB,EAAmB,IAC2B,CAC9C,QAAS,EAAI,EAAG,EAAI,EAAa,IAAK,EAAK,EAE3C,IAAI,EACE,EAAY,YAAY,IAAI,EAClC,QAAS,EAAI,EAAG,EAAI,EAAU,IAAK,EAAS,EAAK,EAEjD,MAAO,EAAE,YAAY,IAAI,EAAI,GAAa,EAAU,CAAM,GAG/C,EAAe,OAAO,OACjC,CAAC,IAAsC,CACrC,IAAM,EAAc,YAAY,IAAI,EAChC,EAAmB,OAAO,SAAS,CAAC,CAAQ,EAAI,CAAC,EAAW,EAKhE,OAHA,EAAmB,IAAM,EAAmB,GAC5C,EAAmB,aAAgB,EAAmB,GAE/C,IAAI,QAAQ,CAAC,IAAY,CAC9B,WAAW,IAAM,EAAQ,YAAY,IAAI,EAAI,CAAW,EAAG,CAAgB,EAC5E,GAEH,CACE,KAAM,CAAC,IAA6B,CAClC,IAAM,EAAc,YAAY,IAAI,EAChC,EAAmB,OAAO,SAAS,CAAC,CAAQ,EAAI,CAAC,EAAW,EAC5D,EAAY,EAEhB,EAAmB,IAAM,EAAmB,GAC5C,EAAmB,aAAgB,EAAmB,GAEtD,OAAQ,EAAY,YAAY,IAAI,EAAI,GAAe,GACvD,OAAO,EAEX,CACF",
|
|
8
|
+
"debugId": "AA36F383FF1C111464756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import type { AnyFunction } from "../types/types.ts";
|
|
2
|
+
export interface Sleep {
|
|
3
|
+
/**
|
|
4
|
+
* Returns a promise that resolves after a specified duration in milliseconds. The resolved value
|
|
5
|
+
* is the actual duration of the sleep, which may differ from the requested duration due to
|
|
6
|
+
* factors such as event loop delays and system load. The `sync` method blocks the main thread
|
|
7
|
+
* for the specified duration and returns the actual duration of the sleep. Note that using
|
|
8
|
+
* `sync` can lead to performance issues and should be used with caution, especially in
|
|
9
|
+
* environments where responsiveness is critical.
|
|
10
|
+
*
|
|
11
|
+
* @param duration The duration of time in milliseconds to sleep.
|
|
12
|
+
* @returns A promise that resolves to the actual time elapsed between calling the `sleep()`
|
|
13
|
+
* method and it resolving. This may differ from the requested duration due to factors such as
|
|
14
|
+
* event loop delays and system load.
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* sleep(1000).then((actualDuration) => {
|
|
19
|
+
* console.log(`Slept for approximately ${actualDuration} ms`);
|
|
20
|
+
* });
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
(duration: number): Promise<number>;
|
|
24
|
+
/**
|
|
25
|
+
* Blocks the main thread for the specified duration and returns the actual duration of the sleep.
|
|
26
|
+
*
|
|
27
|
+
* @param duration The duration of time in milliseconds for which to block the main thread.
|
|
28
|
+
* @returns The actual time elapsed between calling the `sleep.sync()` method and it returning.
|
|
29
|
+
* This may differ from the requested duration due to factors such as event loop delays and system
|
|
30
|
+
* load.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* const actualDuration = sleep.sync(1000);
|
|
35
|
+
* console.log(`Slept for approximately ${actualDuration} ms`);
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* @warning Using `sleep.sync()` can lead to performance issues and should be used with caution,
|
|
39
|
+
* especially in environments where responsiveness is critical, such as in a browser. It blocks
|
|
40
|
+
* the main thread, which can cause the UI to become unresponsive.
|
|
41
|
+
*/
|
|
42
|
+
sync: (duration: number) => number;
|
|
43
|
+
}
|
|
44
|
+
export interface Time {
|
|
45
|
+
/**
|
|
46
|
+
* Measures the average execution time of a given function over a specified number of runs, with
|
|
47
|
+
* an optional warmup phase. The function is executed a certain number of times for warmup (to
|
|
48
|
+
* allow for optimizations like JIT compilation) and then executed a specified number of times to
|
|
49
|
+
* measure the average duration. The result includes both the average duration and the result of
|
|
50
|
+
* the last execution of the function.
|
|
51
|
+
*
|
|
52
|
+
* @param func The function to be timed.
|
|
53
|
+
* @param warmupCount The number of times to execute the function for warmup. This allows for
|
|
54
|
+
* optimizations like JIT compilation to take effect before measuring. Default is 0 (no warmup).
|
|
55
|
+
* @param runCount The number of times to execute the function for timing. The average duration
|
|
56
|
+
* will be calculated based on these runs. Default is 1.
|
|
57
|
+
* @returns A tuple containing the average duration of the function execution in milliseconds and
|
|
58
|
+
* the result of the last execution of the function.
|
|
59
|
+
*
|
|
60
|
+
* @example
|
|
61
|
+
* ```ts
|
|
62
|
+
* const [duration, result] = time(() => {
|
|
63
|
+
* // Some code to be timed
|
|
64
|
+
* }, 10, 100);
|
|
65
|
+
* console.log(`Average duration: ${duration} ms, Result: ${result}`);
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
68
|
+
<T extends AnyFunction>(func: T, warmupCount: number, runCount: number): [duration: number, result: ReturnType<T>];
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/node/timing/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,MAAM,WAAW,KAAK;IACpB;;;;;;;;;;;;;;;;;;;OAmBG;IACH,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC;IAEpC;;;;;;;;;;;;;;;;;OAiBG;IACH,IAAI,EAAE,CAAC,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAC;CACpC;AAED,MAAM,WAAW,IAAI;IACnB;;;;;;;;;;;;;;;;;;;;;;OAsBG;IACH,CAAC,CAAC,SAAS,WAAW,EACpB,IAAI,EAAE,CAAC,EACP,WAAW,EAAE,MAAM,EACnB,QAAQ,EAAE,MAAM,GACf,CAAC,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;CAC9C"}
|
|
@@ -0,0 +1,129 @@
|
|
|
1
|
+
type _Number = -1 | _Numbers[number];
|
|
2
|
+
type _Numbers = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20];
|
|
3
|
+
type _Digit = 0 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9;
|
|
4
|
+
type _DigitString = `${_Digit}`;
|
|
5
|
+
type _NumbersNegShift = _Numbers extends [...infer T, infer _] ? [-1, ...T] : never;
|
|
6
|
+
type _Primitive = string | number | bigint | boolean | symbol | null | undefined;
|
|
7
|
+
type _SS = Exclude<_Primitive, symbol>;
|
|
8
|
+
/**
|
|
9
|
+
* `ArrayOf<Value, Length>` creates a tuple type of a specified length filled with a specified value.
|
|
10
|
+
* If `Length` is -1, it creates an array of any length filled with the value.
|
|
11
|
+
* If `Length` is 0, it creates an empty tuple.
|
|
12
|
+
* If `Length` is not a valid number (within 0 and 20, inclusive), it defaults to an array of any length filled with the value.
|
|
13
|
+
*/
|
|
14
|
+
export type ArrayOf<Value, Length extends number = -1> = Length extends _Number ? Length extends -1 ? Value[] : Length extends 0 ? [] : [Value, ...ArrayOf<Value, _NumbersNegShift[Length]>] : Value[];
|
|
15
|
+
/** A type that represents null or undefined */
|
|
16
|
+
export type Nullish = null | undefined;
|
|
17
|
+
/** A type that represents either a value of type `T` or an array of values of type `T` */
|
|
18
|
+
export type OrArray<T> = T | T[];
|
|
19
|
+
/** A type that represents a 2D vector */
|
|
20
|
+
export type Vector2 = ArrayOf<number, 2>;
|
|
21
|
+
/** A type that represents a 3D vector */
|
|
22
|
+
export type Vector3 = ArrayOf<number, 3>;
|
|
23
|
+
/** A type that represents any function */
|
|
24
|
+
export type AnyFunction = (...args: any[]) => any;
|
|
25
|
+
/**
|
|
26
|
+
* A type that represents a callback function with a specific argument list.
|
|
27
|
+
* The type parameter `T` is a tuple that defines the types of the arguments that the callback
|
|
28
|
+
* function accepts. For example, if `T` is `[string, number]`, then the callback function would
|
|
29
|
+
* have the type `(arg1: string, arg2: number) => void`
|
|
30
|
+
*/
|
|
31
|
+
export type CallbackFunction<T extends any[]> = (...args: T) => void;
|
|
32
|
+
/** A type that represents a callback function that takes a single argument, `T` */
|
|
33
|
+
export type CallbackFunctionOne<T> = (value: T) => void;
|
|
34
|
+
/**
|
|
35
|
+
* A type that represents a function that returns a value of type `T` and takes an optional list of
|
|
36
|
+
* arguments of types specified in the `Args` tuple. For example, if `T` is string and `Args` is
|
|
37
|
+
* `[number, boolean]`, then the function would have the type `(arg1: number, arg2: boolean) => string`
|
|
38
|
+
*/
|
|
39
|
+
export type FunctionThatReturns<T, Args extends any[] = []> = (...args: Args) => T;
|
|
40
|
+
/** A type that enforces that a value of type `T` is also of type `U` */
|
|
41
|
+
export type Enforce<T, U> = T extends U ? T : never;
|
|
42
|
+
/**
|
|
43
|
+
* A type that checks if a type `T` extends another type `Extension` and returns `TrueType` if it
|
|
44
|
+
* does, or `FalseType` if it doesn't.
|
|
45
|
+
*/
|
|
46
|
+
export type IfExtendsThenElse<T, Extension, TrueType, FalseType> = T extends Extension ? TrueType : FalseType;
|
|
47
|
+
type DeepFrozenObject<T extends object> = {
|
|
48
|
+
readonly [K in keyof T]: DeepFrozen<T[K]>;
|
|
49
|
+
};
|
|
50
|
+
type DeepFrozenArray<T extends any[]> = any[] extends T ? Readonly<T> : T extends [infer Head, ...infer Rest] ? [DeepFrozen<Head>, ...DeepFrozenArray<Rest>] : [];
|
|
51
|
+
/**
|
|
52
|
+
* A type that recursively makes all properties of an object and all elements of an array immutable (readonly).
|
|
53
|
+
*
|
|
54
|
+
* If `T` is an array, it applies `DeepFrozen` to each element of the array.
|
|
55
|
+
*
|
|
56
|
+
* If `T` is an object, it applies `DeepFrozen` to each property of the object.
|
|
57
|
+
*
|
|
58
|
+
* If `T` is neither an array nor an object, it returns `T` as is.
|
|
59
|
+
*
|
|
60
|
+
* This type is useful for creating deeply immutable data structures, ensuring that all nested
|
|
61
|
+
* properties and elements cannot be modified after they are created.
|
|
62
|
+
*/
|
|
63
|
+
export type DeepFrozen<T> = T extends any[] ? DeepFrozenArray<T> : T extends object ? DeepFrozenObject<T> : T;
|
|
64
|
+
type ArrayFilterHelper<T extends unknown[], Condition, Collector extends unknown[]> = T extends [
|
|
65
|
+
infer FirstElement,
|
|
66
|
+
...infer RestElements
|
|
67
|
+
] ? ArrayFilterHelper<RestElements, Condition, FirstElement extends Condition ? [...Collector, FirstElement] : Collector> : Collector;
|
|
68
|
+
type ArrayReverseHelper<T extends unknown[], Collector extends unknown[]> = T extends [
|
|
69
|
+
infer FirstElement,
|
|
70
|
+
...infer RestElements
|
|
71
|
+
] ? ArrayReverseHelper<RestElements, [FirstElement, ...Collector]> : Collector;
|
|
72
|
+
type ArrayJoinHelper<T extends unknown[], Separator extends _SS, Collector extends string> = T extends [infer X, ...infer RestElements] ? X extends _SS ? ArrayJoinHelper<RestElements, Separator, `${Collector}${Collector extends "" ? Collector : Separator}${X}`> : string : Collector;
|
|
73
|
+
type StringReverseHelper<T extends string, Collector extends string> = T extends `${infer FirstChar extends string}${infer RestChars extends string}` ? StringReverseHelper<RestChars, `${FirstChar}${Collector}`> : Collector;
|
|
74
|
+
type StringSplitHelper<T extends string, Separator extends string, Collector extends string[]> = T extends `${infer Left extends string}${Separator}${infer Right extends string}` ? StringSplitHelper<Right, Separator, [...Collector, Left]> : T extends "" ? Collector extends [] ? [""] : Collector : [...Collector, T];
|
|
75
|
+
interface NumberDigitStringArrayValue {
|
|
76
|
+
"0": [];
|
|
77
|
+
"1": [null];
|
|
78
|
+
"2": [null, null];
|
|
79
|
+
"3": [null, null, null];
|
|
80
|
+
"4": [null, null, null, null];
|
|
81
|
+
"5": [null, null, null, null, null];
|
|
82
|
+
"6": [null, null, null, null, null, null];
|
|
83
|
+
"7": [null, null, null, null, null, null, null];
|
|
84
|
+
"8": [null, null, null, null, null, null, null, null];
|
|
85
|
+
"9": [null, null, null, null, null, null, null, null, null];
|
|
86
|
+
}
|
|
87
|
+
type NumberDigitStringAddHelper<A extends _DigitString, B extends _DigitString, C extends _DigitString> = [
|
|
88
|
+
...NumberDigitStringArrayValue[A],
|
|
89
|
+
...NumberDigitStringArrayValue[B],
|
|
90
|
+
...NumberDigitStringArrayValue[C]
|
|
91
|
+
]["length"] extends infer Sum extends number ? StringSplit<`${Sum}`, "">["length"] extends 2 ? [StringSplit<`${Sum}`, "">[1], StringSplit<`${Sum}`, "">[0]] : [StringSplit<`${Sum}`, "">[0], "0"] : never;
|
|
92
|
+
type NumberAddHelper<A extends unknown[], B extends unknown[], C extends _DigitString, Collector extends _DigitString[]> = A extends [infer A_First extends _DigitString, ...infer A_Rest extends _DigitString[]] ? B extends [infer B_First extends _DigitString, ...infer B_Rest extends _DigitString[]] ? NumberDigitStringAddHelper<A_First, B_First, C> extends [
|
|
93
|
+
infer Sum extends _DigitString,
|
|
94
|
+
infer Carry extends _DigitString
|
|
95
|
+
] ? NumberAddHelper<A_Rest, B_Rest, Carry, [...Collector, Sum]> : never : NumberDigitStringAddHelper<A_First, "0", C> extends [
|
|
96
|
+
infer Sum extends _DigitString,
|
|
97
|
+
infer Carry extends _DigitString
|
|
98
|
+
] ? NumberAddHelper<A_Rest, B, Carry, [...Collector, Sum]> : never : B extends [infer B_First extends _DigitString, ...infer B_Rest extends _DigitString[]] ? NumberDigitStringAddHelper<"0", B_First, C> extends [
|
|
99
|
+
infer Sum extends _DigitString,
|
|
100
|
+
infer Carry extends _DigitString
|
|
101
|
+
] ? NumberAddHelper<A, B_Rest, Carry, [...Collector, Sum]> : never : NumberCast<ArrayJoin<ArrayReverse<C extends "0" ? Collector : [...Collector, C]>, "">>;
|
|
102
|
+
/** A type that filters an array type `T` based on a specified condition `Condition` */
|
|
103
|
+
export type ArrayFilter<T extends unknown[], Condition> = ArrayFilterHelper<T, Condition, []>;
|
|
104
|
+
/** A type that joins an array of strings, `T`, with a specified separator, `Sep` (default is ",") */
|
|
105
|
+
export type ArrayJoin<T extends _SS[], Sep extends _SS = ","> = ArrayJoinHelper<T, Sep, "">;
|
|
106
|
+
/** A type that reverses an array type `T` */
|
|
107
|
+
export type ArrayReverse<T extends unknown[]> = ArrayReverseHelper<T, []>;
|
|
108
|
+
/**
|
|
109
|
+
* A type that adds two number types `A` and `B` together, returning the result as a number type.
|
|
110
|
+
*
|
|
111
|
+
* @deprecated You absolutely must NOT use this type in production code.
|
|
112
|
+
* @warning "Meta" types like this one go against the general ideology of TypeScript's type system.
|
|
113
|
+
* This type should be considered a "proof of concept" and is not intended for practical use in
|
|
114
|
+
* real-world applications. Do NOT ship this type in production code. You will make other devs
|
|
115
|
+
* very unhappy if you do so. Let this type serve as an inspiration to those looking to explore
|
|
116
|
+
* the limits of TypeScript's type system, but please do not use it in actual projects.
|
|
117
|
+
*/
|
|
118
|
+
export type NumberAdd<A extends number, B extends number> = NumberAddHelper<ArrayReverse<StringSplit<`${A}`>>, ArrayReverse<StringSplit<`${B}`>>, "0", [
|
|
119
|
+
]>;
|
|
120
|
+
/** A type that casts a string type to a number type */
|
|
121
|
+
export type NumberCast<T extends _SS> = `${T}` extends `${infer Num extends number}` ? Num : never;
|
|
122
|
+
/** A type that casts a stringifyable type to a string type */
|
|
123
|
+
export type StringCast<T extends _SS> = `${T}`;
|
|
124
|
+
/** A type that reverses a string type `T` */
|
|
125
|
+
export type StringReverse<T extends string> = StringReverseHelper<T, "">;
|
|
126
|
+
/** A type that splits a string type `T` by a specified separator, `Sep` (default is "") */
|
|
127
|
+
export type StringSplit<T extends string, Sep extends string = ""> = StringSplitHelper<T, Sep, []>;
|
|
128
|
+
export {};
|
|
129
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/node/types/types.ts"],"names":[],"mappings":"AAAA,KAAK,OAAO,GAAG,CAAC,CAAC,GAAG,QAAQ,CAAC,MAAM,CAAC,CAAC;AACrC,KAAK,QAAQ,GAAG,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,EAAE,CAAC,CAAC;AAC3F,KAAK,MAAM,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;AACpD,KAAK,YAAY,GAAG,GAAG,MAAM,EAAE,CAAC;AAChC,KAAK,gBAAgB,GAAG,QAAQ,SAAS,CAAC,GAAG,MAAM,CAAC,EAAE,MAAM,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC,GAAG,KAAK,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AC,SAAS,GAAG,IAAI,GAAG,CAAC,EAAE,CAAC;AAC/C,6CAA6C;AAC7C,MAAM,MAAM,aAAa,CAAC,CAAC,SAAS,MAAM,IAAI,mBAAmB,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACzE,2FAA2F;AAC3F,MAAM,MAAM,WAAW,CAAC,CAAC,SAAS,MAAM,EAAE,GAAG,SAAS,MAAM,GAAG,EAAE,IAAI,iBAAiB,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE,CAAC,CAAC"}
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
export type AssertFunction<T> = (value: unknown, message?: string) => asserts value is T;
|
|
2
|
+
export type CheckFunction<T> = (value: unknown) => value is T;
|
|
3
|
+
export interface Assert {
|
|
4
|
+
/** Asserts that the value is a string. */
|
|
5
|
+
string: AssertFunction<string>;
|
|
6
|
+
/** Asserts that the value is a number. */
|
|
7
|
+
number: AssertFunction<number> & {
|
|
8
|
+
/** Asserts that the value is a positive number. */
|
|
9
|
+
positive: AssertFunction<number>;
|
|
10
|
+
/** Asserts that the value is a negative number. */
|
|
11
|
+
negative: AssertFunction<number>;
|
|
12
|
+
/** Asserts that the value is zero. */
|
|
13
|
+
zero: AssertFunction<number>;
|
|
14
|
+
/** Asserts that the value is an integer. */
|
|
15
|
+
integer: AssertFunction<number>;
|
|
16
|
+
/** Asserts that the value is a float. */
|
|
17
|
+
float: AssertFunction<number>;
|
|
18
|
+
/** Asserts that the value is a finite number. */
|
|
19
|
+
finite: AssertFunction<number>;
|
|
20
|
+
/** Asserts that the value is a safe integer. */
|
|
21
|
+
safeInteger: AssertFunction<number>;
|
|
22
|
+
};
|
|
23
|
+
/** Asserts that the value is true. */
|
|
24
|
+
true: AssertFunction<true>;
|
|
25
|
+
/** Asserts that the value is false. */
|
|
26
|
+
false: AssertFunction<false>;
|
|
27
|
+
/** Asserts that the value is a boolean. */
|
|
28
|
+
boolean: AssertFunction<boolean>;
|
|
29
|
+
/** Asserts that the value is a symbol. */
|
|
30
|
+
symbol: AssertFunction<symbol>;
|
|
31
|
+
/** Asserts that the value is null. */
|
|
32
|
+
null: AssertFunction<null>;
|
|
33
|
+
/** Asserts that the value is undefined. */
|
|
34
|
+
undefined: AssertFunction<undefined>;
|
|
35
|
+
/** Asserts that the value is an object (excluding null). */
|
|
36
|
+
object: AssertFunction<object>;
|
|
37
|
+
/** Asserts that the value is an array. */
|
|
38
|
+
array: AssertFunction<unknown[]>;
|
|
39
|
+
/** Asserts that the value is an ArrayBuffer. */
|
|
40
|
+
arraybuffer: AssertFunction<ArrayBuffer>;
|
|
41
|
+
/** Asserts that the value is an ArrayBufferView. */
|
|
42
|
+
arraybufferview: AssertFunction<ArrayBufferView>;
|
|
43
|
+
/** Asserts that the value is a RegExp. */
|
|
44
|
+
regexp: AssertFunction<RegExp>;
|
|
45
|
+
/** Asserts that the value is not null or undefined. */
|
|
46
|
+
nonNullable: <T>(value: T, message?: string) => asserts value is NonNullable<T>;
|
|
47
|
+
}
|
|
48
|
+
export interface Check {
|
|
49
|
+
/** Returns a boolean indicating whether the value is a string. */
|
|
50
|
+
string: CheckFunction<string>;
|
|
51
|
+
/** Returns a boolean indicating whether the value is a number. */
|
|
52
|
+
number: CheckFunction<number> & {
|
|
53
|
+
/** Returns a boolean indicating whether the value is a positive number. */
|
|
54
|
+
positive: CheckFunction<number>;
|
|
55
|
+
/** Returns a boolean indicating whether the value is a negative number. */
|
|
56
|
+
negative: CheckFunction<number>;
|
|
57
|
+
/** Returns a boolean indicating whether the value is zero. */
|
|
58
|
+
zero: CheckFunction<number>;
|
|
59
|
+
/** Returns a boolean indicating whether the value is an integer. */
|
|
60
|
+
integer: CheckFunction<number>;
|
|
61
|
+
/** Returns a boolean indicating whether the value is a float. */
|
|
62
|
+
float: CheckFunction<number>;
|
|
63
|
+
/** Returns a boolean indicating whether the value is a finite number. */
|
|
64
|
+
finite: CheckFunction<number>;
|
|
65
|
+
/** Returns a boolean indicating whether the value is a safe integer. */
|
|
66
|
+
safeInteger: CheckFunction<number>;
|
|
67
|
+
};
|
|
68
|
+
/** Returns a boolean indicating whether the value is a boolean. */
|
|
69
|
+
boolean: CheckFunction<boolean>;
|
|
70
|
+
/** Returns a boolean indicating whether the value is true. */
|
|
71
|
+
true: CheckFunction<true>;
|
|
72
|
+
/** Returns a boolean indicating whether the value is false. */
|
|
73
|
+
false: CheckFunction<false>;
|
|
74
|
+
/** Returns a boolean indicating whether the value is a symbol. */
|
|
75
|
+
symbol: CheckFunction<symbol>;
|
|
76
|
+
/** Returns a boolean indicating whether the value is null. */
|
|
77
|
+
null: CheckFunction<null>;
|
|
78
|
+
/** Returns a boolean indicating whether the value is undefined. */
|
|
79
|
+
undefined: CheckFunction<undefined>;
|
|
80
|
+
/** Returns a boolean indicating whether the value is an object (excluding null). */
|
|
81
|
+
object: CheckFunction<object>;
|
|
82
|
+
/** Returns a boolean indicating whether the value is an array. */
|
|
83
|
+
array: CheckFunction<unknown[]>;
|
|
84
|
+
/** Returns a boolean indicating whether the value is an ArrayBuffer. */
|
|
85
|
+
arraybuffer: CheckFunction<ArrayBuffer>;
|
|
86
|
+
/** Returns a boolean indicating whether the value is an ArrayBufferView. */
|
|
87
|
+
arraybufferview: CheckFunction<ArrayBufferView>;
|
|
88
|
+
/** Returns a boolean indicating whether the value is a RegExp. */
|
|
89
|
+
regexp: CheckFunction<RegExp>;
|
|
90
|
+
/** Returns a boolean indicating whether the value is not nullish. */
|
|
91
|
+
nonNullable: <T>(value: T) => value is NonNullable<T>;
|
|
92
|
+
}
|
|
93
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/node/validate/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,cAAc,CAAC,CAAC,IAAI,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,MAAM,KAAK,OAAO,CAAC,KAAK,IAAI,CAAC,CAAC;AACz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,IAAI,EAAE,aAAa,CAAC,IAAI,CAAC,CAAC;IAC1B,mEAAmE;IACnE,SAAS,EAAE,aAAa,CAAC,SAAS,CAAC,CAAC;IACpC,oFAAoF;IACpF,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC9B,kEAAkE;IAClE,KAAK,EAAE,aAAa,CAAC,OAAO,EAAE,CAAC,CAAC;IAChC,wEAAwE;IACxE,WAAW,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC;IACxC,4EAA4E;IAC5E,eAAe,EAAE,aAAa,CAAC,eAAe,CAAC,CAAC;IAChD,kEAAkE;IAClE,MAAM,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC9B,qEAAqE;IACrE,WAAW,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,KAAK,KAAK,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC;CACvD"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { Assert, Check } from "./types.ts";
|
|
2
|
+
export declare const assert: Assert;
|
|
3
|
+
export declare const check: Check;
|
|
4
|
+
export declare const isNonNullable: <T>(value: T) => value is NonNullable<T>;
|
|
5
|
+
export declare const nonNullable: <T>(value: T, message?: string) => NonNullable<T>;
|
|
6
|
+
export * from "./types.ts";
|
|
7
|
+
//# sourceMappingURL=validate.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"validate.d.ts","sourceRoot":"","sources":["../../../src/node/validate/validate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAoFhD,eAAO,MAAM,MAAM,EAAE,MAepB,CAAC;AAEF,eAAO,MAAM,KAAK,EAAE,KAenB,CAAC;AAEF,eAAO,MAAM,aAAa,GAAI,CAAC,EAAE,OAAO,CAAC,KAAG,KAAK,IAAI,WAAW,CAAC,CAAC,CAAkB,CAAC;AACrF,eAAO,MAAM,WAAW,GAAI,CAAC,EAAE,OAAO,CAAC,EAAE,UAAU,MAAM,KAAG,WAAW,CAAC,CAAC,CAE/C,CAAC;AAE3B,cAAc,YAAY,CAAC"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import"../chunk-hwenktbz.js";var a=(e)=>typeof e==="string",s=(e)=>typeof e==="number";s.positive=(e)=>s(e)&&e>0;s.negative=(e)=>s(e)&&e<0;s.zero=(e)=>s(e)&&e===0;s.integer=(e)=>s(e)&&Number.isInteger(e);s.float=(e)=>s(e)&&Number.isFinite(e)&&!Number.isInteger(e);s.finite=(e)=>s(e)&&Number.isFinite(e);s.safeInteger=(e)=>s(e)&&Number.isSafeInteger(e);var o=(e)=>typeof e==="boolean",h=(e)=>o(e)&&e,p=(e)=>o(e)&&!e,i=(e)=>typeof e==="symbol",l=(e)=>e===null,u=(e)=>e===void 0,c=(e)=>typeof e==="object"&&e!==null,f=(e)=>Array.isArray(e),b=(e)=>e instanceof ArrayBuffer,d=(e)=>ArrayBuffer.isView(e),_=(e)=>e instanceof RegExp,v=(e)=>e!=null,n=(e,r)=>{if(!e)throw TypeError(r||"value is not truthy")},y=(e,r)=>n(a(e),r||"The provided value is not a string"),t=(e,r)=>n(s(e),r||"The provided value is not a number");t.positive=(e,r)=>n(s.positive(e),r||"The provided value is not a positive number");t.negative=(e,r)=>n(s.negative(e),r||"The provided value is not a negative number");t.zero=(e,r)=>n(s.zero(e),r||"The provided value is not zero");t.integer=(e,r)=>n(s.integer(e),r||"The provided value is not an integer");t.float=(e,r)=>n(s.float(e),r||"The provided value is not a float");t.finite=(e,r)=>n(s.finite(e),r||"The provided value is not a finite number");t.safeInteger=(e,r)=>n(s.safeInteger(e),r||"The provided value is not a safe integer");var m=(e,r)=>n(o(e),r||"The provided value is not a boolean"),g=(e,r)=>n(o(e)&&e,r||"The provided value is not true"),k=(e,r)=>n(o(e)&&!e,r||"The provided value is not false"),T=(e,r)=>n(i(e),r||"The provided value is not a symbol"),A=(e,r)=>n(l(e),r||"The provided value is not null"),N=(e,r)=>n(u(e),r||"The provided value is not undefined"),C=(e,r)=>n(c(e),r||"The provided value is not an object"),x=(e,r)=>n(f(e),r||"The provided value is not an array"),w=(e,r)=>n(b(e),r||"The provided value is not an arraybuffer"),j=(e,r)=>n(d(e),r||"The provided value is not an arraybuffer view"),I=(e,r)=>n(_(e),r||"The provided value is not a regexp"),z=(e,r)=>n(v(e),r||"The provided value is null or undefined"),B={string:y,number:t,boolean:m,true:g,false:k,symbol:T,null:A,undefined:N,object:C,array:x,arraybuffer:w,arraybufferview:j,regexp:I,nonNullable:z},E={string:a,number:s,boolean:o,true:h,false:p,symbol:i,null:l,undefined:u,object:c,array:f,arraybuffer:b,arraybufferview:d,regexp:_,nonNullable:v},F=(e)=>e!=null,S=(e,r)=>(B.false(e==null,r||"The provided value is null or undefined"),e);export{S as nonNullable,F as isNonNullable,E as check,B as assert};
|
|
2
|
+
|
|
3
|
+
//# debugId=1663BE36C86E338C64756E2164756E21
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["..\\..\\src\\node\\validate\\validate.ts"],
|
|
4
|
+
"sourcesContent": [
|
|
5
|
+
"import type { Assert, Check } from \"./types.ts\";\n\nconst _check_string: Check[\"string\"] = (value) => typeof value === \"string\";\nconst _check_number: Check[\"number\"] = (value) => typeof value === \"number\";\n_check_number.positive = (value): value is number => _check_number(value) && value > 0;\n_check_number.negative = (value): value is number => _check_number(value) && value < 0;\n_check_number.zero = (value): value is number => _check_number(value) && value === 0;\n_check_number.integer = (value): value is number => _check_number(value) && Number.isInteger(value);\n_check_number.float = (value): value is number =>\n _check_number(value) && Number.isFinite(value) && !Number.isInteger(value);\n_check_number.finite = (value): value is number => _check_number(value) && Number.isFinite(value);\n_check_number.safeInteger = (value): value is number =>\n _check_number(value) && Number.isSafeInteger(value);\nconst _check_boolean: Check[\"boolean\"] = (value) => typeof value === \"boolean\";\nconst _check_true: Check[\"true\"] = (value) => _check_boolean(value) && value;\nconst _check_false: Check[\"false\"] = (value) => _check_boolean(value) && !value;\nconst _check_symbol: Check[\"symbol\"] = (value) => typeof value === \"symbol\";\nconst _check_null: Check[\"null\"] = (value) => value === null;\nconst _check_undefined: Check[\"undefined\"] = (value) => value === undefined;\nconst _check_object: Check[\"object\"] = (value) => typeof value === \"object\" && value !== null;\nconst _check_array: Check[\"array\"] = (value) => Array.isArray(value);\nconst _check_arraybuffer: Check[\"arraybuffer\"] = (value) => value instanceof ArrayBuffer;\nconst _check_arraybufferview: Check[\"arraybufferview\"] = (value) => ArrayBuffer.isView(value);\nconst _check_regexp: Check[\"regexp\"] = (value) => value instanceof RegExp;\nconst _check_nonNullable: Check[\"nonNullable\"] = (value) => value != null;\n\nconst _base_assert = (value: unknown, message?: string): asserts value => {\n if (!value) throw new TypeError(message || \"value is not truthy\");\n};\nconst _assert_string: Assert[\"string\"] = (value, message) =>\n _base_assert(_check_string(value), message || \"The provided value is not a string\");\nconst _assert_number: Assert[\"number\"] = (value, message) =>\n _base_assert(_check_number(value), message || \"The provided value is not a number\");\n_assert_number.positive = (value, message) =>\n _base_assert(\n _check_number.positive(value),\n message || \"The provided value is not a positive number\",\n );\n_assert_number.negative = (value, message) =>\n _base_assert(\n _check_number.negative(value),\n message || \"The provided value is not a negative number\",\n );\n_assert_number.zero = (value, message) =>\n _base_assert(_check_number.zero(value), message || \"The provided value is not zero\");\n_assert_number.integer = (value, message) =>\n _base_assert(_check_number.integer(value), message || \"The provided value is not an integer\");\n_assert_number.float = (value, message) =>\n _base_assert(_check_number.float(value), message || \"The provided value is not a float\");\n_assert_number.finite = (value, message) =>\n _base_assert(_check_number.finite(value), message || \"The provided value is not a finite number\");\n_assert_number.safeInteger = (value, message) =>\n _base_assert(\n _check_number.safeInteger(value),\n message || \"The provided value is not a safe integer\",\n );\nconst _assert_boolean: Assert[\"boolean\"] = (value, message) =>\n _base_assert(_check_boolean(value), message || \"The provided value is not a boolean\");\nconst _assert_true: Assert[\"true\"] = (value, message) =>\n _base_assert(_check_boolean(value) && value, message || \"The provided value is not true\");\nconst _assert_false: Assert[\"false\"] = (value, message) =>\n _base_assert(_check_boolean(value) && !value, message || \"The provided value is not false\");\nconst _assert_symbol: Assert[\"symbol\"] = (value, message) =>\n _base_assert(_check_symbol(value), message || \"The provided value is not a symbol\");\nconst _assert_null: Assert[\"null\"] = (value, message) =>\n _base_assert(_check_null(value), message || \"The provided value is not null\");\nconst _assert_undefined: Assert[\"undefined\"] = (value, message) =>\n _base_assert(_check_undefined(value), message || \"The provided value is not undefined\");\nconst _assert_object: Assert[\"object\"] = (value, message) =>\n _base_assert(_check_object(value), message || \"The provided value is not an object\");\nconst _assert_array: Assert[\"array\"] = (value, message) =>\n _base_assert(_check_array(value), message || \"The provided value is not an array\");\nconst _assert_arraybuffer: Assert[\"arraybuffer\"] = (value, message) =>\n _base_assert(_check_arraybuffer(value), message || \"The provided value is not an arraybuffer\");\nconst _assert_arraybufferview: Assert[\"arraybufferview\"] = (value, message) =>\n _base_assert(\n _check_arraybufferview(value),\n message || \"The provided value is not an arraybuffer view\",\n );\nconst _assert_regexp: Assert[\"regexp\"] = (value, message) =>\n _base_assert(_check_regexp(value), message || \"The provided value is not a regexp\");\nconst _assert_nonNullable: Assert[\"nonNullable\"] = (value, message) =>\n _base_assert(_check_nonNullable(value), message || \"The provided value is null or undefined\");\n\nexport const assert: Assert = {\n string: _assert_string,\n number: _assert_number,\n boolean: _assert_boolean,\n true: _assert_true,\n false: _assert_false,\n symbol: _assert_symbol,\n null: _assert_null,\n undefined: _assert_undefined,\n object: _assert_object,\n array: _assert_array,\n arraybuffer: _assert_arraybuffer,\n arraybufferview: _assert_arraybufferview,\n regexp: _assert_regexp,\n nonNullable: _assert_nonNullable,\n};\n\nexport const check: Check = {\n string: _check_string,\n number: _check_number,\n boolean: _check_boolean,\n true: _check_true,\n false: _check_false,\n symbol: _check_symbol,\n null: _check_null,\n undefined: _check_undefined,\n object: _check_object,\n array: _check_array,\n arraybuffer: _check_arraybuffer,\n arraybufferview: _check_arraybufferview,\n regexp: _check_regexp,\n nonNullable: _check_nonNullable,\n};\n\nexport const isNonNullable = <T>(value: T): value is NonNullable<T> => value != null;\nexport const nonNullable = <T>(value: T, message?: string): NonNullable<T> =>\n (assert.false(value == null, message || \"The provided value is null or undefined\"),\n value) as NonNullable<T>;\n\nexport * from \"./types.ts\";\n"
|
|
6
|
+
],
|
|
7
|
+
"mappings": "6BAEA,IAAM,EAAiC,CAAC,IAAU,OAAO,IAAU,SAC7D,EAAiC,CAAC,IAAU,OAAO,IAAU,SACnE,EAAc,SAAW,CAAC,IAA2B,EAAc,CAAK,GAAK,EAAQ,EACrF,EAAc,SAAW,CAAC,IAA2B,EAAc,CAAK,GAAK,EAAQ,EACrF,EAAc,KAAO,CAAC,IAA2B,EAAc,CAAK,GAAK,IAAU,EACnF,EAAc,QAAU,CAAC,IAA2B,EAAc,CAAK,GAAK,OAAO,UAAU,CAAK,EAClG,EAAc,MAAQ,CAAC,IACrB,EAAc,CAAK,GAAK,OAAO,SAAS,CAAK,GAAK,CAAC,OAAO,UAAU,CAAK,EAC3E,EAAc,OAAS,CAAC,IAA2B,EAAc,CAAK,GAAK,OAAO,SAAS,CAAK,EAChG,EAAc,YAAc,CAAC,IAC3B,EAAc,CAAK,GAAK,OAAO,cAAc,CAAK,EACpD,IAAM,EAAmC,CAAC,IAAU,OAAO,IAAU,UAC/D,EAA6B,CAAC,IAAU,EAAe,CAAK,GAAK,EACjE,EAA+B,CAAC,IAAU,EAAe,CAAK,GAAK,CAAC,EACpE,EAAiC,CAAC,IAAU,OAAO,IAAU,SAC7D,EAA6B,CAAC,IAAU,IAAU,KAClD,EAAuC,CAAC,IAAU,IAAU,OAC5D,EAAiC,CAAC,IAAU,OAAO,IAAU,UAAY,IAAU,KACnF,EAA+B,CAAC,IAAU,MAAM,QAAQ,CAAK,EAC7D,EAA2C,CAAC,IAAU,aAAiB,YACvE,EAAmD,CAAC,IAAU,YAAY,OAAO,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gCAAgC,EACxE,EAAyC,CAAC,EAAO,IACrD,EAAa,EAAiB,CAAK,EAAG,GAAW,qCAAqC,EAClF,EAAmC,CAAC,EAAO,IAC/C,EAAa,EAAc,CAAK,EAAG,GAAW,qCAAqC,EAC/E,EAAiC,CAAC,EAAO,IAC7C,EAAa,EAAa,CAAK,EAAG,GAAW,oCAAoC,EAC7E,EAA6C,CAAC,EAAO,IACzD,EAAa,EAAmB,CAAK,EAAG,GAAW,0CAA0C,EACzF,EAAqD,CAAC,EAAO,IACjE,EACE,EAAuB,CAAK,EAC5B,GAAW,+CACb,EACI,EAAmC,CAAC,EAAO,IAC/C,EAAa,EAAc,CAAK,EAAG,GAAW,oCAAoC,EAC9E,EAA6C,CAAC,EAAO,IACzD,EAAa,EAAmB,CAAK,EAAG,GAAW,yCAAyC,EAEjF,EAAiB,CAC5B,OAAQ,EACR,OAAQ,EACR,QAAS,EACT,KAAM,EACN,MAAO,EACP,OAAQ,EACR,KAAM,EACN,UAAW,EACX,OAAQ,EACR,MAAO,EACP,YAAa,EACb,gBAAiB,EACjB,OAAQ,EACR,YAAa,CACf,EAEa,EAAe,CAC1B,OAAQ,EACR,OAAQ,EACR,QAAS,EACT,KAAM,EACN,MAAO,EACP,OAAQ,EACR,KAAM,EACN,UAAW,EACX,OAAQ,EACR,MAAO,EACP,YAAa,EACb,gBAAiB,EACjB,OAAQ,EACR,YAAa,CACf,EAEa,EAAgB,CAAI,IAAsC,GAAS,KACnE,EAAc,CAAI,EAAU,KACtC,EAAO,MAAM,GAAS,KAAM,GAAW,yCAAyC,EACjF",
|
|
8
|
+
"debugId": "1663BE36C86E338C64756E2164756E21",
|
|
9
|
+
"names": []
|
|
10
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "1n-broadutils",
|
|
3
|
+
"version": "0.0.1",
|
|
4
|
+
"description": "A library providing utilities covering a wide range of use cases.",
|
|
5
|
+
"homepage": "https://github.com/1natsie/broadutils#readme",
|
|
6
|
+
"author": "Oghenevwegba Obire",
|
|
7
|
+
"license": "MIT",
|
|
8
|
+
"keywords": [
|
|
9
|
+
"broadutils",
|
|
10
|
+
"utility",
|
|
11
|
+
"utils",
|
|
12
|
+
"utilities",
|
|
13
|
+
"canvas",
|
|
14
|
+
"data-manipulation",
|
|
15
|
+
"filesystem",
|
|
16
|
+
"math",
|
|
17
|
+
"misc",
|
|
18
|
+
"network",
|
|
19
|
+
"timing",
|
|
20
|
+
"validation",
|
|
21
|
+
"base64"
|
|
22
|
+
],
|
|
23
|
+
"type": "module",
|
|
24
|
+
"scripts": {
|
|
25
|
+
"build": "bun run ./scripts/build.ts",
|
|
26
|
+
"format": "bunx prettier --write src",
|
|
27
|
+
"test:browser": "bunx vitest run --config vitest.browser.config.ts",
|
|
28
|
+
"test:node": "bunx vitest run --config vitest.node.config.ts"
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"LICENSE",
|
|
32
|
+
"README.md",
|
|
33
|
+
"dist/"
|
|
34
|
+
],
|
|
35
|
+
"exports": {
|
|
36
|
+
"./browser": {
|
|
37
|
+
"import": "./dist/browser/broadutils.js",
|
|
38
|
+
"types": "./dist/browser/broadutils.d.ts"
|
|
39
|
+
},
|
|
40
|
+
"./browser/canvas": {
|
|
41
|
+
"import": "./dist/browser/canvas/canvas.js",
|
|
42
|
+
"types": "./dist/browser/canvas/canvas.d.ts"
|
|
43
|
+
},
|
|
44
|
+
"./browser/data": {
|
|
45
|
+
"import": "./dist/browser/data/data.js",
|
|
46
|
+
"types": "./dist/browser/data/data.d.ts"
|
|
47
|
+
},
|
|
48
|
+
"./browser/math": {
|
|
49
|
+
"import": "./dist/browser/math/math.js",
|
|
50
|
+
"types": "./dist/browser/math/math.d.ts"
|
|
51
|
+
},
|
|
52
|
+
"./browser/misc": {
|
|
53
|
+
"import": "./dist/browser/misc/misc.js",
|
|
54
|
+
"types": "./dist/browser/misc/misc.d.ts"
|
|
55
|
+
},
|
|
56
|
+
"./browser/network": {
|
|
57
|
+
"import": "./dist/browser/network/network.js",
|
|
58
|
+
"types": "./dist/browser/network/network.d.ts"
|
|
59
|
+
},
|
|
60
|
+
"./browser/timing": {
|
|
61
|
+
"import": "./dist/browser/timing/timing.js",
|
|
62
|
+
"types": "./dist/browser/timing/timing.d.ts"
|
|
63
|
+
},
|
|
64
|
+
"./browser/validate": {
|
|
65
|
+
"import": "./dist/browser/validate/validate.js",
|
|
66
|
+
"types": "./dist/browser/validate/validate.d.ts"
|
|
67
|
+
},
|
|
68
|
+
"./browser/types": {
|
|
69
|
+
"types": "./dist/browser/types/types.d.ts"
|
|
70
|
+
},
|
|
71
|
+
"./node": {
|
|
72
|
+
"import": "./dist/node/broadutils.js",
|
|
73
|
+
"types": "./dist/node/broadutils.d.ts"
|
|
74
|
+
},
|
|
75
|
+
"./node/data": {
|
|
76
|
+
"import": "./dist/node/data/data.js",
|
|
77
|
+
"types": "./dist/node/data/data.d.ts"
|
|
78
|
+
},
|
|
79
|
+
"./node/filesystem": {
|
|
80
|
+
"import": "./dist/node/filesystem/filesystem.js",
|
|
81
|
+
"types": "./dist/node/filesystem/filesystem.d.ts"
|
|
82
|
+
},
|
|
83
|
+
"./node/math": {
|
|
84
|
+
"import": "./dist/node/math/math.js",
|
|
85
|
+
"types": "./dist/node/math/math.d.ts"
|
|
86
|
+
},
|
|
87
|
+
"./node/misc": {
|
|
88
|
+
"import": "./dist/node/misc/misc.js",
|
|
89
|
+
"types": "./dist/node/misc/misc.d.ts"
|
|
90
|
+
},
|
|
91
|
+
"./node/timing": {
|
|
92
|
+
"import": "./dist/node/timing/timing.js",
|
|
93
|
+
"types": "./dist/node/timing/timing.d.ts"
|
|
94
|
+
},
|
|
95
|
+
"./node/validate": {
|
|
96
|
+
"import": "./dist/node/validate/validate.js",
|
|
97
|
+
"types": "./dist/node/validate/validate.d.ts"
|
|
98
|
+
},
|
|
99
|
+
"./node/types": {
|
|
100
|
+
"types": "./dist/node/types/types.d.ts"
|
|
101
|
+
}
|
|
102
|
+
},
|
|
103
|
+
"dependencies": {},
|
|
104
|
+
"devDependencies": {
|
|
105
|
+
"@tsconfig/node-ts": "^23.6.4",
|
|
106
|
+
"@tsconfig/node20": "^20.1.9",
|
|
107
|
+
"@types/bun": "^1.3.14",
|
|
108
|
+
"@types/node": "^25.9.1",
|
|
109
|
+
"prettier": "^3.8.1",
|
|
110
|
+
"typescript": "^6.0.2",
|
|
111
|
+
"vitest": "^4.1.8"
|
|
112
|
+
},
|
|
113
|
+
"bugs": {
|
|
114
|
+
"url": "https://github.com/1natsie/broadutils/issues"
|
|
115
|
+
},
|
|
116
|
+
"repository": {
|
|
117
|
+
"type": "git",
|
|
118
|
+
"url": "git+https://github.com/1natsie/broadutils.git"
|
|
119
|
+
}
|
|
120
|
+
}
|