base128-ascii 5.0.3 → 5.0.4
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/main.js +16 -4
- package/package.json +1 -1
package/main.js
CHANGED
|
@@ -2,11 +2,23 @@ let _bytesToStr = (
|
|
|
2
2
|
(
|
|
3
3
|
typeof Buffer == 'function' &&
|
|
4
4
|
Buffer.prototype &&
|
|
5
|
-
typeof Buffer.prototype.latin1Slice == 'function'
|
|
6
|
-
// Exclude Deno. See https://github.com/bddjr/base128/pull/4
|
|
7
|
-
typeof Deno == 'undefined'
|
|
5
|
+
typeof Buffer.prototype.latin1Slice == 'function'
|
|
8
6
|
)
|
|
9
|
-
?
|
|
7
|
+
? typeof Deno == 'undefined'
|
|
8
|
+
? (bytes) => Buffer.prototype.latin1Slice.call(bytes)
|
|
9
|
+
: (bytes) => {
|
|
10
|
+
// https://github.com/bddjr/base128/pull/5
|
|
11
|
+
try {
|
|
12
|
+
Buffer.prototype.latin1Slice.call(0)
|
|
13
|
+
} catch (e) {
|
|
14
|
+
// Deno >= 2.8.2
|
|
15
|
+
// Uncaught TypeError: expected ArrayBufferView
|
|
16
|
+
return (_bytesToStr = (bytes) => Buffer.prototype.latin1Slice.call(bytes))(bytes)
|
|
17
|
+
}
|
|
18
|
+
// Deno < 2.8.2
|
|
19
|
+
const td = new TextDecoder
|
|
20
|
+
return (_bytesToStr = (bytes) => td.decode(bytes))(bytes)
|
|
21
|
+
}
|
|
10
22
|
: (bytes) => {
|
|
11
23
|
// TextDecoder keeps the default UTF-8, which is already the fastest.
|
|
12
24
|
const td = new TextDecoder
|