0.3.0 • Published 8 years ago

@endeo/input v0.3.0

Weekly downloads
-
License
MIT
Repository
github
Last release
8 years ago

@endeo/input

Build Status Dependency Status npm version Coverage Status

Helps extract values from a buffer during decoding.

See packages:

  1. endeo
  2. debyte

Install

npm install --save @endeo/input

Usage

// get the builder
var Input = require('@endeo/input')

// build one with buffer/index
var input = new Input({
  buffer: someBuffer,
  index : 0
})

// look at the next byte without advancing index:
var byte = input.peek()

// advance index one passed the one we peeked at:
input.eat()

// get the next byte and advance index:
byte = input.byte()

// backup an index and return itself:
// useful if you want to backup one and pass input on...
input.back()

// check if we have another byte available
input.hasByte()

// check if we have a set number of bytes available:
input.hasBytes(5)

// get a two byte int value:
input.short()

// get an int from next 1 to 6 bytes:
input.int(4) // accepts 1-6

// get 4 byte floating point number:
input.float4()

// get 8 byte floating point number:
input.float8()

// get a string using the specified byte count:
input.string(12)

// get a buffer slice the size specified:
input.bytes(8)

MIT License

0.3.0

8 years ago

0.2.1

8 years ago

0.2.0

8 years ago

0.1.0

8 years ago