{"id":49269967,"url":"https://github.com/y14e/bunshin-clone","last_synced_at":"2026-04-25T13:01:29.251Z","repository":{"id":353459044,"uuid":"1219506602","full_name":"y14e/bunshin-clone","owner":"y14e","description":"High-performance deep clone utility with descriptor support. Supports circular ref and complex built-in types.","archived":false,"fork":false,"pushed_at":"2026-04-24T01:42:05.000Z","size":31,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2026-04-24T02:28:07.282Z","etag":null,"topics":["circular-reference","clone","deep-clone","property-descriptor","structured-clone","typescript","utility"],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/bunshin-clone","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/y14e.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2026-04-24T00:19:39.000Z","updated_at":"2026-04-24T01:41:41.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/y14e/bunshin-clone","commit_stats":null,"previous_names":["y14e/bunshin-clone"],"tags_count":2,"template":false,"template_full_name":null,"purl":"pkg:github/y14e/bunshin-clone","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/y14e%2Fbunshin-clone","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/y14e%2Fbunshin-clone/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/y14e%2Fbunshin-clone/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/y14e%2Fbunshin-clone/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/y14e","download_url":"https://codeload.github.com/y14e/bunshin-clone/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/y14e%2Fbunshin-clone/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":32262801,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-25T09:15:33.318Z","status":"ssl_error","status_checked_at":"2026-04-25T09:15:31.997Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["circular-reference","clone","deep-clone","property-descriptor","structured-clone","typescript","utility"],"created_at":"2026-04-25T13:01:23.777Z","updated_at":"2026-04-25T13:01:25.423Z","avatar_url":"https://github.com/y14e.png","language":"TypeScript","readme":"# Bunshin Clone\n\nHigh-performance deep clone utility with descriptor support. Supports circular references and complex built-in types.\n\n* ⚡ Fast (no unnecessary overhead)\n* ♻️ Deep clone (no structural sharing)\n* 🔁 Supports circular ref\n* 🧠 Handles Map, Set, Array, TypedArray, Date, RegExp, etc.\n* 🧩 Optional descriptor preservation\n\n---\n\n## Usage\n\n```ts\nimport bunshinClone from 'bunshin-clone';\n\nconst source = { foo: 1, nested: { x: 1 } };\n\nconst result = bunshinClone(source);\n\nconsole.log(result);\n// { foo: 1, nested: { x: 1 } }\n\nconsole.log(result === source); // false\nconsole.log(result.nested === source.nested); // false\n```\n\n## API\n\n```ts\nbunshinClone(target)\nbunshinClone(target, options)\n```\n\n## Options\n\n```ts\ninterface BunshinCloneOptions {\n  preserveDescriptors?: boolean;\n  strictDescriptors?: boolean;\n}\n```\n\n### preserveDescriptors\n\n* `false` (default): use standard merge (faster, ignores property descriptors)\n* `true`: preserve property descriptors (getters/setters, etc.)\n\n\u003cdetails\u003e\n\u003csummary\u003eExample\u003c/summary\u003e\n\n```ts\nconst source = {};\nObject.defineProperty(source, 'x', {\n  get: () =\u003e 42,\n  enumerable: true,\n});\n\nconst result = bunshinClone(source, { preserveDescriptors: true });\n\nObject.getOwnPropertyDescriptor(result, 'x')?.get;\n// =\u003e function\n```\n\u003c/details\u003e\n\n### strictDescriptors\n\n* `false` (default): skip incompatible descriptors\n* `true`: throw if descriptor cannot be merged (e.g. non-configurable or non-writable)\n\n\u003cdetails\u003e\n\u003csummary\u003eExample\u003c/summary\u003e\n\n```ts\nObject.freeze(obj);\n\nbunshinClone(obj, { strictDescriptors: true });\n// =\u003e may throw TypeError\n```\n\u003c/details\u003e\n\n## Supported Types\n\nbunshin-clone correctly handles:\n\n* Object (plain + prototype preserved)\n* Array\n* Map\n* Set\n* Date\n* RegExp\n* ArrayBuffer\n* DataView\n* TypedArray (Uint8Array, etc.)\n* Error / DOMException\n* Blob\n* ImageData\n* URL\n* URLSearchParams\n\n## Circular ref\n\n```ts\nconst a: any = { x: 1 };\na.self = a;\n\nconst result = bunshinClone(a);\n\nresult.self === result; // true\n```\n\n## Descriptor Behavior\n\n### Default (fast path)\n\n```ts\nconst source = {\n  get x() {\n    return 42;\n  }\n};\n\nconst result = bunshinClone(source);\n\nresult.x; // 42\n// getter is NOT preserved\n```\n\n### preserveDescriptors: true\n\n```ts\nconst source = {};\nObject.defineProperty(source, 'x', {\n  get: () =\u003e 42,\n  enumerable: true,\n});\n\nconst result = bunshinClone(source, {\n  preserveDescriptors: true,\n});\n\nObject.getOwnPropertyDescriptor(result, 'x')?.get;\n// =\u003e preserved\n```\n\n### Unsupported / Pass-through Types\n\nSome values are returned as-is:\n\n* Function\n* WeakMap / WeakSet\n* Proxy (not cloned)\n* Other non-cloneable host objects\n\n```ts\nconst fn = () =\u003e {};\n\nbunshinClone(fn) === fn; // true\n```\n\n## Design Notes\n\n### Deep clone (no structural sharing)\n\nUnlike merge utilities, bunshin-clone always produces a new structure:\n\n```ts\nconst source = { a: { b: 1 } };\n\nconst result = bunshinClone(source);\n\nresult !== source; // true\nresult.a !== source.a; // true\n```\n\n### Getter / Setter behavior\n\n* Default: evaluated and converted to value\n* preserveDescriptors: preserved as-is\n\n### Descriptor safety\n\nWhen `preserveDescriptors` is enabled:\n\n* descriptors are cloned safely\n* original object is never mutated\n* errors are controlled via `strictDescriptors`\n\n## Performance\n\n* No proxy / no diffing\n* Minimal branching\n* Fast path for plain objects and arrays\n* Competitive with structuredClone in many cases\n\n## Comparison\n\n| Feature              | Bunshin Clone | structuredClone | lodash.clonedeep |\n|---------------------|--------------|----------------|------------------|\n| Circular refs       | ✅           | ✅             | ✅               |\n| Map / Set           | ✅           | ✅             | ⚠️ (partial)     |\n| TypedArray          | ✅           | ✅             | ⚠️ (shallow)     |\n| Descriptor support  | ✅           | ❌             | ❌               |\n| Functions           | pass-through | ❌ (throws)    | pass-through     |\n| Prototype preserved | ✅           | ❌             | ⚠️               |\n| Custom control      | ✅           | ❌             | ❌               |\n| Performance         | ⚡ fast       | ⚡ fast         | 🐢 slower        |\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fy14e%2Fbunshin-clone","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fy14e%2Fbunshin-clone","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fy14e%2Fbunshin-clone/lists"}