klona

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

Library
npm
v2.0.6
1,733stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
43/100Fair
Development Activity8
Maintenance20
Community44
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
64/100Good
Architecture70
Code Quality75
Innovation65
Learning Curve45

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

Developer Tools · Automation · No Code Platforms

40,825

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
TypeScript68%
Java21%
Updated 3 days ago
TypeScript
100%
Apache 2.0

ILLA Builder

Developer Tools · Low Code Platforms · No Code Platforms

12,312

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

View details
57
Repo Health
71
Technical
63
Dependency
Built with
TypeScript100%
Updated 3 months ago
TypeScript
94%
AGPL 3.0

Laudspeaker

Marketing · Automation

2,620

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
TypeScript94%
Updated 1 months ago
TypeScript
81%
MIT

LibreChat

Developer Tools · AI Assistants

42,871

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
TypeScript81%
JavaScript18%
Updated today
Go
69%
AGPL 3.0

Vikunja

Project Management

5,302

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
71
Dependency
Built with
Go69%
TypeScript19%
Vue10%
Updated today

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

Search