# facile-clone

> Creates a shallow clone of an object, focusing on primitives and omitting or clipping large values.

Latest version **1.2.0** (published 2017-02-10) · MIT license · 0 weekly downloads

## Install

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

## 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.2.0 |
| Published | 2017-02-10 |
| First published | 2017-01-24 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Thorsten Lorenz |
| Maintainers | thlorenz |

## Links

- npm: https://www.npmjs.com/package/facile-clone
- Repository: https://github.com/thlorenz/facile-clone
- Issues: https://github.com/thlorenz/facile-clone/issues
- npm.io page: https://npm.io/package/facile-clone

## Dependencies (1)

- [xtend](https://npm.io/package/xtend.md) ~4.0.1

## Recent versions

- 1.2.0 (latest) — 2017-02-10
- 1.1.1 — 2017-02-08
- 1.1.0 — 2017-02-08
- 1.0.1 — 2017-01-24
- 1.0.0 — 2017-01-24

## README

# facile-clone [![build status](https://secure.travis-ci.org/thlorenz/facile-clone.png)](http://travis-ci.org/thlorenz/facile-clone)

Creates a shallow clone of an object, focusing on primitives and omitting or clipping large values.

```js
const facileClone = require('facile-clone')

const o = {
    num: 1
  , bool: true
  , string: '0123456789'
  , buf: Buffer.from('0123456789')
  , null: null
  , undefined: undefined
  , object: { foo: 'bar' }
}

console.log(facileClone(o))
/*  =>  { num: 1,
          bool: true,
          string: { type: 'string', len: 10, included: 0, val: '<deleted>' },
          buf: { type: 'Buffer', len: 10, included: 0, val: '<deleted>' },
          null: null,
          undefined: undefined,
          object: { type: 'object', val: '<deleted>' } } */

const bufObject = {
  buf: Buffer.from('0123456789')
}
console.log(facileClone(bufObject, { bufferLength: 5 }))
// => { buf: { type: 'Buffer', len: 10, included: 5, val: <Buffer 30 31 32 33 34> } }

const stringObject = {
  string: '0123456789'
}
console.log(facileClone(stringObject, { stringLength: 5 }))
// => { string: { type: 'string', len: 10, included: 5, val: '01234' } }
```

## Installation

    npm install facile-clone

## [API](https://thlorenz.github.io/facile-clone)

<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

### facileClone

Creates a shallow clone of the object, focusing on primitives and omitting
or clipping large values.

For objects it also attempts to detect their prototype and provides it via the `proto`
property.

**Parameters**

-   `x` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** the object to clone
-   `$0` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** options to configure how large values are omitted/clipped
    -   `$0.bufferLength` **[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)?** if greater than `0` parts of buffers are included in the clone, default: `0` (optional, default `0`)
    -   `$0.stringLength` **[Number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)?** if greater than `0` parts of strings are included in the clone, default: `0` (optional, default `0`)
    -   `$0.keepFunctions` **[Boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)?** if `true` functions are kept attached to the object, NOTE that this
        will be a reference to the actual function of the original, i.e. not a clone (optional, default `false`)

## License

MIT

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