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

tdigest-sd

v1.0.1

Published

An implementation of tdigest with serialization and deserialization for space-efficient storage.

Downloads

46

Readme

tdigest

This library is based on welch/tdigest and vadimg/js_bintrees. It adds methods for serialization and deserialization for space-efficient JSON storage. For documentation covering standard usage, please consult the welch/tdigest readme and examples. For information on how to use the serialization and deserialization methods, please read on.

Serialization/Deserialization

To compactly represent a Javascript data structure like a TDigest instance, it is important to consider the storage costs of a JSON stringified object versus a JSON stringified array.

If you wanted to store a student's name and their full time status, for instance, and you didn't care about stringified JSON storage costs, the best way to represent that student is:

{
    "name": "Sheri Hodges",
    "full_time": false
}

Without unnecessary whitespace, this comes out to 41 characters. If we do care about storage of the serialized representation, a better representation would be

[
    "Sheri Hodges", false
]

This comes out to 21 characters. We can make further improvements to serialization/deserialization by serializing all false values to 0 and all true values to 1 (as long as the deserialization process knows whether something should be interpreted as a real number or a boolean). So then we have

[
    "Sheri Hodges", 0
]

This results in 18 characters.

.serialize()

var tdigest = new TDigest();
// Make changes to tdigest
var compact = JSON.stringify(tdigest.serialize());
// Store contents of `compact` for later use

.deserialize(obj)

var obj = JSON.parse(compact); // See above for how `compact` was created
var tdigest = new TDigest();
tdigest.deserialize(obj);

Browser

You can find builds for the browser on the releases page. Look for artifacts like tdigest-X.X.X.min.js where X.X.X is the version name.