bare-buffer 2.7.0 → 3.0.0-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/binding.c +44 -105
- package/index.d.ts +181 -0
- package/index.js +47 -8
- package/lib/constants.js +1 -1
- package/package.json +10 -3
- package/prebuilds/android-arm/bare-buffer.bare +0 -0
- package/prebuilds/android-arm64/bare-buffer.bare +0 -0
- package/prebuilds/android-ia32/bare-buffer.bare +0 -0
- package/prebuilds/android-x64/bare-buffer.bare +0 -0
- package/prebuilds/darwin-arm64/bare-buffer.bare +0 -0
- package/prebuilds/darwin-x64/bare-buffer.bare +0 -0
- package/prebuilds/ios-arm64/bare-buffer.bare +0 -0
- package/prebuilds/ios-arm64-simulator/bare-buffer.bare +0 -0
- package/prebuilds/ios-x64-simulator/bare-buffer.bare +0 -0
- package/prebuilds/linux-arm64/bare-buffer.bare +0 -0
- package/prebuilds/linux-x64/bare-buffer.bare +0 -0
- package/prebuilds/win32-arm64/bare-buffer.bare +0 -0
- package/prebuilds/win32-x64/bare-buffer.bare +0 -0
package/binding.c
CHANGED
|
@@ -10,13 +10,8 @@
|
|
|
10
10
|
|
|
11
11
|
static js_type_tag_t bare_buffer__tag = {0xfea3e944b70b0812, 0xe53bb5c343c040b6};
|
|
12
12
|
|
|
13
|
-
static void
|
|
14
|
-
bare_buffer_set_zero_fill_enabled_fast (js_ffi_receiver_t *receiver, uint32_t enabled) {
|
|
15
|
-
js_set_arraybuffer_zero_fill_enabled(enabled != 0);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
13
|
static js_value_t *
|
|
19
|
-
|
|
14
|
+
bare_buffer_alloc (js_env_t *env, js_callback_info_t *info) {
|
|
20
15
|
int err;
|
|
21
16
|
|
|
22
17
|
size_t argc = 1;
|
|
@@ -27,18 +22,38 @@ bare_buffer_set_zero_fill_enabled (js_env_t *env, js_callback_info_t *info) {
|
|
|
27
22
|
|
|
28
23
|
assert(argc == 1);
|
|
29
24
|
|
|
30
|
-
uint32_t
|
|
31
|
-
err = js_get_value_uint32(env, argv[0], &
|
|
25
|
+
uint32_t len;
|
|
26
|
+
err = js_get_value_uint32(env, argv[0], &len);
|
|
32
27
|
assert(err == 0);
|
|
33
28
|
|
|
34
|
-
|
|
29
|
+
js_value_t *result;
|
|
30
|
+
err = js_create_arraybuffer(env, len, NULL, &result);
|
|
31
|
+
assert(err == 0);
|
|
35
32
|
|
|
36
|
-
return
|
|
33
|
+
return result;
|
|
37
34
|
}
|
|
38
35
|
|
|
39
|
-
static
|
|
40
|
-
|
|
41
|
-
|
|
36
|
+
static js_value_t *
|
|
37
|
+
bare_buffer_alloc_unsafe (js_env_t *env, js_callback_info_t *info) {
|
|
38
|
+
int err;
|
|
39
|
+
|
|
40
|
+
size_t argc = 1;
|
|
41
|
+
js_value_t *argv[1];
|
|
42
|
+
|
|
43
|
+
err = js_get_callback_info(env, info, &argc, argv, NULL, NULL);
|
|
44
|
+
assert(err == 0);
|
|
45
|
+
|
|
46
|
+
assert(argc == 1);
|
|
47
|
+
|
|
48
|
+
uint32_t len;
|
|
49
|
+
err = js_get_value_uint32(env, argv[0], &len);
|
|
50
|
+
assert(err == 0);
|
|
51
|
+
|
|
52
|
+
js_value_t *result;
|
|
53
|
+
err = js_create_unsafe_arraybuffer(env, len, NULL, &result);
|
|
54
|
+
assert(err == 0);
|
|
55
|
+
|
|
56
|
+
return result;
|
|
42
57
|
}
|
|
43
58
|
|
|
44
59
|
static js_value_t *
|
|
@@ -329,11 +344,6 @@ bare_buffer__compare (void *a, size_t a_len, void *b, size_t b_len) {
|
|
|
329
344
|
return r < 0 ? -1 : 1;
|
|
330
345
|
}
|
|
331
346
|
|
|
332
|
-
static int32_t
|
|
333
|
-
bare_buffer_compare_fast (js_ffi_receiver_t *recv, js_ffi_typedarray_t *a, js_ffi_typedarray_t *b) {
|
|
334
|
-
return bare_buffer__compare(a->data.u8, a->len, b->data.u8, b->len);
|
|
335
|
-
}
|
|
336
|
-
|
|
337
347
|
static js_value_t *
|
|
338
348
|
bare_buffer_compare (js_env_t *env, js_callback_info_t *info) {
|
|
339
349
|
int err;
|
|
@@ -408,105 +418,34 @@ static js_value_t *
|
|
|
408
418
|
bare_buffer_exports (js_env_t *env, js_value_t *exports) {
|
|
409
419
|
int err;
|
|
410
420
|
|
|
411
|
-
#define V(name, fn
|
|
421
|
+
#define V(name, fn) \
|
|
412
422
|
{ \
|
|
413
423
|
js_value_t *val; \
|
|
414
|
-
|
|
415
|
-
err = js_create_function_with_ffi(env, name, -1, fn, NULL, ffi, &val); \
|
|
416
|
-
} else { \
|
|
417
|
-
err = js_create_function(env, name, -1, fn, NULL, &val); \
|
|
418
|
-
} \
|
|
424
|
+
err = js_create_function(env, name, -1, fn, NULL, &val); \
|
|
419
425
|
assert(err == 0); \
|
|
420
426
|
err = js_set_named_property(env, exports, name, val); \
|
|
421
427
|
assert(err == 0); \
|
|
422
428
|
}
|
|
423
429
|
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
err = js_ffi_create_type_info(js_ffi_void, &return_info);
|
|
427
|
-
assert(err == 0);
|
|
428
|
-
|
|
429
|
-
js_ffi_type_info_t *arg_info[2];
|
|
430
|
-
|
|
431
|
-
err = js_ffi_create_type_info(js_ffi_receiver, &arg_info[0]);
|
|
432
|
-
assert(err == 0);
|
|
433
|
-
|
|
434
|
-
err = js_ffi_create_type_info(js_ffi_uint32, &arg_info[1]);
|
|
435
|
-
assert(err == 0);
|
|
436
|
-
|
|
437
|
-
js_ffi_function_info_t *function_info;
|
|
438
|
-
err = js_ffi_create_function_info(return_info, arg_info, 2, &function_info);
|
|
439
|
-
assert(err == 0);
|
|
440
|
-
|
|
441
|
-
js_ffi_function_t *ffi;
|
|
442
|
-
err = js_ffi_create_function(bare_buffer_set_zero_fill_enabled_fast, function_info, &ffi);
|
|
443
|
-
assert(err == 0);
|
|
444
|
-
|
|
445
|
-
V("setZeroFillEnabled", bare_buffer_set_zero_fill_enabled, ffi);
|
|
446
|
-
}
|
|
447
|
-
|
|
448
|
-
{
|
|
449
|
-
js_ffi_type_info_t *return_info;
|
|
450
|
-
err = js_ffi_create_type_info(js_ffi_int32, &return_info);
|
|
451
|
-
assert(err == 0);
|
|
452
|
-
|
|
453
|
-
js_ffi_type_info_t *arg_info[2];
|
|
454
|
-
|
|
455
|
-
err = js_ffi_create_type_info(js_ffi_receiver, &arg_info[0]);
|
|
456
|
-
assert(err == 0);
|
|
430
|
+
V("alloc", bare_buffer_alloc);
|
|
431
|
+
V("allocUnsafe", bare_buffer_alloc_unsafe);
|
|
457
432
|
|
|
458
|
-
|
|
459
|
-
|
|
433
|
+
V("byteLengthUTF8", bare_buffer_byte_length_utf8);
|
|
434
|
+
V("toStringUTF8", bare_buffer_to_string_utf8);
|
|
435
|
+
V("writeUTF8", bare_buffer_write_utf8);
|
|
460
436
|
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
assert(err == 0);
|
|
437
|
+
V("toStringUTF16LE", bare_buffer_to_string_utf16le);
|
|
438
|
+
V("writeUTF16LE", bare_buffer_write_utf16le);
|
|
464
439
|
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
assert(err == 0);
|
|
440
|
+
V("toStringBase64", bare_buffer_to_string_base64);
|
|
441
|
+
V("writeBase64", bare_buffer_write_base64);
|
|
468
442
|
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
V("toStringUTF8", bare_buffer_to_string_utf8, NULL);
|
|
473
|
-
V("writeUTF8", bare_buffer_write_utf8, NULL);
|
|
474
|
-
V("toStringUTF16LE", bare_buffer_to_string_utf16le, NULL);
|
|
475
|
-
V("writeUTF16LE", bare_buffer_write_utf16le, NULL);
|
|
476
|
-
V("toStringBase64", bare_buffer_to_string_base64, NULL);
|
|
477
|
-
V("writeBase64", bare_buffer_write_base64, NULL);
|
|
478
|
-
V("toStringHex", bare_buffer_to_string_hex, NULL);
|
|
479
|
-
V("writeHex", bare_buffer_write_hex, NULL);
|
|
480
|
-
|
|
481
|
-
{
|
|
482
|
-
js_ffi_type_info_t *return_info;
|
|
483
|
-
err = js_ffi_create_type_info(js_ffi_int32, &return_info);
|
|
484
|
-
assert(err == 0);
|
|
485
|
-
|
|
486
|
-
js_ffi_type_info_t *arg_info[3];
|
|
487
|
-
|
|
488
|
-
err = js_ffi_create_type_info(js_ffi_receiver, &arg_info[0]);
|
|
489
|
-
assert(err == 0);
|
|
490
|
-
|
|
491
|
-
err = js_ffi_create_type_info(js_ffi_uint8array, &arg_info[1]);
|
|
492
|
-
assert(err == 0);
|
|
493
|
-
|
|
494
|
-
err = js_ffi_create_type_info(js_ffi_uint8array, &arg_info[2]);
|
|
495
|
-
assert(err == 0);
|
|
496
|
-
|
|
497
|
-
js_ffi_function_info_t *function_info;
|
|
498
|
-
err = js_ffi_create_function_info(return_info, arg_info, 3, &function_info);
|
|
499
|
-
assert(err == 0);
|
|
500
|
-
|
|
501
|
-
js_ffi_function_t *ffi;
|
|
502
|
-
err = js_ffi_create_function(bare_buffer_compare_fast, function_info, &ffi);
|
|
503
|
-
assert(err == 0);
|
|
504
|
-
|
|
505
|
-
V("compare", bare_buffer_compare, ffi);
|
|
506
|
-
}
|
|
443
|
+
V("toStringHex", bare_buffer_to_string_hex);
|
|
444
|
+
V("writeHex", bare_buffer_write_hex);
|
|
507
445
|
|
|
508
|
-
V("
|
|
509
|
-
V("
|
|
446
|
+
V("compare", bare_buffer_compare);
|
|
447
|
+
V("tag", bare_buffer_tag);
|
|
448
|
+
V("isTagged", bare_buffer_is_tagged);
|
|
510
449
|
#undef V
|
|
511
450
|
|
|
512
451
|
return exports;
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
type BufferEncoding =
|
|
2
|
+
| 'ascii'
|
|
3
|
+
| 'base64'
|
|
4
|
+
| 'hex'
|
|
5
|
+
| 'ucs-2'
|
|
6
|
+
| 'ucs2'
|
|
7
|
+
| 'utf-16le'
|
|
8
|
+
| 'utf-8'
|
|
9
|
+
| 'utf16le'
|
|
10
|
+
| 'utf8'
|
|
11
|
+
|
|
12
|
+
declare class Buffer extends Uint8Array {
|
|
13
|
+
compare(
|
|
14
|
+
target: Buffer,
|
|
15
|
+
targetStart?: number,
|
|
16
|
+
targetEnd?: number,
|
|
17
|
+
sourceStart?: number,
|
|
18
|
+
sourceEnd?: number
|
|
19
|
+
): number
|
|
20
|
+
|
|
21
|
+
copy(
|
|
22
|
+
target: Buffer,
|
|
23
|
+
targetStart?: number,
|
|
24
|
+
sourceStart?: number,
|
|
25
|
+
sourceEnd?: number
|
|
26
|
+
): number
|
|
27
|
+
|
|
28
|
+
equals(target: Buffer): boolean
|
|
29
|
+
|
|
30
|
+
fill(value: string, encoding?: BufferEncoding): this
|
|
31
|
+
fill(value: string, offset?: number, encoding?: BufferEncoding): this
|
|
32
|
+
fill(
|
|
33
|
+
value: string,
|
|
34
|
+
offset?: number,
|
|
35
|
+
end?: number,
|
|
36
|
+
encoding?: BufferEncoding
|
|
37
|
+
): this
|
|
38
|
+
fill(value: Buffer | number | boolean, offset?: number, end?: number): this
|
|
39
|
+
|
|
40
|
+
includes(value: string, encoding?: BufferEncoding): boolean
|
|
41
|
+
includes(value: string, offset?: number, encoding?: BufferEncoding): boolean
|
|
42
|
+
includes(value: Buffer | number | boolean, offset?: number): boolean
|
|
43
|
+
|
|
44
|
+
indexOf(value: string, encoding?: BufferEncoding): number
|
|
45
|
+
indexOf(value: string, offset?: number, encoding?: BufferEncoding): number
|
|
46
|
+
indexOf(value: Buffer | number | boolean, offset?: number): number
|
|
47
|
+
|
|
48
|
+
lastIndexOf(value: string, encoding?: BufferEncoding): number
|
|
49
|
+
lastIndexOf(value: string, offset?: number, encoding?: BufferEncoding): number
|
|
50
|
+
lastIndexOf(value: Buffer | number | boolean, offset?: number): number
|
|
51
|
+
|
|
52
|
+
swap16(): this
|
|
53
|
+
swap32(): this
|
|
54
|
+
swap64(): this
|
|
55
|
+
|
|
56
|
+
toString(encoding?: BufferEncoding, start?: number, end?: number): string
|
|
57
|
+
|
|
58
|
+
readDoubleBE(offset?: number): number
|
|
59
|
+
readDoubleLE(offset?: number): number
|
|
60
|
+
|
|
61
|
+
readFloatBE(offset?: number): number
|
|
62
|
+
readFloatLE(offset?: number): number
|
|
63
|
+
|
|
64
|
+
readInt8(offset?: number): number
|
|
65
|
+
|
|
66
|
+
readInt16BE(offset?: number): number
|
|
67
|
+
readInt16LE(offset?: number): number
|
|
68
|
+
|
|
69
|
+
readInt32BE(offset?: number): number
|
|
70
|
+
readInt32LE(offset?: number): number
|
|
71
|
+
|
|
72
|
+
readBigInt64BE(offset?: number): bigint
|
|
73
|
+
readBigInt64LE(offset?: number): bigint
|
|
74
|
+
|
|
75
|
+
readUInt8(offset?: number): number
|
|
76
|
+
readUint8(offset?: number): number
|
|
77
|
+
|
|
78
|
+
readUInt16BE(offset?: number): number
|
|
79
|
+
readUint16BE(offset?: number): number
|
|
80
|
+
readUInt16LE(offset?: number): number
|
|
81
|
+
readUint16LE(offset?: number): number
|
|
82
|
+
|
|
83
|
+
readUInt32BE(offset?: number): number
|
|
84
|
+
readUint32BE(offset?: number): number
|
|
85
|
+
readUInt32LE(offset?: number): number
|
|
86
|
+
readUint32LE(offset?: number): number
|
|
87
|
+
|
|
88
|
+
readBigUInt64BE(offset?: number): bigint
|
|
89
|
+
readBigUint64BE(offset?: number): bigint
|
|
90
|
+
readBigUInt64LE(offset?: number): bigint
|
|
91
|
+
readBigUint64LE(offset?: number): bigint
|
|
92
|
+
|
|
93
|
+
write(string: string, encoding?: BufferEncoding): number
|
|
94
|
+
write(string: string, offset?: number, encoding?: BufferEncoding): number
|
|
95
|
+
write(
|
|
96
|
+
string: string,
|
|
97
|
+
offset?: number,
|
|
98
|
+
length?: number,
|
|
99
|
+
encoding?: BufferEncoding
|
|
100
|
+
): number
|
|
101
|
+
|
|
102
|
+
writeDoubleBE(value: number, offset?: number): number
|
|
103
|
+
writeDoubleLE(value: number, offset?: number): number
|
|
104
|
+
|
|
105
|
+
writeFloatBE(value: number, offset?: number): number
|
|
106
|
+
writeFloatLE(value: number, offset?: number): number
|
|
107
|
+
|
|
108
|
+
writeInt8(value: number, offset?: number): number
|
|
109
|
+
|
|
110
|
+
writeInt16BE(value: number, offset?: number): number
|
|
111
|
+
writeInt16LE(value: number, offset?: number): number
|
|
112
|
+
|
|
113
|
+
writeInt32BE(value: number, offset?: number): number
|
|
114
|
+
writeInt32LE(value: number, offset?: number): number
|
|
115
|
+
|
|
116
|
+
writeBigInt64BE(value: bigint, offset?: number): number
|
|
117
|
+
writeBigInt64LE(value: bigint, offset?: number): number
|
|
118
|
+
|
|
119
|
+
writeUInt8(value: number, offset?: number): number
|
|
120
|
+
writeUint8(value: number, offset?: number): number
|
|
121
|
+
|
|
122
|
+
writeUInt16BE(value: number, offset?: number): number
|
|
123
|
+
writeUint16BE(value: number, offset?: number): number
|
|
124
|
+
writeUInt16LE(value: number, offset?: number): number
|
|
125
|
+
writeUint16LE(value: number, offset?: number): number
|
|
126
|
+
|
|
127
|
+
writeUInt32BE(value: number, offset?: number): number
|
|
128
|
+
writeUint32BE(value: number, offset?: number): number
|
|
129
|
+
writeUInt32LE(value: number, offset?: number): number
|
|
130
|
+
writeUint32LE(value: number, offset?: number): number
|
|
131
|
+
|
|
132
|
+
writeBigUint64BE(value: bigint, offset?: number): number
|
|
133
|
+
writeBigUInt64BE(value: bigint, offset?: number): number
|
|
134
|
+
writeBigUint64LE(value: bigint, offset?: number): number
|
|
135
|
+
writeBigUInt64LE(value: bigint, offset?: number): number
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
declare namespace Buffer {
|
|
139
|
+
export { Buffer }
|
|
140
|
+
|
|
141
|
+
export let poolSize: number
|
|
142
|
+
|
|
143
|
+
export function isBuffer(value: unknown): value is Buffer
|
|
144
|
+
|
|
145
|
+
export function isEncoding(encoding: string): encoding is BufferEncoding
|
|
146
|
+
|
|
147
|
+
export function alloc(
|
|
148
|
+
size: number,
|
|
149
|
+
fill: string,
|
|
150
|
+
encoding?: BufferEncoding
|
|
151
|
+
): Buffer
|
|
152
|
+
export function alloc(size: number, fill?: Buffer | number | boolean): Buffer
|
|
153
|
+
|
|
154
|
+
export function allocUnsafe(size: number): Buffer
|
|
155
|
+
|
|
156
|
+
export function allocUnsafeSlow(size: number): Buffer
|
|
157
|
+
|
|
158
|
+
export function byteLength(
|
|
159
|
+
string: ArrayBufferView | ArrayBufferLike | string,
|
|
160
|
+
encoding?: BufferEncoding
|
|
161
|
+
): number
|
|
162
|
+
|
|
163
|
+
export function compare(a: Buffer, b: Buffer): number
|
|
164
|
+
|
|
165
|
+
export function concat(buffers: Buffer[], length?: number): Buffer
|
|
166
|
+
|
|
167
|
+
export function coerce(buffer: Buffer): Buffer
|
|
168
|
+
|
|
169
|
+
export function from(data: Iterable<number>): Buffer
|
|
170
|
+
export function from(data: ArrayLike<number>): Buffer
|
|
171
|
+
export function from(string: string, encoding?: BufferEncoding): Buffer
|
|
172
|
+
export function from(
|
|
173
|
+
arrayBuffer: ArrayBufferLike,
|
|
174
|
+
offset?: number,
|
|
175
|
+
length?: number
|
|
176
|
+
): Buffer
|
|
177
|
+
|
|
178
|
+
export const constants: { MAX_LENGTH: number; MAX_STRING_LENGTH: number }
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
export = Buffer
|
package/index.js
CHANGED
|
@@ -21,6 +21,44 @@ module.exports = exports = class Buffer extends Uint8Array {
|
|
|
21
21
|
poolSize = Math.max(0, value)
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
+
constructor(arrayBuffer, offset, length, opts = {}) {
|
|
25
|
+
if (typeof arrayBuffer === 'number') {
|
|
26
|
+
opts = offset || {}
|
|
27
|
+
|
|
28
|
+
const { uninitialized = false } = opts
|
|
29
|
+
|
|
30
|
+
offset = 0
|
|
31
|
+
length = arrayBuffer
|
|
32
|
+
|
|
33
|
+
if (length > constants.MAX_LENGTH) {
|
|
34
|
+
throw new RangeError(
|
|
35
|
+
`Buffer length must be at most ${constants.MAX_LENGTH}`
|
|
36
|
+
)
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
arrayBuffer = uninitialized
|
|
40
|
+
? binding.allocUnsafe(length)
|
|
41
|
+
: binding.alloc(length)
|
|
42
|
+
} else {
|
|
43
|
+
if (length > constants.MAX_LENGTH) {
|
|
44
|
+
throw new RangeError(
|
|
45
|
+
`Buffer length must be at most ${constants.MAX_LENGTH}`
|
|
46
|
+
)
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (typeof offset === 'object' && offset !== null) {
|
|
50
|
+
opts = offset
|
|
51
|
+
offset = 0
|
|
52
|
+
length = arrayBuffer.byteLength
|
|
53
|
+
} else if (typeof length === 'length' && length !== null) {
|
|
54
|
+
opts = length
|
|
55
|
+
length = arrayBuffer.byteLength - offset
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
super(arrayBuffer, offset, length)
|
|
60
|
+
}
|
|
61
|
+
|
|
24
62
|
[Symbol.species]() {
|
|
25
63
|
return Buffer
|
|
26
64
|
}
|
|
@@ -147,12 +185,18 @@ module.exports = exports = class Buffer extends Uint8Array {
|
|
|
147
185
|
}
|
|
148
186
|
|
|
149
187
|
indexOf(value, offset = 0, encoding) {
|
|
150
|
-
if (typeof value === '
|
|
188
|
+
if (typeof value === 'boolean') value = +value
|
|
189
|
+
|
|
190
|
+
if (typeof value === 'number') {
|
|
191
|
+
return super.indexOf(value & 0xff, offset)
|
|
192
|
+
}
|
|
151
193
|
|
|
152
194
|
return bidirectionalIndexOf(this, value, offset, encoding, true /* first */)
|
|
153
195
|
}
|
|
154
196
|
|
|
155
197
|
lastIndexOf(value, offset = this.byteLength - 1, encoding) {
|
|
198
|
+
if (typeof value === 'boolean') value = +value
|
|
199
|
+
|
|
156
200
|
if (typeof value === 'number') {
|
|
157
201
|
return super.lastIndexOf(value & 0xff, offset)
|
|
158
202
|
}
|
|
@@ -204,7 +248,7 @@ module.exports = exports = class Buffer extends Uint8Array {
|
|
|
204
248
|
return this
|
|
205
249
|
}
|
|
206
250
|
|
|
207
|
-
toString(encoding, start = 0, end = this.byteLength) {
|
|
251
|
+
toString(encoding = 'utf8', start = 0, end = this.byteLength) {
|
|
208
252
|
// toString()
|
|
209
253
|
if (arguments.length === 0) return utf8.toString(this)
|
|
210
254
|
|
|
@@ -528,12 +572,7 @@ exports.alloc = function alloc(size, fill, encoding) {
|
|
|
528
572
|
}
|
|
529
573
|
|
|
530
574
|
exports.allocUnsafe = function allocUnsafe(size) {
|
|
531
|
-
|
|
532
|
-
try {
|
|
533
|
-
return new Buffer(size)
|
|
534
|
-
} finally {
|
|
535
|
-
binding.setZeroFillEnabled(1)
|
|
536
|
-
}
|
|
575
|
+
return new Buffer(size, { uninitialized: true })
|
|
537
576
|
}
|
|
538
577
|
|
|
539
578
|
exports.allocUnsafeSlow = function allocUnsafeSlow(size) {
|
package/lib/constants.js
CHANGED
package/package.json
CHANGED
|
@@ -1,15 +1,19 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "bare-buffer",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-0",
|
|
4
4
|
"description": "Native buffers for JavaScript",
|
|
5
5
|
"exports": {
|
|
6
|
-
".":
|
|
6
|
+
".": {
|
|
7
|
+
"types": "./index.d.ts",
|
|
8
|
+
"default": "./index.js"
|
|
9
|
+
},
|
|
7
10
|
"./package": "./package.json",
|
|
8
11
|
"./global": "./global.js",
|
|
9
12
|
"./constants": "./lib/constants.js"
|
|
10
13
|
},
|
|
11
14
|
"files": [
|
|
12
15
|
"index.js",
|
|
16
|
+
"index.d.ts",
|
|
13
17
|
"global.js",
|
|
14
18
|
"binding.c",
|
|
15
19
|
"binding.js",
|
|
@@ -19,7 +23,7 @@
|
|
|
19
23
|
],
|
|
20
24
|
"addon": true,
|
|
21
25
|
"scripts": {
|
|
22
|
-
"test": "prettier . --check && bare test
|
|
26
|
+
"test": "prettier . --check && bare test.js"
|
|
23
27
|
},
|
|
24
28
|
"repository": {
|
|
25
29
|
"type": "git",
|
|
@@ -31,6 +35,9 @@
|
|
|
31
35
|
"url": "https://github.com/holepunchto/bare-buffer/issues"
|
|
32
36
|
},
|
|
33
37
|
"homepage": "https://github.com/holepunchto/bare-buffer#readme",
|
|
38
|
+
"engines": {
|
|
39
|
+
"bare": ">=1.13.0"
|
|
40
|
+
},
|
|
34
41
|
"devDependencies": {
|
|
35
42
|
"brittle": "^3.1.1",
|
|
36
43
|
"cmake-bare": "^1.1.6",
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|