memfs 4.8.2 → 4.9.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/README.md +12 -9
- package/lib/crud/types.d.ts +7 -4
- package/lib/fsa-to-crud/FsaCrud.d.ts +1 -0
- package/lib/fsa-to-crud/FsaCrud.js +39 -19
- package/lib/fsa-to-crud/FsaCrud.js.map +1 -1
- package/lib/fsa-to-node/json.d.ts +4 -4
- package/lib/fsa-to-node/json.js +2 -2
- package/lib/fsa-to-node/json.js.map +1 -1
- package/lib/internal/buffer.d.ts +1 -0
- package/lib/node/FileHandle.d.ts +1 -0
- package/lib/node/types/FsPromisesApi.d.ts +1 -0
- package/lib/node-to-crud/NodeCrud.d.ts +1 -0
- package/lib/node-to-crud/NodeCrud.js +41 -21
- package/lib/node-to-crud/NodeCrud.js.map +1 -1
- package/lib/node.d.ts +1 -0
- package/lib/print/index.js +1 -1
- package/lib/snapshot/binary.d.ts +1 -1
- package/lib/snapshot/binary.js +2 -2
- package/lib/snapshot/binary.js.map +1 -1
- package/lib/snapshot/json.js +2 -2
- package/lib/snapshot/json.js.map +1 -1
- package/lib/snapshot/shared.d.ts +1 -1
- package/lib/snapshot/shared.js +1 -1
- package/lib/snapshot/shared.js.map +1 -1
- package/package.json +10 -4
- package/lib/json-joy/json-pack/JsonPackExtension.d.ts +0 -13
- package/lib/json-joy/json-pack/JsonPackExtension.js +0 -19
- package/lib/json-joy/json-pack/JsonPackExtension.js.map +0 -1
- package/lib/json-joy/json-pack/JsonPackValue.d.ts +0 -14
- package/lib/json-joy/json-pack/JsonPackValue.js +0 -20
- package/lib/json-joy/json-pack/JsonPackValue.js.map +0 -1
- package/lib/json-joy/json-pack/cbor/CborDecoder.d.ts +0 -65
- package/lib/json-joy/json-pack/cbor/CborDecoder.js +0 -394
- package/lib/json-joy/json-pack/cbor/CborDecoder.js.map +0 -1
- package/lib/json-joy/json-pack/cbor/CborDecoderBase.d.ts +0 -36
- package/lib/json-joy/json-pack/cbor/CborDecoderBase.js +0 -350
- package/lib/json-joy/json-pack/cbor/CborDecoderBase.js.map +0 -1
- package/lib/json-joy/json-pack/cbor/CborEncoder.d.ts +0 -14
- package/lib/json-joy/json-pack/cbor/CborEncoder.js +0 -69
- package/lib/json-joy/json-pack/cbor/CborEncoder.js.map +0 -1
- package/lib/json-joy/json-pack/cbor/CborEncoderFast.d.ts +0 -58
- package/lib/json-joy/json-pack/cbor/CborEncoderFast.js +0 -341
- package/lib/json-joy/json-pack/cbor/CborEncoderFast.js.map +0 -1
- package/lib/json-joy/json-pack/cbor/constants.d.ts +0 -39
- package/lib/json-joy/json-pack/cbor/constants.js +0 -3
- package/lib/json-joy/json-pack/cbor/constants.js.map +0 -1
- package/lib/json-joy/json-pack/cbor/types.d.ts +0 -4
- package/lib/json-joy/json-pack/cbor/types.js +0 -3
- package/lib/json-joy/json-pack/cbor/types.js.map +0 -1
- package/lib/json-joy/json-pack/json/JsonDecoder.d.ts +0 -18
- package/lib/json-joy/json-pack/json/JsonDecoder.js +0 -567
- package/lib/json-joy/json-pack/json/JsonDecoder.js.map +0 -1
- package/lib/json-joy/json-pack/json/JsonEncoder.d.ts +0 -34
- package/lib/json-joy/json-pack/json/JsonEncoder.js +0 -220
- package/lib/json-joy/json-pack/json/JsonEncoder.js.map +0 -1
- package/lib/json-joy/json-pack/types.d.ts +0 -59
- package/lib/json-joy/json-pack/types.js +0 -3
- package/lib/json-joy/json-pack/types.js.map +0 -1
- package/lib/json-joy/json-pointer/index.d.ts +0 -1
- package/lib/json-joy/json-pointer/index.js +0 -5
- package/lib/json-joy/json-pointer/index.js.map +0 -1
- package/lib/json-joy/json-pointer/types.d.ts +0 -2
- package/lib/json-joy/json-pointer/types.js +0 -3
- package/lib/json-joy/json-pointer/types.js.map +0 -1
- package/lib/json-joy/util/base64/constants.d.ts +0 -2
- package/lib/json-joy/util/base64/constants.js +0 -6
- package/lib/json-joy/util/base64/constants.js.map +0 -1
- package/lib/json-joy/util/base64/createFromBase64Bin.d.ts +0 -1
- package/lib/json-joy/util/base64/createFromBase64Bin.js +0 -82
- package/lib/json-joy/util/base64/createFromBase64Bin.js.map +0 -1
- package/lib/json-joy/util/base64/createToBase64Bin.d.ts +0 -1
- package/lib/json-joy/util/base64/createToBase64Bin.js +0 -47
- package/lib/json-joy/util/base64/createToBase64Bin.js.map +0 -1
- package/lib/json-joy/util/base64/fromBase64Bin.d.ts +0 -1
- package/lib/json-joy/util/base64/fromBase64Bin.js +0 -6
- package/lib/json-joy/util/base64/fromBase64Bin.js.map +0 -1
- package/lib/json-joy/util/base64/toBase64Bin.d.ts +0 -1
- package/lib/json-joy/util/base64/toBase64Bin.js +0 -6
- package/lib/json-joy/util/base64/toBase64Bin.js.map +0 -1
- package/lib/json-joy/util/buffers/Reader.d.ts +0 -22
- package/lib/json-joy/util/buffers/Reader.js +0 -95
- package/lib/json-joy/util/buffers/Reader.js.map +0 -1
- package/lib/json-joy/util/buffers/Slice.d.ts +0 -8
- package/lib/json-joy/util/buffers/Slice.js +0 -16
- package/lib/json-joy/util/buffers/Slice.js.map +0 -1
- package/lib/json-joy/util/buffers/Writer.d.ts +0 -75
- package/lib/json-joy/util/buffers/Writer.js +0 -252
- package/lib/json-joy/util/buffers/Writer.js.map +0 -1
- package/lib/json-joy/util/buffers/f16.d.ts +0 -1
- package/lib/json-joy/util/buffers/f16.js +0 -18
- package/lib/json-joy/util/buffers/f16.js.map +0 -1
- package/lib/json-joy/util/buffers/index.d.ts +0 -1
- package/lib/json-joy/util/buffers/index.js +0 -5
- package/lib/json-joy/util/buffers/index.js.map +0 -1
- package/lib/json-joy/util/buffers/isFloat32.d.ts +0 -1
- package/lib/json-joy/util/buffers/isFloat32.js +0 -10
- package/lib/json-joy/util/buffers/isFloat32.js.map +0 -1
- package/lib/json-joy/util/buffers/types.d.ts +0 -106
- package/lib/json-joy/util/buffers/types.js +0 -3
- package/lib/json-joy/util/buffers/types.js.map +0 -1
- package/lib/json-joy/util/buffers/utf8/CachedUtf8Decoder.d.ts +0 -7
- package/lib/json-joy/util/buffers/utf8/CachedUtf8Decoder.js +0 -54
- package/lib/json-joy/util/buffers/utf8/CachedUtf8Decoder.js.map +0 -1
- package/lib/json-joy/util/buffers/utf8/decodeAscii.d.ts +0 -3
- package/lib/json-joy/util/buffers/utf8/decodeAscii.js +0 -181
- package/lib/json-joy/util/buffers/utf8/decodeAscii.js.map +0 -1
- package/lib/json-joy/util/buffers/utf8/decodeUtf8/index.d.ts +0 -2
- package/lib/json-joy/util/buffers/utf8/decodeUtf8/index.js +0 -6
- package/lib/json-joy/util/buffers/utf8/decodeUtf8/index.js.map +0 -1
- package/lib/json-joy/util/buffers/utf8/decodeUtf8/v10.d.ts +0 -2
- package/lib/json-joy/util/buffers/utf8/decodeUtf8/v10.js +0 -43
- package/lib/json-joy/util/buffers/utf8/decodeUtf8/v10.js.map +0 -1
- package/lib/json-joy/util/buffers/utf8/decodeUtf8/v16.d.ts +0 -11
- package/lib/json-joy/util/buffers/utf8/decodeUtf8/v16.js +0 -25
- package/lib/json-joy/util/buffers/utf8/decodeUtf8/v16.js.map +0 -1
- package/lib/json-joy/util/buffers/utf8/decodeUtf8/v18.d.ts +0 -2
- package/lib/json-joy/util/buffers/utf8/decodeUtf8/v18.js +0 -41
- package/lib/json-joy/util/buffers/utf8/decodeUtf8/v18.js.map +0 -1
- package/lib/json-joy/util/buffers/utf8/randomU32.d.ts +0 -2
- package/lib/json-joy/util/buffers/utf8/randomU32.js +0 -13
- package/lib/json-joy/util/buffers/utf8/randomU32.js.map +0 -1
- package/lib/json-joy/util/buffers/utf8/sharedCachedUtf8Decoder.d.ts +0 -3
- package/lib/json-joy/util/buffers/utf8/sharedCachedUtf8Decoder.js +0 -5
- package/lib/json-joy/util/buffers/utf8/sharedCachedUtf8Decoder.js.map +0 -1
- package/lib/json-joy/util/print/printTree.d.ts +0 -3
- package/lib/json-joy/util/print/printTree.js +0 -19
- package/lib/json-joy/util/print/printTree.js.map +0 -1
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Slice = void 0;
|
|
4
|
-
class Slice {
|
|
5
|
-
constructor(uint8, view, start, end) {
|
|
6
|
-
this.uint8 = uint8;
|
|
7
|
-
this.view = view;
|
|
8
|
-
this.start = start;
|
|
9
|
-
this.end = end;
|
|
10
|
-
}
|
|
11
|
-
subarray() {
|
|
12
|
-
return this.uint8.subarray(this.start, this.end);
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
exports.Slice = Slice;
|
|
16
|
-
//# sourceMappingURL=Slice.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Slice.js","sourceRoot":"","sources":["../../../../src/json-joy/util/buffers/Slice.ts"],"names":[],"mappings":";;;AAAA,MAAa,KAAK;IAChB,YACkB,KAAiB,EACjB,IAAc,EACd,KAAa,EACb,GAAW;QAHX,UAAK,GAAL,KAAK,CAAY;QACjB,SAAI,GAAJ,IAAI,CAAU;QACd,UAAK,GAAL,KAAK,CAAQ;QACb,QAAG,GAAH,GAAG,CAAQ;IAC1B,CAAC;IAEG,QAAQ;QACb,OAAO,IAAI,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC;IACnD,CAAC;CACF;AAXD,sBAWC"}
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { Slice } from './Slice';
|
|
2
|
-
import { IWriterGrowable, IWriter } from './types';
|
|
3
|
-
declare global {
|
|
4
|
-
interface Uint8Array {
|
|
5
|
-
utf8Write(str: string, pos: number, maxLength: number): number;
|
|
6
|
-
write(str: string, pos: number, maxLength: number, encoding: string): number;
|
|
7
|
-
}
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Encoder class provides an efficient way to encode binary data. It grows the
|
|
11
|
-
* internal memory buffer automatically as more space is required. It is useful
|
|
12
|
-
* in cases when it is not known in advance the size of memory needed.
|
|
13
|
-
*/
|
|
14
|
-
export declare class Writer implements IWriter, IWriterGrowable {
|
|
15
|
-
allocSize: number;
|
|
16
|
-
/** @ignore */
|
|
17
|
-
uint8: Uint8Array;
|
|
18
|
-
/** @ignore */
|
|
19
|
-
view: DataView;
|
|
20
|
-
/** @ignore */
|
|
21
|
-
x0: number;
|
|
22
|
-
/** @ignore */
|
|
23
|
-
x: number;
|
|
24
|
-
protected size: number;
|
|
25
|
-
/**
|
|
26
|
-
* @param allocSize Number of bytes to allocate at a time when buffer ends.
|
|
27
|
-
*/
|
|
28
|
-
constructor(allocSize?: number);
|
|
29
|
-
/** @ignore */
|
|
30
|
-
protected grow(size: number): void;
|
|
31
|
-
/**
|
|
32
|
-
* Make sure the internal buffer has enough space to write the specified number
|
|
33
|
-
* of bytes, otherwise resize the internal buffer to accommodate for more size.
|
|
34
|
-
*
|
|
35
|
-
* @param capacity Number of bytes.
|
|
36
|
-
*/
|
|
37
|
-
ensureCapacity(capacity: number): void;
|
|
38
|
-
/** @todo Consider renaming to "skip"? */
|
|
39
|
-
move(capacity: number): void;
|
|
40
|
-
reset(): void;
|
|
41
|
-
/**
|
|
42
|
-
* Allocates a new {@link ArrayBuffer}, useful when the underlying
|
|
43
|
-
* {@link ArrayBuffer} cannot be shared between threads.
|
|
44
|
-
*
|
|
45
|
-
* @param size Size of memory to allocate.
|
|
46
|
-
*/
|
|
47
|
-
newBuffer(size: number): void;
|
|
48
|
-
/**
|
|
49
|
-
* @returns Encoded memory buffer contents.
|
|
50
|
-
*/
|
|
51
|
-
flush(): Uint8Array;
|
|
52
|
-
flushSlice(): Slice;
|
|
53
|
-
u8(char: number): void;
|
|
54
|
-
u16(word: number): void;
|
|
55
|
-
u32(dword: number): void;
|
|
56
|
-
i32(dword: number): void;
|
|
57
|
-
u64(qword: number | bigint): void;
|
|
58
|
-
f64(float: number): void;
|
|
59
|
-
u8u16(u8: number, u16: number): void;
|
|
60
|
-
u8u32(u8: number, u32: number): void;
|
|
61
|
-
u8u64(u8: number, u64: number | bigint): void;
|
|
62
|
-
u8f32(u8: number, f32: number): void;
|
|
63
|
-
u8f64(u8: number, f64: number): void;
|
|
64
|
-
buf(buf: Uint8Array, length: number): void;
|
|
65
|
-
/**
|
|
66
|
-
* Encodes string as UTF-8. You need to call .ensureCapacity(str.length * 4)
|
|
67
|
-
* before calling
|
|
68
|
-
*
|
|
69
|
-
* @param str String to encode as UTF-8.
|
|
70
|
-
* @returns The number of bytes written
|
|
71
|
-
*/
|
|
72
|
-
utf8(str: string): number;
|
|
73
|
-
utf8Native(str: string): number;
|
|
74
|
-
ascii(str: string): void;
|
|
75
|
-
}
|
|
@@ -1,252 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.Writer = void 0;
|
|
4
|
-
const Slice_1 = require("./Slice");
|
|
5
|
-
const EMPTY_UINT8 = new Uint8Array([]);
|
|
6
|
-
const EMPTY_VIEW = new DataView(EMPTY_UINT8.buffer);
|
|
7
|
-
const hasBuffer = typeof Buffer === 'function';
|
|
8
|
-
const utf8Write = hasBuffer
|
|
9
|
-
? Buffer.prototype.utf8Write
|
|
10
|
-
: null;
|
|
11
|
-
const from = hasBuffer ? Buffer.from : null;
|
|
12
|
-
const textEncoder = typeof TextEncoder !== 'undefined' ? new TextEncoder() : null;
|
|
13
|
-
/**
|
|
14
|
-
* Encoder class provides an efficient way to encode binary data. It grows the
|
|
15
|
-
* internal memory buffer automatically as more space is required. It is useful
|
|
16
|
-
* in cases when it is not known in advance the size of memory needed.
|
|
17
|
-
*/
|
|
18
|
-
class Writer {
|
|
19
|
-
/**
|
|
20
|
-
* @param allocSize Number of bytes to allocate at a time when buffer ends.
|
|
21
|
-
*/
|
|
22
|
-
constructor(allocSize = 64 * 1024) {
|
|
23
|
-
this.allocSize = allocSize;
|
|
24
|
-
/** @ignore */
|
|
25
|
-
this.view = EMPTY_VIEW;
|
|
26
|
-
/** @ignore */
|
|
27
|
-
this.x0 = 0;
|
|
28
|
-
/** @ignore */
|
|
29
|
-
this.x = 0;
|
|
30
|
-
this.uint8 = new Uint8Array(allocSize);
|
|
31
|
-
this.size = allocSize;
|
|
32
|
-
this.view = new DataView(this.uint8.buffer);
|
|
33
|
-
}
|
|
34
|
-
/** @ignore */
|
|
35
|
-
grow(size) {
|
|
36
|
-
const x0 = this.x0;
|
|
37
|
-
const x = this.x;
|
|
38
|
-
const oldUint8 = this.uint8;
|
|
39
|
-
const newUint8 = new Uint8Array(size);
|
|
40
|
-
const view = new DataView(newUint8.buffer);
|
|
41
|
-
const activeSlice = oldUint8.subarray(x0, x);
|
|
42
|
-
newUint8.set(activeSlice, 0);
|
|
43
|
-
this.x = x - x0;
|
|
44
|
-
this.x0 = 0;
|
|
45
|
-
this.uint8 = newUint8;
|
|
46
|
-
this.size = size;
|
|
47
|
-
this.view = view;
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Make sure the internal buffer has enough space to write the specified number
|
|
51
|
-
* of bytes, otherwise resize the internal buffer to accommodate for more size.
|
|
52
|
-
*
|
|
53
|
-
* @param capacity Number of bytes.
|
|
54
|
-
*/
|
|
55
|
-
ensureCapacity(capacity) {
|
|
56
|
-
const byteLength = this.size;
|
|
57
|
-
const remaining = byteLength - this.x;
|
|
58
|
-
if (remaining < capacity) {
|
|
59
|
-
const total = byteLength - this.x0;
|
|
60
|
-
const required = capacity - remaining;
|
|
61
|
-
const totalRequired = total + required;
|
|
62
|
-
this.grow(totalRequired <= this.allocSize ? this.allocSize : totalRequired * 2);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
/** @todo Consider renaming to "skip"? */
|
|
66
|
-
move(capacity) {
|
|
67
|
-
this.ensureCapacity(capacity);
|
|
68
|
-
this.x += capacity;
|
|
69
|
-
}
|
|
70
|
-
reset() {
|
|
71
|
-
this.x0 = this.x;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Allocates a new {@link ArrayBuffer}, useful when the underlying
|
|
75
|
-
* {@link ArrayBuffer} cannot be shared between threads.
|
|
76
|
-
*
|
|
77
|
-
* @param size Size of memory to allocate.
|
|
78
|
-
*/
|
|
79
|
-
newBuffer(size) {
|
|
80
|
-
const uint8 = (this.uint8 = new Uint8Array(size));
|
|
81
|
-
this.size = size;
|
|
82
|
-
this.view = new DataView(uint8.buffer);
|
|
83
|
-
this.x = this.x0 = 0;
|
|
84
|
-
}
|
|
85
|
-
/**
|
|
86
|
-
* @returns Encoded memory buffer contents.
|
|
87
|
-
*/
|
|
88
|
-
flush() {
|
|
89
|
-
const result = this.uint8.subarray(this.x0, this.x);
|
|
90
|
-
this.x0 = this.x;
|
|
91
|
-
return result;
|
|
92
|
-
}
|
|
93
|
-
flushSlice() {
|
|
94
|
-
const slice = new Slice_1.Slice(this.uint8, this.view, this.x0, this.x);
|
|
95
|
-
this.x0 = this.x;
|
|
96
|
-
return slice;
|
|
97
|
-
}
|
|
98
|
-
u8(char) {
|
|
99
|
-
this.ensureCapacity(1);
|
|
100
|
-
this.uint8[this.x++] = char;
|
|
101
|
-
}
|
|
102
|
-
u16(word) {
|
|
103
|
-
this.ensureCapacity(2);
|
|
104
|
-
this.view.setUint16(this.x, word);
|
|
105
|
-
this.x += 2;
|
|
106
|
-
}
|
|
107
|
-
u32(dword) {
|
|
108
|
-
this.ensureCapacity(4);
|
|
109
|
-
this.view.setUint32(this.x, dword);
|
|
110
|
-
this.x += 4;
|
|
111
|
-
}
|
|
112
|
-
i32(dword) {
|
|
113
|
-
this.ensureCapacity(4);
|
|
114
|
-
this.view.setInt32(this.x, dword);
|
|
115
|
-
this.x += 4;
|
|
116
|
-
}
|
|
117
|
-
u64(qword) {
|
|
118
|
-
this.ensureCapacity(8);
|
|
119
|
-
this.view.setBigUint64(this.x, BigInt(qword));
|
|
120
|
-
this.x += 8;
|
|
121
|
-
}
|
|
122
|
-
f64(float) {
|
|
123
|
-
this.ensureCapacity(8);
|
|
124
|
-
this.view.setFloat64(this.x, float);
|
|
125
|
-
this.x += 8;
|
|
126
|
-
}
|
|
127
|
-
u8u16(u8, u16) {
|
|
128
|
-
this.ensureCapacity(3);
|
|
129
|
-
let x = this.x;
|
|
130
|
-
this.uint8[x++] = u8;
|
|
131
|
-
this.uint8[x++] = u16 >>> 8;
|
|
132
|
-
this.uint8[x++] = u16 & 0xff;
|
|
133
|
-
this.x = x;
|
|
134
|
-
}
|
|
135
|
-
u8u32(u8, u32) {
|
|
136
|
-
this.ensureCapacity(5);
|
|
137
|
-
let x = this.x;
|
|
138
|
-
this.uint8[x++] = u8;
|
|
139
|
-
this.view.setUint32(x, u32);
|
|
140
|
-
this.x = x + 4;
|
|
141
|
-
}
|
|
142
|
-
u8u64(u8, u64) {
|
|
143
|
-
this.ensureCapacity(9);
|
|
144
|
-
let x = this.x;
|
|
145
|
-
this.uint8[x++] = u8;
|
|
146
|
-
this.view.setBigUint64(x, BigInt(u64));
|
|
147
|
-
this.x = x + 8;
|
|
148
|
-
}
|
|
149
|
-
u8f32(u8, f32) {
|
|
150
|
-
this.ensureCapacity(5);
|
|
151
|
-
let x = this.x;
|
|
152
|
-
this.uint8[x++] = u8;
|
|
153
|
-
this.view.setFloat32(x, f32);
|
|
154
|
-
this.x = x + 4;
|
|
155
|
-
}
|
|
156
|
-
u8f64(u8, f64) {
|
|
157
|
-
this.ensureCapacity(9);
|
|
158
|
-
let x = this.x;
|
|
159
|
-
this.uint8[x++] = u8;
|
|
160
|
-
this.view.setFloat64(x, f64);
|
|
161
|
-
this.x = x + 8;
|
|
162
|
-
}
|
|
163
|
-
buf(buf, length) {
|
|
164
|
-
this.ensureCapacity(length);
|
|
165
|
-
const x = this.x;
|
|
166
|
-
this.uint8.set(buf, x);
|
|
167
|
-
this.x = x + length;
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* Encodes string as UTF-8. You need to call .ensureCapacity(str.length * 4)
|
|
171
|
-
* before calling
|
|
172
|
-
*
|
|
173
|
-
* @param str String to encode as UTF-8.
|
|
174
|
-
* @returns The number of bytes written
|
|
175
|
-
*/
|
|
176
|
-
utf8(str) {
|
|
177
|
-
const maxLength = str.length * 4;
|
|
178
|
-
if (maxLength < 168)
|
|
179
|
-
return this.utf8Native(str);
|
|
180
|
-
if (utf8Write) {
|
|
181
|
-
const writeLength = utf8Write.call(this.uint8, str, this.x, maxLength);
|
|
182
|
-
this.x += writeLength;
|
|
183
|
-
return writeLength;
|
|
184
|
-
}
|
|
185
|
-
else if (from) {
|
|
186
|
-
const uint8 = this.uint8;
|
|
187
|
-
const offset = uint8.byteOffset + this.x;
|
|
188
|
-
const buf = from(uint8.buffer).subarray(offset, offset + maxLength);
|
|
189
|
-
const writeLength = buf.write(str, 0, maxLength, 'utf8');
|
|
190
|
-
this.x += writeLength;
|
|
191
|
-
return writeLength;
|
|
192
|
-
}
|
|
193
|
-
else if (maxLength > 1024 && textEncoder) {
|
|
194
|
-
const writeLength = textEncoder.encodeInto(str, this.uint8.subarray(this.x, this.x + maxLength)).written;
|
|
195
|
-
this.x += writeLength;
|
|
196
|
-
return writeLength;
|
|
197
|
-
}
|
|
198
|
-
return this.utf8Native(str);
|
|
199
|
-
}
|
|
200
|
-
utf8Native(str) {
|
|
201
|
-
const length = str.length;
|
|
202
|
-
const uint8 = this.uint8;
|
|
203
|
-
let offset = this.x;
|
|
204
|
-
let pos = 0;
|
|
205
|
-
while (pos < length) {
|
|
206
|
-
let value = str.charCodeAt(pos++);
|
|
207
|
-
if ((value & 0xffffff80) === 0) {
|
|
208
|
-
uint8[offset++] = value;
|
|
209
|
-
continue;
|
|
210
|
-
}
|
|
211
|
-
else if ((value & 0xfffff800) === 0) {
|
|
212
|
-
uint8[offset++] = ((value >> 6) & 0x1f) | 0xc0;
|
|
213
|
-
}
|
|
214
|
-
else {
|
|
215
|
-
if (value >= 0xd800 && value <= 0xdbff) {
|
|
216
|
-
if (pos < length) {
|
|
217
|
-
const extra = str.charCodeAt(pos);
|
|
218
|
-
if ((extra & 0xfc00) === 0xdc00) {
|
|
219
|
-
pos++;
|
|
220
|
-
value = ((value & 0x3ff) << 10) + (extra & 0x3ff) + 0x10000;
|
|
221
|
-
}
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
if ((value & 0xffff0000) === 0) {
|
|
225
|
-
uint8[offset++] = ((value >> 12) & 0x0f) | 0xe0;
|
|
226
|
-
uint8[offset++] = ((value >> 6) & 0x3f) | 0x80;
|
|
227
|
-
}
|
|
228
|
-
else {
|
|
229
|
-
uint8[offset++] = ((value >> 18) & 0x07) | 0xf0;
|
|
230
|
-
uint8[offset++] = ((value >> 12) & 0x3f) | 0x80;
|
|
231
|
-
uint8[offset++] = ((value >> 6) & 0x3f) | 0x80;
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
uint8[offset++] = (value & 0x3f) | 0x80;
|
|
235
|
-
}
|
|
236
|
-
const writeLength = offset - this.x;
|
|
237
|
-
this.x = offset;
|
|
238
|
-
return writeLength;
|
|
239
|
-
}
|
|
240
|
-
ascii(str) {
|
|
241
|
-
const length = str.length;
|
|
242
|
-
this.ensureCapacity(length);
|
|
243
|
-
const uint8 = this.uint8;
|
|
244
|
-
let x = this.x;
|
|
245
|
-
let pos = 0;
|
|
246
|
-
while (pos < length)
|
|
247
|
-
uint8[x++] = str.charCodeAt(pos++);
|
|
248
|
-
this.x = x;
|
|
249
|
-
}
|
|
250
|
-
}
|
|
251
|
-
exports.Writer = Writer;
|
|
252
|
-
//# sourceMappingURL=Writer.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Writer.js","sourceRoot":"","sources":["../../../../src/json-joy/util/buffers/Writer.ts"],"names":[],"mappings":";;;AAAA,mCAA8B;AAG9B,MAAM,WAAW,GAAG,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC;AACvC,MAAM,UAAU,GAAG,IAAI,QAAQ,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;AASpD,MAAM,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AC,CAAC;QACf,IAAI,GAAG,GAAG,CAAC,CAAC;QACZ,OAAO,GAAG,GAAG,MAAM;YAAE,KAAK,CAAC,CAAC,EAAE,CAAC,GAAG,GAAG,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC,CAAC;QACxD,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC;IACb,CAAC;CACF;AA1PD,wBA0PC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const decodeF16: (binary: number) => number;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.decodeF16 = void 0;
|
|
4
|
-
const pow = Math.pow;
|
|
5
|
-
const decodeF16 = (binary) => {
|
|
6
|
-
const exponent = (binary & 0x7c00) >> 10;
|
|
7
|
-
const fraction = binary & 0x03ff;
|
|
8
|
-
return ((binary >> 15 ? -1 : 1) *
|
|
9
|
-
(exponent
|
|
10
|
-
? exponent === 0x1f
|
|
11
|
-
? fraction
|
|
12
|
-
? NaN
|
|
13
|
-
: Infinity
|
|
14
|
-
: pow(2, exponent - 15) * (1 + fraction / 0x400)
|
|
15
|
-
: 6.103515625e-5 * (fraction / 0x400)));
|
|
16
|
-
};
|
|
17
|
-
exports.decodeF16 = decodeF16;
|
|
18
|
-
//# sourceMappingURL=f16.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"f16.js","sourceRoot":"","sources":["../../../../src/json-joy/util/buffers/f16.ts"],"names":[],"mappings":";;;AAAA,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;AAEd,MAAM,SAAS,GAAG,CAAC,MAAc,EAAU,EAAE;IAClD,MAAM,QAAQ,GAAG,CAAC,MAAM,GAAG,MAAM,CAAC,IAAI,EAAE,CAAC;IACzC,MAAM,QAAQ,GAAG,MAAM,GAAG,MAAM,CAAC;IACjC,OAAO,CACL,CAAC,MAAM,IAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACvB,CAAC,QAAQ;YACP,CAAC,CAAC,QAAQ,KAAK,IAAI;gBACjB,CAAC,CAAC,QAAQ;oBACR,CAAC,CAAC,GAAG;oBACL,CAAC,CAAC,QAAQ;gBACZ,CAAC,CAAC,GAAG,CAAC,CAAC,EAAE,QAAQ,GAAG,EAAE,CAAC,GAAG,CAAC,CAAC,GAAG,QAAQ,GAAG,KAAK,CAAC;YAClD,CAAC,CAAC,cAAc,GAAG,CAAC,QAAQ,GAAG,KAAK,CAAC,CAAC,CACzC,CAAC;AACJ,CAAC,CAAC;AAbW,QAAA,SAAS,aAapB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './types';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/json-joy/util/buffers/index.ts"],"names":[],"mappings":";;;AAAA,kDAAwB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const isFloat32: (n: number) => boolean;
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isFloat32 = void 0;
|
|
4
|
-
const view = new DataView(new ArrayBuffer(4));
|
|
5
|
-
const isFloat32 = (n) => {
|
|
6
|
-
view.setFloat32(0, n);
|
|
7
|
-
return n === view.getFloat32(0);
|
|
8
|
-
};
|
|
9
|
-
exports.isFloat32 = isFloat32;
|
|
10
|
-
//# sourceMappingURL=isFloat32.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"isFloat32.js","sourceRoot":"","sources":["../../../../src/json-joy/util/buffers/isFloat32.ts"],"names":[],"mappings":";;;AAAA,MAAM,IAAI,GAAG,IAAI,QAAQ,CAAC,IAAI,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;AAEvC,MAAM,SAAS,GAAG,CAAC,CAAS,EAAW,EAAE;IAC9C,IAAI,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACtB,OAAO,CAAC,KAAK,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;AAClC,CAAC,CAAC;AAHW,QAAA,SAAS,aAGpB"}
|
|
@@ -1,106 +0,0 @@
|
|
|
1
|
-
import type { Slice } from './Slice';
|
|
2
|
-
export interface IWriter {
|
|
3
|
-
/**
|
|
4
|
-
* Uint8Array view of the current memory buffer.
|
|
5
|
-
*/
|
|
6
|
-
uint8: Uint8Array;
|
|
7
|
-
/**
|
|
8
|
-
* DataView view of the current memory buffer.
|
|
9
|
-
*/
|
|
10
|
-
view: DataView;
|
|
11
|
-
/**
|
|
12
|
-
* Position where last flush happened.
|
|
13
|
-
*/
|
|
14
|
-
x0: number;
|
|
15
|
-
/**
|
|
16
|
-
* Current position in the internal buffer.
|
|
17
|
-
*/
|
|
18
|
-
x: number;
|
|
19
|
-
u8(char: number): void;
|
|
20
|
-
u16(word: number): void;
|
|
21
|
-
u32(dword: number): void;
|
|
22
|
-
i32(dword: number): void;
|
|
23
|
-
u64(qword: number | bigint): void;
|
|
24
|
-
u8u16(u8: number, u16: number): void;
|
|
25
|
-
u8u32(u8: number, u32: number): void;
|
|
26
|
-
u8u64(u8: number, u64: number | bigint): void;
|
|
27
|
-
u8f32(u8: number, f64: number): void;
|
|
28
|
-
u8f64(u8: number, f64: number): void;
|
|
29
|
-
f64(dword: number): void;
|
|
30
|
-
/**
|
|
31
|
-
* Write contents of a buffer.
|
|
32
|
-
*
|
|
33
|
-
* @param buf Buffer to copy from.
|
|
34
|
-
* @param length Number of octets to copy.
|
|
35
|
-
*/
|
|
36
|
-
buf(buf: Uint8Array, length: number): void;
|
|
37
|
-
/**
|
|
38
|
-
* Write string as UTF-8. You need to call .ensureCapacity(str.length * 4)
|
|
39
|
-
* before calling
|
|
40
|
-
*
|
|
41
|
-
* @param str JavaScript string to encode as UTF-8 byte sequence.
|
|
42
|
-
*/
|
|
43
|
-
utf8(str: string): number;
|
|
44
|
-
ascii(str: string): void;
|
|
45
|
-
}
|
|
46
|
-
export interface IWriterGrowable {
|
|
47
|
-
/** @deprecated */
|
|
48
|
-
reset(): void;
|
|
49
|
-
/**
|
|
50
|
-
* Calling this method might reset the internal buffer. So, your references
|
|
51
|
-
* (such as `x`, `uint8`, `view`) to the internal buffer might become invalid.
|
|
52
|
-
*
|
|
53
|
-
* @param capacity How many octets to ensure are available after `x`.
|
|
54
|
-
*/
|
|
55
|
-
ensureCapacity(capacity: number): void;
|
|
56
|
-
move(length: number): void;
|
|
57
|
-
flush(): Uint8Array;
|
|
58
|
-
flushSlice(): Slice;
|
|
59
|
-
newBuffer(size: number): void;
|
|
60
|
-
}
|
|
61
|
-
export interface IReaderBase {
|
|
62
|
-
/** Get current byte value without advancing the cursor. */
|
|
63
|
-
peak(): number;
|
|
64
|
-
/** Advance the cursor given number of octets. */
|
|
65
|
-
skip(length: number): void;
|
|
66
|
-
/**
|
|
67
|
-
* Create a new Uint8Array view of provided length starting at
|
|
68
|
-
* the current cursor position.
|
|
69
|
-
*/
|
|
70
|
-
buf(size: number): Uint8Array;
|
|
71
|
-
u8(): number;
|
|
72
|
-
i8(): number;
|
|
73
|
-
u16(): number;
|
|
74
|
-
i16(): number;
|
|
75
|
-
u32(): number;
|
|
76
|
-
u64(): bigint;
|
|
77
|
-
i64(): bigint;
|
|
78
|
-
i32(): number;
|
|
79
|
-
f32(): number;
|
|
80
|
-
f64(): number;
|
|
81
|
-
/**
|
|
82
|
-
* Decode a UTF-8 string.
|
|
83
|
-
*
|
|
84
|
-
* @param size Length of the string.
|
|
85
|
-
*/
|
|
86
|
-
utf8(size: number): string;
|
|
87
|
-
ascii(length: number): string;
|
|
88
|
-
}
|
|
89
|
-
export interface IReader extends IReaderBase {
|
|
90
|
-
/**
|
|
91
|
-
* Uint8Array view of the current memory buffer.
|
|
92
|
-
*/
|
|
93
|
-
uint8: Uint8Array;
|
|
94
|
-
/**
|
|
95
|
-
* DataView view of the current memory buffer.
|
|
96
|
-
*/
|
|
97
|
-
view: DataView;
|
|
98
|
-
/**
|
|
99
|
-
* Cursor in the current memory buffer.
|
|
100
|
-
*/
|
|
101
|
-
x: number;
|
|
102
|
-
}
|
|
103
|
-
export interface IReaderResettable {
|
|
104
|
-
/** Set a new underlying buffer and reset cursor position to 0. */
|
|
105
|
-
reset(uint8: Uint8Array): void;
|
|
106
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/json-joy/util/buffers/types.ts"],"names":[],"mappings":""}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CachedUtf8Decoder = void 0;
|
|
4
|
-
const v10_1 = require("./decodeUtf8/v10");
|
|
5
|
-
const randomU32_1 = require("./randomU32");
|
|
6
|
-
class CacheItem {
|
|
7
|
-
constructor(bytes, value) {
|
|
8
|
-
this.bytes = bytes;
|
|
9
|
-
this.value = value;
|
|
10
|
-
}
|
|
11
|
-
}
|
|
12
|
-
class CachedUtf8Decoder {
|
|
13
|
-
constructor() {
|
|
14
|
-
this.caches = [];
|
|
15
|
-
for (let i = 0; i < 31 /* CONST.MAX_CACHED_STR_LEN */; i++)
|
|
16
|
-
this.caches.push([]);
|
|
17
|
-
}
|
|
18
|
-
get(bytes, offset, size) {
|
|
19
|
-
const records = this.caches[size - 1];
|
|
20
|
-
const len = records.length;
|
|
21
|
-
FIND_CHUNK: for (let i = 0; i < len; i++) {
|
|
22
|
-
const record = records[i];
|
|
23
|
-
const recordBytes = record.bytes;
|
|
24
|
-
for (let j = 0; j < size; j++)
|
|
25
|
-
if (recordBytes[j] !== bytes[offset + j])
|
|
26
|
-
continue FIND_CHUNK;
|
|
27
|
-
return record.value;
|
|
28
|
-
}
|
|
29
|
-
return null;
|
|
30
|
-
}
|
|
31
|
-
store(bytes, value) {
|
|
32
|
-
const records = this.caches[bytes.length - 1];
|
|
33
|
-
const record = new CacheItem(bytes, value);
|
|
34
|
-
const length = records.length;
|
|
35
|
-
if (length >= 16 /* CONST.MAX_RECORDS_PER_SIZE */)
|
|
36
|
-
records[(0, randomU32_1.randomU32)(0, 16 /* CONST.MAX_RECORDS_PER_SIZE */ - 1)] = record;
|
|
37
|
-
else
|
|
38
|
-
records.push(record);
|
|
39
|
-
}
|
|
40
|
-
decode(bytes, offset, size) {
|
|
41
|
-
if (!size)
|
|
42
|
-
return '';
|
|
43
|
-
const cachedValue = this.get(bytes, offset, size);
|
|
44
|
-
if (cachedValue !== null)
|
|
45
|
-
return cachedValue;
|
|
46
|
-
const value = (0, v10_1.default)(bytes, offset, size);
|
|
47
|
-
// Ensure to copy a slice of bytes because the byte may be NodeJS Buffer and Buffer#slice() returns a reference to its internal ArrayBuffer.
|
|
48
|
-
const copy = Uint8Array.prototype.slice.call(bytes, offset, offset + size);
|
|
49
|
-
this.store(copy, value);
|
|
50
|
-
return value;
|
|
51
|
-
}
|
|
52
|
-
}
|
|
53
|
-
exports.CachedUtf8Decoder = CachedUtf8Decoder;
|
|
54
|
-
//# sourceMappingURL=CachedUtf8Decoder.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"CachedUtf8Decoder.js","sourceRoot":"","sources":["../../../../../src/json-joy/util/buffers/utf8/CachedUtf8Decoder.ts"],"names":[],"mappings":";;;AAAA,0CAA0C;AAC1C,2CAAsC;AAEtC,MAAM,SAAS;IACb,YAA4B,KAAiB,EAAkB,KAAa;QAAhD,UAAK,GAAL,KAAK,CAAY;QAAkB,UAAK,GAAL,KAAK,CAAQ;IAAG,CAAC;CACjF;AAOD,MAAa,iBAAiB;IAG5B;QACE,IAAI,CAAC,MAAM,GAAG,EAAE,CAAC;QACjB,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,oCAA2B,EAAE,CAAC,EAAE;YAAE,IAAI,CAAC,MAAM,CAA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B,MAAM,WAAW,GAAG,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;QAClD,IAAI,WAAW,KAAK,IAAI;YAAE,OAAO,WAAW,CAAC;QAC7C,MAAM,KAAK,GAAG,IAAA,aAAU,EAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,CAAC;QAC9C,4IAA4I;QAC5I,MAAM,IAAI,GAAG,UAAU,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;QAC3E,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;QACxB,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AAtCD,8CAsCC"}
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
/** This code was borrowed form cbor-x under the MIT license. */
|
|
2
|
-
export declare const decodeAscii: (src: Uint8Array, position: number, length: number) => string | undefined;
|
|
3
|
-
export declare const decodeAsciiMax15: (src: Uint8Array, position: number, length: number) => string | undefined;
|