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

pixbincodec

v0.1.2

Published

An encoder-decoder for PixBin format

Downloads

3

Readme

Install

npm install --save pixbincodec

The PixBin format

The PixBin format is a simple way to serialize Javascript/JSON objects as well as low-level buffers into a single binary buffer file you can save on your computer. Originally, it was created so that Pixpipejs could save a piece of data and that could later be reinjected into another pipeline for further processing. In the context of Pixpipejs, this piece of data could be an Image2D, an Image3D, a LineString, etc. In the end, it's just Javascript/JSON Objects and low level buffers!

The first use-case is in Pixpipejs/Javascript but the PixBin format can be created and decoded with other languages. For, example we also have Python codec.

Again a new file format??

That's right. At first, we wanted to use one of the NIfTI or MINC formats to encode Pixpipe outputs, but the browser-side Javascript context implied to write a NIfTI or MINC encoder from scratch, was cumbersome. Though MINC can store extensive metadata, multimodality data, and supports internal compression, it is built upon HDF5 making it difficult to reliably interact with in the web, and NIfTI does not have these desirable features.

To learn more about the PixBin format, read this in-depth description.

Advantages

  • Optimized for numerical data
  • Still a generic store-what-you-want format
  • Is multimodality, a bit like an archive, so you can store multiple blocks inside
  • Can handle as many metadata as you need, per block and at the parent level
  • Data of each block are zlib compressed (lossless) - optional
  • Streamable over blocks, since each block of data is compressed independently
  • Perform checksum validation on each block to guaranty data integrity - optional
  • Provide an easy-to-read header with an index of all the blocks (without having to read/decode those blocks)
  • Is a binary format
  • Easy to write a parser for

Examples

See the examples directory for the source, or:

Requirements

In order to be serialize into the PixBin format, a JS object must contain:

  • a _data attribute, no matter what it contains
  • a _metadata attribute, no matter what it contains

Notice: since this format is intended to encode numerical data like pixel arrays or position arrays, the encoding the _data object will be optimized in the following cases:

  1. _data is a typed array. There is a single stream to encode (case 1).
  2. _data is an Array of typed arrays. There are several streams to encode (case 2).

In those cases, the data will directly be encoded as low level types rather than being serialized into a more descriptive language. This will also result in smaller files.

The third case, if you chose that _data is an Object (or {}), then it will be serialized (see Object serialization). There is a single stream to encode (case 3).

Code sample