@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/README.md
CHANGED
|
@@ -21,39 +21,31 @@ import {
|
|
|
21
21
|
} from "@svta/cml-utils";
|
|
22
22
|
|
|
23
23
|
// Unescape HTML entities
|
|
24
|
-
|
|
25
|
-
|
|
24
|
+
console.log(unescapeHtml(""<Hello&World>""));
|
|
25
|
+
// "<Hello&World>"
|
|
26
26
|
|
|
27
27
|
// Convert string to Uint16Array
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
uint16Array ===
|
|
31
|
-
new Uint16Array([104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100])
|
|
32
|
-
);
|
|
28
|
+
console.log(stringToUint16("hello world"));
|
|
29
|
+
// Uint16Array(11) [104, 101, 108, 108, 111, 32, 119, 111, 114, 108, 100]
|
|
33
30
|
|
|
34
31
|
// Convert hex string to ArrayBuffer
|
|
35
32
|
const hex = "a0564af760c2d94b9610c7ae70d5d970";
|
|
36
33
|
const arrayBuffer = hexToArrayBuffer(hex);
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
]);
|
|
40
|
-
assert(new Uint8Array(arrayBuffer) === expected);
|
|
34
|
+
console.log(new Uint8Array(arrayBuffer));
|
|
35
|
+
// Uint8Array(16) [160, 86, 74, 247, 96, 194, 217, 75, 150, 16, 199, 174, 112, 213, 217, 112]
|
|
41
36
|
|
|
42
37
|
// Decode base64
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
decoded ===
|
|
46
|
-
new Uint8Array([72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100])
|
|
47
|
-
);
|
|
38
|
+
console.log(decodeBase64("SGVsbG8gV29ybGQ="));
|
|
39
|
+
// Uint8Array(11) [72, 101, 108, 108, 111, 32, 87, 111, 114, 108, 100]
|
|
48
40
|
|
|
49
41
|
// Convert ArrayBuffer to UUID
|
|
50
42
|
const data = new Uint8Array([
|
|
51
43
|
160, 86, 74, 247, 96, 194, 217, 75, 150, 16, 199, 174, 112, 213, 217, 112,
|
|
52
44
|
]);
|
|
53
|
-
|
|
54
|
-
|
|
45
|
+
console.log(arrayBufferToUuid(data.buffer));
|
|
46
|
+
// a0564af7-60c2-d94b-9610-c7ae70d5d970
|
|
55
47
|
|
|
56
48
|
// Convert ArrayBuffer to hex string
|
|
57
|
-
|
|
58
|
-
|
|
49
|
+
console.log(arrayBufferToHex(data.buffer));
|
|
50
|
+
// a0564af760c2d94b9610c7ae70d5d970
|
|
59
51
|
```
|