Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/eknkc/brw
Binary reader & writer on Typed Arrays
https://github.com/eknkc/brw
Last synced: 9 days ago
JSON representation
Binary reader & writer on Typed Arrays
- Host: GitHub
- URL: https://github.com/eknkc/brw
- Owner: eknkc
- Created: 2015-07-31T19:07:00.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2015-07-31T19:57:56.000Z (over 9 years ago)
- Last Synced: 2024-12-17T01:34:11.259Z (17 days ago)
- Language: JavaScript
- Size: 88.9 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# BRW - Binary Reader Writer
## Install
`npm install brw`
## Reader
```js
var Reader = require("brw").Reader;var r = new Reader(arrayBuffer);
// Static length read functions
r.readInt8()
r.readInt16()
r.readInt32()
r.readUInt8()
r.readUInt16()
r.readUInt32()
r.readFloat32()
r.readFloat64()// Variable length integer
r.readVarInt()
r.readUVarInt()// UTF8 String read
r.readString() // Assumes the string has a length prefix
r.readString({ prefixed: false, len: 100 }) // Read 100 characters
```## Writer
```js
var Writer = require("brw").Writer;var w = new Writer();
// Static length read functions
w.writeInt8(var)
w.writeInt16(var)
w.writeInt32(var)
w.writeUInt8(var)
w.writeUInt16(var)
w.writeUInt32(var)
w.writeFloat32(var)
w.writeFloat64(var)// Variable length integer
w.writeVarInt(var)
w.writeUVarInt(var)// UTF8 String read
w.writeString(var) // Prefixed string with length
w.writeString(var, { prefixed: false })
```