klona is a minimalist, high-performance utility for deep cloning JavaScript objects, arrays, dates, regexps, and other complex data types. Currently stable at version 2.0.6, it maintains a regular release cadence with frequent patches and minor improvements, as seen with multiple patch releases since v2.0.0. Its primary differentiator lies in its tiny footprint (ranging from 240B for `klona/json` to 501B for `klona/full` gzipped) and superior speed compared to many alternatives. It offers multiple "modes" (`klona/json`, `klona/lite`, `klona`, `klona/full`), allowing developers to import only the necessary functionality for specific data type support, thereby optimizing bundle size. It supports ESM, CommonJS, and UMD, and ships with TypeScript types.
npm install klonaVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to import and use the `klona` function to perform a deep clone of a complex object, including nested objects, dates, regexps, sets, and maps, and verifies that modifications to the clone do not affect the original source object.
Update your imports: For ESM, change `import klona from 'klona'` to `import { klona } from 'klona'`. For CommonJS, change `const klona = require('klona')` to `const { klona } = require('klona')`. This applies to all `klona` modes (e.g., `klona/json`, `klona/lite`).Upgrade to `klona@2.0.5` or newer to ensure correct handling of `Object.assign` in class constructors.
Upgrade to `klona@2.0.4` or newer to ensure that prototype methods are correctly copied when using the `klona/full` module.
Upgrade to `klona@1.1.1` or newer to resolve issues with `Set` and `Map` cloning and benefit from improved prototype pollution protection.
Upgrade to `klona@2.0.6` or newer to gain proper TypeScript `nodenext` support.
For ESM, change `import klona from 'klona'` to `import { klona } from 'klona'`. For CommonJS, change `const klona = require('klona')` to `const { klona } = require('klona')`.Ensure your TypeScript version and configuration (`moduleResolution`) are compatible. Clear your editor's TypeScript cache if using VSCode. The correct import for v2+ is `import { klona } from 'klona'`.No dependency data recorded yet.