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

@awsless/json

v0.0.10

Published

The `@awsless/json` package adds support for more JavaScript native types to JSON.

Readme

@awsless/json

The @awsless/json package adds support for more JavaScript native types to JSON.

Features:

  • Lightweight / Using the JS native JSON parser.
  • JSON backwards compatible.
  • No precision loss.
  • Includes support for basic JS types.
  • Extendable.

The Problem

JSON doesn't have support for types like:

  • undefined
  • NaN
  • Infinity
  • Uint8Array
  • RegExp
  • Set
  • Map
  • URL
  • Date
  • BigInt
  • BigFloat - npm package @awsless/bit-float
  • Duration - npm package @awsless/duration

Having to encode & decode these type of values can get quite annoying. We try to solve this problem by encoding these types using valid JSON syntax.

Additionally, the native JSON.parse/stringify functions do not address the potential loss of precision problem.

Basic Usage

import { parse, stringify } from '@awsless/json';

// The output will be {"$bigint":"1"}
const json = stringify(1n)

// Parse the json with a bigint inside.
const value = parse(json)

Patching incorrectly parsed JSON that was parsed with a different JSON parser

In some situations, you may not have control over the JSON parser being used. In these instances, your JSON can still be parsed, but the output may be incorrect. We can correct the inaccurate output by using the patch function.

import { stringify, patch } from '@awsless/json';

const json = stringify(1n)

// The native JSON.parse function will not parse our bigint correctly.
const broken = JSON.parse(json)

// Will fix the broken output.
const fixed = patch(broken)

Extending Supported Types

We let you extend JSON to support your own custom types.

import { parse, stringify, Serializable } from '@awsless/json';

class Custom {
	readonly value

	constructor(value: string) {
		this.value = value
	}
}

const $custom: Serializable<Custom, string> = {
	is: v => v instanceof Custom,
	parse: v => new Custom(v),
	stringify: v => v.value,
}

// Stringify your custom type.
const json = stringify(new Custom('example'), { $custom })

// Parse the json with your custom type.
const value = parse(json, { $custom })

Precision Loss

When using the native JSON.parse/stringify functions you could lose precision when parsing native numbers. And you don't always have the ability to extend JSON with your own custom types. For example when you’re communicating with a third-party API. For this reason, we have 2 utility functions that will parse the native JSON number type to your own precision-safe alternative.

[!NOTE] These utility functions will only work in environments that support JSON.rawJSON https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/rawJSON#browser_compatibility

import { safeNumberParse, safeNumberStringify } from '@awsless/json';
import { BigFloat, eq } from '@awsless/big-float';

const value = new BigFloat(1)
const json = safeNumberStringify(ONE, {
	is: v => v instanceof BigFloat,
	stringify: v => v.toString(),
})

console.log(json) // '1'

const result = safeNumberParse('1', {
	parse: v => new BigFloat(v),
})

console.log(eq(value, result)) // true

Known Issue's

Don't use the $ character inside your JSON.

We use the $ character to encode our special types inside JSON. In order to prevent parsing errors we recommend to avoid using the $ character inside your object property names.