Skip to content

Unity-for-Unity-Manufacturing/teleport-javascript

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

teleport-js

A super light (0.9K) and fast JavaScript object (de)serialization that includes undefined, bigint, regex, etc.",

Installation

$ npm -i teleport-js

Usage

// ESM
import {parse, stringify} from 'teleport-js/esm';

// CJS
const {parse, stringify} = require('teleport-js/cjs');

const a = [{}];
a[0].a = a;
a.push(a);
a[0].b = new Map([[Symbol('s'), new Set([1, /a-z/, -Infinity])]]);
a[0].c = undefined;

const stringified = stringify(a);
// '[["1","0"],{"a":"0","b":"_0","c":"_1"},["M;[[\\"1\\"],[\\"_0\\",\\"_1\\"],[\\"s;s\\",\\"S;[[1,\\\\\\"_0\\\\\\",\\\\\\"_1\\\\\\"],[\\\\\\"R;/a-z/\\\\\\",\\\\\\"n;-Infinity\\\\\\"]]\\"]]","u"]]'

const parsed = parse(stringified);
// [
//   {
//     a: [ [Circular], [Circular] ],
//     b: Map { Symbol(s) => Set { 1, /a-z/, -Infinity } },
//     c: undefined
//   }
// ]

Supported Data Types

  • String
  • Number (including NaN, Infinity, -Infinity)
  • BigInt
  • Boolean
  • Null
  • Undefined
  • Array
  • Symbol
  • Object (including circular reference)
    • RegExp
    • Map
    • Set

Benchmarks

Benchmark Results

License

ISC

About

A super light and fast JavaScript object (de)serialization that includes date, bigint, regex, etc.

Resources

License

Security policy

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%