Skip to content

ivolovikov/fastest-clone

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Fast Array Clone Library

This library can 200X times faster than lodash (benchmark) make deep copies of an array or objects with similar structure in JavaScript

EXAMPLE

// array of SAME STRUCTURED object
var sourceArray = [{ f1 : ..., f2: ... }, ...];

You can use built-in array clone function:

var clonedArray = FastClone.cloneArray(sourceArray);

or object clone constructor factory:

// creating deep clone constructor function
var Clone = FastClone.factory(sourceArray[0]);
var clonedArray = sourceArray.map(function(item) {
    // you can add here custom logic
    return new Clone(item);
});

INSTALLATION

In a browser:

<script src="https://cdn.rawgit.com/ivolovikov/fastest-clone/master/index.js"></script>

Using npm:

npm install fastest-clone

BENCHMARK

Result for Chromium 50.0.2661.102 Ubuntu 14.04 (64-bit)

Library Ops/sec
lodash 66,313
JQuery 62,164
FastClone 16,927,673
Benchmark source code - benchmark

LICENSE

Copyright (c) 2016 Ivan Volovikov

Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php

About

Fast clone library for JavaScript

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published