Skip to content

mithriljs-cn/util_extend_exclude

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

util_extend_exclude Build Status

js object _extend()/_exclude() for deeply operate two object

Usage:

var _extend = require('util_extend_exclude')._extend
var _exclude = require('util_extend_exclude')._exclude
var a = {
  x:1,
  y:{
    z:2
  }
}

var b= {
  y:{
    z:10,
    u:'name'
  }
}
_extend(a,b)
_exclude(a,b)

_extend( a, b )

Deeply merge b properties into a

_extend( a, b )

{
  x:1,
  y:{
    z:10,
    u:'name'
  }
}

_exclude( a, exclude_obj, [newValue] )

Deeply delete exclude_obj(if key has a truthy value) from a, optionally set to newValue if present

_exclude( a, { y:{z:1} } )

{
  x:1,
  y:{
    u:'name'
  }
}

_exclude( a, { y:{z:10} } , null)

{
  x:1,
  y:{
    z:null,
    u:'name'
  }
}

_deepIt( a, b, callback )

Iterate deeply with a && b simultaneously, and callback(objA, objB, key)

_deepIt( a, b, function(objA,objB,key){
    objA[key] = objB[key]
} )
---> same result of _extend(a,b)

Copyright @ Mithriljs_CN

About

Javascript object _extend()/_exclude() for deeply merge/exclude

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published