klona

A tiny, dependency-free utility for deep cloning objects, arrays, dates, and more.

Library
npm
v2.0.6
1,734 stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum. How we score it →
42 /100 Fair
Development Activity 4
Maintenance 20
Community 44
Maturity 60
Momentum 40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation. How we score it →
64 /100 Good
Architecture 70
Code Quality 75
Innovation 65
Learning Curve 45

klona is a minimal JavaScript utility for deep cloning values — objects, arrays, dates, regular expressions, Maps, Sets, typed arrays, and more — without pulling in a dependency-heavy library like lodash. It ships as ES modules, CommonJS, and UMD builds, and offers four progressively capable entry points (klona/json, klona/lite, klona, klona/full) so consumers can trade feature coverage against bundle size, from 240 bytes up to 501 bytes gzipped.

Under the hood klona recursively walks a value’s structure using Object.prototype.toString tag checks rather than instanceof, letting it correctly branch on Object, Array, Date, RegExp, Map, Set, DataView, ArrayBuffer, and TypedArray inputs. The full build additionally preserves Symbol-keyed properties and non-enumerable property descriptors, matching what a hand-rolled recursive copy would otherwise require far more code to achieve.

What You Get

  • Four import modes (klona, klona/json, klona/lite, klona/full) covering different tradeoffs between bundle size and supported types
  • ESM, CommonJS, and UMD builds generated via the bundt bundler, plus bundled TypeScript definitions
  • Deep clone support for Object, Array, Date, RegExp, Map, Set, DataView, ArrayBuffer, and TypedArray values
  • A benchmark suite comparing klona’s throughput and correctness against lodash, clone, rfdc, and clone-deep

Common Use Cases

  • Deep-cloning Redux/Vuex state trees before mutating them to preserve immutability guarantees
  • Copying configuration objects so defaults can be safely overridden per request in a server
  • Cloning parsed JSON payloads in test fixtures to avoid cross-test mutation
  • Snapshotting complex form state (dates, nested objects) in a UI before allowing edits

Under The Hood

Architecture klona is a flat, single-purpose utility with no internal layering: each of its four variants (src/json.js, src/lite.js, src/index.js, src/full.js) exports one recursive klona(x) function, resolved through the exports/modes map in package.json to the matching build. The variants share the same recursive shape but progressively add type-dispatch branches — json handles only plain Objects/Arrays, lite adds Date/RegExp, the default build adds Map/Set/DataView/ArrayBuffer/TypedArray, and full layers in Symbol-keyed and non-enumerable property cloning via a shared set() helper. There is no dependency injection or abstraction layering to speak of; the entire design surface is the branching logic inside one function per build.

Tech Stack Written in plain ES2015+ JavaScript with zero runtime dependencies. Distribution is handled by bundt (produces dist/*.js, *.mjs, and minified UMD bundles per entry point, listed under package.json’s exports and legacy modes fields), with a single index.d.ts copied across the json, lite, and full output directories via the postbuild script. Tests run on uvu (a minimal, fast test runner) loaded through the esm package for ES module support on older Node. CI (GitHub Actions) runs the suite across Node 8, 10, and 12 with nyc coverage uploaded to Codecov.

Code Quality Tests live under test/suites/, one file per data type (array.js, object.js, date.js, regexp.js, map.js, set.js, symbol.js, typedarray.js, pollution.js, class.js, descriptor.js, and more), each exporting a parameterized suite function that is run against every build variant from test/index.js, test/full.js, test/lite.js, and test/json.js — the same assertions verify all four implementations without duplicating test logic. There is a dedicated pollution.js suite specifically asserting __proto__ keys can’t be used to pollute the prototype chain. No TypeScript, ESLint, or Prettier config is present in the repo; naming favors terse single-letter locals (k, tmp, str) consistent with the project’s minimal-bundle-size goal rather than a general-audience readability standard.

What Makes It Unique klona’s core dispatch uses Object.prototype.toString.call(x) tag checks instead of instanceof, which correctly clones values that cross realm boundaries (e.g. arrays from an iframe) where instanceof checks would fail. It explicitly special-cases the __proto__ key with Object.defineProperty in both the default and lite builds to prevent prototype-pollution vectors that affect naive recursive cloners. Its most distinctive choice is offering four separately-published entry points sized from 240 to 501 bytes gzipped, letting consumers opt into exactly the type coverage they need rather than a single one-size-fits-all implementation — a packaging strategy the project’s own benchmarks show outperforming lodash’s cloneDeep by roughly 4-5x.

Used by 5 apps in this directory

TypeScript
68%
Apache 2.0

Appsmith

Automation · Developer Tools · No Code Platforms

40,959

Open-source low-code platform to build admin panels, dashboards, and internal tools connected to any database or API.

View details
93
Repo Health
79
Technical
66
Dependency
Built with
TypeScript 68%
Java 21%
Updated 6 days ago
TypeScript
100%
Apache 2.0

ILLA Builder

Design Tools · Developer Tools · Low Code Platforms

12,327

Open-source low-code platform for building internal tools with drag-and-drop UI, reactive data bindings, and real-time collaboration.

View details
56
Repo Health
71
Technical
63
Dependency
Built with
TypeScript 100%
Updated 4 months ago
TypeScript
94%
AGPL 3.0

Laudspeaker

Automation · Marketing

2,626

Open-source customer engagement platform for building visual, event-triggered messaging journeys across email, SMS, push, in-app, and webhooks.

View details
51
Repo Health
66
Technical
62
Dependency
Built with
TypeScript 94%
Updated 2 months ago
TypeScript
82%
MIT

LibreChat

AI Assistants · Developer Tools

45,009

Unite every major AI model in one self-hosted chat platform with agents, code execution, MCP tools, and enterprise authentication.

View details
93
Repo Health
81
Technical
65
Dependency
Built with
TypeScript 82%
JavaScript 17%
Updated 4 days ago
Go
66%
AGPL 3.0

Vikunja

Project Management

5,533

Self-hosted task management with natural-language quick-add, multiple views, and a fully documented REST API — your tasks, your infrastructure, zero lock-in.

View details
86
Repo Health
81
Technical
68
Dependency
Built with
Go 66%
TypeScript 22%
Vue 10%
Updated 4 days ago

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers