@nuintun/buffer 0.8.1 → 0.8.3

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 CHANGED
@@ -137,12 +137,14 @@ export declare class Buffer {
137
137
  */
138
138
  writeUint8(value: number): void;
139
139
  /**
140
+ * @public
140
141
  * @method writeBoolean
141
142
  * @description 在缓冲区中写入布尔值,true 写 1,false写 0
142
143
  * @param {boolean} value 布尔值
143
144
  */
144
145
  writeBoolean(value: boolean): void;
145
146
  /**
147
+ * @public
146
148
  * @method writeInt16
147
149
  * @description 在缓冲区中写入一个 16 位有符号整数
148
150
  * @param {number} value 要写入的 16 位有符号整数
@@ -150,6 +152,7 @@ export declare class Buffer {
150
152
  */
151
153
  writeInt16(value: number, littleEndian?: boolean): void;
152
154
  /**
155
+ * @public
153
156
  * @method writeUint16
154
157
  * @description 在缓冲区中写入一个 16 位无符号整数
155
158
  * @param {number} value 要写入的 16 位无符号整数
@@ -157,6 +160,7 @@ export declare class Buffer {
157
160
  */
158
161
  writeUint16(value: number, littleEndian?: boolean): void;
159
162
  /**
163
+ * @public
160
164
  * @method writeInt32
161
165
  * @description 在缓冲区中写入一个有符号的 32 位有符号整数
162
166
  * @param {number} value 要写入的 32 位有符号整数
@@ -164,6 +168,7 @@ export declare class Buffer {
164
168
  */
165
169
  writeInt32(value: number, littleEndian?: boolean): void;
166
170
  /**
171
+ * @public
167
172
  * @method writeUint32
168
173
  * @description 在缓冲区中写入一个无符号的 32 位无符号整数
169
174
  * @param {number} value 要写入的 32 位无符号整数
@@ -171,6 +176,7 @@ export declare class Buffer {
171
176
  */
172
177
  writeUint32(value: number, littleEndian?: boolean): void;
173
178
  /**
179
+ * @public
174
180
  * @method writeInt64
175
181
  * @description 在缓冲区中写入一个 64 位有符号整数
176
182
  * @param {bigint} value 要写入的 64 位有符号整数
@@ -178,6 +184,7 @@ export declare class Buffer {
178
184
  */
179
185
  writeInt64(value: bigint, littleEndian?: boolean): void;
180
186
  /**
187
+ * @public
181
188
  * @method writeUint64
182
189
  * @description 在缓冲区中写入一个无符号的 64 位无符号整数
183
190
  * @param {bigint} value 要写入的 64 位无符号整数
@@ -185,6 +192,7 @@ export declare class Buffer {
185
192
  */
186
193
  writeUint64(value: bigint, littleEndian?: boolean): void;
187
194
  /**
195
+ * @public
188
196
  * @method writeFloat32
189
197
  * @description 在缓冲区中写入一个 IEEE 754 单精度 32 位浮点数
190
198
  * @param {number} value 单精度 32 位浮点数
@@ -192,6 +200,7 @@ export declare class Buffer {
192
200
  */
193
201
  writeFloat32(value: number, littleEndian?: boolean): void;
194
202
  /**
203
+ * @public
195
204
  * @method writeFloat64
196
205
  * @description 在缓冲区中写入一个 IEEE 754 双精度 64 位浮点数
197
206
  * @param {number} value 双精度 64 位浮点数
@@ -199,6 +208,7 @@ export declare class Buffer {
199
208
  */
200
209
  writeFloat64(value: number, littleEndian?: boolean): void;
201
210
  /**
211
+ * @public
202
212
  * @method write
203
213
  * @description 将字符串用指定编码写入字节流
204
214
  * @param {string} value 要写入的字符串
@@ -206,6 +216,7 @@ export declare class Buffer {
206
216
  */
207
217
  write(value: string, encoding?: string): void;
208
218
  /**
219
+ * @public
209
220
  * @method write
210
221
  * @description 将 Uint8Array 对象写入字节流
211
222
  * @param {Uint8Array} bytes 要写入 Uint8Array 对象
@@ -214,24 +225,28 @@ export declare class Buffer {
214
225
  */
215
226
  write(bytes: Uint8Array, start?: number, end?: number): void;
216
227
  /**
228
+ * @public
217
229
  * @method readInt8
218
230
  * @description 从缓冲区中读取有符号的整数
219
231
  * @returns {number} 介于 -128 和 127 之间的整数
220
232
  */
221
233
  readInt8(): number;
222
234
  /**
235
+ * @public
223
236
  * @method readUint8
224
237
  * @description 从缓冲区中读取无符号的整数
225
238
  * @returns {number} 介于 0 和 255 之间的无符号整数
226
239
  */
227
240
  readUint8(): number;
228
241
  /**
242
+ * @public
229
243
  * @method readBoolean
230
244
  * @description 从缓冲区中读取布尔值
231
245
  * @returns {boolean} 如果字节非零,则返回 true,否则返回 false
232
246
  */
233
247
  readBoolean(): boolean;
234
248
  /**
249
+ * @public
235
250
  * @method readInt16
236
251
  * @description 从缓冲区中读取一个 16 位有符号整数
237
252
  * @param {boolean} [littleEndian] 是否为小端字节序
@@ -239,6 +254,7 @@ export declare class Buffer {
239
254
  */
240
255
  readInt16(littleEndian?: boolean): number;
241
256
  /**
257
+ * @public
242
258
  * @method readUint16
243
259
  * @description 从缓冲区中读取一个 16 位无符号整数
244
260
  * @param {boolean} [littleEndian] 是否为小端字节序
@@ -246,6 +262,7 @@ export declare class Buffer {
246
262
  */
247
263
  readUint16(littleEndian?: boolean): number;
248
264
  /**
265
+ * @public
249
266
  * @method readInt32
250
267
  * @description 从缓冲区中读取一个 32 位有符号整数
251
268
  * @param {boolean} [littleEndian] 是否为小端字节序
@@ -253,6 +270,7 @@ export declare class Buffer {
253
270
  */
254
271
  readInt32(littleEndian?: boolean): number;
255
272
  /**
273
+ * @public
256
274
  * @method readUint32
257
275
  * @description 从缓冲区中读取一个 32 位无符号整数
258
276
  * @param {boolean} [littleEndian] 是否为小端字节序
@@ -260,6 +278,7 @@ export declare class Buffer {
260
278
  */
261
279
  readUint32(littleEndian?: boolean): number;
262
280
  /**
281
+ * @public
263
282
  * @method readInt64
264
283
  * @description 从缓冲区中读取一个 64 位有符号整数
265
284
  * @param {boolean} [littleEndian] 是否为小端字节序
@@ -267,6 +286,7 @@ export declare class Buffer {
267
286
  */
268
287
  readInt64(littleEndian?: boolean): bigint;
269
288
  /**
289
+ * @public
270
290
  * @method readUint64
271
291
  * @description 从缓冲区中读取一个 64 位无符号整数
272
292
  * @param {boolean} [littleEndian] 是否为小端字节序
@@ -274,6 +294,7 @@ export declare class Buffer {
274
294
  */
275
295
  readUint64(littleEndian?: boolean): bigint;
276
296
  /**
297
+ * @public
277
298
  * @method readFloat32
278
299
  * @description 从缓冲区中读取一个 IEEE 754 单精度 32 位浮点数
279
300
  * @param {boolean} [littleEndian] 是否为小端字节序
@@ -281,6 +302,7 @@ export declare class Buffer {
281
302
  */
282
303
  readFloat32(littleEndian?: boolean): number;
283
304
  /**
305
+ * @public
284
306
  * @method readFloat64
285
307
  * @description 从缓冲区中读取一个 IEEE 754 双精度 64 位浮点数
286
308
  * @param {boolean} [littleEndian] 是否为小端字节序
@@ -288,6 +310,7 @@ export declare class Buffer {
288
310
  */
289
311
  readFloat64(littleEndian?: boolean): number;
290
312
  /**
313
+ * @public
291
314
  * @method read
292
315
  * @description 从缓冲区中读取指定长度的 Uint8Array 对象
293
316
  * @param {number} length 读取的字节长度
@@ -295,6 +318,7 @@ export declare class Buffer {
295
318
  */
296
319
  read(length: number): Uint8Array<ArrayBuffer>;
297
320
  /**
321
+ * @public
298
322
  * @method read
299
323
  * @description 从缓冲区中读取一个字符串
300
324
  * @param {number} length 读取的字节长度
@@ -322,24 +346,28 @@ export declare class Buffer {
322
346
  */
323
347
  copyWithin(target: number, start: number, end?: number): this;
324
348
  /**
349
+ * @public
325
350
  * @method entries
326
351
  * @description 获取迭代器
327
352
  * @returns {IterableIterator<[number, number]>}
328
353
  */
329
354
  entries(): IterableIterator<[number, number]>;
330
355
  /**
356
+ * @public
331
357
  * @method values
332
358
  * @description 获取迭代器
333
359
  * @returns {IterableIterator<number>}
334
360
  */
335
361
  values(): IterableIterator<number>;
336
362
  /**
363
+ * @public
337
364
  * @method iterator
338
365
  * @description 迭代器
339
366
  * @returns {IterableIterator<number>}
340
367
  */
341
368
  [Symbol.iterator](): IterableIterator<number>;
342
369
  /**
370
+ * @public
343
371
  * @override
344
372
  * @method toString
345
373
  * @description 获取 Buffer 对象二进制编码字符串
package/cjs/binary.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package @nuintun/buffer
3
3
  * @license MIT
4
- * @version 0.8.1
4
+ * @version 0.8.3
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A buffer tool for javascript.
7
7
  * @see https://github.com/nuintun/Buffer#readme
package/cjs/encoding.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package @nuintun/buffer
3
3
  * @license MIT
4
- * @version 0.8.1
4
+ * @version 0.8.3
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A buffer tool for javascript.
7
7
  * @see https://github.com/nuintun/Buffer#readme
package/cjs/enum.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package @nuintun/buffer
3
3
  * @license MIT
4
- * @version 0.8.1
4
+ * @version 0.8.3
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A buffer tool for javascript.
7
7
  * @see https://github.com/nuintun/Buffer#readme
package/cjs/errors.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package @nuintun/buffer
3
3
  * @license MIT
4
- * @version 0.8.1
4
+ * @version 0.8.3
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A buffer tool for javascript.
7
7
  * @see https://github.com/nuintun/Buffer#readme
package/cjs/index.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package @nuintun/buffer
3
3
  * @license MIT
4
- * @version 0.8.1
4
+ * @version 0.8.3
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A buffer tool for javascript.
7
7
  * @see https://github.com/nuintun/Buffer#readme
@@ -219,6 +219,7 @@ class Buffer {
219
219
  this.#seek(offset);
220
220
  }
221
221
  /**
222
+ * @public
222
223
  * @method writeBoolean
223
224
  * @description 在缓冲区中写入布尔值,true 写 1,false写 0
224
225
  * @param {boolean} value 布尔值
@@ -227,6 +228,7 @@ class Buffer {
227
228
  this.writeUint8(value ? 1 : 0);
228
229
  }
229
230
  /**
231
+ * @public
230
232
  * @method writeInt16
231
233
  * @description 在缓冲区中写入一个 16 位有符号整数
232
234
  * @param {number} value 要写入的 16 位有符号整数
@@ -239,6 +241,7 @@ class Buffer {
239
241
  this.#seek(offset);
240
242
  }
241
243
  /**
244
+ * @public
242
245
  * @method writeUint16
243
246
  * @description 在缓冲区中写入一个 16 位无符号整数
244
247
  * @param {number} value 要写入的 16 位无符号整数
@@ -251,6 +254,7 @@ class Buffer {
251
254
  this.#seek(offset);
252
255
  }
253
256
  /**
257
+ * @public
254
258
  * @method writeInt32
255
259
  * @description 在缓冲区中写入一个有符号的 32 位有符号整数
256
260
  * @param {number} value 要写入的 32 位有符号整数
@@ -263,6 +267,7 @@ class Buffer {
263
267
  this.#seek(offset);
264
268
  }
265
269
  /**
270
+ * @public
266
271
  * @method writeUint32
267
272
  * @description 在缓冲区中写入一个无符号的 32 位无符号整数
268
273
  * @param {number} value 要写入的 32 位无符号整数
@@ -275,6 +280,7 @@ class Buffer {
275
280
  this.#seek(offset);
276
281
  }
277
282
  /**
283
+ * @public
278
284
  * @method writeInt64
279
285
  * @description 在缓冲区中写入一个 64 位有符号整数
280
286
  * @param {bigint} value 要写入的 64 位有符号整数
@@ -287,6 +293,7 @@ class Buffer {
287
293
  this.#seek(offset);
288
294
  }
289
295
  /**
296
+ * @public
290
297
  * @method writeUint64
291
298
  * @description 在缓冲区中写入一个无符号的 64 位无符号整数
292
299
  * @param {bigint} value 要写入的 64 位无符号整数
@@ -299,6 +306,7 @@ class Buffer {
299
306
  this.#seek(offset);
300
307
  }
301
308
  /**
309
+ * @public
302
310
  * @method writeFloat32
303
311
  * @description 在缓冲区中写入一个 IEEE 754 单精度 32 位浮点数
304
312
  * @param {number} value 单精度 32 位浮点数
@@ -311,6 +319,7 @@ class Buffer {
311
319
  this.#seek(offset);
312
320
  }
313
321
  /**
322
+ * @public
314
323
  * @method writeFloat64
315
324
  * @description 在缓冲区中写入一个 IEEE 754 双精度 64 位浮点数
316
325
  * @param {number} value 双精度 64 位浮点数
@@ -338,6 +347,7 @@ class Buffer {
338
347
  }
339
348
  }
340
349
  /**
350
+ * @public
341
351
  * @method readInt8
342
352
  * @description 从缓冲区中读取有符号的整数
343
353
  * @returns {number} 介于 -128 和 127 之间的整数
@@ -350,6 +360,7 @@ class Buffer {
350
360
  return value;
351
361
  }
352
362
  /**
363
+ * @public
353
364
  * @method readUint8
354
365
  * @description 从缓冲区中读取无符号的整数
355
366
  * @returns {number} 介于 0 和 255 之间的无符号整数
@@ -362,6 +373,7 @@ class Buffer {
362
373
  return value;
363
374
  }
364
375
  /**
376
+ * @public
365
377
  * @method readBoolean
366
378
  * @description 从缓冲区中读取布尔值
367
379
  * @returns {boolean} 如果字节非零,则返回 true,否则返回 false
@@ -370,6 +382,7 @@ class Buffer {
370
382
  return Boolean(this.readUint8());
371
383
  }
372
384
  /**
385
+ * @public
373
386
  * @method readInt16
374
387
  * @description 从缓冲区中读取一个 16 位有符号整数
375
388
  * @param {boolean} [littleEndian] 是否为小端字节序
@@ -383,6 +396,7 @@ class Buffer {
383
396
  return value;
384
397
  }
385
398
  /**
399
+ * @public
386
400
  * @method readUint16
387
401
  * @description 从缓冲区中读取一个 16 位无符号整数
388
402
  * @param {boolean} [littleEndian] 是否为小端字节序
@@ -396,6 +410,7 @@ class Buffer {
396
410
  return value;
397
411
  }
398
412
  /**
413
+ * @public
399
414
  * @method readInt32
400
415
  * @description 从缓冲区中读取一个 32 位有符号整数
401
416
  * @param {boolean} [littleEndian] 是否为小端字节序
@@ -409,6 +424,7 @@ class Buffer {
409
424
  return value;
410
425
  }
411
426
  /**
427
+ * @public
412
428
  * @method readUint32
413
429
  * @description 从缓冲区中读取一个 32 位无符号整数
414
430
  * @param {boolean} [littleEndian] 是否为小端字节序
@@ -422,6 +438,7 @@ class Buffer {
422
438
  return value;
423
439
  }
424
440
  /**
441
+ * @public
425
442
  * @method readInt64
426
443
  * @description 从缓冲区中读取一个 64 位有符号整数
427
444
  * @param {boolean} [littleEndian] 是否为小端字节序
@@ -435,6 +452,7 @@ class Buffer {
435
452
  return value;
436
453
  }
437
454
  /**
455
+ * @public
438
456
  * @method readUint64
439
457
  * @description 从缓冲区中读取一个 64 位无符号整数
440
458
  * @param {boolean} [littleEndian] 是否为小端字节序
@@ -448,6 +466,7 @@ class Buffer {
448
466
  return value;
449
467
  }
450
468
  /**
469
+ * @public
451
470
  * @method readFloat32
452
471
  * @description 从缓冲区中读取一个 IEEE 754 单精度 32 位浮点数
453
472
  * @param {boolean} [littleEndian] 是否为小端字节序
@@ -461,6 +480,7 @@ class Buffer {
461
480
  return value;
462
481
  }
463
482
  /**
483
+ * @public
464
484
  * @method readFloat64
465
485
  * @description 从缓冲区中读取一个 IEEE 754 双精度 64 位浮点数
466
486
  * @param {boolean} [littleEndian] 是否为小端字节序
@@ -495,7 +515,7 @@ class Buffer {
495
515
  * @returns {Buffer}
496
516
  */
497
517
  slice(start, end) {
498
- return new Buffer(this.bytes.slice(start, end), {
518
+ return new Buffer(this.bytes.subarray(start, end), {
499
519
  encode: this.#encode,
500
520
  decode: this.#decode,
501
521
  pageSize: this.#pageSize
@@ -515,6 +535,7 @@ class Buffer {
515
535
  return this;
516
536
  }
517
537
  /**
538
+ * @public
518
539
  * @method entries
519
540
  * @description 获取迭代器
520
541
  * @returns {IterableIterator<[number, number]>}
@@ -527,6 +548,7 @@ class Buffer {
527
548
  }
528
549
  }
529
550
  /**
551
+ * @public
530
552
  * @method values
531
553
  * @description 获取迭代器
532
554
  * @returns {IterableIterator<number>}
@@ -539,6 +561,7 @@ class Buffer {
539
561
  }
540
562
  }
541
563
  /**
564
+ * @public
542
565
  * @method iterator
543
566
  * @description 迭代器
544
567
  * @returns {IterableIterator<number>}
@@ -547,6 +570,7 @@ class Buffer {
547
570
  return this.values();
548
571
  }
549
572
  /**
573
+ * @public
550
574
  * @override
551
575
  * @method toString
552
576
  * @description 获取 Buffer 对象二进制编码字符串
package/cjs/index.d.cts CHANGED
@@ -105,12 +105,14 @@ export declare class Buffer {
105
105
  */
106
106
  writeUint8(value: number): void;
107
107
  /**
108
+ * @public
108
109
  * @method writeBoolean
109
110
  * @description 在缓冲区中写入布尔值,true 写 1,false写 0
110
111
  * @param {boolean} value 布尔值
111
112
  */
112
113
  writeBoolean(value: boolean): void;
113
114
  /**
115
+ * @public
114
116
  * @method writeInt16
115
117
  * @description 在缓冲区中写入一个 16 位有符号整数
116
118
  * @param {number} value 要写入的 16 位有符号整数
@@ -118,6 +120,7 @@ export declare class Buffer {
118
120
  */
119
121
  writeInt16(value: number, littleEndian?: boolean): void;
120
122
  /**
123
+ * @public
121
124
  * @method writeUint16
122
125
  * @description 在缓冲区中写入一个 16 位无符号整数
123
126
  * @param {number} value 要写入的 16 位无符号整数
@@ -125,6 +128,7 @@ export declare class Buffer {
125
128
  */
126
129
  writeUint16(value: number, littleEndian?: boolean): void;
127
130
  /**
131
+ * @public
128
132
  * @method writeInt32
129
133
  * @description 在缓冲区中写入一个有符号的 32 位有符号整数
130
134
  * @param {number} value 要写入的 32 位有符号整数
@@ -132,6 +136,7 @@ export declare class Buffer {
132
136
  */
133
137
  writeInt32(value: number, littleEndian?: boolean): void;
134
138
  /**
139
+ * @public
135
140
  * @method writeUint32
136
141
  * @description 在缓冲区中写入一个无符号的 32 位无符号整数
137
142
  * @param {number} value 要写入的 32 位无符号整数
@@ -139,6 +144,7 @@ export declare class Buffer {
139
144
  */
140
145
  writeUint32(value: number, littleEndian?: boolean): void;
141
146
  /**
147
+ * @public
142
148
  * @method writeInt64
143
149
  * @description 在缓冲区中写入一个 64 位有符号整数
144
150
  * @param {bigint} value 要写入的 64 位有符号整数
@@ -146,6 +152,7 @@ export declare class Buffer {
146
152
  */
147
153
  writeInt64(value: bigint, littleEndian?: boolean): void;
148
154
  /**
155
+ * @public
149
156
  * @method writeUint64
150
157
  * @description 在缓冲区中写入一个无符号的 64 位无符号整数
151
158
  * @param {bigint} value 要写入的 64 位无符号整数
@@ -153,6 +160,7 @@ export declare class Buffer {
153
160
  */
154
161
  writeUint64(value: bigint, littleEndian?: boolean): void;
155
162
  /**
163
+ * @public
156
164
  * @method writeFloat32
157
165
  * @description 在缓冲区中写入一个 IEEE 754 单精度 32 位浮点数
158
166
  * @param {number} value 单精度 32 位浮点数
@@ -160,6 +168,7 @@ export declare class Buffer {
160
168
  */
161
169
  writeFloat32(value: number, littleEndian?: boolean): void;
162
170
  /**
171
+ * @public
163
172
  * @method writeFloat64
164
173
  * @description 在缓冲区中写入一个 IEEE 754 双精度 64 位浮点数
165
174
  * @param {number} value 双精度 64 位浮点数
@@ -167,6 +176,7 @@ export declare class Buffer {
167
176
  */
168
177
  writeFloat64(value: number, littleEndian?: boolean): void;
169
178
  /**
179
+ * @public
170
180
  * @method write
171
181
  * @description 将字符串用指定编码写入字节流
172
182
  * @param {string} value 要写入的字符串
@@ -174,6 +184,7 @@ export declare class Buffer {
174
184
  */
175
185
  write(value: string, encoding?: string): void;
176
186
  /**
187
+ * @public
177
188
  * @method write
178
189
  * @description 将 Uint8Array 对象写入字节流
179
190
  * @param {Uint8Array} bytes 要写入 Uint8Array 对象
@@ -182,24 +193,28 @@ export declare class Buffer {
182
193
  */
183
194
  write(bytes: Uint8Array, start?: number, end?: number): void;
184
195
  /**
196
+ * @public
185
197
  * @method readInt8
186
198
  * @description 从缓冲区中读取有符号的整数
187
199
  * @returns {number} 介于 -128 和 127 之间的整数
188
200
  */
189
201
  readInt8(): number;
190
202
  /**
203
+ * @public
191
204
  * @method readUint8
192
205
  * @description 从缓冲区中读取无符号的整数
193
206
  * @returns {number} 介于 0 和 255 之间的无符号整数
194
207
  */
195
208
  readUint8(): number;
196
209
  /**
210
+ * @public
197
211
  * @method readBoolean
198
212
  * @description 从缓冲区中读取布尔值
199
213
  * @returns {boolean} 如果字节非零,则返回 true,否则返回 false
200
214
  */
201
215
  readBoolean(): boolean;
202
216
  /**
217
+ * @public
203
218
  * @method readInt16
204
219
  * @description 从缓冲区中读取一个 16 位有符号整数
205
220
  * @param {boolean} [littleEndian] 是否为小端字节序
@@ -207,6 +222,7 @@ export declare class Buffer {
207
222
  */
208
223
  readInt16(littleEndian?: boolean): number;
209
224
  /**
225
+ * @public
210
226
  * @method readUint16
211
227
  * @description 从缓冲区中读取一个 16 位无符号整数
212
228
  * @param {boolean} [littleEndian] 是否为小端字节序
@@ -214,6 +230,7 @@ export declare class Buffer {
214
230
  */
215
231
  readUint16(littleEndian?: boolean): number;
216
232
  /**
233
+ * @public
217
234
  * @method readInt32
218
235
  * @description 从缓冲区中读取一个 32 位有符号整数
219
236
  * @param {boolean} [littleEndian] 是否为小端字节序
@@ -221,6 +238,7 @@ export declare class Buffer {
221
238
  */
222
239
  readInt32(littleEndian?: boolean): number;
223
240
  /**
241
+ * @public
224
242
  * @method readUint32
225
243
  * @description 从缓冲区中读取一个 32 位无符号整数
226
244
  * @param {boolean} [littleEndian] 是否为小端字节序
@@ -228,6 +246,7 @@ export declare class Buffer {
228
246
  */
229
247
  readUint32(littleEndian?: boolean): number;
230
248
  /**
249
+ * @public
231
250
  * @method readInt64
232
251
  * @description 从缓冲区中读取一个 64 位有符号整数
233
252
  * @param {boolean} [littleEndian] 是否为小端字节序
@@ -235,6 +254,7 @@ export declare class Buffer {
235
254
  */
236
255
  readInt64(littleEndian?: boolean): bigint;
237
256
  /**
257
+ * @public
238
258
  * @method readUint64
239
259
  * @description 从缓冲区中读取一个 64 位无符号整数
240
260
  * @param {boolean} [littleEndian] 是否为小端字节序
@@ -242,6 +262,7 @@ export declare class Buffer {
242
262
  */
243
263
  readUint64(littleEndian?: boolean): bigint;
244
264
  /**
265
+ * @public
245
266
  * @method readFloat32
246
267
  * @description 从缓冲区中读取一个 IEEE 754 单精度 32 位浮点数
247
268
  * @param {boolean} [littleEndian] 是否为小端字节序
@@ -249,6 +270,7 @@ export declare class Buffer {
249
270
  */
250
271
  readFloat32(littleEndian?: boolean): number;
251
272
  /**
273
+ * @public
252
274
  * @method readFloat64
253
275
  * @description 从缓冲区中读取一个 IEEE 754 双精度 64 位浮点数
254
276
  * @param {boolean} [littleEndian] 是否为小端字节序
@@ -256,6 +278,7 @@ export declare class Buffer {
256
278
  */
257
279
  readFloat64(littleEndian?: boolean): number;
258
280
  /**
281
+ * @public
259
282
  * @method read
260
283
  * @description 从缓冲区中读取指定长度的 Uint8Array 对象
261
284
  * @param {number} length 读取的字节长度
@@ -263,6 +286,7 @@ export declare class Buffer {
263
286
  */
264
287
  read(length: number): Uint8Array<ArrayBuffer>;
265
288
  /**
289
+ * @public
266
290
  * @method read
267
291
  * @description 从缓冲区中读取一个字符串
268
292
  * @param {number} length 读取的字节长度
@@ -290,24 +314,28 @@ export declare class Buffer {
290
314
  */
291
315
  copyWithin(target: number, start: number, end?: number): this;
292
316
  /**
317
+ * @public
293
318
  * @method entries
294
319
  * @description 获取迭代器
295
320
  * @returns {IterableIterator<[number, number]>}
296
321
  */
297
322
  entries(): IterableIterator<[number, number]>;
298
323
  /**
324
+ * @public
299
325
  * @method values
300
326
  * @description 获取迭代器
301
327
  * @returns {IterableIterator<number>}
302
328
  */
303
329
  values(): IterableIterator<number>;
304
330
  /**
331
+ * @public
305
332
  * @method iterator
306
333
  * @description 迭代器
307
334
  * @returns {IterableIterator<number>}
308
335
  */
309
336
  [Symbol.iterator](): IterableIterator<number>;
310
337
  /**
338
+ * @public
311
339
  * @override
312
340
  * @method toString
313
341
  * @description 获取 Buffer 对象二进制编码字符串
package/cjs/utils.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package @nuintun/buffer
3
3
  * @license MIT
4
- * @version 0.8.1
4
+ * @version 0.8.3
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A buffer tool for javascript.
7
7
  * @see https://github.com/nuintun/Buffer#readme
package/esm/binary.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package @nuintun/buffer
3
3
  * @license MIT
4
- * @version 0.8.1
4
+ * @version 0.8.3
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A buffer tool for javascript.
7
7
  * @see https://github.com/nuintun/Buffer#readme
package/esm/encoding.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package @nuintun/buffer
3
3
  * @license MIT
4
- * @version 0.8.1
4
+ * @version 0.8.3
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A buffer tool for javascript.
7
7
  * @see https://github.com/nuintun/Buffer#readme
package/esm/enum.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package @nuintun/buffer
3
3
  * @license MIT
4
- * @version 0.8.1
4
+ * @version 0.8.3
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A buffer tool for javascript.
7
7
  * @see https://github.com/nuintun/Buffer#readme
package/esm/errors.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package @nuintun/buffer
3
3
  * @license MIT
4
- * @version 0.8.1
4
+ * @version 0.8.3
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A buffer tool for javascript.
7
7
  * @see https://github.com/nuintun/Buffer#readme
package/esm/index.d.ts CHANGED
@@ -105,12 +105,14 @@ export declare class Buffer {
105
105
  */
106
106
  writeUint8(value: number): void;
107
107
  /**
108
+ * @public
108
109
  * @method writeBoolean
109
110
  * @description 在缓冲区中写入布尔值,true 写 1,false写 0
110
111
  * @param {boolean} value 布尔值
111
112
  */
112
113
  writeBoolean(value: boolean): void;
113
114
  /**
115
+ * @public
114
116
  * @method writeInt16
115
117
  * @description 在缓冲区中写入一个 16 位有符号整数
116
118
  * @param {number} value 要写入的 16 位有符号整数
@@ -118,6 +120,7 @@ export declare class Buffer {
118
120
  */
119
121
  writeInt16(value: number, littleEndian?: boolean): void;
120
122
  /**
123
+ * @public
121
124
  * @method writeUint16
122
125
  * @description 在缓冲区中写入一个 16 位无符号整数
123
126
  * @param {number} value 要写入的 16 位无符号整数
@@ -125,6 +128,7 @@ export declare class Buffer {
125
128
  */
126
129
  writeUint16(value: number, littleEndian?: boolean): void;
127
130
  /**
131
+ * @public
128
132
  * @method writeInt32
129
133
  * @description 在缓冲区中写入一个有符号的 32 位有符号整数
130
134
  * @param {number} value 要写入的 32 位有符号整数
@@ -132,6 +136,7 @@ export declare class Buffer {
132
136
  */
133
137
  writeInt32(value: number, littleEndian?: boolean): void;
134
138
  /**
139
+ * @public
135
140
  * @method writeUint32
136
141
  * @description 在缓冲区中写入一个无符号的 32 位无符号整数
137
142
  * @param {number} value 要写入的 32 位无符号整数
@@ -139,6 +144,7 @@ export declare class Buffer {
139
144
  */
140
145
  writeUint32(value: number, littleEndian?: boolean): void;
141
146
  /**
147
+ * @public
142
148
  * @method writeInt64
143
149
  * @description 在缓冲区中写入一个 64 位有符号整数
144
150
  * @param {bigint} value 要写入的 64 位有符号整数
@@ -146,6 +152,7 @@ export declare class Buffer {
146
152
  */
147
153
  writeInt64(value: bigint, littleEndian?: boolean): void;
148
154
  /**
155
+ * @public
149
156
  * @method writeUint64
150
157
  * @description 在缓冲区中写入一个无符号的 64 位无符号整数
151
158
  * @param {bigint} value 要写入的 64 位无符号整数
@@ -153,6 +160,7 @@ export declare class Buffer {
153
160
  */
154
161
  writeUint64(value: bigint, littleEndian?: boolean): void;
155
162
  /**
163
+ * @public
156
164
  * @method writeFloat32
157
165
  * @description 在缓冲区中写入一个 IEEE 754 单精度 32 位浮点数
158
166
  * @param {number} value 单精度 32 位浮点数
@@ -160,6 +168,7 @@ export declare class Buffer {
160
168
  */
161
169
  writeFloat32(value: number, littleEndian?: boolean): void;
162
170
  /**
171
+ * @public
163
172
  * @method writeFloat64
164
173
  * @description 在缓冲区中写入一个 IEEE 754 双精度 64 位浮点数
165
174
  * @param {number} value 双精度 64 位浮点数
@@ -167,6 +176,7 @@ export declare class Buffer {
167
176
  */
168
177
  writeFloat64(value: number, littleEndian?: boolean): void;
169
178
  /**
179
+ * @public
170
180
  * @method write
171
181
  * @description 将字符串用指定编码写入字节流
172
182
  * @param {string} value 要写入的字符串
@@ -174,6 +184,7 @@ export declare class Buffer {
174
184
  */
175
185
  write(value: string, encoding?: string): void;
176
186
  /**
187
+ * @public
177
188
  * @method write
178
189
  * @description 将 Uint8Array 对象写入字节流
179
190
  * @param {Uint8Array} bytes 要写入 Uint8Array 对象
@@ -182,24 +193,28 @@ export declare class Buffer {
182
193
  */
183
194
  write(bytes: Uint8Array, start?: number, end?: number): void;
184
195
  /**
196
+ * @public
185
197
  * @method readInt8
186
198
  * @description 从缓冲区中读取有符号的整数
187
199
  * @returns {number} 介于 -128 和 127 之间的整数
188
200
  */
189
201
  readInt8(): number;
190
202
  /**
203
+ * @public
191
204
  * @method readUint8
192
205
  * @description 从缓冲区中读取无符号的整数
193
206
  * @returns {number} 介于 0 和 255 之间的无符号整数
194
207
  */
195
208
  readUint8(): number;
196
209
  /**
210
+ * @public
197
211
  * @method readBoolean
198
212
  * @description 从缓冲区中读取布尔值
199
213
  * @returns {boolean} 如果字节非零,则返回 true,否则返回 false
200
214
  */
201
215
  readBoolean(): boolean;
202
216
  /**
217
+ * @public
203
218
  * @method readInt16
204
219
  * @description 从缓冲区中读取一个 16 位有符号整数
205
220
  * @param {boolean} [littleEndian] 是否为小端字节序
@@ -207,6 +222,7 @@ export declare class Buffer {
207
222
  */
208
223
  readInt16(littleEndian?: boolean): number;
209
224
  /**
225
+ * @public
210
226
  * @method readUint16
211
227
  * @description 从缓冲区中读取一个 16 位无符号整数
212
228
  * @param {boolean} [littleEndian] 是否为小端字节序
@@ -214,6 +230,7 @@ export declare class Buffer {
214
230
  */
215
231
  readUint16(littleEndian?: boolean): number;
216
232
  /**
233
+ * @public
217
234
  * @method readInt32
218
235
  * @description 从缓冲区中读取一个 32 位有符号整数
219
236
  * @param {boolean} [littleEndian] 是否为小端字节序
@@ -221,6 +238,7 @@ export declare class Buffer {
221
238
  */
222
239
  readInt32(littleEndian?: boolean): number;
223
240
  /**
241
+ * @public
224
242
  * @method readUint32
225
243
  * @description 从缓冲区中读取一个 32 位无符号整数
226
244
  * @param {boolean} [littleEndian] 是否为小端字节序
@@ -228,6 +246,7 @@ export declare class Buffer {
228
246
  */
229
247
  readUint32(littleEndian?: boolean): number;
230
248
  /**
249
+ * @public
231
250
  * @method readInt64
232
251
  * @description 从缓冲区中读取一个 64 位有符号整数
233
252
  * @param {boolean} [littleEndian] 是否为小端字节序
@@ -235,6 +254,7 @@ export declare class Buffer {
235
254
  */
236
255
  readInt64(littleEndian?: boolean): bigint;
237
256
  /**
257
+ * @public
238
258
  * @method readUint64
239
259
  * @description 从缓冲区中读取一个 64 位无符号整数
240
260
  * @param {boolean} [littleEndian] 是否为小端字节序
@@ -242,6 +262,7 @@ export declare class Buffer {
242
262
  */
243
263
  readUint64(littleEndian?: boolean): bigint;
244
264
  /**
265
+ * @public
245
266
  * @method readFloat32
246
267
  * @description 从缓冲区中读取一个 IEEE 754 单精度 32 位浮点数
247
268
  * @param {boolean} [littleEndian] 是否为小端字节序
@@ -249,6 +270,7 @@ export declare class Buffer {
249
270
  */
250
271
  readFloat32(littleEndian?: boolean): number;
251
272
  /**
273
+ * @public
252
274
  * @method readFloat64
253
275
  * @description 从缓冲区中读取一个 IEEE 754 双精度 64 位浮点数
254
276
  * @param {boolean} [littleEndian] 是否为小端字节序
@@ -256,6 +278,7 @@ export declare class Buffer {
256
278
  */
257
279
  readFloat64(littleEndian?: boolean): number;
258
280
  /**
281
+ * @public
259
282
  * @method read
260
283
  * @description 从缓冲区中读取指定长度的 Uint8Array 对象
261
284
  * @param {number} length 读取的字节长度
@@ -263,6 +286,7 @@ export declare class Buffer {
263
286
  */
264
287
  read(length: number): Uint8Array<ArrayBuffer>;
265
288
  /**
289
+ * @public
266
290
  * @method read
267
291
  * @description 从缓冲区中读取一个字符串
268
292
  * @param {number} length 读取的字节长度
@@ -290,24 +314,28 @@ export declare class Buffer {
290
314
  */
291
315
  copyWithin(target: number, start: number, end?: number): this;
292
316
  /**
317
+ * @public
293
318
  * @method entries
294
319
  * @description 获取迭代器
295
320
  * @returns {IterableIterator<[number, number]>}
296
321
  */
297
322
  entries(): IterableIterator<[number, number]>;
298
323
  /**
324
+ * @public
299
325
  * @method values
300
326
  * @description 获取迭代器
301
327
  * @returns {IterableIterator<number>}
302
328
  */
303
329
  values(): IterableIterator<number>;
304
330
  /**
331
+ * @public
305
332
  * @method iterator
306
333
  * @description 迭代器
307
334
  * @returns {IterableIterator<number>}
308
335
  */
309
336
  [Symbol.iterator](): IterableIterator<number>;
310
337
  /**
338
+ * @public
311
339
  * @override
312
340
  * @method toString
313
341
  * @description 获取 Buffer 对象二进制编码字符串
package/esm/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package @nuintun/buffer
3
3
  * @license MIT
4
- * @version 0.8.1
4
+ * @version 0.8.3
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A buffer tool for javascript.
7
7
  * @see https://github.com/nuintun/Buffer#readme
@@ -217,6 +217,7 @@ class Buffer {
217
217
  this.#seek(offset);
218
218
  }
219
219
  /**
220
+ * @public
220
221
  * @method writeBoolean
221
222
  * @description 在缓冲区中写入布尔值,true 写 1,false写 0
222
223
  * @param {boolean} value 布尔值
@@ -225,6 +226,7 @@ class Buffer {
225
226
  this.writeUint8(value ? 1 : 0);
226
227
  }
227
228
  /**
229
+ * @public
228
230
  * @method writeInt16
229
231
  * @description 在缓冲区中写入一个 16 位有符号整数
230
232
  * @param {number} value 要写入的 16 位有符号整数
@@ -237,6 +239,7 @@ class Buffer {
237
239
  this.#seek(offset);
238
240
  }
239
241
  /**
242
+ * @public
240
243
  * @method writeUint16
241
244
  * @description 在缓冲区中写入一个 16 位无符号整数
242
245
  * @param {number} value 要写入的 16 位无符号整数
@@ -249,6 +252,7 @@ class Buffer {
249
252
  this.#seek(offset);
250
253
  }
251
254
  /**
255
+ * @public
252
256
  * @method writeInt32
253
257
  * @description 在缓冲区中写入一个有符号的 32 位有符号整数
254
258
  * @param {number} value 要写入的 32 位有符号整数
@@ -261,6 +265,7 @@ class Buffer {
261
265
  this.#seek(offset);
262
266
  }
263
267
  /**
268
+ * @public
264
269
  * @method writeUint32
265
270
  * @description 在缓冲区中写入一个无符号的 32 位无符号整数
266
271
  * @param {number} value 要写入的 32 位无符号整数
@@ -273,6 +278,7 @@ class Buffer {
273
278
  this.#seek(offset);
274
279
  }
275
280
  /**
281
+ * @public
276
282
  * @method writeInt64
277
283
  * @description 在缓冲区中写入一个 64 位有符号整数
278
284
  * @param {bigint} value 要写入的 64 位有符号整数
@@ -285,6 +291,7 @@ class Buffer {
285
291
  this.#seek(offset);
286
292
  }
287
293
  /**
294
+ * @public
288
295
  * @method writeUint64
289
296
  * @description 在缓冲区中写入一个无符号的 64 位无符号整数
290
297
  * @param {bigint} value 要写入的 64 位无符号整数
@@ -297,6 +304,7 @@ class Buffer {
297
304
  this.#seek(offset);
298
305
  }
299
306
  /**
307
+ * @public
300
308
  * @method writeFloat32
301
309
  * @description 在缓冲区中写入一个 IEEE 754 单精度 32 位浮点数
302
310
  * @param {number} value 单精度 32 位浮点数
@@ -309,6 +317,7 @@ class Buffer {
309
317
  this.#seek(offset);
310
318
  }
311
319
  /**
320
+ * @public
312
321
  * @method writeFloat64
313
322
  * @description 在缓冲区中写入一个 IEEE 754 双精度 64 位浮点数
314
323
  * @param {number} value 双精度 64 位浮点数
@@ -336,6 +345,7 @@ class Buffer {
336
345
  }
337
346
  }
338
347
  /**
348
+ * @public
339
349
  * @method readInt8
340
350
  * @description 从缓冲区中读取有符号的整数
341
351
  * @returns {number} 介于 -128 和 127 之间的整数
@@ -348,6 +358,7 @@ class Buffer {
348
358
  return value;
349
359
  }
350
360
  /**
361
+ * @public
351
362
  * @method readUint8
352
363
  * @description 从缓冲区中读取无符号的整数
353
364
  * @returns {number} 介于 0 和 255 之间的无符号整数
@@ -360,6 +371,7 @@ class Buffer {
360
371
  return value;
361
372
  }
362
373
  /**
374
+ * @public
363
375
  * @method readBoolean
364
376
  * @description 从缓冲区中读取布尔值
365
377
  * @returns {boolean} 如果字节非零,则返回 true,否则返回 false
@@ -368,6 +380,7 @@ class Buffer {
368
380
  return Boolean(this.readUint8());
369
381
  }
370
382
  /**
383
+ * @public
371
384
  * @method readInt16
372
385
  * @description 从缓冲区中读取一个 16 位有符号整数
373
386
  * @param {boolean} [littleEndian] 是否为小端字节序
@@ -381,6 +394,7 @@ class Buffer {
381
394
  return value;
382
395
  }
383
396
  /**
397
+ * @public
384
398
  * @method readUint16
385
399
  * @description 从缓冲区中读取一个 16 位无符号整数
386
400
  * @param {boolean} [littleEndian] 是否为小端字节序
@@ -394,6 +408,7 @@ class Buffer {
394
408
  return value;
395
409
  }
396
410
  /**
411
+ * @public
397
412
  * @method readInt32
398
413
  * @description 从缓冲区中读取一个 32 位有符号整数
399
414
  * @param {boolean} [littleEndian] 是否为小端字节序
@@ -407,6 +422,7 @@ class Buffer {
407
422
  return value;
408
423
  }
409
424
  /**
425
+ * @public
410
426
  * @method readUint32
411
427
  * @description 从缓冲区中读取一个 32 位无符号整数
412
428
  * @param {boolean} [littleEndian] 是否为小端字节序
@@ -420,6 +436,7 @@ class Buffer {
420
436
  return value;
421
437
  }
422
438
  /**
439
+ * @public
423
440
  * @method readInt64
424
441
  * @description 从缓冲区中读取一个 64 位有符号整数
425
442
  * @param {boolean} [littleEndian] 是否为小端字节序
@@ -433,6 +450,7 @@ class Buffer {
433
450
  return value;
434
451
  }
435
452
  /**
453
+ * @public
436
454
  * @method readUint64
437
455
  * @description 从缓冲区中读取一个 64 位无符号整数
438
456
  * @param {boolean} [littleEndian] 是否为小端字节序
@@ -446,6 +464,7 @@ class Buffer {
446
464
  return value;
447
465
  }
448
466
  /**
467
+ * @public
449
468
  * @method readFloat32
450
469
  * @description 从缓冲区中读取一个 IEEE 754 单精度 32 位浮点数
451
470
  * @param {boolean} [littleEndian] 是否为小端字节序
@@ -459,6 +478,7 @@ class Buffer {
459
478
  return value;
460
479
  }
461
480
  /**
481
+ * @public
462
482
  * @method readFloat64
463
483
  * @description 从缓冲区中读取一个 IEEE 754 双精度 64 位浮点数
464
484
  * @param {boolean} [littleEndian] 是否为小端字节序
@@ -493,7 +513,7 @@ class Buffer {
493
513
  * @returns {Buffer}
494
514
  */
495
515
  slice(start, end) {
496
- return new Buffer(this.bytes.slice(start, end), {
516
+ return new Buffer(this.bytes.subarray(start, end), {
497
517
  encode: this.#encode,
498
518
  decode: this.#decode,
499
519
  pageSize: this.#pageSize
@@ -513,6 +533,7 @@ class Buffer {
513
533
  return this;
514
534
  }
515
535
  /**
536
+ * @public
516
537
  * @method entries
517
538
  * @description 获取迭代器
518
539
  * @returns {IterableIterator<[number, number]>}
@@ -525,6 +546,7 @@ class Buffer {
525
546
  }
526
547
  }
527
548
  /**
549
+ * @public
528
550
  * @method values
529
551
  * @description 获取迭代器
530
552
  * @returns {IterableIterator<number>}
@@ -537,6 +559,7 @@ class Buffer {
537
559
  }
538
560
  }
539
561
  /**
562
+ * @public
540
563
  * @method iterator
541
564
  * @description 迭代器
542
565
  * @returns {IterableIterator<number>}
@@ -545,6 +568,7 @@ class Buffer {
545
568
  return this.values();
546
569
  }
547
570
  /**
571
+ * @public
548
572
  * @override
549
573
  * @method toString
550
574
  * @description 获取 Buffer 对象二进制编码字符串
package/esm/utils.js CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package @nuintun/buffer
3
3
  * @license MIT
4
- * @version 0.8.1
4
+ * @version 0.8.3
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A buffer tool for javascript.
7
7
  * @see https://github.com/nuintun/Buffer#readme
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@nuintun/buffer",
3
- "version": "0.8.1",
3
+ "version": "0.8.3",
4
4
  "description": "A buffer tool for javascript.",
5
5
  "type": "module",
6
6
  "sideEffects": false,
@@ -40,7 +40,7 @@
40
40
  "dts-paths": "^1.1.12",
41
41
  "prettier": "^3.6.2",
42
42
  "rimraf": "^6.0.1",
43
- "rollup": "^4.50.1",
43
+ "rollup": "^4.52.3",
44
44
  "typescript": "^5.9.2"
45
45
  },
46
46
  "scripts": {