@sachitv/avro-typescript 0.4.1 → 0.5.0
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/esm/avro_reader_sync.d.ts +48 -0
- package/esm/avro_reader_sync.js +79 -0
- package/esm/avro_writer_sync.d.ts +28 -0
- package/esm/avro_writer_sync.js +63 -0
- package/esm/internal/collections/circular_buffer.d.ts +4 -3
- package/esm/internal/collections/circular_buffer.js +8 -6
- package/esm/mod.d.ts +17 -0
- package/esm/mod.js +11 -0
- package/esm/schemas/base_type.d.ts +8 -0
- package/esm/schemas/base_type.js +21 -0
- package/esm/schemas/complex/array_type.d.ts +31 -10
- package/esm/schemas/complex/array_type.js +129 -39
- package/esm/schemas/complex/enum_type.d.ts +24 -7
- package/esm/schemas/complex/enum_type.js +61 -15
- package/esm/schemas/complex/fixed_type.d.ts +27 -12
- package/esm/schemas/complex/fixed_type.js +40 -27
- package/esm/schemas/complex/map_type.d.ts +31 -10
- package/esm/schemas/complex/map_type.js +88 -47
- package/esm/schemas/complex/named_type.d.ts +1 -1
- package/esm/schemas/complex/named_type.js +2 -2
- package/esm/schemas/complex/record_field.d.ts +62 -0
- package/esm/schemas/complex/record_field.js +112 -0
- package/esm/schemas/complex/record_resolver.d.ts +45 -0
- package/esm/schemas/complex/record_resolver.js +92 -0
- package/esm/schemas/complex/record_type.d.ts +45 -70
- package/esm/schemas/complex/record_type.js +158 -213
- package/esm/schemas/complex/record_writer_cache.d.ts +44 -0
- package/esm/schemas/complex/record_writer_cache.js +141 -0
- package/esm/schemas/complex/record_writer_strategy.d.ts +123 -0
- package/esm/schemas/complex/record_writer_strategy.js +309 -0
- package/esm/schemas/complex/union_type.d.ts +23 -11
- package/esm/schemas/complex/union_type.js +77 -29
- package/esm/schemas/logical/decimal_logical_type.d.ts +1 -1
- package/esm/schemas/logical/decimal_logical_type.js +2 -2
- package/esm/schemas/logical/duration_logical_type.d.ts +1 -1
- package/esm/schemas/logical/duration_logical_type.js +2 -2
- package/esm/schemas/logical/logical_type.d.ts +27 -9
- package/esm/schemas/logical/logical_type.js +50 -17
- package/esm/schemas/logical/temporal_logical_types.d.ts +9 -9
- package/esm/schemas/logical/temporal_logical_types.js +18 -18
- package/esm/schemas/logical/uuid_logical_type.d.ts +1 -1
- package/esm/schemas/logical/uuid_logical_type.js +2 -2
- package/esm/schemas/primitive/boolean_type.d.ts +15 -4
- package/esm/schemas/primitive/boolean_type.js +22 -7
- package/esm/schemas/primitive/bytes_type.d.ts +16 -5
- package/esm/schemas/primitive/bytes_type.js +31 -16
- package/esm/schemas/primitive/double_type.d.ts +13 -2
- package/esm/schemas/primitive/double_type.js +34 -5
- package/esm/schemas/primitive/fixed_size_base_type.d.ts +11 -7
- package/esm/schemas/primitive/fixed_size_base_type.js +14 -14
- package/esm/schemas/primitive/float_type.d.ts +11 -2
- package/esm/schemas/primitive/float_type.js +26 -5
- package/esm/schemas/primitive/int_type.d.ts +17 -6
- package/esm/schemas/primitive/int_type.js +26 -17
- package/esm/schemas/primitive/long_type.d.ts +16 -5
- package/esm/schemas/primitive/long_type.js +30 -16
- package/esm/schemas/primitive/null_type.d.ts +15 -4
- package/esm/schemas/primitive/null_type.js +20 -7
- package/esm/schemas/primitive/primitive_type.d.ts +2 -0
- package/esm/schemas/primitive/primitive_type.js +4 -0
- package/esm/schemas/primitive/string_type.d.ts +17 -6
- package/esm/schemas/primitive/string_type.js +33 -18
- package/esm/schemas/resolver.d.ts +6 -0
- package/esm/schemas/type.d.ts +64 -4
- package/esm/schemas/type.js +97 -0
- package/esm/serialization/avro_file_parser_sync.d.ts +34 -0
- package/esm/serialization/avro_file_parser_sync.js +160 -0
- package/esm/serialization/avro_file_writer_sync.d.ts +47 -0
- package/esm/serialization/avro_file_writer_sync.js +211 -0
- package/esm/serialization/buffers/blob_readable_buffer.d.ts +4 -3
- package/esm/serialization/buffers/blob_readable_buffer.js +20 -6
- package/esm/serialization/buffers/buffer.d.ts +6 -1
- package/esm/serialization/buffers/buffer.js +3 -0
- package/esm/serialization/buffers/buffer_error.d.ts +28 -0
- package/esm/serialization/buffers/buffer_error.js +70 -0
- package/esm/serialization/buffers/buffer_sync.d.ts +51 -0
- package/esm/serialization/buffers/buffer_sync.js +4 -0
- package/esm/serialization/buffers/in_memory_buffer.d.ts +1 -0
- package/esm/serialization/buffers/in_memory_buffer.js +7 -5
- package/esm/serialization/buffers/in_memory_buffer_sync.d.ts +133 -0
- package/esm/serialization/buffers/in_memory_buffer_sync.js +259 -0
- package/esm/serialization/counting_writable_tap.d.ts +45 -0
- package/esm/serialization/counting_writable_tap.js +90 -0
- package/esm/serialization/counting_writable_tap_sync.d.ts +46 -0
- package/esm/serialization/counting_writable_tap_sync.js +87 -0
- package/esm/serialization/decoders/decoder_null_sync.d.ts +12 -0
- package/esm/serialization/decoders/decoder_null_sync.js +13 -0
- package/esm/serialization/decoders/decoder_sync.d.ts +15 -0
- package/esm/serialization/decoders/decoder_sync.js +1 -0
- package/esm/serialization/encoders/encoder_null_sync.d.ts +12 -0
- package/esm/serialization/encoders/encoder_null_sync.js +13 -0
- package/esm/serialization/encoders/encoder_sync.d.ts +15 -0
- package/esm/serialization/encoders/encoder_sync.js +1 -0
- package/esm/serialization/streams/fixed_size_stream_readable_buffer_adapter.d.ts +3 -2
- package/esm/serialization/streams/fixed_size_stream_readable_buffer_adapter.js +19 -9
- package/esm/serialization/streams/fixed_size_stream_reader_sync.d.ts +25 -0
- package/esm/serialization/streams/fixed_size_stream_reader_sync.js +63 -0
- package/esm/serialization/streams/fixed_size_stream_writer_sync.d.ts +45 -0
- package/esm/serialization/streams/fixed_size_stream_writer_sync.js +98 -0
- package/esm/serialization/streams/forward_only_stream_readable_buffer_adapter.d.ts +5 -3
- package/esm/serialization/streams/forward_only_stream_readable_buffer_adapter.js +18 -8
- package/esm/serialization/streams/stream_readable_buffer_adapter.d.ts +3 -2
- package/esm/serialization/streams/stream_readable_buffer_adapter.js +19 -6
- package/esm/serialization/streams/stream_readable_buffer_adapter_sync.d.ts +36 -0
- package/esm/serialization/streams/stream_readable_buffer_adapter_sync.js +93 -0
- package/esm/serialization/streams/stream_writable_buffer_adapter_sync.d.ts +45 -0
- package/esm/serialization/streams/stream_writable_buffer_adapter_sync.js +78 -0
- package/esm/serialization/streams/streams_sync.d.ts +36 -0
- package/esm/serialization/streams/streams_sync.js +4 -0
- package/esm/serialization/tap.d.ts +15 -32
- package/esm/serialization/tap.js +45 -134
- package/esm/serialization/tap_sync.d.ts +240 -0
- package/esm/serialization/tap_sync.js +545 -0
- package/esm/serialization/text_encoding.d.ts +16 -0
- package/esm/serialization/text_encoding.js +48 -1
- package/esm/type/create_type.d.ts +20 -0
- package/esm/type/create_type.js +49 -28
- package/package.json +2 -2
- package/esm/serialization/manipulate_bytes.d.ts +0 -6
- package/esm/serialization/manipulate_bytes.js +0 -13
- package/esm/serialization/read_uint_le.d.ts +0 -4
- package/esm/serialization/read_uint_le.js +0 -14
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { TapBase } from "./tap.js";
|
|
2
|
+
import { utf8ByteLength } from "./text_encoding.js";
|
|
3
|
+
/**
|
|
4
|
+
* A writable tap that counts encoded bytes without allocating buffers.
|
|
5
|
+
*
|
|
6
|
+
* Used for two-pass serialization where the first pass calculates the
|
|
7
|
+
* exact buffer size needed, then the second pass writes to a pre-allocated
|
|
8
|
+
* buffer. This avoids buffer reallocations and copies.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* // Pass 1: Calculate size
|
|
13
|
+
* const countingTap = new CountingWritableTap();
|
|
14
|
+
* await type.write(countingTap, value);
|
|
15
|
+
* const size = countingTap.getPos();
|
|
16
|
+
*
|
|
17
|
+
* // Pass 2: Write to exact-size buffer
|
|
18
|
+
* const buffer = new ArrayBuffer(size);
|
|
19
|
+
* const tap = new WritableTap(buffer);
|
|
20
|
+
* await type.write(tap, value);
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export class CountingWritableTap extends TapBase {
|
|
24
|
+
/** Creates a new counting tap starting at position 0. */
|
|
25
|
+
constructor() {
|
|
26
|
+
super(0);
|
|
27
|
+
}
|
|
28
|
+
/** Returns whether the tap is valid (always true for counting tap). */
|
|
29
|
+
isValid() {
|
|
30
|
+
return Promise.resolve(true);
|
|
31
|
+
}
|
|
32
|
+
/** Counts a boolean value (1 byte). */
|
|
33
|
+
writeBoolean(_value) {
|
|
34
|
+
this.pos += 1;
|
|
35
|
+
return Promise.resolve();
|
|
36
|
+
}
|
|
37
|
+
/** Counts an integer value using varint encoding. */
|
|
38
|
+
writeInt(value) {
|
|
39
|
+
return this.writeLong(BigInt(value));
|
|
40
|
+
}
|
|
41
|
+
/** Counts a long value using zigzag + varint encoding. */
|
|
42
|
+
writeLong(value) {
|
|
43
|
+
// Calculate varint size for zigzag-encoded value
|
|
44
|
+
let n = value < 0n ? ((-value) << 1n) - 1n : value << 1n;
|
|
45
|
+
let size = 1;
|
|
46
|
+
while (n >= 0x80n) {
|
|
47
|
+
size++;
|
|
48
|
+
n >>= 7n;
|
|
49
|
+
}
|
|
50
|
+
this.pos += size;
|
|
51
|
+
return Promise.resolve();
|
|
52
|
+
}
|
|
53
|
+
/** Counts a float value (4 bytes). */
|
|
54
|
+
writeFloat(_value) {
|
|
55
|
+
this.pos += 4;
|
|
56
|
+
return Promise.resolve();
|
|
57
|
+
}
|
|
58
|
+
/** Counts a double value (8 bytes). */
|
|
59
|
+
writeDouble(_value) {
|
|
60
|
+
this.pos += 8;
|
|
61
|
+
return Promise.resolve();
|
|
62
|
+
}
|
|
63
|
+
/** Counts a fixed-length byte sequence. */
|
|
64
|
+
writeFixed(buf) {
|
|
65
|
+
this.pos += buf.length;
|
|
66
|
+
return Promise.resolve();
|
|
67
|
+
}
|
|
68
|
+
/** Counts a length-prefixed byte sequence. */
|
|
69
|
+
writeBytes(buf) {
|
|
70
|
+
const len = buf.length;
|
|
71
|
+
// Length prefix + data
|
|
72
|
+
return this.writeLong(BigInt(len)).then(() => {
|
|
73
|
+
this.pos += len;
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
/** Counts a length-prefixed UTF-8 string. */
|
|
77
|
+
writeString(str) {
|
|
78
|
+
// Calculate UTF-8 byte length
|
|
79
|
+
const len = utf8ByteLength(str);
|
|
80
|
+
return this.writeLong(BigInt(len)).then(() => {
|
|
81
|
+
this.pos += len;
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
/** Counts raw binary bytes without length prefix. */
|
|
85
|
+
writeBinary(_str, len) {
|
|
86
|
+
if (len > 0)
|
|
87
|
+
this.pos += len;
|
|
88
|
+
return Promise.resolve();
|
|
89
|
+
}
|
|
90
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { TapBase } from "./tap.js";
|
|
2
|
+
import type { SyncWritableTapLike } from "./tap_sync.js";
|
|
3
|
+
/**
|
|
4
|
+
* A synchronous writable tap that counts encoded bytes without allocating buffers.
|
|
5
|
+
*
|
|
6
|
+
* Used for two-pass serialization where the first pass calculates the
|
|
7
|
+
* exact buffer size needed, then the second pass writes to a pre-allocated
|
|
8
|
+
* buffer. This avoids buffer reallocations and copies.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* // Pass 1: Calculate size
|
|
13
|
+
* const countingTap = new SyncCountingWritableTap();
|
|
14
|
+
* type.writeSync(countingTap, value);
|
|
15
|
+
* const size = countingTap.getPos();
|
|
16
|
+
*
|
|
17
|
+
* // Pass 2: Write to exact-size buffer
|
|
18
|
+
* const buffer = new ArrayBuffer(size);
|
|
19
|
+
* const tap = new SyncWritableTap(buffer);
|
|
20
|
+
* type.writeSync(tap, value);
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare class SyncCountingWritableTap extends TapBase implements SyncWritableTapLike {
|
|
24
|
+
/** Creates a new counting tap starting at position 0. */
|
|
25
|
+
constructor();
|
|
26
|
+
/** Returns whether the tap is valid (always true for counting tap). */
|
|
27
|
+
isValid(): boolean;
|
|
28
|
+
/** Counts a boolean value (1 byte). */
|
|
29
|
+
writeBoolean(_value: boolean): void;
|
|
30
|
+
/** Counts an integer value using varint encoding. */
|
|
31
|
+
writeInt(value: number): void;
|
|
32
|
+
/** Counts a long value using zigzag + varint encoding. */
|
|
33
|
+
writeLong(value: bigint): void;
|
|
34
|
+
/** Counts a float value (4 bytes). */
|
|
35
|
+
writeFloat(_value: number): void;
|
|
36
|
+
/** Counts a double value (8 bytes). */
|
|
37
|
+
writeDouble(_value: number): void;
|
|
38
|
+
/** Counts a fixed-length byte sequence. */
|
|
39
|
+
writeFixed(buf: Uint8Array): void;
|
|
40
|
+
/** Counts a length-prefixed byte sequence. */
|
|
41
|
+
writeBytes(buf: Uint8Array): void;
|
|
42
|
+
/** Counts a length-prefixed UTF-8 string. */
|
|
43
|
+
writeString(str: string): void;
|
|
44
|
+
/** Counts raw binary bytes without length prefix. */
|
|
45
|
+
writeBinary(_str: string, len: number): void;
|
|
46
|
+
}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import { TapBase } from "./tap.js";
|
|
2
|
+
import { utf8ByteLength } from "./text_encoding.js";
|
|
3
|
+
/**
|
|
4
|
+
* A synchronous writable tap that counts encoded bytes without allocating buffers.
|
|
5
|
+
*
|
|
6
|
+
* Used for two-pass serialization where the first pass calculates the
|
|
7
|
+
* exact buffer size needed, then the second pass writes to a pre-allocated
|
|
8
|
+
* buffer. This avoids buffer reallocations and copies.
|
|
9
|
+
*
|
|
10
|
+
* @example
|
|
11
|
+
* ```ts
|
|
12
|
+
* // Pass 1: Calculate size
|
|
13
|
+
* const countingTap = new SyncCountingWritableTap();
|
|
14
|
+
* type.writeSync(countingTap, value);
|
|
15
|
+
* const size = countingTap.getPos();
|
|
16
|
+
*
|
|
17
|
+
* // Pass 2: Write to exact-size buffer
|
|
18
|
+
* const buffer = new ArrayBuffer(size);
|
|
19
|
+
* const tap = new SyncWritableTap(buffer);
|
|
20
|
+
* type.writeSync(tap, value);
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export class SyncCountingWritableTap extends TapBase {
|
|
24
|
+
/** Creates a new counting tap starting at position 0. */
|
|
25
|
+
constructor() {
|
|
26
|
+
super(0);
|
|
27
|
+
}
|
|
28
|
+
/** Returns whether the tap is valid (always true for counting tap). */
|
|
29
|
+
isValid() {
|
|
30
|
+
return true;
|
|
31
|
+
}
|
|
32
|
+
/** Counts a boolean value (1 byte). */
|
|
33
|
+
writeBoolean(_value) {
|
|
34
|
+
this.pos += 1;
|
|
35
|
+
}
|
|
36
|
+
/** Counts an integer value using varint encoding. */
|
|
37
|
+
writeInt(value) {
|
|
38
|
+
// Calculate varint size for zigzag-encoded 32-bit int
|
|
39
|
+
let n = ((value << 1) ^ (value >> 31)) >>> 0;
|
|
40
|
+
let size = 1;
|
|
41
|
+
while (n > 0x7f) {
|
|
42
|
+
size++;
|
|
43
|
+
n >>>= 7;
|
|
44
|
+
}
|
|
45
|
+
this.pos += size;
|
|
46
|
+
}
|
|
47
|
+
/** Counts a long value using zigzag + varint encoding. */
|
|
48
|
+
writeLong(value) {
|
|
49
|
+
// Calculate varint size for zigzag-encoded value
|
|
50
|
+
let n = value < 0n ? ((-value) << 1n) - 1n : value << 1n;
|
|
51
|
+
let size = 1;
|
|
52
|
+
while (n >= 0x80n) {
|
|
53
|
+
size++;
|
|
54
|
+
n >>= 7n;
|
|
55
|
+
}
|
|
56
|
+
this.pos += size;
|
|
57
|
+
}
|
|
58
|
+
/** Counts a float value (4 bytes). */
|
|
59
|
+
writeFloat(_value) {
|
|
60
|
+
this.pos += 4;
|
|
61
|
+
}
|
|
62
|
+
/** Counts a double value (8 bytes). */
|
|
63
|
+
writeDouble(_value) {
|
|
64
|
+
this.pos += 8;
|
|
65
|
+
}
|
|
66
|
+
/** Counts a fixed-length byte sequence. */
|
|
67
|
+
writeFixed(buf) {
|
|
68
|
+
this.pos += buf.length;
|
|
69
|
+
}
|
|
70
|
+
/** Counts a length-prefixed byte sequence. */
|
|
71
|
+
writeBytes(buf) {
|
|
72
|
+
const len = buf.length;
|
|
73
|
+
this.writeLong(BigInt(len));
|
|
74
|
+
this.pos += len;
|
|
75
|
+
}
|
|
76
|
+
/** Counts a length-prefixed UTF-8 string. */
|
|
77
|
+
writeString(str) {
|
|
78
|
+
const len = utf8ByteLength(str);
|
|
79
|
+
this.writeLong(BigInt(len));
|
|
80
|
+
this.pos += len;
|
|
81
|
+
}
|
|
82
|
+
/** Counts raw binary bytes without length prefix. */
|
|
83
|
+
writeBinary(_str, len) {
|
|
84
|
+
if (len > 0)
|
|
85
|
+
this.pos += len;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { SyncDecoder } from "./decoder_sync.js";
|
|
2
|
+
/**
|
|
3
|
+
* Built-in sync null decoder that returns data unchanged.
|
|
4
|
+
*/
|
|
5
|
+
export declare class NullDecoderSync implements SyncDecoder {
|
|
6
|
+
/**
|
|
7
|
+
* Decodes data by returning the same buffer.
|
|
8
|
+
* @param compressedData The input data.
|
|
9
|
+
* @returns The same data buffer.
|
|
10
|
+
*/
|
|
11
|
+
decode(compressedData: Uint8Array): Uint8Array;
|
|
12
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in sync null decoder that returns data unchanged.
|
|
3
|
+
*/
|
|
4
|
+
export class NullDecoderSync {
|
|
5
|
+
/**
|
|
6
|
+
* Decodes data by returning the same buffer.
|
|
7
|
+
* @param compressedData The input data.
|
|
8
|
+
* @returns The same data buffer.
|
|
9
|
+
*/
|
|
10
|
+
decode(compressedData) {
|
|
11
|
+
return compressedData;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interface for custom synchronous Avro codec decoders.
|
|
3
|
+
*/
|
|
4
|
+
export interface SyncDecoder {
|
|
5
|
+
/**
|
|
6
|
+
* Decompresses the compressed block synchronously.
|
|
7
|
+
* @param compressedData The compressed block data.
|
|
8
|
+
* @returns The decompressed bytes.
|
|
9
|
+
*/
|
|
10
|
+
decode(compressedData: Uint8Array): Uint8Array;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Registry mapping codec names to synchronous decoder implementations.
|
|
14
|
+
*/
|
|
15
|
+
export type SyncDecoderRegistry = Record<string, SyncDecoder>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { SyncEncoder } from "./encoder_sync.js";
|
|
2
|
+
/**
|
|
3
|
+
* Built-in sync null encoder (no compression).
|
|
4
|
+
*/
|
|
5
|
+
export declare class NullEncoderSync implements SyncEncoder {
|
|
6
|
+
/**
|
|
7
|
+
* Encodes data by returning the buffer unchanged.
|
|
8
|
+
* @param uncompressedData The data to encode.
|
|
9
|
+
* @returns The same data buffer.
|
|
10
|
+
*/
|
|
11
|
+
encode(uncompressedData: Uint8Array): Uint8Array;
|
|
12
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Built-in sync null encoder (no compression).
|
|
3
|
+
*/
|
|
4
|
+
export class NullEncoderSync {
|
|
5
|
+
/**
|
|
6
|
+
* Encodes data by returning the buffer unchanged.
|
|
7
|
+
* @param uncompressedData The data to encode.
|
|
8
|
+
* @returns The same data buffer.
|
|
9
|
+
*/
|
|
10
|
+
encode(uncompressedData) {
|
|
11
|
+
return uncompressedData;
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Interface for custom synchronous Avro codec encoders.
|
|
3
|
+
*/
|
|
4
|
+
export interface SyncEncoder {
|
|
5
|
+
/**
|
|
6
|
+
* Compresses the data synchronously using the codec's algorithm.
|
|
7
|
+
* @param uncompressedData Raw block data to compress.
|
|
8
|
+
* @returns The compressed result.
|
|
9
|
+
*/
|
|
10
|
+
encode(uncompressedData: Uint8Array): Uint8Array;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Registry of codec names to sync encoder implementations.
|
|
14
|
+
*/
|
|
15
|
+
export type SyncEncoderRegistry = Record<string, SyncEncoder>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -40,9 +40,10 @@ export declare class FixedSizeStreamReadableBufferAdapter implements IReadableBu
|
|
|
40
40
|
*
|
|
41
41
|
* @param offset The byte offset to start reading from (0-based, stream-relative)
|
|
42
42
|
* @param size The number of bytes to read
|
|
43
|
-
* @returns A Promise that resolves to a new Uint8Array containing the read bytes
|
|
43
|
+
* @returns A Promise that resolves to a new Uint8Array containing the read bytes.
|
|
44
|
+
* @throws ReadBufferError if the requested range is out of bounds.
|
|
44
45
|
*/
|
|
45
|
-
read(offset: number, size: number): Promise<Uint8Array
|
|
46
|
+
read(offset: number, size: number): Promise<Uint8Array>;
|
|
46
47
|
/**
|
|
47
48
|
* Checks if more data can be read starting at the given offset.
|
|
48
49
|
* @param offset The byte offset to check.
|
|
@@ -10,6 +10,7 @@ var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (
|
|
|
10
10
|
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
11
|
};
|
|
12
12
|
var _FixedSizeStreamReadableBufferAdapter_instances, _FixedSizeStreamReadableBufferAdapter_streamBuffer, _FixedSizeStreamReadableBufferAdapter_windowSize, _FixedSizeStreamReadableBufferAdapter_circularBuffer, _FixedSizeStreamReadableBufferAdapter_eof, _FixedSizeStreamReadableBufferAdapter_extractFromBuffer, _FixedSizeStreamReadableBufferAdapter_fillBuffer;
|
|
13
|
+
import { ReadBufferError } from "../buffers/buffer_error.js";
|
|
13
14
|
import { CircularBuffer } from "../../internal/collections/circular_buffer.js";
|
|
14
15
|
/**
|
|
15
16
|
* A limited buffer adapter that maintains a rolling window of stream data.
|
|
@@ -65,19 +66,20 @@ export class FixedSizeStreamReadableBufferAdapter {
|
|
|
65
66
|
*
|
|
66
67
|
* @param offset The byte offset to start reading from (0-based, stream-relative)
|
|
67
68
|
* @param size The number of bytes to read
|
|
68
|
-
* @returns A Promise that resolves to a new Uint8Array containing the read bytes
|
|
69
|
+
* @returns A Promise that resolves to a new Uint8Array containing the read bytes.
|
|
70
|
+
* @throws ReadBufferError if the requested range is out of bounds.
|
|
69
71
|
*/
|
|
70
72
|
async read(offset, size) {
|
|
71
73
|
if (offset < 0 || size < 0) {
|
|
72
|
-
|
|
74
|
+
throw new ReadBufferError(`Offset and size must be non-negative. Got offset=${offset}, size=${size}`, offset, size, __classPrivateFieldGet(this, _FixedSizeStreamReadableBufferAdapter_circularBuffer, "f").windowEnd());
|
|
73
75
|
}
|
|
74
76
|
// Check if requested size exceeds window size - throw error immediately
|
|
75
77
|
if (size > __classPrivateFieldGet(this, _FixedSizeStreamReadableBufferAdapter_windowSize, "f")) {
|
|
76
|
-
throw new
|
|
78
|
+
throw new ReadBufferError(`Requested size ${size} exceeds window size ${__classPrivateFieldGet(this, _FixedSizeStreamReadableBufferAdapter_windowSize, "f")}`, offset, size, __classPrivateFieldGet(this, _FixedSizeStreamReadableBufferAdapter_windowSize, "f"));
|
|
77
79
|
}
|
|
78
80
|
// Check if offset is before the current window start - raise error
|
|
79
81
|
if (offset < __classPrivateFieldGet(this, _FixedSizeStreamReadableBufferAdapter_circularBuffer, "f").windowStart()) {
|
|
80
|
-
throw new
|
|
82
|
+
throw new ReadBufferError(`Cannot read data before window start. Offset ${offset} is before window start ${__classPrivateFieldGet(this, _FixedSizeStreamReadableBufferAdapter_circularBuffer, "f").windowStart()}`, offset, size, __classPrivateFieldGet(this, _FixedSizeStreamReadableBufferAdapter_circularBuffer, "f").windowEnd());
|
|
81
83
|
}
|
|
82
84
|
// Check if data is already in cache
|
|
83
85
|
if (offset + size <= __classPrivateFieldGet(this, _FixedSizeStreamReadableBufferAdapter_circularBuffer, "f").windowEnd()) {
|
|
@@ -88,7 +90,7 @@ export class FixedSizeStreamReadableBufferAdapter {
|
|
|
88
90
|
await __classPrivateFieldGet(this, _FixedSizeStreamReadableBufferAdapter_instances, "m", _FixedSizeStreamReadableBufferAdapter_fillBuffer).call(this, offset + size);
|
|
89
91
|
// Check if the requested range is available after filling
|
|
90
92
|
if (offset + size > __classPrivateFieldGet(this, _FixedSizeStreamReadableBufferAdapter_circularBuffer, "f").windowEnd()) {
|
|
91
|
-
|
|
93
|
+
throw new ReadBufferError(`Operation exceeds buffer bounds. offset=${offset}, size=${size}, bufferLength=${__classPrivateFieldGet(this, _FixedSizeStreamReadableBufferAdapter_circularBuffer, "f").windowEnd()}`, offset, size, __classPrivateFieldGet(this, _FixedSizeStreamReadableBufferAdapter_circularBuffer, "f").windowEnd());
|
|
92
94
|
}
|
|
93
95
|
// Extract data from buffer
|
|
94
96
|
return __classPrivateFieldGet(this, _FixedSizeStreamReadableBufferAdapter_instances, "m", _FixedSizeStreamReadableBufferAdapter_extractFromBuffer).call(this, offset, size);
|
|
@@ -99,8 +101,16 @@ export class FixedSizeStreamReadableBufferAdapter {
|
|
|
99
101
|
* @returns True if at least one byte can be read from the offset.
|
|
100
102
|
*/
|
|
101
103
|
async canReadMore(offset) {
|
|
102
|
-
|
|
103
|
-
|
|
104
|
+
try {
|
|
105
|
+
await this.read(offset, 1);
|
|
106
|
+
return true;
|
|
107
|
+
}
|
|
108
|
+
catch (err) {
|
|
109
|
+
if (err instanceof ReadBufferError) {
|
|
110
|
+
return false;
|
|
111
|
+
}
|
|
112
|
+
throw err;
|
|
113
|
+
}
|
|
104
114
|
}
|
|
105
115
|
}
|
|
106
116
|
_FixedSizeStreamReadableBufferAdapter_streamBuffer = new WeakMap(), _FixedSizeStreamReadableBufferAdapter_windowSize = new WeakMap(), _FixedSizeStreamReadableBufferAdapter_circularBuffer = new WeakMap(), _FixedSizeStreamReadableBufferAdapter_eof = new WeakMap(), _FixedSizeStreamReadableBufferAdapter_instances = new WeakSet(), _FixedSizeStreamReadableBufferAdapter_extractFromBuffer = function _FixedSizeStreamReadableBufferAdapter_extractFromBuffer(offset, size) {
|
|
@@ -120,8 +130,8 @@ async function _FixedSizeStreamReadableBufferAdapter_fillBuffer(targetOffset) {
|
|
|
120
130
|
__classPrivateFieldGet(this, _FixedSizeStreamReadableBufferAdapter_circularBuffer, "f").push(chunk);
|
|
121
131
|
}
|
|
122
132
|
catch (error) {
|
|
123
|
-
if (error instanceof
|
|
124
|
-
throw new
|
|
133
|
+
if (error instanceof ReadBufferError) {
|
|
134
|
+
throw new ReadBufferError(`Cannot buffer chunk of size ${chunk.length}: ${error.message}`, __classPrivateFieldGet(this, _FixedSizeStreamReadableBufferAdapter_circularBuffer, "f").windowEnd(), chunk.length, __classPrivateFieldGet(this, _FixedSizeStreamReadableBufferAdapter_windowSize, "f"));
|
|
125
135
|
}
|
|
126
136
|
throw error;
|
|
127
137
|
}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import type { ISyncStreamReadableBuffer } from "./streams_sync.js";
|
|
2
|
+
/**
|
|
3
|
+
* Simple synchronous stream reader backed by a fixed-size Uint8Array.
|
|
4
|
+
* Data is delivered sequentially in fixed-size chunks until the buffer is exhausted.
|
|
5
|
+
*/
|
|
6
|
+
export declare class SyncFixedSizeStreamReader implements ISyncStreamReadableBuffer {
|
|
7
|
+
#private;
|
|
8
|
+
/**
|
|
9
|
+
* Creates a new fixed-size reader.
|
|
10
|
+
*
|
|
11
|
+
* @param source The source data to read from.
|
|
12
|
+
* @param chunkSize The maximum chunk size to return per readNext call.
|
|
13
|
+
*/
|
|
14
|
+
constructor(source: Uint8Array, chunkSize: number);
|
|
15
|
+
/**
|
|
16
|
+
* Reads the next chunk of data from the underlying source.
|
|
17
|
+
*
|
|
18
|
+
* @returns The next Uint8Array chunk, or undefined if the stream is exhausted or closed.
|
|
19
|
+
*/
|
|
20
|
+
readNext(): Uint8Array | undefined;
|
|
21
|
+
/**
|
|
22
|
+
* Closes the reader and prevents further reads.
|
|
23
|
+
*/
|
|
24
|
+
close(): void;
|
|
25
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var _SyncFixedSizeStreamReader_source, _SyncFixedSizeStreamReader_chunkSize, _SyncFixedSizeStreamReader_offset, _SyncFixedSizeStreamReader_isClosed;
|
|
13
|
+
/**
|
|
14
|
+
* Simple synchronous stream reader backed by a fixed-size Uint8Array.
|
|
15
|
+
* Data is delivered sequentially in fixed-size chunks until the buffer is exhausted.
|
|
16
|
+
*/
|
|
17
|
+
export class SyncFixedSizeStreamReader {
|
|
18
|
+
/**
|
|
19
|
+
* Creates a new fixed-size reader.
|
|
20
|
+
*
|
|
21
|
+
* @param source The source data to read from.
|
|
22
|
+
* @param chunkSize The maximum chunk size to return per readNext call.
|
|
23
|
+
*/
|
|
24
|
+
constructor(source, chunkSize) {
|
|
25
|
+
_SyncFixedSizeStreamReader_source.set(this, void 0);
|
|
26
|
+
_SyncFixedSizeStreamReader_chunkSize.set(this, void 0);
|
|
27
|
+
_SyncFixedSizeStreamReader_offset.set(this, 0);
|
|
28
|
+
_SyncFixedSizeStreamReader_isClosed.set(this, false);
|
|
29
|
+
if (chunkSize <= 0) {
|
|
30
|
+
throw new RangeError("chunkSize must be positive");
|
|
31
|
+
}
|
|
32
|
+
__classPrivateFieldSet(this, _SyncFixedSizeStreamReader_source, source, "f");
|
|
33
|
+
__classPrivateFieldSet(this, _SyncFixedSizeStreamReader_chunkSize, chunkSize, "f");
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Reads the next chunk of data from the underlying source.
|
|
37
|
+
*
|
|
38
|
+
* @returns The next Uint8Array chunk, or undefined if the stream is exhausted or closed.
|
|
39
|
+
*/
|
|
40
|
+
readNext() {
|
|
41
|
+
if (__classPrivateFieldGet(this, _SyncFixedSizeStreamReader_isClosed, "f") || __classPrivateFieldGet(this, _SyncFixedSizeStreamReader_offset, "f") >= __classPrivateFieldGet(this, _SyncFixedSizeStreamReader_source, "f").length) {
|
|
42
|
+
return undefined;
|
|
43
|
+
}
|
|
44
|
+
const remaining = __classPrivateFieldGet(this, _SyncFixedSizeStreamReader_source, "f").length - __classPrivateFieldGet(this, _SyncFixedSizeStreamReader_offset, "f");
|
|
45
|
+
const size = Math.min(__classPrivateFieldGet(this, _SyncFixedSizeStreamReader_chunkSize, "f"), remaining);
|
|
46
|
+
const chunk = __classPrivateFieldGet(this, _SyncFixedSizeStreamReader_source, "f").slice(__classPrivateFieldGet(this, _SyncFixedSizeStreamReader_offset, "f"), __classPrivateFieldGet(this, _SyncFixedSizeStreamReader_offset, "f") + size);
|
|
47
|
+
__classPrivateFieldSet(this, _SyncFixedSizeStreamReader_offset, __classPrivateFieldGet(this, _SyncFixedSizeStreamReader_offset, "f") + size, "f");
|
|
48
|
+
return chunk;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Closes the reader and prevents further reads.
|
|
52
|
+
*/
|
|
53
|
+
close() {
|
|
54
|
+
__classPrivateFieldSet(this, _SyncFixedSizeStreamReader_isClosed, true, "f");
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* @internal test helper exposing the current read offset.
|
|
58
|
+
*/
|
|
59
|
+
_testOnlyOffset() {
|
|
60
|
+
return __classPrivateFieldGet(this, _SyncFixedSizeStreamReader_offset, "f");
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
_SyncFixedSizeStreamReader_source = new WeakMap(), _SyncFixedSizeStreamReader_chunkSize = new WeakMap(), _SyncFixedSizeStreamReader_offset = new WeakMap(), _SyncFixedSizeStreamReader_isClosed = new WeakMap();
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import type { ISyncStreamWritableBuffer } from "./streams_sync.js";
|
|
2
|
+
/**
|
|
3
|
+
* Simple synchronous stream writer backed by a fixed-size Uint8Array.
|
|
4
|
+
* Writes append sequentially until the buffer reaches capacity.
|
|
5
|
+
*/
|
|
6
|
+
export declare class SyncFixedSizeStreamWriter implements ISyncStreamWritableBuffer {
|
|
7
|
+
#private;
|
|
8
|
+
/**
|
|
9
|
+
* Creates a new fixed-size writer.
|
|
10
|
+
*
|
|
11
|
+
* @param target The target buffer to write into.
|
|
12
|
+
*/
|
|
13
|
+
constructor(target: Uint8Array);
|
|
14
|
+
/**
|
|
15
|
+
* Writes bytes to the underlying target buffer.
|
|
16
|
+
*
|
|
17
|
+
* @param data The bytes to write.
|
|
18
|
+
* @throws WriteBufferError If the write would exceed the buffer capacity.
|
|
19
|
+
* @throws Error If the writer has been closed.
|
|
20
|
+
*/
|
|
21
|
+
writeBytes(data: Uint8Array): void;
|
|
22
|
+
/**
|
|
23
|
+
* Writes a slice of bytes to the underlying target buffer.
|
|
24
|
+
*
|
|
25
|
+
* @param data The source bytes.
|
|
26
|
+
* @param offset The starting offset in data.
|
|
27
|
+
* @param length The number of bytes to write.
|
|
28
|
+
* @throws RangeError If the source range parameters are invalid.
|
|
29
|
+
* @throws WriteBufferError If the write would exceed the buffer capacity.
|
|
30
|
+
* @throws Error If the writer has been closed.
|
|
31
|
+
*/
|
|
32
|
+
writeBytesFrom(data: Uint8Array, offset: number, length: number): void;
|
|
33
|
+
/**
|
|
34
|
+
* Closes the writer and prevents further writes.
|
|
35
|
+
*/
|
|
36
|
+
close(): void;
|
|
37
|
+
/**
|
|
38
|
+
* Returns a copy of the bytes written to the underlying target buffer.
|
|
39
|
+
*/
|
|
40
|
+
toUint8Array(): Uint8Array;
|
|
41
|
+
/**
|
|
42
|
+
* Returns the remaining capacity of the writer.
|
|
43
|
+
*/
|
|
44
|
+
remaining(): number;
|
|
45
|
+
}
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
2
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
3
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
4
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
5
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
6
|
+
};
|
|
7
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
8
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
9
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
10
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
11
|
+
};
|
|
12
|
+
var _SyncFixedSizeStreamWriter_target, _SyncFixedSizeStreamWriter_offset, _SyncFixedSizeStreamWriter_isClosed;
|
|
13
|
+
import { WriteBufferError } from "../buffers/buffer_sync.js";
|
|
14
|
+
/**
|
|
15
|
+
* Simple synchronous stream writer backed by a fixed-size Uint8Array.
|
|
16
|
+
* Writes append sequentially until the buffer reaches capacity.
|
|
17
|
+
*/
|
|
18
|
+
export class SyncFixedSizeStreamWriter {
|
|
19
|
+
/**
|
|
20
|
+
* Creates a new fixed-size writer.
|
|
21
|
+
*
|
|
22
|
+
* @param target The target buffer to write into.
|
|
23
|
+
*/
|
|
24
|
+
constructor(target) {
|
|
25
|
+
_SyncFixedSizeStreamWriter_target.set(this, void 0);
|
|
26
|
+
_SyncFixedSizeStreamWriter_offset.set(this, 0);
|
|
27
|
+
_SyncFixedSizeStreamWriter_isClosed.set(this, false);
|
|
28
|
+
__classPrivateFieldSet(this, _SyncFixedSizeStreamWriter_target, target, "f");
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Writes bytes to the underlying target buffer.
|
|
32
|
+
*
|
|
33
|
+
* @param data The bytes to write.
|
|
34
|
+
* @throws WriteBufferError If the write would exceed the buffer capacity.
|
|
35
|
+
* @throws Error If the writer has been closed.
|
|
36
|
+
*/
|
|
37
|
+
writeBytes(data) {
|
|
38
|
+
if (__classPrivateFieldGet(this, _SyncFixedSizeStreamWriter_isClosed, "f")) {
|
|
39
|
+
throw new Error("Cannot write to a closed writer");
|
|
40
|
+
}
|
|
41
|
+
if (data.length === 0) {
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
if (__classPrivateFieldGet(this, _SyncFixedSizeStreamWriter_offset, "f") + data.length > __classPrivateFieldGet(this, _SyncFixedSizeStreamWriter_target, "f").length) {
|
|
45
|
+
throw new WriteBufferError("Write operation exceeds buffer capacity", __classPrivateFieldGet(this, _SyncFixedSizeStreamWriter_offset, "f"), data.length, __classPrivateFieldGet(this, _SyncFixedSizeStreamWriter_target, "f").length);
|
|
46
|
+
}
|
|
47
|
+
__classPrivateFieldGet(this, _SyncFixedSizeStreamWriter_target, "f").set(data, __classPrivateFieldGet(this, _SyncFixedSizeStreamWriter_offset, "f"));
|
|
48
|
+
__classPrivateFieldSet(this, _SyncFixedSizeStreamWriter_offset, __classPrivateFieldGet(this, _SyncFixedSizeStreamWriter_offset, "f") + data.length, "f");
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Writes a slice of bytes to the underlying target buffer.
|
|
52
|
+
*
|
|
53
|
+
* @param data The source bytes.
|
|
54
|
+
* @param offset The starting offset in data.
|
|
55
|
+
* @param length The number of bytes to write.
|
|
56
|
+
* @throws RangeError If the source range parameters are invalid.
|
|
57
|
+
* @throws WriteBufferError If the write would exceed the buffer capacity.
|
|
58
|
+
* @throws Error If the writer has been closed.
|
|
59
|
+
*/
|
|
60
|
+
writeBytesFrom(data, offset, length) {
|
|
61
|
+
if (__classPrivateFieldGet(this, _SyncFixedSizeStreamWriter_isClosed, "f")) {
|
|
62
|
+
throw new Error("Cannot write to a closed writer");
|
|
63
|
+
}
|
|
64
|
+
if (length === 0) {
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (!Number.isInteger(offset) || !Number.isInteger(length) ||
|
|
68
|
+
offset < 0 || length < 0 || offset + length > data.length) {
|
|
69
|
+
throw new RangeError(`Invalid source range offset=${offset} length=${length} for dataSize=${data.length}`);
|
|
70
|
+
}
|
|
71
|
+
if (__classPrivateFieldGet(this, _SyncFixedSizeStreamWriter_offset, "f") + length > __classPrivateFieldGet(this, _SyncFixedSizeStreamWriter_target, "f").length) {
|
|
72
|
+
throw new WriteBufferError("Write operation exceeds buffer capacity", __classPrivateFieldGet(this, _SyncFixedSizeStreamWriter_offset, "f"), length, __classPrivateFieldGet(this, _SyncFixedSizeStreamWriter_target, "f").length);
|
|
73
|
+
}
|
|
74
|
+
for (let i = 0; i < length; i++) {
|
|
75
|
+
__classPrivateFieldGet(this, _SyncFixedSizeStreamWriter_target, "f")[__classPrivateFieldGet(this, _SyncFixedSizeStreamWriter_offset, "f") + i] = data[offset + i];
|
|
76
|
+
}
|
|
77
|
+
__classPrivateFieldSet(this, _SyncFixedSizeStreamWriter_offset, __classPrivateFieldGet(this, _SyncFixedSizeStreamWriter_offset, "f") + length, "f");
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Closes the writer and prevents further writes.
|
|
81
|
+
*/
|
|
82
|
+
close() {
|
|
83
|
+
__classPrivateFieldSet(this, _SyncFixedSizeStreamWriter_isClosed, true, "f");
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Returns a copy of the bytes written to the underlying target buffer.
|
|
87
|
+
*/
|
|
88
|
+
toUint8Array() {
|
|
89
|
+
return __classPrivateFieldGet(this, _SyncFixedSizeStreamWriter_target, "f").slice(0, __classPrivateFieldGet(this, _SyncFixedSizeStreamWriter_offset, "f"));
|
|
90
|
+
}
|
|
91
|
+
/**
|
|
92
|
+
* Returns the remaining capacity of the writer.
|
|
93
|
+
*/
|
|
94
|
+
remaining() {
|
|
95
|
+
return __classPrivateFieldGet(this, _SyncFixedSizeStreamWriter_target, "f").length - __classPrivateFieldGet(this, _SyncFixedSizeStreamWriter_offset, "f");
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
_SyncFixedSizeStreamWriter_target = new WeakMap(), _SyncFixedSizeStreamWriter_offset = new WeakMap(), _SyncFixedSizeStreamWriter_isClosed = new WeakMap();
|