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

quick-copy

v1.0.2

Published

NPMs fastest ES6 deep-copier. Circular references OK.

Downloads

6

Readme

quick-copy 1.0.0

This package provides the quickCopy() function, which is the fastest ES6 deep copier on NPM, handling all ES6 = ECMA-2015 data-types. The fast-copy package previously held the crown, and it documents its speed against other packages, so we just document how many times faster quick-copy is over fast-copy in the table below.

|Object type|How many times faster quick-copy is over fast-copy| |---|---| |Strings|5.0 times faster| |Numbers|2.1 times faster| |Booleans|2.2 times faster| |Dates|1.12 times faster| |RegExps|1.29 times faster| |Sets|1.15 times faster| |ArrayBuffers|1.23 times faster| |Buffers|1.61 times faster| |DataViews/Typed Arrays|NA because only quick-copy is correct (*)| |Errors|1.27 times faster|

(*) quick-copy will copy circular/duplicate ArrayBuffer references amongst typed-arrays and DataViews. Here quick-copy is faster only by a whisker. Also, with Numbers and Booleans, only quick-copy is correct.

All forms of quick-copy, copy WeakSets, WeakMaps, and Promises as is.

To copy property descriptors, non-enumerable properties, getters/setters, and properties of the data-types use quickCopy.all() rather than quickCopy(). For example, in copying a Boolean with property p, if you want the property p to be copied use quickCopy.all().

Circular/duplicate references are copied by both quickCopy(), and quickCopy.all(). quickCopy() will copy functions as is. quickCopy.all() will properly copy functions in addition to getters/setters. Like fast-copy, both quick-copies copy Errors as is. That's because copying errors properly will slow code down to a crawl since call stacks are traced.

Usage

    const {quickCopy} = require('quick-copy')
    
    const x = Object built from plain objects, plain functions, 
              ES6 data-types and Node's Buffer.  
              
    const y = quickCopy(x)          // y is a deep copy of x.
    
    const z = quickCopy.all(x)      // z is a deep copy of x.

    If property descriptors, non-enumerable properties, 
    getters/setters, and properties of the data-types are a factor, 
    then use quickCopy.all(). Otherwise you may use quickCopy()  

Configure your own Deep Copier

The quick-copy package also exports the quickCopyExt(x, params) function. quickCopyExt(x), without the second parameter, is exactly like quickCopy(x) except that it doesn't handle circular/duplicate references. So it is even faster than quickCopy(x).

Otherwise params has too many fields, so the idea is to use params only to configure your own deep copier. See Supplement.md, in the node-modules/quick-copy folder, for details.

Exports Summary

|Export|Description| |---|---| |quickCopy(x)|Fastest ES6 deep copier on NPM.| |quickCopy.all(x)|Properly copies functions and getters/setters. Copies properties of the data-types. Copies property descriptors. Copies all properties, not just the enumerable ones. In its class also fastest on NPM.| |quickCopyExt(x)|Even faster than quickCopy since it doesn't handle circular/duplicate references.| |quickCopyExt(x, params)|Configure your own deep-copier. See Supplement.md.|

P.S.

In addition to its speed, another reason to consider this package is its total iron-clad correctness: No other ES6 deep-copying package has passed this author's test suite.