# fast-clone

> Extremely fast deep cloning function

Latest version **1.5.13** (published 2019-03-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install fast-clone
pnpm add fast-clone
yarn add fast-clone
bun add fast-clone
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.5.13 |
| Published | 2019-03-09 |
| First published | 2016-05-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 11 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 22 |
| Author | Ben Daniel |
| Maintainers | codeandcats |
| Keywords | clone, copy, deep, object, date, fast, fastest, quick, efficient |

## Links

- npm: https://www.npmjs.com/package/fast-clone
- Repository: https://github.com/codeandcats/fast-clone
- Homepage: https://github.com/codeandcats/fast-clone#readme
- Issues: https://github.com/codeandcats/fast-clone/issues
- npm.io page: https://npm.io/package/fast-clone

## Alternatives

- [@js-joda/timezone](https://npm.io/package/@js-joda/timezone.md) — 383.4K weekly downloads
- [chartjs-adapter-moment](https://npm.io/package/chartjs-adapter-moment.md) — 210.8K weekly downloads
- [strftime](https://npm.io/package/strftime.md) — 171.2K weekly downloads
- [vue-flatpickr-component](https://npm.io/package/vue-flatpickr-component.md) — 115.8K weekly downloads
- [timepicker](https://npm.io/package/timepicker.md) — 51.0K weekly downloads

## Recent versions

- 1.5.13 (latest) — 2019-03-09
- 1.5.12 — 2019-03-09
- 1.5.9 — 2019-03-09
- 1.5.8 — 2019-03-09
- 1.5.7 — 2019-03-09
- 1.5.6 — 2019-03-09
- 1.5.3 — 2018-04-07
- 1.5.2 — 2018-03-12
- 1.5.1 — 2018-03-12
- 1.4.2 — 2016-09-30
- 1.4.0 — 2016-09-30
- 1.3.0 — 2016-07-23
- 1.2.0 — 2016-07-19
- 1.1.0 — 2016-07-14
- 1.0.2 — 2016-05-22
- … 2 more at https://npm.io/package/fast-clone/versions

## README

<center>
	<img src="https://raw.githubusercontent.com/codeandcats/fast-clone/master/logo.png" />
</center>

[![npm version](https://badge.fury.io/js/fast-clone.svg)](https://badge.fury.io/js/fast-clone)
[![Build Status](https://travis-ci.org/codeandcats/fast-clone.svg?branch=master)](https://travis-ci.org/codeandcats/fast-clone)
[![Coverage Status](https://coveralls.io/repos/github/codeandcats/fast-clone/badge.svg?branch=master)](https://coveralls.io/github/codeandcats/fast-clone?branch=master)
[![Greenkeeper badge](https://badges.greenkeeper.io/codeandcats/fast-clone.svg)](https://greenkeeper.io/)


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.

Library            |    7.15 MB |
-------------------|------------|
✔ **fast-clone**   | **120 ms** |
✘ deepClone        |   138 ms   |
✘ lodash.cloneDeep |   155 ms   |
✘ snapshot         | 1,127 ms   |
✘ angular.copy     | 1,942 ms   |
✘ clone            | 2,085 ms   |

## Installation

### NPM
```sh
npm install fast-clone --save
```

### Yarn
```sh
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
```ts
import clone = require('fast-clone');
```

### JavaScript
```js
const clone = require('fast-clone');
```

```ts
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:
```ts
['Pistols', 'Espionage']
['Pistols', 'Espionage', 'That grabby thing she does with her legs']
```

## Contributing
Got an issue or a feature request? [Log it](https://github.com/codeandcats/fast-clone/issues).

[Pull-requests](https://github.com/codeandcats/fast-clone/pulls) are also welcome. 😸

---
_Source: https://npm.io/package/fast-clone · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
