@exodus/bytes 1.0.0-rc.8 → 1.0.0-rc.9
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 +128 -4
- package/encoding.js +234 -0
- package/fallback/_utils.js +88 -10
- package/fallback/encoding.labels.js +46 -0
- package/fallback/encoding.util.js +34 -0
- package/fallback/hex.js +2 -70
- package/fallback/latin1.js +2 -1
- package/fallback/multi-byte.encodings.cjs +1 -0
- package/fallback/multi-byte.encodings.json +545 -0
- package/fallback/multi-byte.js +449 -0
- package/fallback/multi-byte.table.js +114 -0
- package/fallback/single-byte.encodings.js +45 -0
- package/fallback/single-byte.js +83 -0
- package/fallback/utf16.js +180 -0
- package/hex.node.js +2 -0
- package/multi-byte.js +13 -0
- package/multi-byte.node.js +25 -0
- package/package.json +39 -8
- package/single-byte.js +55 -0
- package/single-byte.node.js +62 -0
- package/utf16.js +73 -0
- package/utf16.node.js +79 -0
- package/utf8.js +7 -9
- package/utf8.node.js +8 -5
package/fallback/latin1.js
CHANGED
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
nativeDecoderLatin1,
|
|
5
5
|
nativeBuffer,
|
|
6
6
|
isHermes,
|
|
7
|
+
isDeno,
|
|
7
8
|
} from './_utils.js'
|
|
8
9
|
|
|
9
10
|
// See http://stackoverflow.com/a/22747272/680742, which says that lowest limit is in Chrome, with 0xffff args
|
|
@@ -64,7 +65,7 @@ export function decodeLatin1(arr, start = 0, stop = arr.length) {
|
|
|
64
65
|
export const decodeAscii = nativeBuffer
|
|
65
66
|
? (a) =>
|
|
66
67
|
// Buffer is faster on Node.js (but only for long enough data), if we know that output is ascii
|
|
67
|
-
a.byteLength >= 0x3_00
|
|
68
|
+
a.byteLength >= 0x3_00 && !isDeno
|
|
68
69
|
? nativeBuffer.from(a.buffer, a.byteOffset, a.byteLength).latin1Slice(0, a.byteLength) // .latin1Slice is faster than .asciiSlice
|
|
69
70
|
: nativeDecoder.decode(a) // On Node.js, utf8 decoder is faster than latin1
|
|
70
71
|
: nativeDecoderLatin1
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = () => require('./multi-byte.encodings.json') // lazy-load
|