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

qclone

v1.2.0

Published

the fastest function for deep clone js objects compatible with es6

Downloads

569

Readme

qclone

the fastest function for deep clone js objects compatible with es6

*according to the author, this cloning script is the fastest in the industry(watch benchmarks)

Install

npm install --save qclone

Usage

const qclone = require('qclone');

or connect separate modules:

const qclone = require('qclone/qcloneStrictCircular');

const newCloneObj = qclone({ foo: 1 });

Features

  • support for all new classes ES6;
  • very quickly clone(qclone);
  • correctly clone(qcloneStrict / qcloneStrictCircular);
  • support circular objects(qcloneCircular / qcloneStrictCircular);
  • library has no dependencies;

The library contains four cloning functions: qclone, qcloneStrict, qcloneCircular, qcloneStrictCircular.

For more than 90% of cases, the algorithm is suitable - qclone. If you lack it, for example, for cyclic objects or strict copying, you can use the following algorithms:

  • qcloneStrict - for strict cloning(non-enumerable and Symbol properties);
  • qcloneCircular - for cyclic objects (without strict cloning);
  • qcloneStrictCircular - for strict cloning of cyclic objects;

Benchmarks

For more balanced testing of performance, tests of other projects were used

Nodejs - v13.3.0
Date - 22.01.2020

rfdc project test result

benchDeepCopy*100: 7776.478ms
benchLodashCloneDeep*100: 20040.199ms
benchFastCopy*100: 10990.298ms
benchRfdc*100: 4435.846ms
benchQclone*100: 3481.686ms
benchQcloneCircular*100: 5113.696ms
benchQcloneStrict*100: 47226.868ms
benchQcloneStrictCircular*100: 48079.723ms
benchRfdcProto*100: 4354.412ms
benchRfdcCircles*100: 5461.455ms
benchRfdcCirclesProto*100: 5541.977ms

fast-copy project test result

| Name | Ops / sec | | -------------------- | --------- | | qclone | 2,069.919 | | qcloneCircular | 1,092.98 | | fast-copy | 674.629 | | lodash.cloneDeep | 323.661 | | clone | 323.007 | | ramda | 206.035 | | deepclone | 175.292 | | qcloneStrictCircular | 156.258 | | fast-copy (strict) | 151.173 | | fast-clone | 125.238 | | qcloneStrict | 121.703 |

Nodejs - v14.9.0
Date - 01.10.2020

klona project test result

Benchmark :: json
  JSON.stringify         x 18,355 ops/sec ±0.68% (83 runs sampled)
  lodash                 x 19,501 ops/sec ±0.53% (87 runs sampled)
  rfdc                   x 90,519 ops/sec ±0.57% (88 runs sampled)
  clone                  x 16,963 ops/sec ±0.33% (88 runs sampled)
  clone/include          x 9,343 ops/sec ±0.70% (90 runs sampled)
  clone-deep             x 52,055 ops/sec ±0.79% (89 runs sampled)
  deep-copy              x 51,496 ops/sec ±0.22% (87 runs sampled)
  klona/full             x 21,732 ops/sec ±0.24% (92 runs sampled)
  klona                  x 114,363 ops/sec ±0.57% (89 runs sampled)
  klona/lite             x 127,689 ops/sec ±0.57% (88 runs sampled)
  klona/json             x 136,417 ops/sec ±0.23% (92 runs sampled)
  qclone                 x 141,203 ops/sec ±0.41% (90 runs sampled)

  Benchmark :: lite
  lodash                 x 14,211 ops/sec ±0.36% (92 runs sampled)
  clone                  x 14,738 ops/sec ±1.38% (87 runs sampled)
  clone/include          x 7,970 ops/sec ±0.67% (89 runs sampled)
  clone-deep             x 41,739 ops/sec ±0.47% (90 runs sampled)
  klona/full             x 18,371 ops/sec ±0.34% (89 runs sampled)
  klona                  x 89,160 ops/sec ±0.42% (91 runs sampled)
  klona/lite             x 97,288 ops/sec ±0.65% (90 runs sampled)
  qclone                 x 109,539 ops/sec ±0.27% (90 runs sampled)

*The next two tests below clone the keys for the Map class if those are objects. I do not consider this behavior to be correct, since the work for such keys is based on references and not values (most cloning libraries support my opinion).

  Benchmark :: default
  lodash                 x 14,529 ops/sec ±2.64% (82 runs sampled)
  clone                  x 31,979 ops/sec ±0.35% (88 runs sampled)
  clone/include          x 18,751 ops/sec ±0.50% (87 runs sampled)
  klona/full             x 30,788 ops/sec ±1.00% (88 runs sampled)
  klona                  x 77,617 ops/sec ±0.34% (91 runs sampled)
  qclone                 x 169,658 ops/sec ±0.59% (90 runs sampled)

  Benchmark :: full
  lBenchmark :: full
  lodash                 x 15,230 ops/sec ±3.17% (89 runs sampled)
  clone/include          x 13,651 ops/sec ±0.43% (86 runs sampled)
  klona/full             x 26,493 ops/sec ±2.05% (92 runs sampled)
  qclone(qcloneStrict)   x 39,462 ops/sec ±1.05% (90 runs sampled)

License

MIT Yuriy Khomenko