@nuintun/buffer 0.1.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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2021 nuintun
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,310 @@
1
+ # Buffer
2
+
3
+ <!-- prettier-ignore -->
4
+ > A buffer tool for javascript.
5
+ >
6
+ > [![NPM Version][npm-image]][npm-url]
7
+ > [![Download Status][download-image]][npm-url]
8
+ > [![Languages Status][languages-image]][github-url]
9
+ > [![Tree Shakeable][tree-shakeable-image]][bundle-phobia-url]
10
+ > [![Side Effect][side-effect-image]][bundle-phobia-url]
11
+ > [![License][license-image]][license-url]
12
+
13
+ ### Usage
14
+
15
+ ##### Common Interface
16
+
17
+ ```ts
18
+ /**
19
+ * @module Buffer
20
+ */
21
+ export declare enum Endian {
22
+ Big = 0,
23
+ Little = 1
24
+ }
25
+ /**
26
+ * @function endianness
27
+ * @description 获取系统默认字节序
28
+ * @returns {Endian}
29
+ */
30
+ export declare function endianness(): Endian;
31
+ /**
32
+ * @class Buffer
33
+ * @classdesc Buffer 类提供用于优化读取,写入以及处理二进制数据的方法和属性
34
+ */
35
+ export declare class Buffer {
36
+ #private;
37
+ /**
38
+ * @constructor
39
+ * @param {number} [length] 缓冲区初始大小
40
+ * @param {number} [pageSize] 缓冲区分页大小,扩容时将按分页大小增加
41
+ */
42
+ constructor(length?: number, pageSize?: number);
43
+ /**
44
+ * @constructor
45
+ * @param {Uint8Array} bytes 缓冲区初始数据
46
+ * @param {number} [pageSize] 缓冲区分页大小,扩容时将按分页大小增加
47
+ */
48
+ constructor(bytes?: Uint8Array, pageSize?: number);
49
+ /**
50
+ * @public
51
+ * @property {number} offset
52
+ * @description 设置读写指针位置,以字节为单位
53
+ * @description 下一次调用读写方法时将在此位置开始读写
54
+ */
55
+ set offset(offset: number);
56
+ /**
57
+ * @public
58
+ * @property {number} offset
59
+ * @description 获取读写指针的位置
60
+ * @returns {number}
61
+ */
62
+ get offset(): number;
63
+ /**
64
+ * @public
65
+ * @property {number} length
66
+ * @description 设置 Buffer 长度
67
+ * @description 如果将长度设置为小于当前长度的值,将会截断该字节数组
68
+ * @description 如果将长度设置为大于当前长度的值,则用零填充字节数组的右侧
69
+ */
70
+ set length(length: number);
71
+ /**
72
+ * @public
73
+ * @property {number} length
74
+ * @description 获取 Buffer 长度
75
+ * @returns {number}
76
+ */
77
+ get length(): number;
78
+ /**
79
+ * @public
80
+ * @property {ArrayBuffer} buffer
81
+ * @description 获取 ArrayBuffer 缓冲区
82
+ * @returns {ArrayBuffer}
83
+ */
84
+ get buffer(): ArrayBuffer;
85
+ /**
86
+ * @public
87
+ * @property {Uint8Array} bytes
88
+ * @description 获取 Uint8Array 缓冲区
89
+ * @returns {Uint8Array}
90
+ */
91
+ get bytes(): Uint8Array;
92
+ /**
93
+ * @public
94
+ * @method writeInt8
95
+ * @description 在缓冲区中写入一个有符号整数
96
+ * @param {number} value 介于 -128 和 127 之间的整数
97
+ */
98
+ writeInt8(value: number): void;
99
+ /**
100
+ * @public
101
+ * @method writeUint8
102
+ * @description 在缓冲区中写入一个无符号整数
103
+ * @param {number} value 介于 0 和 255 之间的整数
104
+ */
105
+ writeUint8(value: number): void;
106
+ /**
107
+ * @method writeBoolean
108
+ * @description 在缓冲区中写入布尔值,true 写 1,false写 0
109
+ * @param {boolean} value 布尔值
110
+ */
111
+ writeBoolean(value: boolean): void;
112
+ /**
113
+ * @method writeInt16
114
+ * @description 在缓冲区中写入一个 16 位有符号整数
115
+ * @param {number} value 要写入的 16 位有符号整数
116
+ * @param {boolean} [littleEndian] 是否为小端字节序
117
+ */
118
+ writeInt16(value: number, littleEndian?: boolean): void;
119
+ /**
120
+ * @method writeUint16
121
+ * @description 在缓冲区中写入一个 16 位无符号整数
122
+ * @param {number} value 要写入的 16 位无符号整数
123
+ * @param {boolean} [littleEndian] 是否为小端字节序
124
+ */
125
+ writeUint16(value: number, littleEndian?: boolean): void;
126
+ /**
127
+ * @method writeInt32
128
+ * @description 在缓冲区中写入一个有符号的 32 位有符号整数
129
+ * @param {number} value 要写入的 32 位有符号整数
130
+ * @param {boolean} [littleEndian] 是否为小端字节序
131
+ */
132
+ writeInt32(value: number, littleEndian?: boolean): void;
133
+ /**
134
+ * @method writeUint32
135
+ * @description 在缓冲区中写入一个无符号的 32 位无符号整数
136
+ * @param {number} value 要写入的 32 位无符号整数
137
+ * @param {boolean} [littleEndian] 是否为小端字节序
138
+ */
139
+ writeUint32(value: number, littleEndian?: boolean): void;
140
+ /**
141
+ * @method writeInt64
142
+ * @description 在缓冲区中写入一个无符号的 64 位有符号整数
143
+ * @param {bigint} value 要写入的 32 位有符号整数
144
+ * @param {boolean} [littleEndian] 是否为小端字节序
145
+ */
146
+ writeInt64(value: bigint, littleEndian?: boolean): void;
147
+ /**
148
+ * @method writeUint64
149
+ * @description 在缓冲区中写入一个无符号的 64 位无符号整数
150
+ * @param {bigint} value 要写入的 64 位无符号整数
151
+ * @param {boolean} [littleEndian] 是否为小端字节序
152
+ */
153
+ writeUint64(value: bigint, littleEndian?: boolean): void;
154
+ /**
155
+ * @method writeFloat32
156
+ * @description 在缓冲区中写入一个 IEEE 754 单精度 32 位浮点数
157
+ * @param {number} value 单精度 32 位浮点数
158
+ * @param {boolean} [littleEndian] 是否为小端字节序
159
+ */
160
+ writeFloat32(value: number, littleEndian?: boolean): void;
161
+ /**
162
+ * @method writeFloat64
163
+ * @description 在缓冲区中写入一个 IEEE 754 双精度 64 位浮点数
164
+ * @param {number} value 双精度 64 位浮点数
165
+ * @param {boolean} [littleEndian] 是否为小端字节序
166
+ */
167
+ writeFloat64(value: number, littleEndian?: boolean): void;
168
+ /**
169
+ * @method write
170
+ * @description 将字符串用指定编码写入字节流
171
+ * @param {string} value 要写入的字符串
172
+ * @param {string} [encoding] 字符串编码
173
+ */
174
+ write(value: string, encoding?: string): void;
175
+ /**
176
+ * @method write
177
+ * @description 将 Uint8Array 对象写入字节流
178
+ * @param {Uint8Array} bytes 要写入 Uint8Array 对象
179
+ * @param {number} [start] Uint8Array 对象开始索引
180
+ * @param {number} [end] Uint8Array 对象结束索引
181
+ */
182
+ write(bytes: Uint8Array, start?: number, end?: number): void;
183
+ /**
184
+ * @method readInt8
185
+ * @description 从缓冲区中读取有符号的整数
186
+ * @returns {number} 介于 -128 和 127 之间的整数
187
+ */
188
+ readInt8(): number;
189
+ /**
190
+ * @method readUint8
191
+ * @description 从缓冲区中读取无符号的整数
192
+ * @returns {number} 介于 0 和 255 之间的无符号整数
193
+ */
194
+ readUint8(): number;
195
+ /**
196
+ * @method readBoolean
197
+ * @description 从缓冲区中读取布尔值
198
+ * @returns {boolean} 如果字节非零,则返回 true,否则返回 false
199
+ */
200
+ readBoolean(): boolean;
201
+ /**
202
+ * @method readInt16
203
+ * @description 从缓冲区中读取一个 16 位有符号整数
204
+ * @param {boolean} [littleEndian] 是否为小端字节序
205
+ * @returns {number} 介于 -32768 和 32767 之间的 16 位有符号整数
206
+ */
207
+ readInt16(littleEndian?: boolean): number;
208
+ /**
209
+ * @method readUint16
210
+ * @description 从缓冲区中读取一个 16 位无符号整数
211
+ * @param {boolean} [littleEndian] 是否为小端字节序
212
+ * @returns {number} 介于 0 和 65535 之间的 16 位无符号整数
213
+ */
214
+ readUint16(littleEndian?: boolean): number;
215
+ /**
216
+ * @method readInt32
217
+ * @description 从缓冲区中读取一个 32 位有符号整数
218
+ * @param {boolean} [littleEndian] 是否为小端字节序
219
+ * @returns {number} 介于 -2147483648 和 2147483647 之间的 32 位有符号整数
220
+ */
221
+ readInt32(littleEndian?: boolean): number;
222
+ /**
223
+ * @method readUint32
224
+ * @description 从缓冲区中读取一个 32 位无符号整数
225
+ * @param {boolean} [littleEndian] 是否为小端字节序
226
+ * @returns {number} 介于 0 和 4294967295 之间的 32 位无符号整数
227
+ */
228
+ readUint32(littleEndian?: boolean): number;
229
+ /**
230
+ * @method readInt64
231
+ * @description 从缓冲区中读取一个 64 位有符号整数
232
+ * @param {boolean} [littleEndian] 是否为小端字节序
233
+ * @returns {bigint} 介于 -9223372036854775808 和 9223372036854775807 之间的 64 位有符号整数
234
+ */
235
+ readInt64(littleEndian?: boolean): bigint;
236
+ /**
237
+ * @method readUint64
238
+ * @description 从缓冲区中读取一个 64 位无符号整数
239
+ * @param {boolean} [littleEndian] 是否为小端字节序
240
+ * @returns {bigint} 介于 0 和 18446744073709551615 之间的 64 位无符号整数
241
+ */
242
+ readUint64(littleEndian?: boolean): bigint;
243
+ /**
244
+ * @method readFloat32
245
+ * @description 从缓冲区中读取一个 IEEE 754 单精度 32 位浮点数
246
+ * @param {boolean} [littleEndian] 是否为小端字节序
247
+ * @returns {number} 单精度 32 位浮点数
248
+ */
249
+ readFloat32(littleEndian?: boolean): number;
250
+ /**
251
+ * @method readFloat64
252
+ * @description 从缓冲区中读取一个 IEEE 754 双精度 64 位浮点数
253
+ * @param {boolean} [littleEndian] 是否为小端字节序
254
+ * @returns {number} 双精度 64 位浮点数
255
+ */
256
+ readFloat64(littleEndian?: boolean): number;
257
+ /**
258
+ * @method read
259
+ * @description 从缓冲区中读取指定长度的 Uint8Array 对象
260
+ * @param {number} length 读取的字节长度
261
+ * @returns {Uint8Array}
262
+ */
263
+ read(length: number): Uint8Array;
264
+ /**
265
+ * @method read
266
+ * @description 从缓冲区中读取一个字符串
267
+ * @param {number} length 读取的字节长度
268
+ * @param {string} encoding 字符串编码
269
+ * @returns {string} 指定编码的字符串
270
+ */
271
+ read(length: number, encoding: string): string;
272
+ /**
273
+ * @public
274
+ * @method slice
275
+ * @description 从指定开始和结束位置索引截取并返回新的 Buffer 对象
276
+ * @param {number} [start] 截取开始位置索引
277
+ * @param {number} [end] 截取结束位置索引
278
+ * @returns {Buffer}
279
+ */
280
+ slice(start?: number, end?: number): Buffer;
281
+ /**
282
+ * @public
283
+ * @method copyWithin
284
+ * @description 从 Buffer 对象中将指定位置的数据复制到以 target 起始的位置
285
+ * @param {number} target 粘贴开始位置索引
286
+ * @param {number} start 复制开始位置索引
287
+ * @param {number} [end] 复制结束位置索引
288
+ * @returns {this}
289
+ */
290
+ copyWithin(target: number, start: number, end?: number): this;
291
+ /**
292
+ * @override
293
+ * @method toString
294
+ * @description 获取 Buffer 对象二进制编码字符串
295
+ * @returns {string}
296
+ */
297
+ toString(): string;
298
+ }
299
+ ```
300
+
301
+ [npm-image]: https://img.shields.io/npm/v/@nuintun/buffer?style=flat-square
302
+ [npm-url]: https://www.npmjs.org/package/@nuintun/buffer
303
+ [download-image]: https://img.shields.io/npm/dm/@nuintun/buffer?style=flat-square
304
+ [languages-image]: https://img.shields.io/github/languages/top/nuintun/buffer?style=flat-square
305
+ [github-url]: https://github.com/nuintun/buffer
306
+ [tree-shakeable-image]: https://img.shields.io/badge/tree--shakeable-true-brightgreen?style=flat-square
307
+ [side-effect-image]: https://img.shields.io/badge/side--effect-free-brightgreen?style=flat-square
308
+ [bundle-phobia-url]: https://bundlephobia.com/result?p=@nuintun/buffer
309
+ [license-image]: https://img.shields.io/github/license/nuintun/buffer?style=flat-square
310
+ [license-url]: https://github.com/nuintun/buffer/blob/main/LICENSE
package/cjs/Binary.cjs ADDED
@@ -0,0 +1,25 @@
1
+ /**
2
+ * @package @nuintun/buffer
3
+ * @license MIT
4
+ * @version 0.1.0
5
+ * @author nuintun <nuintun@qq.com>
6
+ * @description A buffer tool for javascript.
7
+ * @see https://github.com/nuintun/Buffer#readme
8
+ */
9
+
10
+ 'use strict';
11
+
12
+ /**
13
+ * @module Binary
14
+ */
15
+ /**
16
+ * @type {string[]}
17
+ * @description 已获得的二进制映射表
18
+ */
19
+ const mapping = [];
20
+ // 生成映射表
21
+ for (let code = 0; code < 256; code++) {
22
+ mapping[code] = String.fromCharCode(code);
23
+ }
24
+
25
+ exports.mapping = mapping;
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @module Binary
3
+ */
4
+ /**
5
+ * @type {string[]}
6
+ * @description 已获得的二进制映射表
7
+ */
8
+ export declare const mapping: string[];
@@ -0,0 +1,33 @@
1
+ /**
2
+ * @package @nuintun/buffer
3
+ * @license MIT
4
+ * @version 0.1.0
5
+ * @author nuintun <nuintun@qq.com>
6
+ * @description A buffer tool for javascript.
7
+ * @see https://github.com/nuintun/Buffer#readme
8
+ */
9
+
10
+ 'use strict';
11
+
12
+ /**
13
+ * @module UTF8
14
+ */
15
+ // 编码器实例
16
+ const encoder = new TextEncoder();
17
+ // 解码器实例
18
+ const decoder = new TextDecoder();
19
+ /**
20
+ * @function encode
21
+ * @param {string} input
22
+ * @returns {Uint8Array}
23
+ */
24
+ const encode = encoder.encode.bind(encoder);
25
+ /**
26
+ * @function decode
27
+ * @param {BufferSource} input
28
+ * @returns {string}
29
+ */
30
+ const decode = decoder.decode.bind(decoder);
31
+
32
+ exports.decode = decode;
33
+ exports.encode = encode;
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @module UTF8
3
+ */
4
+ /**
5
+ * @function encode
6
+ * @param {string} input
7
+ * @returns {Uint8Array}
8
+ */
9
+ export declare const encode: (input?: string) => Uint8Array;
10
+ /**
11
+ * @function decode
12
+ * @param {BufferSource} input
13
+ * @returns {string}
14
+ */
15
+ export declare const decode: (input?: BufferSource) => string;
@@ -0,0 +1,45 @@
1
+ /**
2
+ * @package @nuintun/buffer
3
+ * @license MIT
4
+ * @version 0.1.0
5
+ * @author nuintun <nuintun@qq.com>
6
+ * @description A buffer tool for javascript.
7
+ * @see https://github.com/nuintun/Buffer#readme
8
+ */
9
+
10
+ 'use strict';
11
+
12
+ /**
13
+ * @module Unicode
14
+ */
15
+ /**
16
+ * @function encode
17
+ * @param {string} input
18
+ * @param {TypeArray} Buffer
19
+ * @returns {Uint8Array}
20
+ */
21
+ function encode(input, TypeArray) {
22
+ const { length } = input;
23
+ const array = new TypeArray(length);
24
+ for (let i = 0; i < length; i++) {
25
+ array[i] = input.codePointAt(i) || 0;
26
+ }
27
+ return new Uint8Array(array.buffer);
28
+ }
29
+ /**
30
+ * @function decode
31
+ * @param {BufferSource} input
32
+ * @param {TypeArray} Buffer
33
+ * @returns {string}
34
+ */
35
+ function decode(input, TypeArray) {
36
+ let result = '';
37
+ const array = new TypeArray(ArrayBuffer.isView(input) ? input.buffer : input);
38
+ for (const code of array) {
39
+ result += String.fromCodePoint(code);
40
+ }
41
+ return result;
42
+ }
43
+
44
+ exports.decode = decode;
45
+ exports.encode = encode;
@@ -0,0 +1,18 @@
1
+ /**
2
+ * @module Unicode
3
+ */
4
+ export type TypeArray = typeof Uint16Array | typeof Uint32Array;
5
+ /**
6
+ * @function encode
7
+ * @param {string} input
8
+ * @param {TypeArray} Buffer
9
+ * @returns {Uint8Array}
10
+ */
11
+ export declare function encode(input: string, TypeArray: TypeArray): Uint8Array;
12
+ /**
13
+ * @function decode
14
+ * @param {BufferSource} input
15
+ * @param {TypeArray} Buffer
16
+ * @returns {string}
17
+ */
18
+ export declare function decode(input: BufferSource, TypeArray: TypeArray): string;
@@ -0,0 +1,65 @@
1
+ /**
2
+ * @package @nuintun/buffer
3
+ * @license MIT
4
+ * @version 0.1.0
5
+ * @author nuintun <nuintun@qq.com>
6
+ * @description A buffer tool for javascript.
7
+ * @see https://github.com/nuintun/Buffer#readme
8
+ */
9
+
10
+ 'use strict';
11
+
12
+ const UTF8 = require('./UTF8.cjs');
13
+ const errors = require('../errors.cjs');
14
+ const Unicode = require('./Unicode.cjs');
15
+
16
+ /**
17
+ * @module Encoding
18
+ */
19
+ /**
20
+ * @function encode
21
+ * @description 用指定编码编码字符串
22
+ * @param {string} input 需要编码的字符串
23
+ * @param {string} [encoding] 字符串编码
24
+ * @returns {Uint8Array}
25
+ */
26
+ function encode(input, encoding = 'UTF8') {
27
+ switch (encoding.toUpperCase()) {
28
+ case 'UTF8':
29
+ case 'UTF-8':
30
+ return UTF8.encode(input);
31
+ case 'UTF16':
32
+ case 'UTF-16':
33
+ return Unicode.encode(input, Uint16Array);
34
+ case 'UTF32':
35
+ case 'UTF-32':
36
+ return Unicode.encode(input, Uint32Array);
37
+ default:
38
+ throw new TypeError(errors.encodingInvalid(encoding));
39
+ }
40
+ }
41
+ /**
42
+ * @function decode
43
+ * @description 用指定编码解码字符串数据
44
+ * @param {BufferSource} input 需要解码的字符串数据
45
+ * @param {string} [encoding] 字符串编码
46
+ * @returns {string}
47
+ */
48
+ function decode(input, encoding = 'UTF8') {
49
+ switch (encoding.toUpperCase()) {
50
+ case 'UTF8':
51
+ case 'UTF-8':
52
+ return UTF8.decode(input);
53
+ case 'UTF16':
54
+ case 'UTF-16':
55
+ return Unicode.decode(input, Uint16Array);
56
+ case 'UTF32':
57
+ case 'UTF-32':
58
+ return Unicode.decode(input, Uint32Array);
59
+ default:
60
+ throw new TypeError(errors.encodingInvalid(encoding));
61
+ }
62
+ }
63
+
64
+ exports.decode = decode;
65
+ exports.encode = encode;
@@ -0,0 +1,19 @@
1
+ /**
2
+ * @module Encoding
3
+ */
4
+ /**
5
+ * @function encode
6
+ * @description 用指定编码编码字符串
7
+ * @param {string} input 需要编码的字符串
8
+ * @param {string} [encoding] 字符串编码
9
+ * @returns {Uint8Array}
10
+ */
11
+ export declare function encode(input: string, encoding?: string): Uint8Array;
12
+ /**
13
+ * @function decode
14
+ * @description 用指定编码解码字符串数据
15
+ * @param {BufferSource} input 需要解码的字符串数据
16
+ * @param {string} [encoding] 字符串编码
17
+ * @returns {string}
18
+ */
19
+ export declare function decode(input: BufferSource, encoding?: string): string;
package/cjs/enum.d.cts ADDED
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @module enum
3
+ */
4
+ export declare const enum SizeOf {
5
+ INT8 = 1,
6
+ UINT8 = 1,
7
+ INT16 = 2,
8
+ UINT16 = 2,
9
+ INT32 = 4,
10
+ UINT32 = 4,
11
+ INI64 = 8,
12
+ UINT64 = 8,
13
+ FLOAT32 = 4,
14
+ FLOAT64 = 8
15
+ }
package/cjs/errors.cjs ADDED
@@ -0,0 +1,35 @@
1
+ /**
2
+ * @package @nuintun/buffer
3
+ * @license MIT
4
+ * @version 0.1.0
5
+ * @author nuintun <nuintun@qq.com>
6
+ * @description A buffer tool for javascript.
7
+ * @see https://github.com/nuintun/Buffer#readme
8
+ */
9
+
10
+ 'use strict';
11
+
12
+ /**
13
+ * @module errors
14
+ */
15
+ // 未支持的编码格式
16
+ function encodingInvalid(encoding) {
17
+ return 'unsupported encoding ' + encoding;
18
+ }
19
+ // 未知字节序
20
+ const unknownEndianness = 'unknown endianness';
21
+ // 非法长度
22
+ const lengthInvalid = 'invalid buffer length';
23
+ // 非法读写指针
24
+ const offsetInvalid = 'invalid buffer offset';
25
+ // 数据读取溢出
26
+ const readOverflow = 'read is outside the bounds of the Buffer';
27
+ // 读写指针溢出
28
+ const offsetOverflow = 'offset is outside the bounds of the Buffer';
29
+
30
+ exports.encodingInvalid = encodingInvalid;
31
+ exports.lengthInvalid = lengthInvalid;
32
+ exports.offsetInvalid = offsetInvalid;
33
+ exports.offsetOverflow = offsetOverflow;
34
+ exports.readOverflow = readOverflow;
35
+ exports.unknownEndianness = unknownEndianness;
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @module errors
3
+ */
4
+ export declare function encodingInvalid(encoding: string): string;
5
+ export declare const unknownEndianness = 'unknown endianness';
6
+ export declare const lengthInvalid = 'invalid buffer length';
7
+ export declare const offsetInvalid = 'invalid buffer offset';
8
+ export declare const readOverflow = 'read is outside the bounds of the Buffer';
9
+ export declare const offsetOverflow = 'offset is outside the bounds of the Buffer';