utilium 1.10.0 → 1.10.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/dist/string.js CHANGED
@@ -16,7 +16,13 @@ const decoder = new TextDecoder();
16
16
  * Decodes a UTF-8 string from a buffer
17
17
  */
18
18
  export function decodeUTF8(input) {
19
- return decoder.decode(input);
19
+ if (!input)
20
+ return '';
21
+ if (input.buffer instanceof ArrayBuffer && !input.buffer.resizable)
22
+ return decoder.decode(input);
23
+ const buffer = new Uint8Array(input.byteLength);
24
+ buffer.set(input);
25
+ return decoder.decode(buffer);
20
26
  }
21
27
  export function encodeASCII(input) {
22
28
  const data = new Uint8Array(input.length);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "utilium",
3
- "version": "1.10.0",
3
+ "version": "1.10.1",
4
4
  "description": "Typescript utilities",
5
5
  "funding": {
6
6
  "type": "individual",
package/src/string.ts CHANGED
@@ -36,7 +36,13 @@ const decoder = new TextDecoder();
36
36
  * Decodes a UTF-8 string from a buffer
37
37
  */
38
38
  export function decodeUTF8(input?: Uint8Array): string {
39
- return decoder.decode(input);
39
+ if (!input) return '';
40
+
41
+ if (input.buffer instanceof ArrayBuffer && !input.buffer.resizable) return decoder.decode(input);
42
+
43
+ const buffer = new Uint8Array(input.byteLength);
44
+ buffer.set(input);
45
+ return decoder.decode(buffer);
40
46
  }
41
47
 
42
48
  export function encodeASCII(input: string): Uint8Array {