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

@brillout/jpp

v0.1.3

Published

JSON++ - Same as JSON but with support for: Date, undefined, NaN, Infinity, and RegExp.

Readme

JSON++

Same as JSON but with added support for:

  • Date
  • undefined
  • NaN
  • Inifinity
  • RegExp

JSON is great but is lacking for some (crucial) JavaScript types such as Date:

const assert = require('assert');

let obj = {
  time: new Date(),
};

assert(obj.time.constructor===Date);

// JSON converts dates to strings
obj = JSON.parse(JSON.stringify(obj));
assert(obj.time.constructor===String);

Whereas JSON++ supports Date:

const assert = require('assert');
const parse = require('@brillout/jpp/parse');
const stringify = require('@brillout/jpp/stringify');

let obj = {
  time: new Date(),
};

assert(obj.time.constructor===Date);

// JSON++ preserves Date
obj = parse(stringify(obj));
assert(obj.time.constructor===Date);

Usage

// npm install @brillout/jpp
const parse = require('@brillout/jpp/parse');
const stringify = require('@brillout/jpp/stringify');

const obj = {
  hello: 'from the future',
  time: new Date('2042-01-01'),
};

// Serialize with JSON++
const obj_serialized = stringify(obj);

// Deserialize a JSON++ string
const obj_deserialized = parse(obj_serialized);

JSON++'s stringify and parse have the exact same interface than JSON.stringify and JSON.parse. So you can use all JSON's options.

Full example

Example exposing all differences between JSON and JSON++.

// /examples/jpp.js

const assert = require('assert');

const parse = require('@brillout/jpp/parse');
const stringify = require('@brillout/jpp/stringify');

const obj = {
  date: new Date(),
  undefined: undefined,
  NaN: NaN,
  Infinity: Infinity,
  regexp: /^\d+$/g,
};

// All of `obj` can be serialized with JSON++
const obj_jpp = parse(stringify(obj))
assert(obj_jpp.date.getTime()===obj.date.getTime());
assert(obj_jpp.undefined===undefined && 'undefined' in obj_jpp);
assert(isNaN(obj_jpp.NaN));
assert(obj_jpp.Infinity===Infinity);
assert(obj_jpp.regexp.toString()===obj.regexp.toString());

// JSON cannot serialize any of `obj`
const obj_json = JSON.parse(JSON.stringify(obj))
// JSON converts dates to strings
assert(obj_json.constructor!==Date);
// JSON removes properties with a value of `undefined`
assert(!('undefined' in obj_json));
// JSON converts `NaN` to `null`
assert(obj_json.NaN===null);
// JSON converts `Infinity` to `null`
assert(obj_json.Infinity===null);
// JSON converts RegExp to an empty object
assert(obj_json.regexp.constructor===Object && Object.keys(obj_json.regexp).length===0);

To run the example:

$ git clone [email protected]:brillout/jpp.git
$ cd jpp
$ npm install
$ npm run link
$ node ./examples/jpp.js

The npm run link is required to be able to self require('@brillout/jpp').

How it works

Let's see how JSON++ serializes an object:

// /examples/inspect.js

const stringify = require('@brillout/jpp/stringify');

const obj = {
  date: new Date(),
  undefined: undefined,
  NaN: NaN,
  Infinity: Infinity,
  regexp: /^\d+$/g,
};

// We use the second argument `2` to have a prettified JSON++ string.
// (Same as in `JSON.stringify(obj, undefined, 2)`).
console.log(stringify(obj, undefined, 2));
// Prints:
/*
{
  "date": "@brillout/jpp:tYpE|Date|2018-11-14T17:39:09.245Z",
  "undefined": "@brillout/jpp:tYpE|undefined",
  "NaN": "@brillout/jpp:tYpE|NaN",
  "Infinity": "@brillout/jpp:tYpE|Infinity",
  "regexp": "@brillout/jpp:tYpE|RegExp|/^\\d+$/g"
}
*/

JSON++ is based on JSON while using prefixed strings for unsupported types. The string @brillout/jpp:tYpE is used as a unique prefix to denote our special strings and make sure that regular strings are not converted.

@brillout/jpp uses the native JSON.parse and JSON.stringify functions while modifying the serialization of unsupported types.