{"_id":"structured-clone-es","_rev":"4-60590c87413e083e9a130c8dfe420a3f","name":"structured-clone-es","dist-tags":{"latest":"2.0.1"},"versions":{"0.0.0":{"name":"structured-clone-es","version":"0.0.0","keywords":[],"author":{"name":"Andrea Giammarchi"},"license":"ISC","_id":"structured-clone-es@0.0.0","maintainers":[{"name":"antfu","email":"anthonyfu117@hotmail.com"}],"homepage":"https://github.com/antfu/structured-clone-es#readme","bugs":{"url":"https://github.com/antfu/structured-clone-es/issues"},"dist":{"shasum":"406f07ba502e341258508143a4ebe55cc5503ba2","tarball":"https://registry.npmjs.org/structured-clone-es/-/structured-clone-es-0.0.0.tgz","fileCount":6,"integrity":"sha512-n+SWFlhaTc1jdPA+umNQ8b1yu7pEZvKxPnWIA++tLDaw2+4nSJntf/i31hzjBIB1wklWgwCAM2tuEDctmA73nw==","signatures":[{"sig":"MEYCIQDqEi18NOW59Cj4DqelIiqCrBDGbpoVr3KWhyFT4sOaEgIhAIRt6M3w8Lbz3PG+nDCOxiYxsg6j5f5/MlGk8d6yTCQA","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":12215},"main":"./dist/index.mjs","type":"module","_from":"file:structured-clone-es-0.0.0.tgz","types":"./dist/index.d.mts","module":"./dist/index.mjs","exports":{".":"./dist/index.mjs"},"scripts":{"dev":"unbuild --stub","lint":"eslint .","build":"unbuild","start":"tsx src/index.ts","release":"bumpp && pnpm publish","typecheck":"tsc --noEmit"},"_npmUser":{"name":"antfu","email":"anthonyfu117@hotmail.com"},"_resolved":"/private/var/folders/30/nymxcyb909ggq2j5lwn7b_600000gn/T/c0aab3398467bdc376fdb10699acda9d/structured-clone-es-0.0.0.tgz","_integrity":"sha512-n+SWFlhaTc1jdPA+umNQ8b1yu7pEZvKxPnWIA++tLDaw2+4nSJntf/i31hzjBIB1wklWgwCAM2tuEDctmA73nw==","repository":{"url":"git+https://github.com/antfu/structured-clone-es.git","type":"git"},"_npmVersion":"10.9.0","description":"A re-distribution of @ungap/structured-clone for Node.js comptaible ES Modules","directories":{},"lint-staged":{"*":"eslint --fix"},"sideEffects":false,"_nodeVersion":"22.12.0","_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.19.2","pnpm":"^9.15.4","vite":"^6.0.7","bumpp":"^9.10.1","eslint":"^9.18.0","unbuild":"^3.3.1","@antfu/ni":"^23.2.0","typescript":"^5.7.3","@types/node":"^22.10.6","lint-staged":"^15.3.0","@antfu/utils":"^8.1.0","simple-git-hooks":"^2.11.1","@antfu/eslint-config":"^3.14.0","@ungap/structured-clone":"^1.2.1","@types/ungap__structured-clone":"^1.2.0"},"simple-git-hooks":{"pre-commit":"pnpm lint-staged"},"_npmOperationalInternal":{"tmp":"tmp/structured-clone-es_0.0.0_1738318245193_0.4047192818675256","host":"s3://npm-registry-packages-npm-production"}},"1.0.0":{"name":"structured-clone-es","version":"1.0.0","keywords":[],"author":{"name":"Andrea Giammarchi"},"license":"ISC","_id":"structured-clone-es@1.0.0","maintainers":[{"name":"antfu","email":"anthonyfu117@hotmail.com"}],"homepage":"https://github.com/antfu/structured-clone-es#readme","bugs":{"url":"https://github.com/antfu/structured-clone-es/issues"},"dist":{"shasum":"cc37f73c519c0d9e5d8d8efd3a7a9250207e688d","tarball":"https://registry.npmjs.org/structured-clone-es/-/structured-clone-es-1.0.0.tgz","fileCount":6,"integrity":"sha512-FL8EeKFFyNQv5cMnXI31CIMCsFarSVI2bF0U0ImeNE3g/F1IvJQyqzOXxPBRXiwQfyBTlbNe88jh1jFW0O/jiQ==","signatures":[{"sig":"MEQCIDbA1RKb7hIBvrnoki2vDWfilsMCOpKj2e+e3iEVpofVAiBUNqT93Aq+WrNx+xUzvFxkqdBOuFGgJBvRPc6JuLmRVw==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":12215},"main":"./dist/index.mjs","type":"module","_from":"file:structured-clone-es-1.0.0.tgz","types":"./dist/index.d.mts","module":"./dist/index.mjs","exports":{".":"./dist/index.mjs"},"scripts":{"dev":"unbuild --stub","lint":"eslint .","build":"unbuild","start":"tsx src/index.ts","release":"bumpp && pnpm publish","typecheck":"tsc --noEmit"},"_npmUser":{"name":"antfu","email":"anthonyfu117@hotmail.com"},"_resolved":"/private/var/folders/30/nymxcyb909ggq2j5lwn7b_600000gn/T/703bf645becc0d010df2d0d05dd2bac1/structured-clone-es-1.0.0.tgz","_integrity":"sha512-FL8EeKFFyNQv5cMnXI31CIMCsFarSVI2bF0U0ImeNE3g/F1IvJQyqzOXxPBRXiwQfyBTlbNe88jh1jFW0O/jiQ==","repository":{"url":"git+https://github.com/antfu/structured-clone-es.git","type":"git"},"_npmVersion":"10.9.0","description":"A re-distribution of @ungap/structured-clone for Node.js comptaible ES Modules","directories":{},"lint-staged":{"*":"eslint --fix"},"sideEffects":false,"_nodeVersion":"22.12.0","_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.19.2","pnpm":"^9.15.4","vite":"^6.0.7","bumpp":"^9.10.1","eslint":"^9.18.0","unbuild":"^3.3.1","@antfu/ni":"^23.2.0","typescript":"^5.7.3","@types/node":"^22.10.6","lint-staged":"^15.3.0","@antfu/utils":"^8.1.0","simple-git-hooks":"^2.11.1","@antfu/eslint-config":"^3.14.0","@ungap/structured-clone":"^1.2.1","@types/ungap__structured-clone":"^1.2.0"},"simple-git-hooks":{"pre-commit":"pnpm lint-staged"},"_npmOperationalInternal":{"tmp":"tmp/structured-clone-es_1.0.0_1738321286657_0.24063329063974326","host":"s3://npm-registry-packages-npm-production"}},"2.0.0":{"name":"structured-clone-es","version":"2.0.0","keywords":["structured-clone","serialize","deserialize"],"author":{"name":"Andrea Giammarchi"},"license":"ISC","_id":"structured-clone-es@2.0.0","maintainers":[{"name":"antfu","email":"anthonyfu117@hotmail.com"}],"homepage":"https://github.com/antfu-collective/structured-clone-es#readme","bugs":{"url":"https://github.com/antfu-collective/structured-clone-es/issues"},"dist":{"shasum":"ab53cf4e2934c7b5fb17bda9761ac5e809d1b9cd","tarball":"https://registry.npmjs.org/structured-clone-es/-/structured-clone-es-2.0.0.tgz","fileCount":5,"integrity":"sha512-5UuAHmBLXYPCl22xWJrFuGmIhBKQzxISPVz6E7nmTmTcAOpUzlbjKJsRrCE4vADmMQ0dzeCnlWn9XufnAGf76Q==","signatures":[{"sig":"MEYCIQCJTtQH3JmGJJO9oQ4flRGNvmFhkjAsxy+15eZJZM6PpgIhANT7Pnxir1OFV7tVZEYlCnZF4/KGjSn6o0c05DCUx7Hm","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/structured-clone-es@2.0.0","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":14772},"type":"module","_from":"file:structured-clone-es-2.0.0.tgz","types":"./dist/index.d.mts","exports":{".":"./dist/index.mjs","./package.json":"./package.json"},"scripts":{"dev":"tsdown --watch","lint":"eslint .","test":"vitest","build":"tsdown","start":"tsx src/index.ts","release":"bumpp","typecheck":"tsc --noEmit"},"_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:c8bad579-0eb9-4512-bd7e-678c609f7144"}},"_resolved":"/tmp/5cb488017931273bf92db593eba89068/structured-clone-es-2.0.0.tgz","_integrity":"sha512-5UuAHmBLXYPCl22xWJrFuGmIhBKQzxISPVz6E7nmTmTcAOpUzlbjKJsRrCE4vADmMQ0dzeCnlWn9XufnAGf76Q==","repository":{"url":"git+https://github.com/antfu-collective/structured-clone-es.git","type":"git"},"_npmVersion":"11.9.0","description":"An env-agnostic serializer and deserializer with recursion ability and types beyond JSON, based on the HTML structured clone algorithm.","directories":{},"lint-staged":{"*":"eslint --fix"},"sideEffects":false,"_nodeVersion":"24.14.0","_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.21.0","pnpm":"^10.32.1","bumpp":"^10.4.1","eslint":"^10.0.3","tsdown":"^0.21.2","vitest":"^4.0.18","@antfu/ni":"^28.3.0","typescript":"^5.9.3","@types/node":"^25.4.0","lint-staged":"^16.3.3","@antfu/utils":"^9.3.0","simple-git-hooks":"^2.13.1","@vitest/coverage-v8":"3.2.4","@antfu/eslint-config":"^7.7.2"},"simple-git-hooks":{"pre-commit":"pnpm lint-staged"},"_npmOperationalInternal":{"tmp":"tmp/structured-clone-es_2.0.0_1773364568511_0.07107323538097576","host":"s3://npm-registry-packages-npm-production"}},"2.0.1":{"_id":"structured-clone-es@2.0.1","bugs":"https://github.com/antfu-collective/structured-clone-es/issues","dist":{"shasum":"3c64f91a617a67d05266038d530130e872540bc6","tarball":"https://registry.npmjs.org/structured-clone-es/-/structured-clone-es-2.0.1.tgz","fileCount":5,"integrity":"sha512-10ZL5r77LhknxlP1FBiCW+VdnuWOEFLdSS2SKtjyEV+L4qP1hUEIMIZW94LC3jKxRmT/Dj7KkD1mqh/IY6lhKQ==","signatures":[{"sig":"MEYCIQCTiz8viV6T4IK8zg0By/EHDVcuuHgYA1/fBqm7ptbBDQIhAIxOoWqf6PP+oUJEHQDRT6slBhgoT6k3zOdWdN96lAZc","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIDBmmiz7E91JusdBpkirN8Ybl8ay4SzX6WskTQX+gUk4AiEA+U0Y8RmkrUGGzfvyr3B3/MpHKtqtqBLs+gsO+ZWs/vE="}],"attestations":{"url":"https://registry.npmjs.org/-/npm/v1/attestations/structured-clone-es@2.0.1","provenance":{"predicateType":"https://slsa.dev/provenance/v1"}},"unpackedSize":15472},"name":"structured-clone-es","type":"module","types":"./dist/index.d.mts","author":"Andrea Giammarchi","exports":{".":"./dist/index.mjs","./package.json":"./package.json"},"license":"ISC","scripts":{"dev":"tsdown --watch","lint":"eslint .","test":"vitest","build":"tsdown","start":"tsx src/index.ts","release":"bumpp","typecheck":"tsc --noEmit"},"version":"2.0.1","_npmUser":{"name":"GitHub Actions","email":"npm-oidc-no-reply@github.com","trustedPublisher":{"id":"github","oidcConfigId":"oidc:c8bad579-0eb9-4512-bd7e-678c609f7144"}},"homepage":"https://github.com/antfu-collective/structured-clone-es#readme","keywords":["structured-clone","serialize","deserialize"],"repository":{"url":"git+https://github.com/antfu-collective/structured-clone-es.git","type":"git"},"description":"An env-agnostic serializer and deserializer with recursion ability and types beyond JSON, based on the HTML structured clone algorithm.","directories":{},"lint-staged":{"*":"eslint --fix"},"maintainers":[{"name":"antfu","email":"anthonyfu117@hotmail.com"}],"sideEffects":false,"_nodeVersion":"24.18.0","_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.23.1","pnpm":"^11.17.0","bumpp":"^12.1.1","eslint":"^10.8.0","tsdown":"^0.22.14","vitest":"^4.1.10","@antfu/ni":"^30.3.0","typescript":"^5.9.3","@types/node":"^26.1.2","lint-staged":"^17.2.0","@antfu/utils":"^9.3.0","simple-git-hooks":"^2.13.1","@vitest/coverage-v8":"3.2.4","@antfu/eslint-config":"^9.2.0"},"simple-git-hooks":{"pre-commit":"pnpm lint-staged"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/structured-clone-es_2.0.1_1785311423146_0.8041346115774044"}}},"time":{"created":"2025-01-31T10:10:45.192Z","modified":"2026-07-29T07:50:23.579Z","0.0.0":"2025-01-31T10:10:45.352Z","1.0.0":"2025-01-31T11:01:26.834Z","2.0.0":"2026-03-13T01:16:08.650Z","2.0.1":"2026-07-29T07:50:23.264Z"},"bugs":"https://github.com/antfu-collective/structured-clone-es/issues","author":"Andrea Giammarchi","license":"ISC","homepage":"https://github.com/antfu-collective/structured-clone-es#readme","keywords":["structured-clone","serialize","deserialize"],"repository":{"url":"git+https://github.com/antfu-collective/structured-clone-es.git","type":"git"},"description":"An env-agnostic serializer and deserializer with recursion ability and types beyond JSON, based on the HTML structured clone algorithm.","maintainers":[{"name":"antfu","email":"anthonyfu117@hotmail.com"}],"readme":"# structured-clone-es\n\n[![npm version][npm-version-src]][npm-version-href]\n[![npm downloads][npm-downloads-src]][npm-downloads-href]\n[![bundle][bundle-src]][bundle-href]\n[![JSDocs][jsdocs-src]][jsdocs-href]\n[![License][license-src]][license-href]\n\nAn env-agnostic serializer and deserializer with recursion ability and types beyond JSON, based on the [HTML structured clone algorithm](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm).\n\nPorted from [`@ungap/structured-clone`](https://github.com/ungap/structured-clone) by [Andrea Giammarchi](https://github.com/WebReflection), with TypeScript support and modern ESM packaging.\n\n> [!NOTE]\n> If you are targeting modern environments, the native [`structuredClone()`](https://developer.mozilla.org/en-US/docs/Web/API/structuredClone) is available in all major browsers and Node.js 17+. Use it directly for better performance.\n>\n> The main value of this package is the **`serialize` / `deserialize`** and **`stringify` / `parse`** utilities, which allow you to convert complex and recursive objects into JSON-safe representations — useful for sending structured data across processes or over the network (e.g. client-server RPC communication).\n>\n> Used by [Nuxt DevTools](https://github.com/nuxt/devtools), [Vite DevTools](https://github.com/nicepkg/vite-plugin-devtools), [Node Modules Inspector](https://github.com/nicepkg/node-modules-inspector), [ESLint Config Inspector](https://github.com/eslint/config-inspector), and more.\n\n## Install\n\n```bash\nnpm i structured-clone-es\n```\n\n## Usage\n\n### Serialize / Deserialize\n\nThe result of `serialize` can be safely stringified as JSON, even if the original data contains recursive references, `BigInt` values, typed arrays, and so on.\n\n```ts\nimport { deserialize, serialize } from 'structured-clone-es'\n\n// serialize any value into a JSON-compatible array of records\nconst serialized = serialize({ any: 'serializable' })\n\n// reconstruct the original object\nconst deserialized = deserialize(serialized)\n```\n\n### Stringify / Parse\n\nA convenience wrapper that combines `serialize` + `JSON.stringify` and `JSON.parse` + `deserialize`:\n\n```ts\nimport { parse, stringify } from 'structured-clone-es'\n\nconst str = stringify({ any: 'serializable' })\nconst obj = parse(str)\n```\n\n### structuredClone\n\nA pure `structuredClone` implementation is also exported. It always uses the serialize/deserialize path without relying on the runtime's native `structuredClone`.\n\n```ts\nimport { structuredClone } from 'structured-clone-es'\n\nconst cloned = structuredClone({ any: 'serializable' })\n```\n\nIf you need polyfill `globalThis.structuredClone`, you can attach it manually:\n\n```ts\nimport { structuredClone } from 'structured-clone-es'\n\nif (!('structuredClone' in globalThis)) {\n  globalThis.structuredClone = structuredClone\n}\n```\n\n## Supported Types\n\n- Primitives: `string`, `number`, `boolean`, `null`, `undefined`, `BigInt`\n- Collections: `Array`, `Object`, `Map`, `Set`\n- Typed Arrays: `Uint8Array`, `Uint16Array`, `Uint32Array`, `Int8Array`, `Int16Array`, `Int32Array`, `ArrayBuffer`, `DataView`\n- `Date`, `RegExp`, `Error`\n- Boxed primitives: `Boolean`, `Number`, `String`\n- Circular / recursive references\n\nSee the [MDN documentation](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API/Structured_clone_algorithm#supported_types) for the full structured clone algorithm spec. Note that browser-specific types (Blob, File, ImageBitmap, etc.) are not supported by this library.\n\n## Lossy Mode\n\nBy default, `serialize` throws on incompatible types like `function` or `symbol`. Use the `lossy` option to silently replace them with `null` instead:\n\n```ts\nimport { structuredClone } from 'structured-clone-es'\n\nconst cloned = structuredClone(\n  {\n    method() { /* ignored */ },\n    special: Symbol('also ignored'),\n  },\n  { lossy: true },\n)\n```\n\n### JSON Mode\n\nThe `json` option implies `lossy` and additionally checks for `toJSON()` methods on objects:\n\n```ts\nimport { structuredClone } from 'structured-clone-es'\n\nconst cloned = structuredClone(\n  {\n    date: {\n      toJSON() {\n        return '2024-01-01'\n      },\n    },\n  },\n  { json: true },\n)\n```\n\nThe `stringify` / `parse` exports use both `json` and `lossy` by default.\n\n## Credits\n\nThis project is a TypeScript port of [`@ungap/structured-clone`](https://github.com/ungap/structured-clone), originally created by [Andrea Giammarchi](https://github.com/WebReflection) under the ISC license.\n\n## License\n\n[ISC](./LICENSE.md)\n\n<!-- Badges -->\n\n[npm-version-src]: https://img.shields.io/npm/v/structured-clone-es?style=flat&colorA=080f12&colorB=1fa669\n[npm-version-href]: https://npmjs.com/package/structured-clone-es\n[npm-downloads-src]: https://img.shields.io/npm/dm/structured-clone-es?style=flat&colorA=080f12&colorB=1fa669\n[npm-downloads-href]: https://npmjs.com/package/structured-clone-es\n[bundle-src]: https://img.shields.io/bundlephobia/minzip/structured-clone-es?style=flat&colorA=080f12&colorB=1fa669&label=minzip\n[bundle-href]: https://bundlephobia.com/result?p=structured-clone-es\n[license-src]: https://img.shields.io/github/license/antfu-collective/structured-clone-es.svg?style=flat&colorA=080f12&colorB=1fa669\n[license-href]: https://github.com/antfu-collective/structured-clone-es/blob/main/LICENSE\n[jsdocs-src]: https://img.shields.io/badge/jsdocs-reference-080f12?style=flat&colorA=080f12&colorB=1fa669\n[jsdocs-href]: https://www.jsdocs.io/package/structured-clone-es\n","readmeFilename":""}