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

defuss-dson

v1.1.1

Published

Typed serialization/deserialization for JavaScript datatypes (a superset of JSON).

Readme

defuss-dson

Definitely-typed Serialized Object Notation (DSON)

A TypeScript-first serialization library that extends JSON to support complex JavaScript data types while preserving type information and prototype chains.

Overview

defuss-dson serializes JavaScript data structures into JSON while preserving metadata about their original types. It's a superset of JSON, meaning any valid JSON is also valid DSON. However, with DSON, when you serialize complex types like Map, Set, Date, RegExp.

Features

  • 🔄 Bidirectional serialization - Parse and stringify with full type preservation
  • 🧬 Deep cloning - Create deep copies of complex objects with async support
  • ⚖️ Equality comparison - Smart comparison that handles complex nested structures
  • 🔗 Circular reference support - Handles circular references safely
  • 🌐 Universal compatibility - Works in browsers, Node.js, and other JavaScript environments

Installation

npm install defuss-dson

Supported Data Types

DSON supports serialization of:

Primitives

  • string, number, boolean, null, undefined
  • bigint

Built-in Objects

  • Date, RegExp, Error
  • Map, Set, WeakMap, WeakSet
  • ArrayBuffer, DataView
  • Typed arrays (Uint8Array, Int32Array, etc.)

API Reference

DSON provides two API layers:

1. JSON-Compatible Synchronous API

Perfect for simple use cases and JSON replacement:

import DSON from 'defuss-dson';

// Synchronous API - works like JSON
const data = new Map([['key', 'value']]);
const serialized = DSON.stringify(data);
const parsed = DSON.parse(serialized);

// Additional utilities
const isEqual = DSON.isEqual(data, parsed); // true
const cloned = DSON.clone(data);

Usage Examples

Basic Data Types

import DSON from 'defuss-dson';

// Dates
const date = new Date();
const serialized = DSON.stringify(date);
const parsed = DSON.parse(serialized);
console.log(parsed instanceof Date); // true

// RegExp
const regex = /test/gi;
const serializedRegex = DSON.stringify(regex);
const parsedRegex = DSON.parse(serializedRegex);
console.log(parsedRegex instanceof RegExp); // true
console.log(parsedRegex.source); // "test"
console.log(parsedRegex.flags); // "gi"

// Maps and Sets
const map = new Map([['a', 1], ['b', 2]]);
const set = new Set([1, 2, 3]);
const data = { map, set };

const serialized = DSON.stringify(data);
const parsed = DSON.parse(serialized);
console.log(parsed.map instanceof Map); // true
console.log(parsed.set instanceof Set); // true

Circular References

const obj = { name: 'parent' };
obj.self = obj; // circular reference

const serialized = DSON.stringify(obj);
const parsed = DSON.parse(serialized);
console.log(parsed.self === parsed); // true

Deep Cloning

import { clone } from 'defuss-dson';

const complex = {
  date: new Date(),
  map: new Map([['key', 'value']]),
  nested: {
    array: [1, 2, { deep: true }]
  }
};

const cloned = await clone(complex);
console.log(DSON.isEqual(complex, cloned)); // true
console.log(complex !== cloned); // true (different object)

Equality Comparison

const obj1 = {
  date: new Date('2023-01-01'),
  map: new Map([['a', 1]]),
  set: new Set([1, 2, 3])
};

const obj2 = {
  date: new Date('2023-01-01'),
  map: new Map([['a', 1]]),
  set: new Set([1, 2, 3])
};

console.log(DSON.isEqual(obj1, obj2)); // true
console.log(obj1 === obj2); // false

License

MIT License - see the LICENSE file for details.

Contributing

Contributions are welcome! Please read our contributing guidelines and submit pull requests to our GitHub repository.


Part of the defuss ecosystem.