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

linearize

v0.4.0

Published

Javascript object encoder

Downloads

28

Readme

Linearize - Encode and Decode Data

In a Nutshell

Linearizer does basically what JSON.stringify() and JSON.parse() does, but instead of a JSON string, the encoded blob is an compact array of bytes (Uint8Array in JavaScript).

Caution!

This is work in progress. Wait for version 1.0.

Reference

const { enc, dec } = require('linearize');

let a = { a: [1,2,3],  b: 123, c: Math.pow(Math.PI, 200), t: [ true, false ], str: '100.000.000€' };
let b = enc(a);
console.log(`len=${b.length}: ${b.join(',')}`);
let c = dec(b);
let d = JSON.stringify(c);
console.log(`len=${d.length}: ${d}`);
len=63: 81,31,60,61,22,97,0,71,23,21,22,23,61,22,98,0,31,123,61,22,99,0,10,220,101,181,252,15,176,147,84,61,24,115,116,114,0,61,31,15,49,48,48,46,48,48,48,46,48,48,48,226,130,172,0,61,22,116,0,71,22,1,2
len=85: {"a":[1,2,3],"b":123,"c":2.691377013238864e+99,"str":"100.000.000€","t":[true,false]}

Encoding

  • The encoded data is not a printable string but instead a binary blob.
  • Undefined value can not be encoded and there is no implicit conversion from undefined to null.
  • Strings are UTF-8 encoded and encoding of a string includes an extra NUL byte after the string itself, so that some implementations may refer to the string in-place rather than copying it. That NUL is not included into to the decoded string.
  • Object encoding does not maintain key order. In fact keys are sorted to alphabetical order as implemented by Array.sort() in JavaScript

Author

Timo J. Rinne [email protected]

License

MIT License