Socket
Socket
Sign inDemoInstall

fast-clone

Package Overview
Dependencies
0
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    fast-clone

Extremely fast deep cloning function


Version published
Maintainers
1
Install size
11.8 kB
Created

Changelog

Source

1.5.13 (2019-03-09)

Bug Fixes

  • package: update dependencies to address vulnerabilities (766fc2a)

<a name="1.5.12"></a>

Readme

Source

npm version Build Status Coverage Status Greenkeeper badge

The fastest deep cloning function on NPM that supports the following types:

  • Objects (POJOs, null, undefined)
  • Arrays
  • Dates
  • Regular Expressions
  • Strings
  • Numbers (NaN, Positive Infinity, Negative Infinity)
  • Booleans

Speed Comparison

Average runtime of various NPM clone libraries on a large complex object loaded from json files of varying sizes ranging from 3.5 MB to 15 MB.

Library7.15 MB
fast-clone120 ms
✘ deepClone138 ms
✘ lodash.cloneDeep155 ms
✘ snapshot1,127 ms
✘ angular.copy1,942 ms
✘ clone2,085 ms

Installation

NPM

npm install fast-clone --save

Yarn

yarn add fast-clone

Usage

Fast-clone is a UMD module so you can use it in Node.js, or in Browser either using Browserfy/Webpack, or by using the global clone function if not using a module loader.

TypeScript

import clone = require('fast-clone');

JavaScript

const clone = require('fast-clone');
const a = {
	name: 'Natasha Rominov',
	age: 30,
	skills: [
		'Pistols',
		'Espionage'
	],
	dateOfBirth: new Date('1986-05-21T00:00:00.000Z')
};

const b = clone(a);

b.skills.push('That grabby thing she does with her legs');

console.log(a.skills)
console.log(b.skills);

Output will be:

['Pistols', 'Espionage']
['Pistols', 'Espionage', 'That grabby thing she does with her legs']

Contributing

Got an issue or a feature request? Log it.

Pull-requests are also welcome. 😸

Keywords

FAQs

Last updated on 09 Mar 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc