You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is a NodeJS library to help to read [Buffer](https://cn.nodejs.org/api/buffer.html) instance easily.
3
+
4
+
## Install
5
+
```terminal
6
+
npm i ginkgoch-buffer-reader --save
7
+
```
8
+
9
+
## Example
10
+
11
+
**Prepare for data**
12
+
```js
13
+
constbuffer=Buffer.alloc(4);
14
+
buffer.writeInt8(8, 0);
15
+
buffer.writeInt16LE(16, 1);
16
+
buffer.writeUInt32LE(32, 3);
17
+
buffer.writeDoubleBE(54.8765, 7);
18
+
```
19
+
20
+
**Without `Ginkgoch Buffer Reader`**
21
+
```js
22
+
let i1 =buffer.readInt8(0);
23
+
let i2 =buffer.readInt16LE(1);
24
+
let i3 =buffer.readUInt32LE(3);
25
+
let i4 =buffer.readDoubleBE(7);
26
+
```
27
+
28
+
**With `Ginkgoch Buffer Reader`, it automatically manages the read position for you. You don't need to remember the position and the boring type length calculations.**
29
+
```js
30
+
let i1 =br.nextInt8();
31
+
let i2 =br.nextInt16LE();
32
+
let i3 =br.nextUInt32LE();
33
+
let i4 =br.nextDoubleBE();
34
+
```
35
+
36
+
## API
37
+
```js
38
+
constructor(buffer:Buffer);
39
+
seek(offset: number, fromBeginning = true);
40
+
nextBuffer(length: number);
41
+
nextString(length: number, encoding = 'utf-8');
42
+
nextIn8();
43
+
nextUInt8();
44
+
nextUInt16LE();
45
+
nextUInt16BE();
46
+
nextInt16LE();
47
+
nextInt16BE();
48
+
nextUInt32LE();
49
+
nextUInt32BE();
50
+
nextInt32LE();
51
+
nextInt32BE();
52
+
nextFloatLE();
53
+
nextFloatBE();
54
+
nextDoubleLE();
55
+
nextDoubleBE();
56
+
```
57
+
58
+
## Issues
59
+
Contact [ginkgoch@outlook.com](mailto:ginkgoch@outlook.com) or [sumbit an issue](https://github.com/ginkgoch/node-buffer-reader/issues).
0 commit comments