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 🙏

© 2025 – Pkg Stats / Ryan Hefner

wackson

v1.1.7

Published

Ultra-lightweight JavaScript serializer/deserializer

Readme

Ultra-lightweight JavaScript serializer/deserializer

wackson: kinda like jackson, but wack. Also not very much like jackson.

The goal is to send a complex object through the tubes, preserving custom classes and reference equalities including circular references

You probably shouldn't use this. But if you can get away with it, it is < 100 lines of vanilla JS, so that's something.

Handles:

  • circular references
  • by-reference object deduplication and structure recreation
  • prototype restoration

Does not handle:

  • HUGE LIMITATION: function serialization (closures would be hell or maybe impossible)
    • this means dependency injection can only be done with class instances (or be used only once in constructor)
    • things like creating methods in the constructor (including binding functions) will also not work
  • Array reference deduplication (will anyone need this? would have to add wrappers all over)
  • more obscure data types like Map, Set, Symbol (some could be added fairly easily if anyone needs them)
  • constructors do not re-run on serialization
    • so no external side effects in constructors (don't do this anyway please)
  • very old javascript versions
  • already serialized chunks: can't serialize things that have _instanceReferenceId, etc.
    • this is probably the next thing to be added
  • And Much More!

If you want it to do something else, you're probably better off just editing the code for your own needs rather than trying to make this package customizable.

Installation

npm install wackson

Currently only available as an ES module because again, you can change the export format yourself. Why maintain a build process...

Usage

If you pass a registry object (map of all relevant constructor names to constructors) to deserialize, it will restore the prototypes of serialized objects and _constructorName will be deleted. If you do not, they will be plain objects and they will still have a _constructorName property.

import { serialize, deserialize } from 'wackson'
// or, you know, just copy and paste the 100 or so lines into your project

class X {
    constructor () {
        this.a = 1
    }
}

class Y extends X {
    constructor () {
        super()
        this.b = 2
    }
}

const thing = new X()
const stuff = new Y()

stuff.self = stuff
stuff.blah = thing
stuff.bleh = thing
stuff.bluh = thing

const serializedStuff = serialize(stuff)

console.log(serializedStuff)
// output:
//
// {
//   "a": 1,
//   "b": 2,
//   "self": {
//     "_instanceReference": 0.28643731385907323
//   },
//   "blah": {
//     "a": 1,
//     "_instanceReferenceId": 0.769051027807722,
//     "_constructorName": "X"
//   },
//   "bleh": {
//     "_instanceReference": 0.769051027807722
//   },
//   "bluh": {
//     "_instanceReference": 0.769051027807722
//   },
//   "_instanceReferenceId": 0.28643731385907323,
//   "_constructorName": "Y"
// }


console.log(deserialize(serializedStuff))
// output:
//
// {
//   a : 1
//   b : 2
//   blah : {a: 1, _constructorName: 'X'}
//   bleh : {a: 1, _constructorName: 'X'}
//   bluh : {a: 1, _constructorName: 'X'}
//   self : {a: 1, b: 2, self: {...}, blah: {...}, bleh: {...}, bluh: {...}, _constructorName : "Y"}
//   _constructorName : "Y"
// }


console.log(deserialize(serializedStuff, { X, Y }))
// output:
//
// {
//   a : 1
//   b : 2
//   blah : X {a: 1}
//   bleh : X {a: 1}
//   bluh : X {a: 1}
//   self : Y {a: 1, b: 2, self: Y, blah: X, bleh: X, bluh: X }
//   [[Prototype]] : X
//     constructor : class Y
// }
// 

serialize() also takes an options object:

{
    space: 2, // a common third argument to JSON.stringify,
    deduplicateInstances: true, // true by default. If false, non-circular duplicate references will still have their data in the serialized output
}

License: Steal away! I am not liable yada yada