JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 4
  • Score
    100M100P100Q18877F
  • License MIT

Make almost any JavaScript Object JSON safe.

Package Exports

  • jxo

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (jxo) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

JxO

Make almost any JavaScript Object JSON safe for use with JSON.stringify and JSON.parse. With support for circular references, Maps, Sets, Typed Arrays, Symbols and custom types.

Installation

npm install jxo
pnpm add jxo
yarn add jxo

Basic Usage

Use as a replacement for JSON.stringify and JSON.parse

import { JxO } from 'jxo';

const JXO = new JxO();

const obj = {
  supports: new Set([NaN, Infinity, undefined, new Date(), new Map([['and', 'more']])]),
};

const str = JXO.stringify(obj);

const res = JXO.parse(str);

Examples

See test.js for more examples.


TODO

  • More examples
  • Better fallback handing with customisation
  • Validate the custom types
  • Encoders for typed arrays
  • Buffers