@nuintun/buffer 0.1.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -22,18 +22,19 @@ export declare enum Endian {
22
22
  Big = 0,
23
23
  Little = 1
24
24
  }
25
+
25
26
  /**
26
27
  * @function endianness
27
28
  * @description 获取系统默认字节序
28
29
  * @returns {Endian}
29
30
  */
30
31
  export declare function endianness(): Endian;
32
+
31
33
  /**
32
34
  * @class Buffer
33
35
  * @classdesc Buffer 类提供用于优化读取,写入以及处理二进制数据的方法和属性
34
36
  */
35
37
  export declare class Buffer {
36
- #private;
37
38
  /**
38
39
  * @constructor
39
40
  * @param {number} [length] 缓冲区初始大小
@@ -46,6 +47,7 @@ export declare class Buffer {
46
47
  * @param {number} [pageSize] 缓冲区分页大小,扩容时将按分页大小增加
47
48
  */
48
49
  constructor(bytes?: Uint8Array, pageSize?: number);
50
+
49
51
  /**
50
52
  * @public
51
53
  * @property {number} offset
@@ -53,6 +55,7 @@ export declare class Buffer {
53
55
  * @description 下一次调用读写方法时将在此位置开始读写
54
56
  */
55
57
  set offset(offset: number);
58
+
56
59
  /**
57
60
  * @public
58
61
  * @property {number} offset
@@ -60,6 +63,7 @@ export declare class Buffer {
60
63
  * @returns {number}
61
64
  */
62
65
  get offset(): number;
66
+
63
67
  /**
64
68
  * @public
65
69
  * @property {number} length
@@ -68,6 +72,7 @@ export declare class Buffer {
68
72
  * @description 如果将长度设置为大于当前长度的值,则用零填充字节数组的右侧
69
73
  */
70
74
  set length(length: number);
75
+
71
76
  /**
72
77
  * @public
73
78
  * @property {number} length
@@ -75,6 +80,7 @@ export declare class Buffer {
75
80
  * @returns {number}
76
81
  */
77
82
  get length(): number;
83
+
78
84
  /**
79
85
  * @public
80
86
  * @property {ArrayBuffer} buffer
@@ -82,6 +88,7 @@ export declare class Buffer {
82
88
  * @returns {ArrayBuffer}
83
89
  */
84
90
  get buffer(): ArrayBuffer;
91
+
85
92
  /**
86
93
  * @public
87
94
  * @property {Uint8Array} bytes
@@ -89,6 +96,7 @@ export declare class Buffer {
89
96
  * @returns {Uint8Array}
90
97
  */
91
98
  get bytes(): Uint8Array;
99
+
92
100
  /**
93
101
  * @public
94
102
  * @method writeInt8
@@ -96,6 +104,7 @@ export declare class Buffer {
96
104
  * @param {number} value 介于 -128 和 127 之间的整数
97
105
  */
98
106
  writeInt8(value: number): void;
107
+
99
108
  /**
100
109
  * @public
101
110
  * @method writeUint8
@@ -103,12 +112,14 @@ export declare class Buffer {
103
112
  * @param {number} value 介于 0 和 255 之间的整数
104
113
  */
105
114
  writeUint8(value: number): void;
115
+
106
116
  /**
107
117
  * @method writeBoolean
108
118
  * @description 在缓冲区中写入布尔值,true 写 1,false写 0
109
119
  * @param {boolean} value 布尔值
110
120
  */
111
121
  writeBoolean(value: boolean): void;
122
+
112
123
  /**
113
124
  * @method writeInt16
114
125
  * @description 在缓冲区中写入一个 16 位有符号整数
@@ -116,6 +127,7 @@ export declare class Buffer {
116
127
  * @param {boolean} [littleEndian] 是否为小端字节序
117
128
  */
118
129
  writeInt16(value: number, littleEndian?: boolean): void;
130
+
119
131
  /**
120
132
  * @method writeUint16
121
133
  * @description 在缓冲区中写入一个 16 位无符号整数
@@ -123,6 +135,7 @@ export declare class Buffer {
123
135
  * @param {boolean} [littleEndian] 是否为小端字节序
124
136
  */
125
137
  writeUint16(value: number, littleEndian?: boolean): void;
138
+
126
139
  /**
127
140
  * @method writeInt32
128
141
  * @description 在缓冲区中写入一个有符号的 32 位有符号整数
@@ -130,6 +143,7 @@ export declare class Buffer {
130
143
  * @param {boolean} [littleEndian] 是否为小端字节序
131
144
  */
132
145
  writeInt32(value: number, littleEndian?: boolean): void;
146
+
133
147
  /**
134
148
  * @method writeUint32
135
149
  * @description 在缓冲区中写入一个无符号的 32 位无符号整数
@@ -137,6 +151,7 @@ export declare class Buffer {
137
151
  * @param {boolean} [littleEndian] 是否为小端字节序
138
152
  */
139
153
  writeUint32(value: number, littleEndian?: boolean): void;
154
+
140
155
  /**
141
156
  * @method writeInt64
142
157
  * @description 在缓冲区中写入一个无符号的 64 位有符号整数
@@ -144,6 +159,7 @@ export declare class Buffer {
144
159
  * @param {boolean} [littleEndian] 是否为小端字节序
145
160
  */
146
161
  writeInt64(value: bigint, littleEndian?: boolean): void;
162
+
147
163
  /**
148
164
  * @method writeUint64
149
165
  * @description 在缓冲区中写入一个无符号的 64 位无符号整数
@@ -151,6 +167,7 @@ export declare class Buffer {
151
167
  * @param {boolean} [littleEndian] 是否为小端字节序
152
168
  */
153
169
  writeUint64(value: bigint, littleEndian?: boolean): void;
170
+
154
171
  /**
155
172
  * @method writeFloat32
156
173
  * @description 在缓冲区中写入一个 IEEE 754 单精度 32 位浮点数
@@ -158,6 +175,7 @@ export declare class Buffer {
158
175
  * @param {boolean} [littleEndian] 是否为小端字节序
159
176
  */
160
177
  writeFloat32(value: number, littleEndian?: boolean): void;
178
+
161
179
  /**
162
180
  * @method writeFloat64
163
181
  * @description 在缓冲区中写入一个 IEEE 754 双精度 64 位浮点数
@@ -165,6 +183,7 @@ export declare class Buffer {
165
183
  * @param {boolean} [littleEndian] 是否为小端字节序
166
184
  */
167
185
  writeFloat64(value: number, littleEndian?: boolean): void;
186
+
168
187
  /**
169
188
  * @method write
170
189
  * @description 将字符串用指定编码写入字节流
@@ -180,24 +199,28 @@ export declare class Buffer {
180
199
  * @param {number} [end] Uint8Array 对象结束索引
181
200
  */
182
201
  write(bytes: Uint8Array, start?: number, end?: number): void;
202
+
183
203
  /**
184
204
  * @method readInt8
185
205
  * @description 从缓冲区中读取有符号的整数
186
206
  * @returns {number} 介于 -128 和 127 之间的整数
187
207
  */
188
208
  readInt8(): number;
209
+
189
210
  /**
190
211
  * @method readUint8
191
212
  * @description 从缓冲区中读取无符号的整数
192
213
  * @returns {number} 介于 0 和 255 之间的无符号整数
193
214
  */
194
215
  readUint8(): number;
216
+
195
217
  /**
196
218
  * @method readBoolean
197
219
  * @description 从缓冲区中读取布尔值
198
220
  * @returns {boolean} 如果字节非零,则返回 true,否则返回 false
199
221
  */
200
222
  readBoolean(): boolean;
223
+
201
224
  /**
202
225
  * @method readInt16
203
226
  * @description 从缓冲区中读取一个 16 位有符号整数
@@ -205,6 +228,7 @@ export declare class Buffer {
205
228
  * @returns {number} 介于 -32768 和 32767 之间的 16 位有符号整数
206
229
  */
207
230
  readInt16(littleEndian?: boolean): number;
231
+
208
232
  /**
209
233
  * @method readUint16
210
234
  * @description 从缓冲区中读取一个 16 位无符号整数
@@ -212,6 +236,7 @@ export declare class Buffer {
212
236
  * @returns {number} 介于 0 和 65535 之间的 16 位无符号整数
213
237
  */
214
238
  readUint16(littleEndian?: boolean): number;
239
+
215
240
  /**
216
241
  * @method readInt32
217
242
  * @description 从缓冲区中读取一个 32 位有符号整数
@@ -219,6 +244,7 @@ export declare class Buffer {
219
244
  * @returns {number} 介于 -2147483648 和 2147483647 之间的 32 位有符号整数
220
245
  */
221
246
  readInt32(littleEndian?: boolean): number;
247
+
222
248
  /**
223
249
  * @method readUint32
224
250
  * @description 从缓冲区中读取一个 32 位无符号整数
@@ -226,6 +252,7 @@ export declare class Buffer {
226
252
  * @returns {number} 介于 0 和 4294967295 之间的 32 位无符号整数
227
253
  */
228
254
  readUint32(littleEndian?: boolean): number;
255
+
229
256
  /**
230
257
  * @method readInt64
231
258
  * @description 从缓冲区中读取一个 64 位有符号整数
@@ -233,6 +260,7 @@ export declare class Buffer {
233
260
  * @returns {bigint} 介于 -9223372036854775808 和 9223372036854775807 之间的 64 位有符号整数
234
261
  */
235
262
  readInt64(littleEndian?: boolean): bigint;
263
+
236
264
  /**
237
265
  * @method readUint64
238
266
  * @description 从缓冲区中读取一个 64 位无符号整数
@@ -240,6 +268,7 @@ export declare class Buffer {
240
268
  * @returns {bigint} 介于 0 和 18446744073709551615 之间的 64 位无符号整数
241
269
  */
242
270
  readUint64(littleEndian?: boolean): bigint;
271
+
243
272
  /**
244
273
  * @method readFloat32
245
274
  * @description 从缓冲区中读取一个 IEEE 754 单精度 32 位浮点数
@@ -247,6 +276,7 @@ export declare class Buffer {
247
276
  * @returns {number} 单精度 32 位浮点数
248
277
  */
249
278
  readFloat32(littleEndian?: boolean): number;
279
+
250
280
  /**
251
281
  * @method readFloat64
252
282
  * @description 从缓冲区中读取一个 IEEE 754 双精度 64 位浮点数
@@ -254,6 +284,7 @@ export declare class Buffer {
254
284
  * @returns {number} 双精度 64 位浮点数
255
285
  */
256
286
  readFloat64(littleEndian?: boolean): number;
287
+
257
288
  /**
258
289
  * @method read
259
290
  * @description 从缓冲区中读取指定长度的 Uint8Array 对象
@@ -269,6 +300,7 @@ export declare class Buffer {
269
300
  * @returns {string} 指定编码的字符串
270
301
  */
271
302
  read(length: number, encoding: string): string;
303
+
272
304
  /**
273
305
  * @public
274
306
  * @method slice
@@ -278,6 +310,7 @@ export declare class Buffer {
278
310
  * @returns {Buffer}
279
311
  */
280
312
  slice(start?: number, end?: number): Buffer;
313
+
281
314
  /**
282
315
  * @public
283
316
  * @method copyWithin
@@ -288,6 +321,7 @@ export declare class Buffer {
288
321
  * @returns {this}
289
322
  */
290
323
  copyWithin(target: number, start: number, end?: number): this;
324
+
291
325
  /**
292
326
  * @override
293
327
  * @method toString
package/cjs/Binary.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package @nuintun/buffer
3
3
  * @license MIT
4
- * @version 0.1.0
4
+ * @version 0.2.1
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A buffer tool for javascript.
7
7
  * @see https://github.com/nuintun/Buffer#readme
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package @nuintun/buffer
3
3
  * @license MIT
4
- * @version 0.1.0
4
+ * @version 0.2.1
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A buffer tool for javascript.
7
7
  * @see https://github.com/nuintun/Buffer#readme
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package @nuintun/buffer
3
3
  * @license MIT
4
- * @version 0.1.0
4
+ * @version 0.2.1
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A buffer tool for javascript.
7
7
  * @see https://github.com/nuintun/Buffer#readme
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * @package @nuintun/buffer
3
3
  * @license MIT
4
- * @version 0.1.0
4
+ * @version 0.2.1
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.1.0
4
+ * @version 0.2.1
5
5
  * @author nuintun <nuintun@qq.com>
6
6
  * @description A buffer tool for javascript.
7
7
  * @see https://github.com/nuintun/Buffer#readme