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 🙏

© 2024 – Pkg Stats / Ryan Hefner

nano-copy

v0.1.1

Published

Superfast, super small JavaScript object deep copy.

Downloads

1,245

Readme

nano-copy

Superfast, super small (1,461 bytes minimized, 709 gzipped) JavaScript object deep copy. Comparable to fast-copy in speed across multiple test runs.

Usage

npm install nano-copy
const nanoCopy = require("nano-copy");

or

<script src="./browser/nano-copy.min.js" type="application/javascript"></script>

Clone Types Supported

Built-in Classes

[ArrayBuffer,BigInt,Blob,Boolean,Buffer,DataView,Date,Error,Int8Array,Int16Array,Int32Array,Map,Number,RegExp,Set,String,Uint8Array,Uint16Array,Uint32Array]

Blob, Buffer and DataView are platform dependent and are included or excluded accordingly.

Custom constructors assuming:

  1. There is a static from method on the class constructor that creates a deep copy.

Or

  1. Object.create(Object.getPrototypeOf(source)) plus interating over all entries in the source and assigning their copies to the newly created object is correct.

Direct Copy, i.e. the same instance will be in the copy

Types returned by typeof plus,

[Boolean,Error,Number,Promise,String,Symbol,WeakMap,WeakSet]

Not Currently Supported

  1. Non-enumerable properties

API

const copy = nanoCopy(source);

Or, to copy non-standard properties on Arrays and other built-in classes pass an optional argument. Note, there is a negative performance impact on long arrays.

const copy = nanoCopy(source,{nonStandard:true);

Benchmarks

Note, ALL JavaScript benchmarks in a browser or Node.js or Deno should be taken with a grain of salt when packages are within 10 ro 15% of each other due to browser, operating system, and garbage collection driven impacts.

simple object.

| Name | Ops / sec | | ---------------- | --------- | | nanocopy | 6,114,025 | | fast-copy | 4,913,596 | | lodash.cloneDeep | 2,497,153 | | clone | 1,931,488 | | ramda | 1,082,327 | | fast-clone | 939,717 | | deepclone | 933,128 |

complex object.

| Name | Ops / sec | | ---------------- | --------- | | nanocopy | 140,249 | | fast-copy | 118,246 | | ramda | 112,758 | | deepclone | 103,544 | | fast-clone | 68,412 | | clone | 58,591 | | lodash.cloneDeep | 42,097 |

circular object

| Name | Ops / sec | | ---------------- | --------- | | nanocopy | 2,621,642 | | fast-copy | 1,719,962 | | ramda | 1,036,171 | | deepclone | 967,305 | | clone | 787,177 | | lodash.cloneDeep | 755,432 | | fast-clone | 0 |

averages

| Name | Ops / sec | | ---------------- | --------- | | nanocopy | 2,997.136 | | fast-copy | 2,221.935 | | lodash.cloneDeep | 1,160.977 | | clone | 914.969 | | ramda | 710.087 | | deepclone | 585.068 | | fast-clone | 447.621 |

Release History (Reverse Chronological Order)

2024-12-09 v0.1.1 Fixed issue related to objects potentially not having a constructor. Re-ran benchmarks.

2020-12-13 v0.1.0 Added support for non-standard properties on Arrays and clonable objects.

2020-12-10 v0.0.4b Documentation fixes.

2020-12-10 v0.0.3b Fixed node export. Added benchee benchmarks.

2020-12-10 v0.0.2b Replaced Object.entries(data) with for(const key in data). Faster and gets inherited properties.

2020-12-09 v0.0.1b Initial public release (BETA)