0.0.12 • Published 4 years ago

filter-clone v0.0.12

Weekly downloads
2
License
MIT
Repository
-
Last release
4 years ago

you can easy copy a js object

use like this:

npm install filter-clone --save
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

/**
 * 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)}
0.0.12

4 years ago

0.0.11

5 years ago

0.0.10

5 years ago

0.0.9

5 years ago

0.0.8

5 years ago

0.0.7

5 years ago

0.0.6

5 years ago

0.0.5

5 years ago

0.0.4

5 years ago

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago