# filter-clone

> cloning of objects and arrays by set some filters

Latest version **0.0.12** (published 2019-12-31) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.12 |
| Published | 2019-12-31 |
| First published | 2019-08-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 10.3 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | yaotaiyang99@gmail.com |
| Maintainers | yaotaiyang |
| Keywords | js, clone, filter |

## Links

- npm: https://www.npmjs.com/package/filter-clone
- npm.io page: https://npm.io/package/filter-clone

## 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

- 0.0.12 (latest) — 2019-12-31
- 0.0.11 — 2019-10-28
- 0.0.10 — 2019-10-24
- 0.0.9 — 2019-09-18
- 0.0.8 — 2019-09-17
- 0.0.7 — 2019-08-20
- 0.0.6 — 2019-08-20
- 0.0.5 — 2019-08-20
- 0.0.4 — 2019-08-20
- 0.0.3 — 2019-08-20
- 0.0.2 — 2019-08-20
- 0.0.1 — 2019-08-20

## README

you can easy copy a js object

use like this:

```javascript
npm install filter-clone --save
```

```javascript
import filterClone from 'filter-clone'
// some code
filterClone(object, include, exclude)
```

if include and exclude are all exist, exclude will be ignored

`object` can be a `array` or `object`  
`include` can be a `array` , `regexp` or `function`  
`exclude` can be a `array` or `regexp` or `function`

```javascript
/**
 * key array
 ***/
var obj = { a: 1, b: 2, c: 3 }
var b = filterClone(obj, ['a', 'b'])
// b = {a:1,b:2}

var b1 = filterClone(obj, [], ['a'])
// b1 = {b:2,c:3}

/**
 *  key reg
 ***/
var obj2 = { a: 1, b: 2, c: 3 }
var b2 = filterClone(obj, /a/)
// b2 = {a:1}

var b3 = filterClone(obj, null, /a/)
// b3 = {b:2,c:3}

/**
 *  key,value function
 ***/
var obj = { a: 123, b: 234, c: [1, 2, 3] }
var b4 = filterClone(obj, function(key, value) {
  return value > 1
})
//{a: 123, b: 234}

var b5 = filterClone(obj, null, function(key, value) {
  return value > 1
})
//{c: Array(3)}
```

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