Skip to content

fast-clone

High-performance, zero-allocation deep clone utility for JavaScript.

Part of the OcyrusJs suite.

✨ Features

  • Blazing Fast: Up to 8.5x faster than native structuredClone.
  • Lightweight: Tiny bundle size (under 1KB).
  • Zero-Allocation Path: Optimized for speed and minimal GC pressure.
  • Support: Handles primitives, nested objects, and arrays.

🚀 Performance

MethodOps/secComparison
fastClone4.7MFastest
lodash/cloneDeep1.0M4.4x slower
structuredClone0.5M8.5x slower

📦 Installation

bash
npm install @ocyrusjs/fast-clone

🛠️ Usage

typescript
import { fastClone } from '@ocyrusjs/fast-clone';

const obj = { user: { id: 1, settings: { theme: 'dark' } } };
const copy = fastClone(obj);

console.log(copy !== obj); // true
console.log(copy.user.settings !== obj.user.settings); // true

License

MIT © Nishith Patel

Released under the MIT License.