npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

deepit

v0.2.1

Published

A pragmatic deep-clone library for JavaScript/TypeScript — preserves prototypes, descriptors, Maps, Sets, circular refs and optionally clones functions.

Downloads

17

Readme

deepit

deepit is a predictable, safe deep-clone utility for JavaScript and TypeScript. It performs structural deep cloning of complex data types while preserving prototypes, property descriptors, circular references, Maps, Sets, Dates, RegExps, ArrayBuffers, typed arrays, and more.

The library intentionally does not attempt to clone functions or closures. Functions are always copied by reference, consistent with JavaScript semantics and the behavior of established libraries.

deepit is written in TypeScript, thoroughly tested, and built for real production workloads.


Features

  • Deep cloning of objects, arrays, and nested structures.
  • Prototype preservation (supports classes and custom prototypes).
  • Property descriptor preservation, including getters and setters.
  • Circular reference handling.
  • Full support for Map and Set.
  • Full support for Date and RegExp.
  • Support for ArrayBuffer and typed arrays.
  • Typed, predictable API.
  • Functions are never cloned; they are copied by reference.
  • Zero dependencies.
  • ESM and CJS output builds.

Installation

npm install deepit

or

yarn add deepit

or

pnpm add deepit

Quick Example

import { clone } from 'deepit';

const input = {
  value: 1,
  nested: { a: 2 },
  map: new Map([['k', { x: 10 }]]),
  date: new Date(),
};

const output = clone(input);

The resulting object is deeply cloned, structurally identical, prototype-safe, and independent.


API

clone<T>(value: T, options?: CloneOptions): T

Performs a deep, structural clone of the provided value. Prototypes, descriptors, and supported built-in types are preserved.

Parameters

value The input value to clone.

options Optional configuration.

CloneOptions

interface CloneOptions {
  maxDepth?: number | null;
  skipKeys?: string[];
}
  • maxDepth: Controls recursion depth. When null (default), there is no limit. When set to a number, the clone operation will throw if it exceeds that depth.
  • skipKeys: An array of property names to omit from the cloned result. Useful for removing sensitive or unnecessary data while cloning deeply.

Return value

Returns a deep, independent copy of the input value, with the following rules:

  • Objects and arrays are cloned deeply.
  • Maps and Sets are cloned with their entries deeply cloned.
  • Prototypes and property descriptors are preserved.
  • Functions are copied by reference.
  • WeakMap and WeakSet are not cloned (they are left as references).
  • Circular references in the input are preserved.

Supported Types

| Type | Behavior | | ----------- | --------------------------------------------- | | Object | Cloned with prototype + descriptors preserved | | Array | Deep cloned | | Map | Deep cloned (keys and values) | | Set | Deep cloned (values) | | Date | Cloned | | RegExp | Cloned | | ArrayBuffer | Copied | | TypedArray | Copied | | Error | Cloned (name, message, stack) | | Function | Copied by reference | | WeakMap | Reference preserved | | WeakSet | Reference preserved |


Design Principles

Predictability

deepit avoids any behavior that could create ambiguous or incorrect clones, such as replicating closures or attempting to re-generate function internals.

Structural fidelity

The clone matches the original object's shape, descriptors, and prototypes.

Type safety

The implementation and API are written entirely in TypeScript and designed to maintain strong type guarantees.

Zero dependencies

The implementation is self-contained to avoid dependency security risks and reduce bundle size.


Limitations

These are intentional constraints that maintain correctness:

  • Functions are not cloned; they are copied by reference.
  • Closures cannot be cloned because JavaScript does not expose closure environments.
  • WeakMap and WeakSet cannot be cloned because their contents are not observable.
  • DOM nodes are not handled; deepit focuses on JavaScript data structures.

Contributing

Contributions are welcome. Please follow these steps:

  1. Fork the repository.
  2. Create a feature branch with a descriptive name.
  3. Add or update tests for all behavior changes.
  4. Ensure npm test and npm run lint pass.
  5. Submit a pull request with a clear explanation of the changes.

Issues, feature requests, and bug reports should include reproducible examples where possible.


Development

Build

npm run build

Test

npm test

Lint and Format

npm run lint
npm run format

Project Structure

src/
  index.ts
  clone.ts
  handlers/
    object.ts
    collection.ts
tests/
  clone.spec.ts

Versioning

deepit follows semantic versioning (semver):

  • Patch versions for fixes and safe refactors.
  • Minor versions for new capabilities.
  • Major versions for breaking changes.

Author

deepit is developed and maintained by Gautam Suthar. Focused on building reliable developer tooling, high-performance JavaScript utilities, and clean architectural patterns.


License

MIT License. See the LICENSE file for details.