# fclone

> Clone objects by dropping circular references

Latest version **1.0.11** (published 2017-01-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install fclone
pnpm add fclone
yarn add fclone
bun add fclone
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.11 |
| Published | 2017-01-23 |
| First published | 2016-07-01 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 62 |
| Author | soyuka |
| Maintainers | soyuka |
| Keywords | clone, deep, circular, json, stringify, fast |

## Links

- npm: https://www.npmjs.com/package/fclone
- Repository: https://github.com/soyuka/fclone
- Homepage: https://github.com/soyuka/fclone#readme
- Issues: https://github.com/soyuka/fclone/issues
- npm.io page: https://npm.io/package/fclone

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.0.11 (latest) — 2017-01-23
- 1.0.10 — 2016-09-26
- 1.0.9 — 2016-08-19
- 1.0.8 — 2016-07-29
- 1.0.7 — 2016-07-04
- 1.0.6 — 2016-07-03
- 1.0.5 — 2016-07-02
- 1.0.4 — 2016-07-02
- 1.0.3 — 2016-07-01
- 1.0.2 — 2016-07-01
- 1.0.1 — 2016-07-01

## README

# FClone

Clone objects by dropping circular references 

[![Build Status](https://travis-ci.org/soyuka/fclone.svg?branch=master)](https://travis-ci.org/soyuka/fclone)

This module clones a Javascript object in safe mode (eg: drops circular values) recursively. Circular values are replaced with a string: `'[Circular]'`.

Ideas from [tracker1/safe-clone-deep](https://github.com/tracker1/safe-clone-deep). I improved the workflow a bit by:
- refactoring the code (complete rewrite)
- fixing node 6+
- micro optimizations
- use of `Array.isArray` and `Buffer.isBuffer`

Node 0.10 compatible, distributed files are translated to es2015.

## Installation

```bash
npm install fclone
# or
bower install fclone
```

## Usage

```javascript
const fclone = require('fclone');

let a = {c: 'hello'};
a.b = a;

let o = fclone(a);

console.log(o);
// outputs: { c: 'hello', b: '[Circular]' }

//JSON.stringify is now safe
console.log(JSON.stringify(o));
```

## Benchmarks

Some benchs:

```
fclone x 17,081 ops/sec ±0.71% (79 runs sampled)
fclone + json.stringify x 9,433 ops/sec ±0.91% (81 runs sampled)
util.inspect (outputs a string) x 2,498 ops/sec ±0.77% (90 runs sampled)
jsan x 5,379 ops/sec ±0.82% (91 runs sampled)
circularjson x 4,719 ops/sec ±1.16% (91 runs sampled)
deepcopy x 5,478 ops/sec ±0.77% (86 runs sampled)
json-stringify-safe x 5,828 ops/sec ±1.30% (84 runs sampled)
clone x 8,713 ops/sec ±0.68% (88 runs sampled)
Fastest is util.format (outputs a string)
```

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