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

detailed-json

v1.0.3

Published

Package that provides a type-safe and circularly-safe API for working with detailed JSON

Readme

detailed-json

Latest Release Total Downloads Install Size License

Provides a type-safe and circularly-safe API for working with detailed JSON.

Advantages

✨ Stringification of values without losing the objects' own properties

✨ JSON circular structure detection

✨ Compatibility with native JSON API

✨ Type-safe API

Installation

npm install detailed-json

# or
pnpm install detailed-json

# or
yarn add detailed-json

API

stringify

Type: (value: unknown, replacer?: Replacer, space?: number) => string

Converts a JavaScript value to a JavaScript Object Notation (JSON) string.

Options

  • value — A JavaScript value, usually an object or array, to be converted.
  • replacer — An array of strings and numbers that acts as an approved list for selecting the object properties that will be stringified. (Optional, default value - undefined)
  • space — Adds indentation, white space, and line break characters to the return-value JSON text to make it easier to read. (Optional, default value - 4)

Example

import { Json } from 'detailed-json';

const object = {
  string: 'foo bar',
  number: 123,
  bigint: 123n,
  infinity: Infinity,
  boolean: true,
  null: null,
  undefined: undefined,
  symbol: Symbol('description'),
  map: new Map([['key', 'value']]),
  set: new Set([1, 2, 3]),
  array: [1, 2, 3],
  date: new Date(),
  error: new Error('Some error'),
  function: function func() {},
  object: {
    error: new Error('Nested error'),
  },
};

object.circularRef = object;

console.log(Json.stringify(object));

/*
 * Output:
 * {
 *     "string": "foo bar",
 *     "number": 123,
 *     "bigint": "123n",
 *     "infinity": null,
 *     "boolean": true,
 *     "null": null,
 *     "map": {
 *         "key": "value"
 *     },
 *     "set": [
 *         1,
 *         2,
 *         3
 *     ],
 *     "array": [
 *         1,
 *         2,
 *         3
 *     ],
 *     "date": "2025-04-06T15:59:01.374Z",
 *     "error": {
 *         "stack": "Error: Some error …",
 *         "message": "Some error"
 *     },
 *     "object": {
 *         "error": {
 *             "stack": "Error: Nested error …",
 *             "message": "Nested error"
 *         }
 *     },
 *     "circularRef": "[Circular]"
 * }
 */

parse

Type: (text: string, reviver?: Reviver) => unknown

Converts a JavaScript Object Notation (JSON) string into an object.

Options

  • text — A valid JSON string.
  • reviver — A function that transforms the results. This function is called for each member of the object. If a member contains nested objects, the nested objects are transformed before the parent object is. (Optional, default value - undefined)

Example

import { Json } from 'detailed-json';

const text = [
  '{',
  '    "string": "foo bar",',
  '    "number": 123,',
  '    "bigint": "123n",',
  '    "infinity": null,',
  '    "boolean": true,',
  '    "null": null,',
  '    "array": [',
  '        1,',
  '        2,',
  '        3',
  '    ],',
  '    "date": "2025-04-06T15:59:01.374Z",',
  '    "error": {',
  '        "stack": "Error: Some error …",',
  '        "message": "Some error"',
  '    },',
  '    "object": {',
  '        "error": {',
  '            "stack": "Error: Nested error …",',
  '            "message": "Nested error"',
  '        }',
  '    },',
  '    "circularRef": "[Circular]"',
  '}',
].join('');

console.log(Json.parse(text));

/*
 * Output:
 * {
 *     string: 'foo bar',
 *     number: 123,
 *     bigint: 123n,
 *     infinity: null,
 *     boolean: true,
 *     null: null,
 *     array: [ 1, 2, 3 ],
 *     date: '2025-04-06T15:59:01.374Z', // Date object
 *     error: {
 *        stack: 'Error: Some error …',
 *        message: 'Some error'
 *     },
 *     object: {
 *         error: {
 *             stack: 'Error: Nested error …',
 *             message: 'Nested error'
 *         }
 *     },
 *     circularRef: '[Circular]'
 * }
 */