Skip to content

[Replacement]: @ungap/structured-clone #1308

Backlog

Description

@maksimgm

Package to replace

@ungap/structured-clone

Package link

https://npmx.dev/package/@ungap/structured-clone

Native replacement(s)

structuredClone (global, already in the native manifest)

Documentation

https://developer.mozilla.org/en-US/docs/Web/API/Window/structuredClone

Availability

Node.js v17+, Deno, Bun and all modern browsers

Rationale

it's a polyfill for structuredClone. ~136M weekly downloads. on dates, maps, sets, regexps, bigints, sparse arrays, errors, typed arrays and circular refs the clone came out the same as the native one, and both throw DataCloneError on functions by default. the lossy: true option (drops functions and symbols instead of throwing) and the @ungap/structured-clone/json helpers don't have a native equivalent

Code example (optional)

import structuredClone from '@ungap/structured-clone' // [!code --]

const copy = structuredClone(value)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions