@svta/cml-utils 0.19.0 → 0.20.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +57 -0
- package/dist/index.d.ts +407 -31
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +472 -31
- package/dist/index.js.map +1 -1
- package/package.json +4 -23
- package/dist/DecodeTextOptions.d.ts +0 -14
- package/dist/DecodeTextOptions.d.ts.map +0 -1
- package/dist/DecodeTextOptions.js +0 -2
- package/dist/DecodeTextOptions.js.map +0 -1
- package/dist/Encoding.d.ts +0 -25
- package/dist/Encoding.d.ts.map +0 -1
- package/dist/Encoding.js +0 -17
- package/dist/Encoding.js.map +0 -1
- package/dist/Request.d.ts +0 -47
- package/dist/Request.d.ts.map +0 -1
- package/dist/Request.js +0 -2
- package/dist/Request.js.map +0 -1
- package/dist/RequestType.d.ts +0 -21
- package/dist/RequestType.d.ts.map +0 -1
- package/dist/RequestType.js +0 -16
- package/dist/RequestType.js.map +0 -1
- package/dist/ResourceTiming.d.ts +0 -13
- package/dist/ResourceTiming.d.ts.map +0 -1
- package/dist/ResourceTiming.js +0 -2
- package/dist/ResourceTiming.js.map +0 -1
- package/dist/TypedResult.d.ts +0 -11
- package/dist/TypedResult.d.ts.map +0 -1
- package/dist/TypedResult.js +0 -2
- package/dist/TypedResult.js.map +0 -1
- package/dist/UTF_16.d.ts +0 -8
- package/dist/UTF_16.d.ts.map +0 -1
- package/dist/UTF_16.js +0 -8
- package/dist/UTF_16.js.map +0 -1
- package/dist/UTF_16_BE.d.ts +0 -8
- package/dist/UTF_16_BE.d.ts.map +0 -1
- package/dist/UTF_16_BE.js +0 -8
- package/dist/UTF_16_BE.js.map +0 -1
- package/dist/UTF_16_LE.d.ts +0 -8
- package/dist/UTF_16_LE.d.ts.map +0 -1
- package/dist/UTF_16_LE.js +0 -8
- package/dist/UTF_16_LE.js.map +0 -1
- package/dist/UTF_8.d.ts +0 -8
- package/dist/UTF_8.d.ts.map +0 -1
- package/dist/UTF_8.js +0 -8
- package/dist/UTF_8.js.map +0 -1
- package/dist/ValueOf.d.ts +0 -8
- package/dist/ValueOf.d.ts.map +0 -1
- package/dist/ValueOf.js +0 -2
- package/dist/ValueOf.js.map +0 -1
- package/dist/ValueOrArray.d.ts +0 -8
- package/dist/ValueOrArray.d.ts.map +0 -1
- package/dist/ValueOrArray.js +0 -2
- package/dist/ValueOrArray.js.map +0 -1
- package/dist/arrayBufferToHex.d.ts +0 -14
- package/dist/arrayBufferToHex.d.ts.map +0 -1
- package/dist/arrayBufferToHex.js +0 -17
- package/dist/arrayBufferToHex.js.map +0 -1
- package/dist/arrayBufferToUuid.d.ts +0 -14
- package/dist/arrayBufferToUuid.d.ts.map +0 -1
- package/dist/arrayBufferToUuid.js +0 -18
- package/dist/arrayBufferToUuid.js.map +0 -1
- package/dist/base64decode.d.ts +0 -15
- package/dist/base64decode.d.ts.map +0 -1
- package/dist/base64decode.js +0 -18
- package/dist/base64decode.js.map +0 -1
- package/dist/base64encode.d.ts +0 -15
- package/dist/base64encode.d.ts.map +0 -1
- package/dist/base64encode.js +0 -18
- package/dist/base64encode.js.map +0 -1
- package/dist/convertUint8ToUint16.d.ts +0 -10
- package/dist/convertUint8ToUint16.d.ts.map +0 -1
- package/dist/convertUint8ToUint16.js +0 -17
- package/dist/convertUint8ToUint16.js.map +0 -1
- package/dist/decodeBase64.d.ts +0 -11
- package/dist/decodeBase64.d.ts.map +0 -1
- package/dist/decodeBase64.js +0 -13
- package/dist/decodeBase64.js.map +0 -1
- package/dist/decodeText.d.ts +0 -17
- package/dist/decodeText.d.ts.map +0 -1
- package/dist/decodeText.js +0 -140
- package/dist/decodeText.js.map +0 -1
- package/dist/encodeBase64.d.ts +0 -11
- package/dist/encodeBase64.d.ts.map +0 -1
- package/dist/encodeBase64.js +0 -13
- package/dist/encodeBase64.js.map +0 -1
- package/dist/getBandwidthBps.d.ts +0 -12
- package/dist/getBandwidthBps.d.ts.map +0 -1
- package/dist/getBandwidthBps.js +0 -15
- package/dist/getBandwidthBps.js.map +0 -1
- package/dist/hexToArrayBuffer.d.ts +0 -14
- package/dist/hexToArrayBuffer.d.ts.map +0 -1
- package/dist/hexToArrayBuffer.js +0 -21
- package/dist/hexToArrayBuffer.js.map +0 -1
- package/dist/roundToEven.d.ts +0 -13
- package/dist/roundToEven.d.ts.map +0 -1
- package/dist/roundToEven.js +0 -28
- package/dist/roundToEven.js.map +0 -1
- package/dist/stringToUint16.d.ts +0 -14
- package/dist/stringToUint16.d.ts.map +0 -1
- package/dist/stringToUint16.js +0 -21
- package/dist/stringToUint16.js.map +0 -1
- package/dist/tsconfig.tsbuildinfo +0 -1
- package/dist/unescapeHtml.d.ts +0 -14
- package/dist/unescapeHtml.d.ts.map +0 -1
- package/dist/unescapeHtml.js +0 -38
- package/dist/unescapeHtml.js.map +0 -1
- package/dist/urlToRelativePath.d.ts +0 -12
- package/dist/urlToRelativePath.d.ts.map +0 -1
- package/dist/urlToRelativePath.js +0 -37
- package/dist/urlToRelativePath.js.map +0 -1
- package/dist/uuid.d.ts +0 -10
- package/dist/uuid.d.ts.map +0 -1
- package/dist/uuid.js +0 -31
- package/dist/uuid.js.map +0 -1
- package/dist/uuidToArrayBuffer.d.ts +0 -14
- package/dist/uuidToArrayBuffer.d.ts.map +0 -1
- package/dist/uuidToArrayBuffer.js +0 -18
- package/dist/uuidToArrayBuffer.js.map +0 -1
package/README.md
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# @svta/cml-utils
|
|
2
|
+
|
|
3
|
+
Common utility functions for media processing.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm i @svta/cml-utils
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
12
|
+
|
|
13
|
+
```typescript
|
|
14
|
+
import { unescapeHtml } from "@svta/cml-utils/unescapeHtml";
|
|
15
|
+
import { stringToUint16 } from "@svta/cml-utils/stringToUint16";
|
|
16
|
+
import { hexToArrayBuffer } from "@svta/cml-utils/hexToArrayBuffer";
|
|
17
|
+
import { decodeBase64 } from "@svta/cml-utils/decodeBase64";
|
|
18
|
+
import { arrayBufferToUuid } from "@svta/cml-utils/arrayBufferToUuid";
|
|
19
|
+
import { arrayBufferToHex } from "@svta/cml-utils/arrayBufferToHex";
|
|
20
|
+
|
|
21
|
+
// Unescape HTML entities
|
|
22
|
+
const unescaped = unescapeHtml(""<Hello&World>"");
|
|
23
|
+
assert(unescaped === `"<Hello&World>"`);
|
|
24
|
+
|
|
25
|
+
// Convert string to Uint16Array
|
|
26
|
+
const uint16Array = stringToUint16("hello world");
|
|
27
|
+
assert(
|
|
28
|
+
uint16Array ===
|
|
29
|
+
new Uint16Array([104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100])
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
// Convert hex string to ArrayBuffer
|
|
33
|
+
const hex = "a0564af760c2d94b9610c7ae70d5d970";
|
|
34
|
+
const arrayBuffer = hexToArrayBuffer(hex);
|
|
35
|
+
const expected = new Uint8Array([
|
|
36
|
+
160, 86, 74, 247, 96, 194, 217, 75, 150, 16, 199, 174, 112, 213, 217, 112,
|
|
37
|
+
]);
|
|
38
|
+
assert(new Uint8Array(arrayBuffer) === expected);
|
|
39
|
+
|
|
40
|
+
// Decode base64
|
|
41
|
+
const decoded = decodeBase64("SGVsbG8gV29ybGQ=");
|
|
42
|
+
assert(
|
|
43
|
+
decoded ===
|
|
44
|
+
new Uint8Array([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100])
|
|
45
|
+
);
|
|
46
|
+
|
|
47
|
+
// Convert ArrayBuffer to UUID
|
|
48
|
+
const data = new Uint8Array([
|
|
49
|
+
160, 86, 74, 247, 96, 194, 217, 75, 150, 16, 199, 174, 112, 213, 217, 112,
|
|
50
|
+
]);
|
|
51
|
+
const uuid = arrayBufferToUuid(data.buffer);
|
|
52
|
+
assert(uuid === "a0564af7-60c2-d94b-9610-c7ae70d5d970");
|
|
53
|
+
|
|
54
|
+
// Convert ArrayBuffer to hex string
|
|
55
|
+
const hexString = arrayBufferToHex(data.buffer);
|
|
56
|
+
assert(hexString === "a0564af760c2d94b9610c7ae70d5d970");
|
|
57
|
+
```
|
package/dist/index.d.ts
CHANGED
|
@@ -1,33 +1,409 @@
|
|
|
1
|
+
//#region src/arrayBufferToHex.d.ts
|
|
1
2
|
/**
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
3
|
+
* Encodes an ArrayBuffer as a hexadecimal string.
|
|
4
|
+
*
|
|
5
|
+
* @param buffer - The ArrayBuffer to encode.
|
|
6
|
+
* @returns The hexadecimal string representation.
|
|
7
|
+
*
|
|
8
|
+
*
|
|
9
|
+
* @beta
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* {@includeCode ../test/arrayBufferToHex.test.ts#example}
|
|
13
|
+
*/
|
|
14
|
+
declare function arrayBufferToHex(buffer: ArrayBuffer): string;
|
|
15
|
+
//#endregion
|
|
16
|
+
//#region src/arrayBufferToUuid.d.ts
|
|
17
|
+
/**
|
|
18
|
+
* Converts an ArrayBuffer to a UUID string.
|
|
19
|
+
*
|
|
20
|
+
* @param buffer - The ArrayBuffer to convert.
|
|
21
|
+
* @returns The UUID string representation.
|
|
22
|
+
*
|
|
23
|
+
*
|
|
24
|
+
* @beta
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* {@includeCode ../test/arrayBufferToUuid.test.ts#example}
|
|
28
|
+
*/
|
|
29
|
+
declare function arrayBufferToUuid(buffer: ArrayBuffer): string;
|
|
30
|
+
//#endregion
|
|
31
|
+
//#region src/decodeBase64.d.ts
|
|
32
|
+
/**
|
|
33
|
+
* Decodes a base64 encoded string into binary data
|
|
34
|
+
*
|
|
35
|
+
* @param str - The base64 encoded string to decode
|
|
36
|
+
* @returns The decoded binary data
|
|
37
|
+
*
|
|
38
|
+
*
|
|
39
|
+
* @beta
|
|
40
|
+
*/
|
|
41
|
+
declare function decodeBase64(str: string): Uint8Array;
|
|
42
|
+
//#endregion
|
|
43
|
+
//#region src/base64decode.d.ts
|
|
44
|
+
/**
|
|
45
|
+
* Decodes a base64 encoded string into binary data
|
|
46
|
+
*
|
|
47
|
+
* @param str - The base64 encoded string to decode
|
|
48
|
+
* @returns The decoded binary data
|
|
49
|
+
*
|
|
50
|
+
*
|
|
51
|
+
* @beta
|
|
52
|
+
*
|
|
53
|
+
* @deprecated Use {@link decodeBase64} instead.
|
|
54
|
+
*
|
|
55
|
+
* @see {@link decodeBase64}
|
|
56
|
+
*/
|
|
57
|
+
declare const base64decode: typeof decodeBase64;
|
|
58
|
+
//#endregion
|
|
59
|
+
//#region src/encodeBase64.d.ts
|
|
60
|
+
/**
|
|
61
|
+
* Encodes binary data to base64
|
|
62
|
+
*
|
|
63
|
+
* @param binary - The binary data to encode
|
|
64
|
+
* @returns The base64 encoded string
|
|
65
|
+
*
|
|
66
|
+
*
|
|
67
|
+
* @beta
|
|
68
|
+
*/
|
|
69
|
+
declare function encodeBase64(binary: Uint8Array): string;
|
|
70
|
+
//#endregion
|
|
71
|
+
//#region src/base64encode.d.ts
|
|
72
|
+
/**
|
|
73
|
+
* Encodes binary data to base64
|
|
74
|
+
*
|
|
75
|
+
* @param binary - The binary data to encode
|
|
76
|
+
* @returns The base64 encoded string
|
|
77
|
+
*
|
|
78
|
+
*
|
|
79
|
+
* @beta
|
|
80
|
+
*
|
|
81
|
+
* @deprecated Use {@link encodeBase64} instead.
|
|
82
|
+
*
|
|
83
|
+
* @see {@link encodeBase64}
|
|
84
|
+
*/
|
|
85
|
+
declare const base64encode: typeof encodeBase64;
|
|
86
|
+
//#endregion
|
|
87
|
+
//#region src/convertUint8ToUint16.d.ts
|
|
88
|
+
/**
|
|
89
|
+
* Converts a Uint8Array to a Uint16Array by aligning its buffer.
|
|
90
|
+
*
|
|
91
|
+
* @param input - The Uint8Array to convert
|
|
92
|
+
* @returns A properly aligned Uint16Array
|
|
93
|
+
*
|
|
94
|
+
* @beta
|
|
95
|
+
*/
|
|
96
|
+
declare function convertUint8ToUint16(input: Uint8Array): Uint16Array;
|
|
97
|
+
//#endregion
|
|
98
|
+
//#region src/UTF_16.d.ts
|
|
99
|
+
/**
|
|
100
|
+
* UTF-16 Encoding.
|
|
101
|
+
*
|
|
102
|
+
*
|
|
103
|
+
* @beta
|
|
104
|
+
*/
|
|
105
|
+
declare const UTF_16 = "utf-16";
|
|
106
|
+
//#endregion
|
|
107
|
+
//#region src/UTF_16_BE.d.ts
|
|
108
|
+
/**
|
|
109
|
+
* UTF-16 Big Endian Encoding.
|
|
110
|
+
*
|
|
111
|
+
*
|
|
112
|
+
* @beta
|
|
113
|
+
*/
|
|
114
|
+
declare const UTF_16_BE = "utf-16be";
|
|
115
|
+
//#endregion
|
|
116
|
+
//#region src/UTF_16_LE.d.ts
|
|
117
|
+
/**
|
|
118
|
+
* UTF-16 Little Endian Encoding.
|
|
119
|
+
*
|
|
120
|
+
*
|
|
121
|
+
* @beta
|
|
122
|
+
*/
|
|
123
|
+
declare const UTF_16_LE = "utf-16le";
|
|
124
|
+
//#endregion
|
|
125
|
+
//#region src/UTF_8.d.ts
|
|
126
|
+
/**
|
|
127
|
+
* UTF-8 Encoding.
|
|
128
|
+
*
|
|
129
|
+
*
|
|
130
|
+
* @beta
|
|
131
|
+
*/
|
|
132
|
+
declare const UTF_8 = "utf-8";
|
|
133
|
+
//#endregion
|
|
134
|
+
//#region src/ValueOf.d.ts
|
|
135
|
+
/**
|
|
136
|
+
* Utility type to get the value of a given object type.
|
|
137
|
+
*
|
|
138
|
+
*
|
|
139
|
+
* @beta
|
|
140
|
+
*/
|
|
141
|
+
type ValueOf<T> = T[keyof T];
|
|
142
|
+
//#endregion
|
|
143
|
+
//#region src/Encoding.d.ts
|
|
144
|
+
/**
|
|
145
|
+
* Text encoding types.
|
|
146
|
+
*
|
|
147
|
+
*
|
|
148
|
+
* @beta
|
|
149
|
+
*/
|
|
150
|
+
declare const Encoding: {
|
|
151
|
+
readonly UTF8: typeof UTF_8;
|
|
152
|
+
readonly UTF16: typeof UTF_16;
|
|
153
|
+
readonly UTF16BE: typeof UTF_16_BE;
|
|
154
|
+
readonly UTF16LE: typeof UTF_16_LE;
|
|
155
|
+
};
|
|
156
|
+
/**
|
|
157
|
+
* Text encoding types.
|
|
158
|
+
*
|
|
159
|
+
*
|
|
160
|
+
* @beta
|
|
161
|
+
*/
|
|
162
|
+
type Encoding = ValueOf<typeof Encoding>;
|
|
163
|
+
//#endregion
|
|
164
|
+
//#region src/DecodeTextOptions.d.ts
|
|
165
|
+
/**
|
|
166
|
+
* Options for the `decodeText` function.
|
|
167
|
+
*
|
|
168
|
+
*
|
|
169
|
+
* @beta
|
|
170
|
+
*/
|
|
171
|
+
type DecodeTextOptions = {
|
|
172
|
+
/**
|
|
173
|
+
* The encoding to use. If not provided, the function will try to detect the encoding from the BOM.
|
|
174
|
+
*/
|
|
175
|
+
encoding?: Encoding;
|
|
176
|
+
};
|
|
177
|
+
//#endregion
|
|
178
|
+
//#region src/decodeText.d.ts
|
|
179
|
+
/**
|
|
180
|
+
* Converts an ArrayBuffer or ArrayBufferView to a string. Similar to `TextDecoder.decode`
|
|
181
|
+
* but with a fallback for environments that don't support `TextDecoder`.
|
|
182
|
+
*
|
|
183
|
+
* @param data - The data to decode.
|
|
184
|
+
* @param options - The options for the decoding.
|
|
185
|
+
* @returns The string representation of the ArrayBuffer.
|
|
186
|
+
*
|
|
187
|
+
*
|
|
188
|
+
* @beta
|
|
189
|
+
*
|
|
190
|
+
* @example
|
|
191
|
+
* {@includeCode ../test/decodeText.test.ts#example}
|
|
192
|
+
*/
|
|
193
|
+
declare function decodeText(data: ArrayBuffer | ArrayBufferView<ArrayBuffer>, options?: DecodeTextOptions): string;
|
|
194
|
+
//#endregion
|
|
195
|
+
//#region src/ResourceTiming.d.ts
|
|
196
|
+
/**
|
|
197
|
+
* Resource Timing.
|
|
198
|
+
*
|
|
199
|
+
*
|
|
200
|
+
* @beta
|
|
201
|
+
*/
|
|
202
|
+
type ResourceTiming = {
|
|
203
|
+
startTime: number;
|
|
204
|
+
encodedBodySize: number;
|
|
205
|
+
responseStart?: number;
|
|
206
|
+
duration: number;
|
|
207
|
+
};
|
|
208
|
+
//#endregion
|
|
209
|
+
//#region src/getBandwidthBps.d.ts
|
|
210
|
+
/**
|
|
211
|
+
* Converts a ResourceTiming sample to bandwidth in bits per second (bps).
|
|
212
|
+
*
|
|
213
|
+
* @param sample - A ResourceTiming sample
|
|
214
|
+
* @returns
|
|
215
|
+
*
|
|
216
|
+
*
|
|
217
|
+
* @beta
|
|
218
|
+
*/
|
|
219
|
+
declare function getBandwidthBps(sample: ResourceTiming): number;
|
|
220
|
+
//#endregion
|
|
221
|
+
//#region src/hexToArrayBuffer.d.ts
|
|
222
|
+
/**
|
|
223
|
+
* Decodes a hexadecimal string into an ArrayBuffer.
|
|
224
|
+
*
|
|
225
|
+
* @param hex - The hexadecimal string to decode.
|
|
226
|
+
* @returns The decoded ArrayBuffer.
|
|
227
|
+
*
|
|
228
|
+
*
|
|
229
|
+
* @beta
|
|
230
|
+
*
|
|
231
|
+
* @example
|
|
232
|
+
* {@includeCode ../test/hexToArrayBuffer.test.ts#example}
|
|
233
|
+
*/
|
|
234
|
+
declare function hexToArrayBuffer(hex: string): ArrayBuffer;
|
|
235
|
+
//#endregion
|
|
236
|
+
//#region src/RequestType.d.ts
|
|
237
|
+
/**
|
|
238
|
+
* The content type of the request.
|
|
239
|
+
*
|
|
240
|
+
*
|
|
241
|
+
* @enum
|
|
242
|
+
*
|
|
243
|
+
* @beta
|
|
244
|
+
*/
|
|
245
|
+
declare const RequestType: {
|
|
246
|
+
readonly TEXT: "text";
|
|
247
|
+
readonly JSON: "json";
|
|
248
|
+
readonly BLOB: "blob";
|
|
249
|
+
readonly ARRAY_BUFFER: "arrayBuffer";
|
|
250
|
+
readonly DOCUMENT: "document";
|
|
251
|
+
};
|
|
252
|
+
/**
|
|
253
|
+
* @beta
|
|
254
|
+
*/
|
|
255
|
+
type RequestType = ValueOf<typeof RequestType>;
|
|
256
|
+
//#endregion
|
|
257
|
+
//#region src/Request.d.ts
|
|
258
|
+
/**
|
|
259
|
+
* Generic request API.
|
|
260
|
+
*
|
|
261
|
+
*
|
|
262
|
+
* @beta
|
|
263
|
+
*/
|
|
264
|
+
type Request<D = any> = {
|
|
265
|
+
/**
|
|
266
|
+
* The URL of the request.
|
|
267
|
+
*/
|
|
268
|
+
url: string;
|
|
269
|
+
/**
|
|
270
|
+
* The request's method (GET, POST, etc).
|
|
271
|
+
*/
|
|
272
|
+
method?: string;
|
|
273
|
+
/**
|
|
274
|
+
* The body of the request.
|
|
275
|
+
*/
|
|
276
|
+
body?: BodyInit;
|
|
277
|
+
/**
|
|
278
|
+
* The response type with which the response from the server shall be compatible.
|
|
279
|
+
*/
|
|
280
|
+
responseType?: RequestType;
|
|
281
|
+
/**
|
|
282
|
+
* The headers object associated with the request.
|
|
283
|
+
*/
|
|
284
|
+
headers?: Record<string, string>;
|
|
285
|
+
/**
|
|
286
|
+
* Indicates whether the user agent should send or receive cookies from the other domain in the case of cross-origin requests.
|
|
287
|
+
*/
|
|
288
|
+
credentials?: RequestCredentials;
|
|
289
|
+
/**
|
|
290
|
+
* The mode of the request (e.g., cors, no-cors, same-origin, etc).
|
|
291
|
+
*/
|
|
292
|
+
mode?: RequestMode;
|
|
293
|
+
/**
|
|
294
|
+
* The number of milliseconds the request can take before automatically being terminated.
|
|
295
|
+
* If undefined or value is 0 then there is no timeout.
|
|
296
|
+
*/
|
|
297
|
+
timeout?: number;
|
|
298
|
+
/**
|
|
299
|
+
* Any custom data.
|
|
300
|
+
*/
|
|
301
|
+
customData?: D;
|
|
302
|
+
};
|
|
303
|
+
//#endregion
|
|
304
|
+
//#region src/roundToEven.d.ts
|
|
305
|
+
/**
|
|
306
|
+
* This implements the rounding procedure described in step 2 of the "Serializing a Decimal" specification.
|
|
307
|
+
* This rounding style is known as "even rounding", "banker's rounding", or "commercial rounding".
|
|
308
|
+
*
|
|
309
|
+
* @param value - The value to round
|
|
310
|
+
* @param precision - The number of decimal places to round to
|
|
311
|
+
* @returns The rounded value
|
|
312
|
+
*
|
|
313
|
+
*
|
|
314
|
+
* @beta
|
|
315
|
+
*/
|
|
316
|
+
declare function roundToEven(value: number, precision: number): number;
|
|
317
|
+
//#endregion
|
|
318
|
+
//#region src/stringToUint16.d.ts
|
|
319
|
+
/**
|
|
320
|
+
* Converts a string to a Uint16Array.
|
|
321
|
+
*
|
|
322
|
+
* @param str - The string to convert
|
|
323
|
+
* @returns A Uint16Array representation of the string
|
|
324
|
+
*
|
|
325
|
+
*
|
|
326
|
+
* @beta
|
|
327
|
+
*
|
|
328
|
+
* @example
|
|
329
|
+
* {@includeCode ../test/stringToUint16.test.ts#example}
|
|
330
|
+
*/
|
|
331
|
+
declare function stringToUint16(str: string): Uint16Array<ArrayBuffer>;
|
|
332
|
+
//#endregion
|
|
333
|
+
//#region src/TypedResult.d.ts
|
|
334
|
+
/**
|
|
335
|
+
* Utility type to create a typed result.
|
|
336
|
+
*
|
|
337
|
+
*
|
|
338
|
+
* @beta
|
|
339
|
+
*/
|
|
340
|
+
type TypedResult<T, D> = {
|
|
341
|
+
type: T;
|
|
342
|
+
data: D;
|
|
343
|
+
};
|
|
344
|
+
//#endregion
|
|
345
|
+
//#region src/unescapeHtml.d.ts
|
|
346
|
+
/**
|
|
347
|
+
* Unescapes HTML entities
|
|
348
|
+
*
|
|
349
|
+
* @param text - The text to unescape
|
|
350
|
+
* @returns The unescaped text
|
|
351
|
+
*
|
|
352
|
+
*
|
|
353
|
+
* @beta
|
|
354
|
+
*
|
|
355
|
+
* @example
|
|
356
|
+
* {@includeCode ../test/unescapeHtml.test.ts#example}
|
|
357
|
+
*/
|
|
358
|
+
declare function unescapeHtml(text: string): string;
|
|
359
|
+
//#endregion
|
|
360
|
+
//#region src/urlToRelativePath.d.ts
|
|
361
|
+
/**
|
|
362
|
+
* Constructs a relative path from a URL.
|
|
363
|
+
*
|
|
364
|
+
* @param url - The destination URL
|
|
365
|
+
* @param base - The base URL
|
|
366
|
+
* @returns The relative path
|
|
367
|
+
*
|
|
368
|
+
*
|
|
369
|
+
* @beta
|
|
370
|
+
*/
|
|
371
|
+
declare function urlToRelativePath(url: string, base: string): string;
|
|
372
|
+
//#endregion
|
|
373
|
+
//#region src/uuid.d.ts
|
|
374
|
+
/**
|
|
375
|
+
* Generate a random v4 UUID
|
|
376
|
+
*
|
|
377
|
+
* @returns A random v4 UUID
|
|
378
|
+
*
|
|
379
|
+
*
|
|
380
|
+
* @beta
|
|
381
|
+
*/
|
|
382
|
+
declare function uuid(): string;
|
|
383
|
+
//#endregion
|
|
384
|
+
//#region src/uuidToArrayBuffer.d.ts
|
|
385
|
+
/**
|
|
386
|
+
* Converts a UUID string to an ArrayBuffer.
|
|
387
|
+
*
|
|
388
|
+
* @param uuid - The UUID string to convert.
|
|
389
|
+
* @returns The ArrayBuffer representation.
|
|
390
|
+
*
|
|
391
|
+
*
|
|
392
|
+
* @beta
|
|
393
|
+
*
|
|
394
|
+
* @example
|
|
395
|
+
* {@includeCode ../test/uuidToArrayBuffer.test.ts#example}
|
|
396
|
+
*/
|
|
397
|
+
declare function uuidToArrayBuffer(uuid: string): ArrayBuffer;
|
|
398
|
+
//#endregion
|
|
399
|
+
//#region src/ValueOrArray.d.ts
|
|
400
|
+
/**
|
|
401
|
+
* A type that represents either a single value or an array of values.
|
|
402
|
+
*
|
|
403
|
+
*
|
|
404
|
+
* @beta
|
|
405
|
+
*/
|
|
406
|
+
type ValueOrArray<T> = T | T[];
|
|
407
|
+
//#endregion
|
|
408
|
+
export { DecodeTextOptions, Encoding, Request, RequestType, ResourceTiming, TypedResult, UTF_16, UTF_16_BE, UTF_16_LE, UTF_8, ValueOf, ValueOrArray, arrayBufferToHex, arrayBufferToUuid, base64decode, base64encode, convertUint8ToUint16, decodeBase64, decodeText, encodeBase64, getBandwidthBps, hexToArrayBuffer, roundToEven, stringToUint16, unescapeHtml, urlToRelativePath, uuid, uuidToArrayBuffer };
|
|
33
409
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":["base64decode: typeof decodeBase64","base64encode: typeof encodeBase64"],"sources":["../src/arrayBufferToHex.ts","../src/arrayBufferToUuid.ts","../src/decodeBase64.ts","../src/base64decode.ts","../src/encodeBase64.ts","../src/base64encode.ts","../src/convertUint8ToUint16.ts","../src/UTF_16.ts","../src/UTF_16_BE.ts","../src/UTF_16_LE.ts","../src/UTF_8.ts","../src/ValueOf.ts","../src/Encoding.ts","../src/DecodeTextOptions.ts","../src/decodeText.ts","../src/ResourceTiming.ts","../src/getBandwidthBps.ts","../src/hexToArrayBuffer.ts","../src/RequestType.ts","../src/Request.ts","../src/roundToEven.ts","../src/stringToUint16.ts","../src/TypedResult.ts","../src/unescapeHtml.ts","../src/urlToRelativePath.ts","../src/uuid.ts","../src/uuidToArrayBuffer.ts","../src/ValueOrArray.ts"],"sourcesContent":[],"mappings":";;AAYA;;;;ACEA;;;;ACLA;;;iBFGgB,gBAAA,SAAyB;;;;AAAzC;;;;ACEA;;;;ACLA;;;iBDKgB,iBAAA,SAA0B;;;;ADF1C;;;;ACEA;;;;ACLgB,iBAAA,YAAA,CAA2B,GAAA,EAAA,MAAA,CAAA,EAAA,UAAA;;;AFG3C;;;;ACEA;;;;ACLA;;;;ACMA;cAAaA,qBAAqB;;;;AHHlC;;;;ACEA;;;;ACLgB,iBEAA,YAAA,CFA2B,MAAA,EEAN,UFAM,CAAA,EAAA,MAAA;;;AFG3C;;;;ACEA;;;;ACLA;;;;ACMA;cEAaC,qBAAqB;;;;ALHlC;;;;ACEA;;;iBKNgB,oBAAA,QAA4B,aAAa;;;;ANIzD;;;;ACEA;cMRa,MAAA;;;;APMb;;;;ACEA;cORa,SAAA;;;;ARMb;;;;ACEA;cQRa,SAAA;;;;ATMb;;;;ACEA;cSRa,KAAA;;;;AVMb;;;;ACEA;KURY,aAAa,QAAQ;;;AVQjC;;;;ACLA;;cUGa;wBACU;ETEvB,SAAaD,KAAAA,EAAAA,OSDY,MTCS;2BSAJ;2BACA;;ARP9B;;;;ACMA;;KOUY,QAAA,GAAW,eAAe;;;AZbtC;;;;ACEA;;KYNY,iBAAA;;AXCZ;;aWGY;;;;AbAZ;;;;ACEA;;;;ACLA;;;;ACMA;;iBWKgB,UAAA,OAAiB,cAAc,gBAAgB,wBAAuB;;;;AdRtF;;;;ACEA;KcRY,cAAA;;;EbGZ,aAAgB,CAAA,EAAA,MAAA;;;;;AFGhB;;;;ACEA;;;;ACLA;iBcEgB,eAAA,SAAwB;;;;AhBCxC;;;;ACEA;;;;ACLA;;;iBeGgB,gBAAA,eAA+B;;;AjBA/C;;;;ACEA;;;;ACLgB,cgBCH,WhBD8B,EAAA;;;;ECM3C,SAAaA,YAAqB,EAAA,aAAA;;;;ACNlC;;KcYY,WAAA,GAAc,eAAe;;;AlBTzC;;;;ACEA;;KkBNY;;AjBCZ;;;;ACMA;;;;ACNA;;SecQ;;AdRR;;iBcagB;;AbpBhB;;SAA4C,CAAA,EayBjC,MbzBiC,CAAA,MAAA,EAAA,MAAA,CAAA;;;;gBa8B7B;;AZhCf;;SYqCQ;;AXrCR;;;;ECAA;;;eUgDc;AThDd,CAAA;;;;AVMA;;;;ACEA;;;;ACLA;;iBkBEgB,WAAA;;;;ApBChB;;;;ACEA;;;;ACLA;;;iBmBGgB,cAAA,eAA6B,YAAY;;;;ArBAzD;;;;ACEA;KqBRY,iBpBGZ,GAAgB;QoBFT;QACA;;;;;AtBIP;;;;ACEA;;;;ACLA;;;iBqBKgB,YAAA;;;;AvBFhB;;;;ACEA;;;;ACLA;iBsBCgB,iBAAA;;;;AxBEhB;;;;ACEA;;;iBwBNgB,IAAA,CAAA;;;;AzBIhB;;;;ACEA;;;;ACLA;;;iBwBKgB,iBAAA,gBAAiC;;;;A1BFjD;;;;ACEA;K0BRY,kBAAkB,IAAI"}
|