# ginkgoch-buffer-io

> This is a library to help to easily read and write Buffer instance.

Latest version **1.1.3** (published 2019-08-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install ginkgoch-buffer-io
pnpm add ginkgoch-buffer-io
yarn add ginkgoch-buffer-io
bun add ginkgoch-buffer-io
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.1.3 |
| Published | 2019-08-29 |
| First published | 2019-07-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 36.4 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Ginkgoch |
| Maintainers | ginkgoch-dev |
| Keywords | ginkgoch, buffer-reader, bufferreader, node-buffer-reader, buffer-writer, bufferwriter, node-buffer-writer |

## Links

- npm: https://www.npmjs.com/package/ginkgoch-buffer-io
- Repository: https://github.com/ginkgoch/node-buffer-io
- npm.io page: https://npm.io/package/ginkgoch-buffer-io

## Alternatives

- [flatbuffers](https://npm.io/package/flatbuffers.md) — 6.0M weekly downloads
- [jwt-simple](https://npm.io/package/jwt-simple.md) — 259.5K weekly downloads
- [@exodus/patch-broken-hermes-typed-arrays](https://npm.io/package/@exodus/patch-broken-hermes-typed-arrays.md) — 28.5K weekly downloads
- [@native-to-anchor/buffer-layout](https://npm.io/package/@native-to-anchor/buffer-layout.md) — 12.2K weekly downloads
- [binary-parser-encoder](https://npm.io/package/binary-parser-encoder.md) — 5.3K weekly downloads

## Recent versions

- 1.1.3 (latest) — 2019-08-29
- 1.1.2 — 2019-08-27
- 1.1.1 — 2019-08-03
- 1.1.0 — 2019-07-19
- 1.1.0-beta — 2019-07-19
- 1.0.2 — 2019-07-13
- 1.0.1 — 2019-07-12
- 1.0.0 — 2019-07-12

## README

# Ginkgoch Buffer IO for NodeJS
This is a NodeJS library to help to read/write [Buffer](https://cn.nodejs.org/api/buffer.html) instance easily.

## Install
```terminal
npm i ginkgoch-buffer-io --save
```

## Test
```terminal
npm test
```

## BufferReader Example

**Without `Ginkgoch Buffer I/O`**
```js
const buffer = Buffer.alloc(16);
buffer.writeInt8(8, 0);
buffer.writeInt16LE(16, 1);
buffer.writeUInt32LE(32, 3);
buffer.writeDoubleBE(54.8765, 7);

let i1 = buffer.readInt8(0);
let i2 = buffer.readInt16LE(1);
let i3 = buffer.readUInt32LE(3);
let i4 = buffer.readDoubleBE(7);
```

**With `Ginkgoch Buffer I/O`**
It automatically manages the read position for you. You don't need to remember the position and the boring type length calculations.
```js
const { BufferReader, BufferWriter } = require('ginkgoch-buffer-io');

const buffer = Buffer.alloc(16);
const bw = new BufferWriter(buffer);
bw.writeInt8(8);
bw.writeInt16(16);
bw.writeUInt32(32);
bw.writeDoubleBE(54.8765);

const br = new BufferReader(buffer);
let i1 = br.nextInt8();
let i2 = br.nextInt16();
let i3 = br.nextUInt32();
let i4 = br.nextDoubleBE();
```

## BufferReader
* constructor(buffer: Buffer)
* seek(offset: number, fromBeginning = true)
* nextBuffer(length: number)
* nextString(length: number, encoding = 'utf-8')
* nextInt8()
* nextUInt8()
* nextUInt16()
* nextUInt16LE()
* nextUInt16BE()
* nextInt16()
* nextInt16LE()
* nextInt16BE()
* nextUInt32()
* nextUInt32LE()
* nextUInt32BE()
* nextInt32()
* nextInt32LE()
* nextInt32BE()
* nextFloat()
* nextFloatLE()
* nextFloatBE()
* nextDouble()
* nextDoubleLE()
* nextDoubleBE()

## BufferWriter
* constructor(buffer: Buffer)
* seek(offset: number[, fromBeginning = true])
* writeBuffer(length: number)
* writeString(length: number[, encoding = 'utf-8'])
* writeInt8()
* writeUInt8()
* writeUInt16()
* writeUInt16LE()
* writeUInt16BE()
* writeInt16()
* writeInt16LE()
* writeInt16BE()
* writeUInt32()
* writeUInt32LE()
* writeUInt32BE()
* writeInt32()
* writeInt32LE()
* writeInt32BE()
* writeFloat()
* writeFloatLE()
* writeFloatBE()
* writeDouble()
* writeDoubleLE()
* writeDoubleBE()

## Issues
Contact [ginkgoch@outlook.com](mailto:ginkgoch@outlook.com) or [sumbit an issue](https://github.com/ginkgoch/node-buffer-reader/issues).

---
_Source: https://npm.io/package/ginkgoch-buffer-io · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
