JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 27511380
  • Score
    100M100P100Q251466F
  • License ISC

A structuredClone polyfill

Package Exports

  • @ungap/structured-clone
  • @ungap/structured-clone/package.json

Readme

structuredClone polyfill

build status Coverage Status

An env agnostic serializer and deserializer with recursion ability and types beyond JSON from the HTML standard itself.

Serialized values can be safely stringified as JSON too, and deserialization resurrect all values, even recursive, or more complex than what JSON allows.

// as default export
import structuredClone from '@ungap/structured-clone';
const cloned = structuredClone({any: 'serializable'});

// as independent serializer/deserializer
import {serialize, deserialize} from '@ungap/structured-clone';

// the result can be stringified as JSON without issues
// even if there is recursive data, bigint values,
// typed arrays, and so on
const serialized = serialize({any: 'serializable'});

// the result will be a replica of the original object
const deserialized = deserialize(serialized);