npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

binbone

v0.2.0

Published

A binary encoder/decoder aimed at achieving optimal space utilization.

Downloads

3

Readme

node-binbone

Node.js(io.js) implemention of binbone, A binary encode specification aimed at achieving optimal space utilization.

NPM version Build Status Build status

Installation

npm i binbone -S

Usage

  • Use Block. Block can be use as both an encoder and a decoder.
Block = require("binbone");
block = new Block(1024); // args are the same as a QueueBuffer

block.writeArray([1, 2, 3]);
block.writeUInt("123456789012345"); // Big integer(use [jsbn](https://github.com/andyperlitch/jsbn))
block.readArray();
block.readUInt();
  • Use encoder/decoder.

Directly:

Encoder = require("binbone").Encoder;
encodeBlock = new Encoder();

encodeBlock.writeInt(123);

Specify a Buffer for data:

binbone = require('binbone');
buf = new binbone.QueueBuffer();
buf.writeUInt16BE(12);
decoder = new binbone.Decoder(buf);
decoder.readUInt({length: 2});

API

Encoder

  • constructor (outputBlock)

    constructor

    • param: outputBlock { FlexBuffer }

      An BinboneBlock Object

  • writeTo (outputBlock)

    Reset data block

    • param: outputBlock { FlexBuffer }

      An BinboneBlock Object

  • writeByte (value = 0)

    Write a byte.

    • param: value { number=0 }

      byte value

    • return: { number }

      length to write (always 1)

  • writeBoolean (value) (alias: writeBool)

    Write a boolean value.

    • param: value { boolean }

      boolean value

    • return: { number }

      length to write (always 1)

  • writeUInt (num = 0 | string, opts = {}) (alias: writeLength, writeSign)

    Write an unsigned integer, using variable-length coding.

    • param: num { number=0 | string }

      integer, use string for any big integer

    • param: opts { Object={} }

      options

    • option: length { number }

      byte length of integer (1, 2, 4, 8)

    • return: { number }

      length to write

  • writeInt (opts = {}) (alias: writeLong)

    Write an signed integer, using zig-zag variable-length coding.

    • param: opts { Object={} }

      options

    • option: length { number }

      byte length of integer (1, 2, 4, 8)

    • return: { number }

      length to write

  • writeFloat (value = 0)

    Write a float.

    • param: value { number=0 }

      float point number

    • return: { number }

      length to write (always 4)

  • writeDouble (value = 0)

    Write a double.

    • param: value { number=0 }

      float point number

    • return: { number }

      length to write (always 8)

  • writeBytes (values, opts = {})

    Write bytes.

    • param: values { Array | Buffer }

      bytes

    • param: opts { Object={} }

      options

    • option: length { number }

      number of bytes

    • return: { number }

      length to write

  • writeString (str, opts = {})

    Write a string.

    • param: str { string }

      string

    • param: opts { Object={} }

      options

    • option: length { number }

      byte length of string

    • return: { number }

      length to write

  • writeMap (map = {}, opts = {})

    Write a map.

    • param: map { Object | Map = {} }

      key-value map

    • param: opts { Object={} }

      options

    • option: length { number }

      size of map

    • option: keyType { string|Object }

      type of key [required]

    • option: valueType { string|Object }

      type of value [required]

    • return: { number }

      length to write

  • writeArray (arr = [], opts = {})

    Write an array of data.

    • param: arr { Array=[] }

      Array

    • param: opts { Object={} }

      options

    • option: length { number }

      length of array

    • option: valueType { string|Object }

      type of array item

    • return: { number }

      length to write

  • writeObject (obj = {}, opts = {})

    Write an object.

    • param: obj { Object={} }

      object

    • param: opts { Object={} }

      options

    • option: length { number }

      size of object

    • option: valueType { string|Object }

      type of object value

    • return: { number }

      length to write

Decoder

  • constructor (inputBlock)

    constructor

    • param: inputBlock { QueueBuffer }

      An QueueBuffer Object

  • readFrom (inputBlock)

    Reset data block

    • param: inputBlock { QueueBuffer }

      An QueueBuffer Object

  • readByte ()

    Read a single byte.

    • return: { number }

      byte

  • skipByte ()

    Skip a single byte.

  • readBoolean () (alias: readBool)

    Read boolean value.

    • return: { Boolean }

      boolean value

  • skipBoolean () (alias: skipBool)

    skip a boolean value.

  • readUInt (opts = {}) (alias: readLength, readSign)

    Read an unsigned integer.

    • param: opts { Object={} }

      options

    • option: length { number }

      byte length of integer (1, 2, 4, 8)

    • return: { number|string }

      integer, string for big integer

  • skipUInt (opts = {}) (alias: skipLength, skipSign)

    Skip an unsigned integer.

    • param: opts { Object={} }

      options (see readUint)

  • readInt (opts = {}) (alias: readLong)

    Read an signed integer.

    • param: opts { Object={} }

      options

    • option: length { number }

      byte length of integer (1, 2, 4, 8)

    • return: { number|string }

      integer, string for big integer

  • skipInt (opts = {}) (alias: skipLong)

    Skip a signed integer.

    • param: opts { Object={} }

      options(see readInt)

  • readFloat ()

    Read a float.

    • return: { Number }

      float number

  • skipFloat ()

    Skip a float.

  • readDouble ()

    Read a double.

    • return: { number }

      double number

  • skipDouble ()

    Skip a double.

  • readBytes (opts = {})

    Read bytes.

    • param: opts { Object={} }

      options

    • option: length { number }

      number of bytes

    • return: { Buffer }

      bytes

  • skipBytes (opts = {})

    Skip bytes

    • param: opts { Object={} }

      options(see readBytes)

  • readString (opts = {})

    Read a string.

    • param: opts { Object={} }

      options

    • option: length { number }

      byte length of string

    • return: { string }

      string

  • skipString (opts = {})

    Skip a string.

    • param: opts { Object={} }

      options(see readString)

  • readMap (opts = {})

    Read a map.

    • param: opts { Object={} }

      options

    • option: length { number }

      size of map

    • option: keyType { string|Object }

      type of key[required]

    • option: valueType { string|Object }

      type of value[required]

    • return: { Map(es6)|Object(else) }

      map

  • skipMap (opts = {})

    Skip a map.

    • param: opts { Object={} }

      options(see readMap)

  • readArray (opts = {})

    Read an array.

    • param: opts { Object={} }

      options

    • option: length { number }

      length of array

    • option: valueType { string|Object }

      type of array item

    • return: { Array }

      array

  • skipArray (opts = {})

    Skip an array.

    • param: opts { Object={} }

      options(see readArray)

  • readObject (opts = {})

    Read an object.

    • param: opts { Object={} }

      options

    • option: length { number }

      size of object

    • option: valueType { string|Object }

      type of object value

    • return: { Object }

      object

  • skipObject (opts = {})

    Skip an array.

    • param: opts { Object={} }

      options(see readObject)

Test

npm test

TODO

  • Record type

License

MIT@Jingchen Zhao