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

jsonsuperset

v1.0.0

Published

Extended JSON serialization supporting RegExp, Date, Error, undefined, Map, Set, and circular references

Downloads

91

Readme

JsonSuperSet

Extended JSON serialization supporting Date, RegExp, Error, undefined, Map, Set, and circular references.

Installation

npm install jsonsuperset

Quick Start

const jss = require('jsonsuperset')

const data = {
  created: new Date(),
  pattern: /hello/gi,
  items: new Set([1, 2, 3]),
  config: new Map([['key', 'value']])
}

const json = jss.stringify(data)
const restored = jss.parse(json)

restored.created  // Date object
restored.pattern  // RegExp /hello/gi
restored.items    // Set {1, 2, 3}
restored.config   // Map {'key' => 'value'}

Supported Types

| Type | Description | |------|-------------| | Date | Preserved as Date objects | | RegExp | Pattern and flags preserved | | Error | Type, message, and stack preserved | | undefined | Preserved (normally lost in JSON) | | Map | Key-value pairs preserved | | Set | Unique values preserved | | Circular refs | Self-references and shared objects maintained |

API

stringify(obj)

Serializes an object to a JSON string with type information.

jss.stringify({ date: new Date('2025-01-01') })
// '{"date<!D>":1735689600000}'

parse(str)

Deserializes a JSON string back to an object with types restored.

jss.parse('{"date<!D>":1735689600000}')
// { date: Date('2025-01-01') }

encode(obj) / decode(obj)

Low-level functions for inspecting the tagged format without JSON stringification.

const encoded = jss.encode({ d: new Date(), s: new Set([1, 2]) })
// { "d<!D>": 1234567890, "s<!S>": [1, 2] }

const decoded = jss.decode(encoded)
// { d: Date, s: Set }

custom(tag, config)

Register a custom type handler.

jss.custom('B', {
  check: (key, value) => typeof value === 'bigint',
  encode: (path, key, value, context) => value.toString(),
  decode: (value, path, context) => BigInt(value)
})

jss.stringify({ big: 9007199254740993n })
// '{"big<!B>":"9007199254740993"}'

Examples

Error Preservation

const error = new TypeError('Invalid input')
error.code = 'ERR_INVALID'

const result = jss.parse(jss.stringify({ err: error }))
result.err instanceof TypeError  // true
result.err.message               // 'Invalid input'
result.err.stack                 // original stack trace

Circular References

const obj = { name: 'root' }
obj.self = obj

const result = jss.parse(jss.stringify(obj))
result.self === result  // true

Shared References

const shared = { value: 42 }
const data = { a: shared, b: shared }

const result = jss.parse(jss.stringify(data))
result.a === result.b  // true (same object reference)

Wire Format

Properties with special types are tagged using <!TAG> suffix:

key<!D>  → Date (stored as timestamp)
key<!R>  → RegExp (stored as "/pattern/flags")
key<!E>  → Error (stored as [name, message, stack])
key<!U>  → undefined (stored as null)
key<!M>  → Map (stored as object)
key<!S>  → Set (stored as array)
key<!P>  → Pointer (circular reference path)

Arrays with typed elements use compound tags: arr<![D,D,D]> or shorthand arr<![*D]> for homogeneous arrays.