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

bitmapper

v0.0.6

Published

Map objects to a compact buffer using a bit map and reverse it.

Downloads

3

Readme

bitmapper

Parse/unparse complex objects to/from a buffer array based on a bit structure;

Setup a structure map by defining the bit size of each property. And then convert it back and forth. The most compact data protocol possible. Perfect for low capacity hardware such as smartcards/rfids or low other band situations.

Currently only supports buffers, numbers and fixed size arrays. Don't expect the unparsed buffer to be the same since undefined and null will be zeros.

Installation

NPM Installation:

npm install bitmapper --save

Usage example

With typescript decorators

class TestItem {
  @value({ size: 10 })
  key: number;
  @value({ size: 5 })
  value: number;
}

class Test {
  //when the type is an array of other type the size is the fixed array length 
  @value({ size: 14, type: TestItem })
  array: TestMixItem[];
  //defaul type is unsigned number
  @value({ size: 10 })
  value: number;
  @value({ size: 46, type: ValueType.buffer })
  buffer: Buffer;
}

const TestMappable = bitMappable(Test); //to create a extension of the class with parse/unparse method;

const obj1 = new TestMappable();
const buffer = obj1.toBitBuffer(); //this will return a fixed size buffer based on the object map.
const obj2 = TestMappable.fromBitBuffer(buffer); //by acessing this static method you can get an instance of the TestMappable object similar to the obj1

Don't need to use the bitMappable class decorator.

const obj1 = new Test();
const buffer = toBitBuffer(obj1);
const obj2 = fromBitBuffer(buffer, { type: Test }); 

Without any typescript decorators

Also don't need to use any class decorator.

    const obj1 = { value1: 0xF, value2: 0xAA }
    const bitmap = [ { prop: "value1", size: 4, type: ValueType.unsigned }, { prop: "value2", size: 8, type: ValueType.unsigned } ];
    const buffer = toBitBuffer(x, { bitmap });
    const obj2 = fromBitBuffer(buffer, { bitmap });

For more examples and usage, please refer to the Test.

Release History

  • 0.0.5
    • remove log
  • 0.0.4
    • fix strange problem with bit-buffer
  • 0.0.3
    • finished readme
    • Add non typescript option without use of decorators
  • 0.0.2
    • Fix ignores
    • Add typescript declaration
  • 0.0.1
    • Work in progress

Meta

Distributed under the MIT license.

https://github.com/msi-dev/bitmapper

Contributing

  1. Fork it (https://github.com/msi-dev/bitmapper/fork)
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Commit your changes (git commit -am 'Add some fooBar')
  4. Push to the branch (git push origin feature/fooBar)
  5. Create a new Pull Request