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 🙏

© 2026 – Pkg Stats / Ryan Hefner

bserializer

v1.1.0

Published

A TypeScript-based serialization/deserialization library built for exploration and learning.

Downloads

10

Readme

Data Serializer

A TypeScript-based serialization/deserialization library built for exploration and learning.


Features

  • Supports common data types:
    string, number, boolean, null, undefined, object, array, and custom handling for fixed-point decimals.
  • Compression-ready: Built-in zlib integration for file I/O.
  • Type-safe: Written in TypeScript with explicit type codes.

Installation

npm install bserializer

Requires Node.js v18+.


Usage

Serialize & Deserialize Data

import { serializeData, deserializeData } from "bserializer";

const data = { foo: [42, "bar", true], baz: null };
const serialized = serializeData(data);
const deserialized = deserializeData(serialized); // { foo: [42, "bar", true], baz: null }

File I/O with Compression

import { writeToFile, readFromFile } from "bserializer";

// Write
writeToFile("data.bin", { planets: ["🌍", "🚀", 3.1415] });

// Read
const loadedData = readFromFile("data.bin"); // { planets: ["🌍", "🚀", 3.1415] }

Benchmark

Mixed Array 100000 entries

| | Serialize Time | Size | Compressed Size | Deserialize Time | Heap Used | Heap Total | |---------------|----------------|----------------|----------------|----------------|----------------|----------------| | JSON | 94.04 ms | 14.59 MB | 1.58 MB | 112.15 ms | 94.13 MB | 124.13 MB | | Custom | 612.77 ms | 17.70 MB | 1.58 MB | 335.87 ms | 108.61 MB | 142.39 MB | | BSON | 797.34 ms | 15.76 MB | 1.64 MB | 595.68 ms | 166.28 MB | 190.45 MB | | MsgPack | 306.57 ms | 10.12 MB | 1.35 MB | 323.97 ms | 200.08 MB | 231.47 MB |

Flat Numbers 100000 entries

| | Serialize Time | Size | Compressed Size | Deserialize Time | Heap Used | Heap Total | |---------------|----------------|----------------|----------------|----------------|----------------|----------------| | JSON | 2.03 ms | 0.56 MB | 0.20 MB | 2.19 ms | 203.71 MB | 233.63 MB | | Custom | 8.75 ms | 0.86 MB | 0.12 MB | 3.41 ms | 208.68 MB | 235.93 MB | | BSON | 44.46 ms | 1.04 MB | 0.28 MB | 4.49 ms | 213.66 MB | 238.24 MB | | MsgPack | 19.48 ms | 0.35 MB | 0.20 MB | 11.17 ms | 218.25 MB | 239.01 MB |

Empy Nested Object Depth 50 100000 entries

| | Serialize Time | Size | Compressed Size | Deserialize Time | Heap Used | Heap Total | |---------------|----------------|----------------|----------------|----------------|----------------|----------------| | JSON | 581.69 ms | 47.02 MB | 0.21 MB | 842.08 ms | 294.89 MB | 330.49 MB | | Custom | 4186.99 ms | 66.28 MB | 0.32 MB | 1073.71 ms | 365.73 MB | 389.75 MB | | BSON | ERROR | ERROR | ERROR | ERROR | ERROR | ERROR | | MsgPack | 3557.09 ms | 32.52 MB | 0.14 MB | 4098.36 ms | 365.95 MB | 399.46 MB |

How It Works

Serialization Rules

  • Numbers: Stored as double by default. Fixed-point decimals (e.g., 3.14) are scaled to integers for precision.
  • Strings/Keys: UTF-8 encoded with 1-byte length headers.
  • Objects: Stored as [count][key-value pairs].
  • Special Types: undefined and null have dedicated type codes.

Compression

Uses zlib.gzipSync for file writes and zlib.gunzipSync for reads.


License

ISC.