@svta/cml-utils 1.6.0 → 1.6.2
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/README.md +12 -20
- package/dist/index.d.ts +370 -368
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +64 -81
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,319 +1,321 @@
|
|
|
1
1
|
//#region src/arrayBufferToHex.d.ts
|
|
2
2
|
/**
|
|
3
|
-
* Encodes an ArrayBuffer as a hexadecimal string.
|
|
4
|
-
*
|
|
5
|
-
* @param buffer - The ArrayBuffer to encode.
|
|
6
|
-
* @returns The hexadecimal string representation.
|
|
7
|
-
*
|
|
8
|
-
* @public
|
|
9
|
-
*
|
|
10
|
-
* @example
|
|
11
|
-
* {@includeCode ../test/arrayBufferToHex.test.ts#example}
|
|
12
|
-
*/
|
|
13
|
-
declare function arrayBufferToHex(buffer: ArrayBuffer): string;
|
|
3
|
+
* Encodes an ArrayBuffer as a hexadecimal string.
|
|
4
|
+
*
|
|
5
|
+
* @param buffer - The ArrayBuffer to encode.
|
|
6
|
+
* @returns The hexadecimal string representation.
|
|
7
|
+
*
|
|
8
|
+
* @public
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* {@includeCode ../test/arrayBufferToHex.test.ts#example}
|
|
12
|
+
*/
|
|
13
|
+
export declare function arrayBufferToHex(buffer: ArrayBuffer): string;
|
|
14
14
|
//#endregion
|
|
15
15
|
//#region src/arrayBufferToUuid.d.ts
|
|
16
16
|
/**
|
|
17
|
-
* Converts an ArrayBuffer to a UUID string.
|
|
18
|
-
*
|
|
19
|
-
* @param buffer - The ArrayBuffer to convert.
|
|
20
|
-
* @returns The UUID string representation.
|
|
21
|
-
*
|
|
22
|
-
* @public
|
|
23
|
-
*
|
|
24
|
-
* @example
|
|
25
|
-
* {@includeCode ../test/arrayBufferToUuid.test.ts#example}
|
|
26
|
-
*/
|
|
27
|
-
declare function arrayBufferToUuid(buffer: ArrayBuffer): string;
|
|
17
|
+
* Converts an ArrayBuffer to a UUID string.
|
|
18
|
+
*
|
|
19
|
+
* @param buffer - The ArrayBuffer to convert.
|
|
20
|
+
* @returns The UUID string representation.
|
|
21
|
+
*
|
|
22
|
+
* @public
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* {@includeCode ../test/arrayBufferToUuid.test.ts#example}
|
|
26
|
+
*/
|
|
27
|
+
export declare function arrayBufferToUuid(buffer: ArrayBuffer): string;
|
|
28
28
|
//#endregion
|
|
29
29
|
//#region src/decodeBase64.d.ts
|
|
30
30
|
/**
|
|
31
|
-
* Decodes a base64 encoded string into binary data
|
|
32
|
-
*
|
|
33
|
-
* @param str - The base64 encoded string to decode
|
|
34
|
-
* @returns The decoded binary data
|
|
35
|
-
*
|
|
36
|
-
* @public
|
|
37
|
-
*/
|
|
38
|
-
declare function decodeBase64(str: string): Uint8Array;
|
|
31
|
+
* Decodes a base64 encoded string into binary data
|
|
32
|
+
*
|
|
33
|
+
* @param str - The base64 encoded string to decode
|
|
34
|
+
* @returns The decoded binary data
|
|
35
|
+
*
|
|
36
|
+
* @public
|
|
37
|
+
*/
|
|
38
|
+
export declare function decodeBase64(str: string): Uint8Array;
|
|
39
39
|
//#endregion
|
|
40
40
|
//#region src/base64decode.d.ts
|
|
41
41
|
/**
|
|
42
|
-
* Decodes a base64 encoded string into binary data
|
|
43
|
-
*
|
|
44
|
-
* @param str - The base64 encoded string to decode
|
|
45
|
-
* @returns The decoded binary data
|
|
46
|
-
*
|
|
47
|
-
* @public
|
|
48
|
-
*
|
|
49
|
-
* @deprecated Use {@link decodeBase64} instead.
|
|
50
|
-
*
|
|
51
|
-
* @see {@link decodeBase64}
|
|
52
|
-
*/
|
|
53
|
-
declare const base64decode: typeof decodeBase64;
|
|
42
|
+
* Decodes a base64 encoded string into binary data
|
|
43
|
+
*
|
|
44
|
+
* @param str - The base64 encoded string to decode
|
|
45
|
+
* @returns The decoded binary data
|
|
46
|
+
*
|
|
47
|
+
* @public
|
|
48
|
+
*
|
|
49
|
+
* @deprecated Use {@link decodeBase64} instead.
|
|
50
|
+
*
|
|
51
|
+
* @see {@link decodeBase64}
|
|
52
|
+
*/
|
|
53
|
+
export declare const base64decode: typeof decodeBase64;
|
|
54
54
|
//#endregion
|
|
55
55
|
//#region src/encodeBase64.d.ts
|
|
56
56
|
/**
|
|
57
|
-
* Encodes binary data to base64
|
|
58
|
-
*
|
|
59
|
-
* @param binary - The binary data to encode
|
|
60
|
-
* @returns The base64 encoded string
|
|
61
|
-
*
|
|
62
|
-
* @public
|
|
63
|
-
|
|
64
|
-
|
|
57
|
+
* Encodes binary data to base64
|
|
58
|
+
*
|
|
59
|
+
* @param binary - The binary data to encode
|
|
60
|
+
* @returns The base64 encoded string
|
|
61
|
+
*
|
|
62
|
+
* @public
|
|
63
|
+
*
|
|
64
|
+
* @example
|
|
65
|
+
* {@includeCode ../test/encodeBase64.test.ts#example}
|
|
66
|
+
*/
|
|
67
|
+
export declare function encodeBase64(binary: Uint8Array): string;
|
|
65
68
|
//#endregion
|
|
66
69
|
//#region src/base64encode.d.ts
|
|
67
70
|
/**
|
|
68
|
-
* Encodes binary data to base64
|
|
69
|
-
*
|
|
70
|
-
* @param binary - The binary data to encode
|
|
71
|
-
* @returns The base64 encoded string
|
|
72
|
-
*
|
|
73
|
-
* @public
|
|
74
|
-
*
|
|
75
|
-
* @deprecated Use {@link encodeBase64} instead.
|
|
76
|
-
*
|
|
77
|
-
* @see {@link encodeBase64}
|
|
78
|
-
*/
|
|
79
|
-
declare const base64encode: typeof encodeBase64;
|
|
71
|
+
* Encodes binary data to base64
|
|
72
|
+
*
|
|
73
|
+
* @param binary - The binary data to encode
|
|
74
|
+
* @returns The base64 encoded string
|
|
75
|
+
*
|
|
76
|
+
* @public
|
|
77
|
+
*
|
|
78
|
+
* @deprecated Use {@link encodeBase64} instead.
|
|
79
|
+
*
|
|
80
|
+
* @see {@link encodeBase64}
|
|
81
|
+
*/
|
|
82
|
+
export declare const base64encode: typeof encodeBase64;
|
|
80
83
|
//#endregion
|
|
81
84
|
//#region src/convertUint8ToUint16.d.ts
|
|
82
85
|
/**
|
|
83
|
-
* Converts a Uint8Array to a Uint16Array by aligning its buffer.
|
|
84
|
-
*
|
|
85
|
-
* @param input - The Uint8Array to convert
|
|
86
|
-
* @returns A properly aligned Uint16Array
|
|
87
|
-
*
|
|
88
|
-
* @public
|
|
89
|
-
*/
|
|
90
|
-
declare function convertUint8ToUint16(input: Uint8Array): Uint16Array;
|
|
86
|
+
* Converts a Uint8Array to a Uint16Array by aligning its buffer.
|
|
87
|
+
*
|
|
88
|
+
* @param input - The Uint8Array to convert
|
|
89
|
+
* @returns A properly aligned Uint16Array
|
|
90
|
+
*
|
|
91
|
+
* @public
|
|
92
|
+
*/
|
|
93
|
+
export declare function convertUint8ToUint16(input: Uint8Array): Uint16Array;
|
|
91
94
|
//#endregion
|
|
92
95
|
//#region src/UTF_16.d.ts
|
|
93
96
|
/**
|
|
94
|
-
* UTF-16 Encoding.
|
|
95
|
-
*
|
|
96
|
-
* @public
|
|
97
|
-
*/
|
|
98
|
-
declare const UTF_16 = "utf-16";
|
|
97
|
+
* UTF-16 Encoding.
|
|
98
|
+
*
|
|
99
|
+
* @public
|
|
100
|
+
*/
|
|
101
|
+
export declare const UTF_16 = "utf-16";
|
|
99
102
|
//#endregion
|
|
100
103
|
//#region src/UTF_16_BE.d.ts
|
|
101
104
|
/**
|
|
102
|
-
* UTF-16 Big Endian Encoding.
|
|
103
|
-
*
|
|
104
|
-
* @public
|
|
105
|
-
*/
|
|
106
|
-
declare const UTF_16_BE = "utf-16be";
|
|
105
|
+
* UTF-16 Big Endian Encoding.
|
|
106
|
+
*
|
|
107
|
+
* @public
|
|
108
|
+
*/
|
|
109
|
+
export declare const UTF_16_BE = "utf-16be";
|
|
107
110
|
//#endregion
|
|
108
111
|
//#region src/UTF_16_LE.d.ts
|
|
109
112
|
/**
|
|
110
|
-
* UTF-16 Little Endian Encoding.
|
|
111
|
-
*
|
|
112
|
-
* @public
|
|
113
|
-
*/
|
|
114
|
-
declare const UTF_16_LE = "utf-16le";
|
|
113
|
+
* UTF-16 Little Endian Encoding.
|
|
114
|
+
*
|
|
115
|
+
* @public
|
|
116
|
+
*/
|
|
117
|
+
export declare const UTF_16_LE = "utf-16le";
|
|
115
118
|
//#endregion
|
|
116
119
|
//#region src/UTF_8.d.ts
|
|
117
120
|
/**
|
|
118
|
-
* UTF-8 Encoding.
|
|
119
|
-
*
|
|
120
|
-
* @public
|
|
121
|
-
*/
|
|
122
|
-
declare const UTF_8 = "utf-8";
|
|
121
|
+
* UTF-8 Encoding.
|
|
122
|
+
*
|
|
123
|
+
* @public
|
|
124
|
+
*/
|
|
125
|
+
export declare const UTF_8 = "utf-8";
|
|
123
126
|
//#endregion
|
|
124
127
|
//#region src/ValueOf.d.ts
|
|
125
128
|
/**
|
|
126
|
-
* Utility type to get the value of a given object type.
|
|
127
|
-
*
|
|
128
|
-
* @public
|
|
129
|
-
*/
|
|
130
|
-
type ValueOf<T> = T[keyof T];
|
|
129
|
+
* Utility type to get the value of a given object type.
|
|
130
|
+
*
|
|
131
|
+
* @public
|
|
132
|
+
*/
|
|
133
|
+
export type ValueOf<T> = T[keyof T];
|
|
131
134
|
//#endregion
|
|
132
135
|
//#region src/Encoding.d.ts
|
|
133
136
|
/**
|
|
134
|
-
* Text encoding types.
|
|
135
|
-
*
|
|
136
|
-
* @public
|
|
137
|
-
*/
|
|
138
|
-
declare const Encoding: {
|
|
137
|
+
* Text encoding types.
|
|
138
|
+
*
|
|
139
|
+
* @public
|
|
140
|
+
*/
|
|
141
|
+
export declare const Encoding: {
|
|
139
142
|
readonly UTF8: typeof UTF_8;
|
|
140
143
|
readonly UTF16: typeof UTF_16;
|
|
141
144
|
readonly UTF16BE: typeof UTF_16_BE;
|
|
142
145
|
readonly UTF16LE: typeof UTF_16_LE;
|
|
143
146
|
};
|
|
144
147
|
/**
|
|
145
|
-
* Text encoding types.
|
|
146
|
-
*
|
|
147
|
-
* @public
|
|
148
|
-
*/
|
|
149
|
-
type Encoding = ValueOf<typeof Encoding>;
|
|
148
|
+
* Text encoding types.
|
|
149
|
+
*
|
|
150
|
+
* @public
|
|
151
|
+
*/
|
|
152
|
+
export type Encoding = ValueOf<typeof Encoding>;
|
|
150
153
|
//#endregion
|
|
151
154
|
//#region src/DecodeTextOptions.d.ts
|
|
152
155
|
/**
|
|
153
|
-
* Options for the `decodeText` function.
|
|
154
|
-
*
|
|
155
|
-
* @public
|
|
156
|
-
*/
|
|
157
|
-
type DecodeTextOptions = {
|
|
156
|
+
* Options for the `decodeText` function.
|
|
157
|
+
*
|
|
158
|
+
* @public
|
|
159
|
+
*/
|
|
160
|
+
export type DecodeTextOptions = {
|
|
158
161
|
/**
|
|
159
|
-
|
|
160
|
-
|
|
162
|
+
* The encoding to use. If omitted, the function tries to detect the encoding from the BOM.
|
|
163
|
+
*/
|
|
161
164
|
encoding?: Encoding;
|
|
162
165
|
};
|
|
163
166
|
//#endregion
|
|
164
167
|
//#region src/decodeText.d.ts
|
|
165
168
|
/**
|
|
166
|
-
* Converts an ArrayBuffer or ArrayBufferView to a string.
|
|
167
|
-
*
|
|
168
|
-
*
|
|
169
|
-
* @param data - The data to decode.
|
|
170
|
-
* @param options - The options for the decoding.
|
|
171
|
-
* @returns The string representation of the ArrayBuffer.
|
|
172
|
-
*
|
|
173
|
-
* @public
|
|
174
|
-
*
|
|
175
|
-
* @example
|
|
176
|
-
* {@includeCode ../test/decodeText.test.ts#example}
|
|
177
|
-
*/
|
|
178
|
-
declare function decodeText(data: ArrayBufferLike | ArrayBufferView, options?: DecodeTextOptions): string;
|
|
169
|
+
* Converts an ArrayBuffer or ArrayBufferView to a string. The function works like
|
|
170
|
+
* `TextDecoder.decode` and also supports environments without `TextDecoder`.
|
|
171
|
+
*
|
|
172
|
+
* @param data - The data to decode.
|
|
173
|
+
* @param options - The options for the decoding.
|
|
174
|
+
* @returns The string representation of the ArrayBuffer.
|
|
175
|
+
*
|
|
176
|
+
* @public
|
|
177
|
+
*
|
|
178
|
+
* @example
|
|
179
|
+
* {@includeCode ../test/decodeText.test.ts#example}
|
|
180
|
+
*/
|
|
181
|
+
export declare function decodeText(data: ArrayBufferLike | ArrayBufferView, options?: DecodeTextOptions): string;
|
|
179
182
|
//#endregion
|
|
180
183
|
//#region src/DeepReadonly.d.ts
|
|
181
184
|
/**
|
|
182
|
-
* Utility type that marks every property of a given type as `readonly`,
|
|
183
|
-
* recursively.
|
|
184
|
-
*
|
|
185
|
-
* `Readonly<T>` stops at the top level, so a nested object
|
|
186
|
-
* `value.nested.field = …` still compiles.
|
|
187
|
-
* including through arrays.
|
|
188
|
-
*
|
|
189
|
-
* Functions
|
|
190
|
-
*
|
|
191
|
-
*
|
|
192
|
-
* @typeParam T - The type to make deeply readonly.
|
|
193
|
-
*
|
|
194
|
-
* @example
|
|
195
|
-
* {@includeCode ../test/DeepReadonly.test.ts#example}
|
|
196
|
-
*
|
|
197
|
-
* @public
|
|
198
|
-
*/
|
|
199
|
-
type DeepReadonly<T> = T extends ((...args: never[]) => unknown) ? T : T extends readonly (infer U)[] ? readonly DeepReadonly<U>[] : T extends object ? { readonly [P in keyof T]: DeepReadonly<T[P]
|
|
185
|
+
* Utility type that marks every property of a given type as `readonly`,
|
|
186
|
+
* recursively.
|
|
187
|
+
*
|
|
188
|
+
* `Readonly<T>` stops at the top level, so a nested object remains writable and
|
|
189
|
+
* `value.nested.field = …` still compiles. `DeepReadonly` applies at every depth,
|
|
190
|
+
* including through arrays.
|
|
191
|
+
*
|
|
192
|
+
* Functions keep their type, so callbacks on a value remain callable.
|
|
193
|
+
* Primitives keep their type.
|
|
194
|
+
*
|
|
195
|
+
* @typeParam T - The type to make deeply readonly.
|
|
196
|
+
*
|
|
197
|
+
* @example
|
|
198
|
+
* {@includeCode ../test/DeepReadonly.test.ts#example}
|
|
199
|
+
*
|
|
200
|
+
* @public
|
|
201
|
+
*/
|
|
202
|
+
type DeepReadonly<T> = T extends ((...args: never[]) => unknown) ? T : T extends readonly (infer U)[] ? readonly DeepReadonly<U>[] : T extends object ? { readonly [P in keyof T]: DeepReadonly<T[P]>; } : T;
|
|
200
203
|
//#endregion
|
|
201
204
|
//#region src/encodeText.d.ts
|
|
202
205
|
/**
|
|
203
|
-
* Converts a string to a Uint8Array.
|
|
204
|
-
*
|
|
205
|
-
*
|
|
206
|
-
* @param data - The string to encode.
|
|
207
|
-
* @returns The Uint8Array representation of the string.
|
|
208
|
-
*
|
|
209
|
-
* @public
|
|
210
|
-
*
|
|
211
|
-
* @example
|
|
212
|
-
* {@includeCode ../test/encodeText.test.ts#example}
|
|
213
|
-
*/
|
|
214
|
-
declare function encodeText(data: string): Uint8Array;
|
|
206
|
+
* Converts a string to a Uint8Array. The function works like
|
|
207
|
+
* `TextEncoder.encode` and also supports environments without `TextEncoder`.
|
|
208
|
+
*
|
|
209
|
+
* @param data - The string to encode.
|
|
210
|
+
* @returns The Uint8Array representation of the string.
|
|
211
|
+
*
|
|
212
|
+
* @public
|
|
213
|
+
*
|
|
214
|
+
* @example
|
|
215
|
+
* {@includeCode ../test/encodeText.test.ts#example}
|
|
216
|
+
*/
|
|
217
|
+
export declare function encodeText(data: string): Uint8Array;
|
|
215
218
|
//#endregion
|
|
216
219
|
//#region src/ExclusiveRecord.d.ts
|
|
217
220
|
/**
|
|
218
|
-
* A record that is exclusive to a given key.
|
|
219
|
-
*
|
|
220
|
-
* @public
|
|
221
|
-
*/
|
|
222
|
-
type ExclusiveRecord<K extends PropertyKey, V> = { [P in K]: Record<P, V> & Partial<Record<Exclude<K, P>, never>> extends infer O ? { [Q in keyof O]: O[Q] } : never }[K];
|
|
221
|
+
* A record that is exclusive to a given key.
|
|
222
|
+
*
|
|
223
|
+
* @public
|
|
224
|
+
*/
|
|
225
|
+
export type ExclusiveRecord<K extends PropertyKey, V> = { [P in K]: Record<P, V> & Partial<Record<Exclude<K, P>, never>> extends (infer O) ? { [Q in keyof O]: O[Q]; } : never; }[K];
|
|
223
226
|
//#endregion
|
|
224
227
|
//#region src/ResourceTiming.d.ts
|
|
225
228
|
/**
|
|
226
|
-
*
|
|
227
|
-
* https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming
|
|
228
|
-
*
|
|
229
|
-
* @public
|
|
230
|
-
*/
|
|
231
|
-
type ResourceTiming = {
|
|
229
|
+
* A subset of the `PerformanceResourceTiming` interface.
|
|
230
|
+
* https://developer.mozilla.org/en-US/docs/Web/API/PerformanceResourceTiming
|
|
231
|
+
*
|
|
232
|
+
* @public
|
|
233
|
+
*/
|
|
234
|
+
export type ResourceTiming = {
|
|
232
235
|
/**
|
|
233
|
-
|
|
234
|
-
|
|
236
|
+
* A `DOMHighResTimeStamp` for the time a resource fetch started.
|
|
237
|
+
*/
|
|
235
238
|
startTime: number;
|
|
236
239
|
/**
|
|
237
|
-
|
|
238
|
-
|
|
240
|
+
* The size (in octets) of the payload body before removing any applied content encodings.
|
|
241
|
+
*/
|
|
239
242
|
encodedBodySize: number;
|
|
240
243
|
/**
|
|
241
|
-
|
|
242
|
-
|
|
244
|
+
* A `DOMHighResTimeStamp` immediately after the browser receives the first byte of the response from the server.
|
|
245
|
+
*/
|
|
243
246
|
responseStart?: number;
|
|
244
247
|
/**
|
|
245
|
-
|
|
246
|
-
|
|
248
|
+
* The difference (in milliseconds) between the `responseEnd` and the `startTime`.
|
|
249
|
+
*/
|
|
247
250
|
duration: number;
|
|
248
251
|
};
|
|
249
252
|
//#endregion
|
|
250
253
|
//#region src/getBandwidthBps.d.ts
|
|
251
254
|
/**
|
|
252
|
-
* Converts a ResourceTiming sample to bandwidth in bits per second
|
|
253
|
-
*
|
|
254
|
-
* @param sample - A ResourceTiming sample
|
|
255
|
-
* @returns
|
|
256
|
-
*
|
|
257
|
-
* @public
|
|
258
|
-
*/
|
|
259
|
-
declare function getBandwidthBps(sample: ResourceTiming): number;
|
|
255
|
+
* Converts a ResourceTiming sample to bandwidth in bits per second.
|
|
256
|
+
*
|
|
257
|
+
* @param sample - A ResourceTiming sample
|
|
258
|
+
* @returns The bandwidth in bits per second.
|
|
259
|
+
*
|
|
260
|
+
* @public
|
|
261
|
+
*/
|
|
262
|
+
export declare function getBandwidthBps(sample: ResourceTiming): number;
|
|
260
263
|
//#endregion
|
|
261
264
|
//#region src/getBaseUrl.d.ts
|
|
262
265
|
/**
|
|
263
|
-
*
|
|
264
|
-
*
|
|
265
|
-
* @param fullUrl - The full URL or URL object.
|
|
266
|
-
* @returns The base URL.
|
|
267
|
-
*
|
|
268
|
-
* @public
|
|
269
|
-
*
|
|
270
|
-
* @example
|
|
271
|
-
* {@includeCode ../test/getBaseUrl.test.ts#example}
|
|
272
|
-
*/
|
|
273
|
-
declare function getBaseUrl(fullUrl: string | URL): string;
|
|
266
|
+
* Gets the base URL from a full URL or a URL object.
|
|
267
|
+
*
|
|
268
|
+
* @param fullUrl - The full URL or URL object.
|
|
269
|
+
* @returns The base URL.
|
|
270
|
+
*
|
|
271
|
+
* @public
|
|
272
|
+
*
|
|
273
|
+
* @example
|
|
274
|
+
* {@includeCode ../test/getBaseUrl.test.ts#example}
|
|
275
|
+
*/
|
|
276
|
+
export declare function getBaseUrl(fullUrl: string | URL): string;
|
|
274
277
|
//#endregion
|
|
275
278
|
//#region src/hexToArrayBuffer.d.ts
|
|
276
279
|
/**
|
|
277
|
-
* Decodes a hexadecimal string into an ArrayBuffer.
|
|
278
|
-
*
|
|
279
|
-
* @param hex - The hexadecimal string to decode.
|
|
280
|
-
* @returns The decoded ArrayBuffer.
|
|
281
|
-
*
|
|
282
|
-
* @public
|
|
283
|
-
*
|
|
284
|
-
* @example
|
|
285
|
-
* {@includeCode ../test/hexToArrayBuffer.test.ts#example}
|
|
286
|
-
*/
|
|
287
|
-
declare function hexToArrayBuffer(hex: string): ArrayBuffer;
|
|
280
|
+
* Decodes a hexadecimal string into an ArrayBuffer.
|
|
281
|
+
*
|
|
282
|
+
* @param hex - The hexadecimal string to decode.
|
|
283
|
+
* @returns The decoded ArrayBuffer.
|
|
284
|
+
*
|
|
285
|
+
* @public
|
|
286
|
+
*
|
|
287
|
+
* @example
|
|
288
|
+
* {@includeCode ../test/hexToArrayBuffer.test.ts#example}
|
|
289
|
+
*/
|
|
290
|
+
export declare function hexToArrayBuffer(hex: string): ArrayBuffer;
|
|
288
291
|
//#endregion
|
|
289
292
|
//#region src/isArrayBufferLike.d.ts
|
|
290
293
|
/**
|
|
291
|
-
* Checks if the given value is `ArrayBufferLike
|
|
292
|
-
*
|
|
293
|
-
*
|
|
294
|
-
*
|
|
295
|
-
*
|
|
296
|
-
*
|
|
297
|
-
*
|
|
298
|
-
* @
|
|
299
|
-
*
|
|
300
|
-
*
|
|
301
|
-
*
|
|
302
|
-
*
|
|
303
|
-
* @example
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
declare function isArrayBufferLike(value: unknown): value is ArrayBufferLike;
|
|
294
|
+
* Checks if the given value is `ArrayBufferLike`: an `ArrayBuffer` or a
|
|
295
|
+
* `SharedArrayBuffer`.
|
|
296
|
+
*
|
|
297
|
+
* The function also works where `SharedArrayBuffer` is not defined, such as
|
|
298
|
+
* browser contexts without cross-origin isolation.
|
|
299
|
+
*
|
|
300
|
+
* @param value - The value to check.
|
|
301
|
+
* @returns `true` if the value is an `ArrayBuffer` or `SharedArrayBuffer`.
|
|
302
|
+
*
|
|
303
|
+
* @public
|
|
304
|
+
*
|
|
305
|
+
* @example
|
|
306
|
+
* {@includeCode ../test/isArrayBufferLike.test.ts#example}
|
|
307
|
+
*/
|
|
308
|
+
export declare function isArrayBufferLike(value: unknown): value is ArrayBufferLike;
|
|
307
309
|
//#endregion
|
|
308
310
|
//#region src/RequestResponseType.d.ts
|
|
309
311
|
/**
|
|
310
|
-
* The response type of the request.
|
|
311
|
-
*
|
|
312
|
-
* @enum
|
|
313
|
-
*
|
|
314
|
-
* @public
|
|
315
|
-
*/
|
|
316
|
-
declare const RequestResponseType: {
|
|
312
|
+
* The response type of the request.
|
|
313
|
+
*
|
|
314
|
+
* @enum
|
|
315
|
+
*
|
|
316
|
+
* @public
|
|
317
|
+
*/
|
|
318
|
+
export declare const RequestResponseType: {
|
|
317
319
|
readonly TEXT: "text";
|
|
318
320
|
readonly JSON: "json";
|
|
319
321
|
readonly BLOB: "blob";
|
|
@@ -322,62 +324,62 @@ declare const RequestResponseType: {
|
|
|
322
324
|
readonly STREAM: "stream";
|
|
323
325
|
};
|
|
324
326
|
/**
|
|
325
|
-
* @public
|
|
326
|
-
*/
|
|
327
|
-
type RequestResponseType = ValueOf<typeof RequestResponseType>;
|
|
327
|
+
* @public
|
|
328
|
+
*/
|
|
329
|
+
export type RequestResponseType = ValueOf<typeof RequestResponseType>;
|
|
328
330
|
//#endregion
|
|
329
331
|
//#region src/HttpRequest.d.ts
|
|
330
332
|
/**
|
|
331
|
-
* Generic request API.
|
|
332
|
-
*
|
|
333
|
-
* @public
|
|
334
|
-
*/
|
|
335
|
-
type HttpRequest<D = any> = {
|
|
333
|
+
* Generic request API.
|
|
334
|
+
*
|
|
335
|
+
* @public
|
|
336
|
+
*/
|
|
337
|
+
export type HttpRequest<D = any> = {
|
|
336
338
|
/**
|
|
337
|
-
|
|
338
|
-
|
|
339
|
+
* The URL of the request.
|
|
340
|
+
*/
|
|
339
341
|
url: string;
|
|
340
342
|
/**
|
|
341
|
-
|
|
342
|
-
|
|
343
|
+
* The request's method (GET, POST, etc).
|
|
344
|
+
*/
|
|
343
345
|
method?: string;
|
|
344
346
|
/**
|
|
345
|
-
|
|
346
|
-
|
|
347
|
+
* The body of the request.
|
|
348
|
+
*/
|
|
347
349
|
body?: BodyInit;
|
|
348
350
|
/**
|
|
349
|
-
|
|
350
|
-
|
|
351
|
+
* The type that the response from the server must be compatible with.
|
|
352
|
+
*/
|
|
351
353
|
responseType?: RequestResponseType;
|
|
352
354
|
/**
|
|
353
|
-
|
|
354
|
-
|
|
355
|
+
* The headers object associated with the request.
|
|
356
|
+
*/
|
|
355
357
|
headers?: Record<string, string>;
|
|
356
358
|
/**
|
|
357
|
-
|
|
358
|
-
|
|
359
|
+
* Whether the user agent should send or receive cookies from the other domain in cross-origin requests.
|
|
360
|
+
*/
|
|
359
361
|
credentials?: RequestCredentials;
|
|
360
362
|
/**
|
|
361
|
-
|
|
362
|
-
|
|
363
|
+
* The mode of the request, for example cors, no-cors, or same-origin.
|
|
364
|
+
*/
|
|
363
365
|
mode?: RequestMode;
|
|
364
366
|
/**
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
367
|
+
* The number of milliseconds the request may take before it is terminated.
|
|
368
|
+
* If the value is undefined or 0, there is no timeout.
|
|
369
|
+
*/
|
|
368
370
|
timeout?: number;
|
|
369
371
|
/**
|
|
370
|
-
|
|
371
|
-
|
|
372
|
+
* Any custom data.
|
|
373
|
+
*/
|
|
372
374
|
customData?: D;
|
|
373
375
|
};
|
|
374
376
|
//#endregion
|
|
375
377
|
//#region src/XmlNode.d.ts
|
|
376
378
|
/**
|
|
377
|
-
* XML node
|
|
378
|
-
*
|
|
379
|
-
* @public
|
|
380
|
-
*/
|
|
379
|
+
* XML node
|
|
380
|
+
*
|
|
381
|
+
* @public
|
|
382
|
+
*/
|
|
381
383
|
type XmlNode = {
|
|
382
384
|
nodeName: string;
|
|
383
385
|
nodeValue: string | null;
|
|
@@ -390,169 +392,169 @@ type XmlNode = {
|
|
|
390
392
|
//#endregion
|
|
391
393
|
//#region src/ResponseTypeMap.d.ts
|
|
392
394
|
/**
|
|
393
|
-
* Maps a request's `responseType` to the corresponding data type.
|
|
394
|
-
*
|
|
395
|
-
* @public
|
|
396
|
-
*/
|
|
395
|
+
* Maps a request's `responseType` to the corresponding data type.
|
|
396
|
+
*
|
|
397
|
+
* @public
|
|
398
|
+
*/
|
|
397
399
|
type ResponseTypeMap<T extends string | undefined> = T extends "json" ? any : T extends "text" ? string : T extends "blob" ? Blob : T extends "arrayBuffer" ? ArrayBuffer : T extends "document" ? XmlNode : T extends "stream" ? ReadableStream : unknown;
|
|
398
400
|
//#endregion
|
|
399
401
|
//#region src/HttpResponse.d.ts
|
|
400
402
|
/**
|
|
401
|
-
* Generic response API.
|
|
402
|
-
*
|
|
403
|
-
* @public
|
|
404
|
-
*/
|
|
405
|
-
type HttpResponse<R extends HttpRequest = HttpRequest> = {
|
|
403
|
+
* Generic response API.
|
|
404
|
+
*
|
|
405
|
+
* @public
|
|
406
|
+
*/
|
|
407
|
+
export type HttpResponse<R extends HttpRequest = HttpRequest> = {
|
|
406
408
|
/**
|
|
407
|
-
|
|
408
|
-
|
|
409
|
+
* The origin request.
|
|
410
|
+
*/
|
|
409
411
|
request: R;
|
|
410
412
|
/**
|
|
411
|
-
|
|
412
|
-
|
|
413
|
+
* The final URL obtained after any redirects.
|
|
414
|
+
*/
|
|
413
415
|
url?: string;
|
|
414
416
|
/**
|
|
415
|
-
|
|
416
|
-
|
|
417
|
+
* Whether the request was redirected.
|
|
418
|
+
*/
|
|
417
419
|
redirected?: boolean;
|
|
418
420
|
/**
|
|
419
|
-
|
|
420
|
-
|
|
421
|
+
* The HTTP status code of the response.
|
|
422
|
+
*/
|
|
421
423
|
status?: number;
|
|
422
424
|
/**
|
|
423
|
-
|
|
424
|
-
|
|
425
|
+
* The status message corresponding to the HTTP status code.
|
|
426
|
+
*/
|
|
425
427
|
statusText?: string;
|
|
426
428
|
/**
|
|
427
|
-
|
|
428
|
-
|
|
429
|
+
* The type of the response.
|
|
430
|
+
*/
|
|
429
431
|
type?: string;
|
|
430
432
|
/**
|
|
431
|
-
|
|
432
|
-
|
|
433
|
+
* The response headers.
|
|
434
|
+
*/
|
|
433
435
|
headers?: Record<string, string>;
|
|
434
436
|
/**
|
|
435
|
-
|
|
436
|
-
|
|
437
|
+
* The response data.
|
|
438
|
+
*/
|
|
437
439
|
data?: ResponseTypeMap<R["responseType"]>;
|
|
438
440
|
/**
|
|
439
|
-
|
|
440
|
-
|
|
441
|
+
* The network timing of the request/response.
|
|
442
|
+
*/
|
|
441
443
|
resourceTiming?: ResourceTiming;
|
|
442
444
|
};
|
|
443
445
|
//#endregion
|
|
444
446
|
//#region src/Request.d.ts
|
|
445
447
|
/**
|
|
446
|
-
* Request API.
|
|
447
|
-
*
|
|
448
|
-
* @public
|
|
449
|
-
* @deprecated Use {@link HttpRequest} instead.
|
|
450
|
-
*/
|
|
448
|
+
* Request API.
|
|
449
|
+
*
|
|
450
|
+
* @public
|
|
451
|
+
* @deprecated Use {@link HttpRequest} instead.
|
|
452
|
+
*/
|
|
451
453
|
type Request = HttpRequest;
|
|
452
454
|
//#endregion
|
|
453
455
|
//#region src/roundToEven.d.ts
|
|
454
456
|
/**
|
|
455
|
-
*
|
|
456
|
-
*
|
|
457
|
-
*
|
|
458
|
-
* @param value - The value to round
|
|
459
|
-
* @param precision - The number of decimal places to round to
|
|
460
|
-
* @returns The rounded value
|
|
461
|
-
*
|
|
462
|
-
* @public
|
|
463
|
-
*/
|
|
464
|
-
declare function roundToEven(value: number, precision: number): number;
|
|
457
|
+
* Rounds a value with the procedure from step 2 of the "Serializing a Decimal" specification.
|
|
458
|
+
* The style is known as "even rounding", "banker's rounding", or "commercial rounding".
|
|
459
|
+
*
|
|
460
|
+
* @param value - The value to round
|
|
461
|
+
* @param precision - The number of decimal places to round to
|
|
462
|
+
* @returns The rounded value
|
|
463
|
+
*
|
|
464
|
+
* @public
|
|
465
|
+
*/
|
|
466
|
+
export declare function roundToEven(value: number, precision: number): number;
|
|
465
467
|
//#endregion
|
|
466
468
|
//#region src/stringToUint16.d.ts
|
|
467
469
|
/**
|
|
468
|
-
* Converts a string to a Uint16Array.
|
|
469
|
-
*
|
|
470
|
-
* @param str - The string to convert
|
|
471
|
-
* @returns A Uint16Array representation of the string
|
|
472
|
-
*
|
|
473
|
-
* @public
|
|
474
|
-
*
|
|
475
|
-
* @example
|
|
476
|
-
* {@includeCode ../test/stringToUint16.test.ts#example}
|
|
477
|
-
*/
|
|
478
|
-
declare function stringToUint16(str: string): Uint16Array;
|
|
470
|
+
* Converts a string to a Uint16Array.
|
|
471
|
+
*
|
|
472
|
+
* @param str - The string to convert
|
|
473
|
+
* @returns A Uint16Array representation of the string
|
|
474
|
+
*
|
|
475
|
+
* @public
|
|
476
|
+
*
|
|
477
|
+
* @example
|
|
478
|
+
* {@includeCode ../test/stringToUint16.test.ts#example}
|
|
479
|
+
*/
|
|
480
|
+
export declare function stringToUint16(str: string): Uint16Array;
|
|
479
481
|
//#endregion
|
|
480
482
|
//#region src/TypedResult.d.ts
|
|
481
483
|
/**
|
|
482
|
-
* Utility type to create a typed result.
|
|
483
|
-
*
|
|
484
|
-
* @public
|
|
485
|
-
*/
|
|
486
|
-
type TypedResult<T, D> = {
|
|
484
|
+
* Utility type to create a typed result.
|
|
485
|
+
*
|
|
486
|
+
* @public
|
|
487
|
+
*/
|
|
488
|
+
export type TypedResult<T, D> = {
|
|
487
489
|
type: T;
|
|
488
490
|
data: D;
|
|
489
491
|
};
|
|
490
492
|
//#endregion
|
|
491
493
|
//#region src/unescapeHtml.d.ts
|
|
492
494
|
/**
|
|
493
|
-
* Unescapes HTML entities
|
|
494
|
-
*
|
|
495
|
-
* @param text - The text to unescape
|
|
496
|
-
* @returns The unescaped text
|
|
497
|
-
*
|
|
498
|
-
* @public
|
|
499
|
-
*
|
|
500
|
-
* @example
|
|
501
|
-
* {@includeCode ../test/unescapeHtml.test.ts#example}
|
|
502
|
-
*/
|
|
503
|
-
declare function unescapeHtml(text: string): string;
|
|
495
|
+
* Unescapes HTML entities
|
|
496
|
+
*
|
|
497
|
+
* @param text - The text to unescape
|
|
498
|
+
* @returns The unescaped text
|
|
499
|
+
*
|
|
500
|
+
* @public
|
|
501
|
+
*
|
|
502
|
+
* @example
|
|
503
|
+
* {@includeCode ../test/unescapeHtml.test.ts#example}
|
|
504
|
+
*/
|
|
505
|
+
export declare function unescapeHtml(text: string): string;
|
|
504
506
|
//#endregion
|
|
505
507
|
//#region src/urlToRelativePath.d.ts
|
|
506
508
|
/**
|
|
507
|
-
* Constructs a relative path from a URL.
|
|
508
|
-
*
|
|
509
|
-
* If `url` is already
|
|
510
|
-
*
|
|
511
|
-
* @param url - The destination URL
|
|
512
|
-
* @param base - The base URL
|
|
513
|
-
* @returns The relative path
|
|
514
|
-
*
|
|
515
|
-
* @public
|
|
516
|
-
*
|
|
517
|
-
* @example
|
|
518
|
-
* {@includeCode ../test/urlToRelativePath.test.ts#example}
|
|
519
|
-
*/
|
|
520
|
-
declare function urlToRelativePath(url: string, base: string): string;
|
|
509
|
+
* Constructs a relative path from a URL.
|
|
510
|
+
*
|
|
511
|
+
* If `url` is already relative, or its origin differs from `base`, the function returns `url` unchanged.
|
|
512
|
+
*
|
|
513
|
+
* @param url - The destination URL
|
|
514
|
+
* @param base - The base URL
|
|
515
|
+
* @returns The relative path
|
|
516
|
+
*
|
|
517
|
+
* @public
|
|
518
|
+
*
|
|
519
|
+
* @example
|
|
520
|
+
* {@includeCode ../test/urlToRelativePath.test.ts#example}
|
|
521
|
+
*/
|
|
522
|
+
export declare function urlToRelativePath(url: string, base: string): string;
|
|
521
523
|
//#endregion
|
|
522
524
|
//#region src/uuid.d.ts
|
|
523
525
|
/**
|
|
524
|
-
*
|
|
525
|
-
*
|
|
526
|
-
* @returns A random v4 UUID
|
|
527
|
-
*
|
|
528
|
-
* @public
|
|
529
|
-
*
|
|
530
|
-
* @example
|
|
531
|
-
* {@includeCode ../test/uuid.test.ts#example}
|
|
532
|
-
*/
|
|
533
|
-
declare function uuid(): string;
|
|
526
|
+
* Generates a random v4 UUID
|
|
527
|
+
*
|
|
528
|
+
* @returns A random v4 UUID
|
|
529
|
+
*
|
|
530
|
+
* @public
|
|
531
|
+
*
|
|
532
|
+
* @example
|
|
533
|
+
* {@includeCode ../test/uuid.test.ts#example}
|
|
534
|
+
*/
|
|
535
|
+
export declare function uuid(): string;
|
|
534
536
|
//#endregion
|
|
535
537
|
//#region src/uuidToArrayBuffer.d.ts
|
|
536
538
|
/**
|
|
537
|
-
* Converts a UUID string to an ArrayBuffer.
|
|
538
|
-
*
|
|
539
|
-
* @param uuid - The UUID string to convert.
|
|
540
|
-
* @returns The ArrayBuffer representation.
|
|
541
|
-
*
|
|
542
|
-
* @public
|
|
543
|
-
*
|
|
544
|
-
* @example
|
|
545
|
-
* {@includeCode ../test/uuidToArrayBuffer.test.ts#example}
|
|
546
|
-
*/
|
|
547
|
-
declare function uuidToArrayBuffer(uuid: string): ArrayBuffer;
|
|
539
|
+
* Converts a UUID string to an ArrayBuffer.
|
|
540
|
+
*
|
|
541
|
+
* @param uuid - The UUID string to convert.
|
|
542
|
+
* @returns The ArrayBuffer representation.
|
|
543
|
+
*
|
|
544
|
+
* @public
|
|
545
|
+
*
|
|
546
|
+
* @example
|
|
547
|
+
* {@includeCode ../test/uuidToArrayBuffer.test.ts#example}
|
|
548
|
+
*/
|
|
549
|
+
export declare function uuidToArrayBuffer(uuid: string): ArrayBuffer;
|
|
548
550
|
//#endregion
|
|
549
551
|
//#region src/ValueOrArray.d.ts
|
|
550
552
|
/**
|
|
551
|
-
* A type that represents either a single value or an array of values.
|
|
552
|
-
*
|
|
553
|
-
* @public
|
|
554
|
-
*/
|
|
555
|
-
type ValueOrArray<T> = T | T[];
|
|
553
|
+
* A type that represents either a single value or an array of values.
|
|
554
|
+
*
|
|
555
|
+
* @public
|
|
556
|
+
*/
|
|
557
|
+
export type ValueOrArray<T> = T | T[];
|
|
556
558
|
//#endregion
|
|
557
|
-
export {
|
|
559
|
+
export type { DeepReadonly, Request, ResponseTypeMap, XmlNode };
|
|
558
560
|
//# sourceMappingURL=index.d.ts.map
|