mixy
Sugar methods to manipulate objects
Last updated 5 years ago by zoubin .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install mixy 
SYNC missed versions from official npm registry.

mixy

Sugar methods to manipulate objects.

version status coverage devDependencies

Methods

var mixy = require('mixy')
// actually `mix === mixy`
var mix = mixy.mix

r = mix(r, ...sources)

Mix own properties from all sources into the receiver object r.

var o = { x: 1 }
mix(o, { x: 2 }, null, { y: 3 }, { x: 4 })
// o == { x: 4, y: 3 }

r = fill(r, defaults)

Mix own properties from defaults into the receiver object r, except those r already owns.

var o = { x: 1, y: 2, z: null, w: undefined }
fill(o, { x: 2, z: 3, w: 4, a: null, b: undefined })
// o == { x: 1, y: 2, z: null, w: undefined, a: null, b: undefined }

o = pick(keys, ...sources)

Pick properties specified in keys from sources to create the returned object.

var o = pick(['x', 'y'], { x: 1, y: 2 }, null, { x: 3 })
// o == { x: 3, y: 2 }

o = pick('x', { x: 1, y: 2 }, { x: 3 })
// o == { x: 3 }

o = exclude(keys, ...sources)

Pick properties except thos specified in keys from sources to create the returned object.

var o = exclude('y', { x: 1, y: 2 }, null, { x: 3 })
// o == { x: 3 }

o = exclude(['x', 'y'], { x: 1, y: 2, z: 3 }, { x: 3, z: 4 })
// o == { z: 4 }

o = del(keys, target)

Delete keys from target, and return a new object containing those deleted key-values. If none is deleted, null will be returned.

var o = del('y', { x: 1, y: 2 })
// o == { y: 2 }

var o = del('z', { x: 1, y: 2 })
// o == null

o = del(['x', 'y'], { x: 1, y: 2, z: 3 })
// o == { x: 1, y: 2 }

Current Tags

  • 1.0.0                                ...           latest (5 years ago)

1 Versions

  • 1.0.0                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 2
This Month 8
Last Day 0
Last Week 1
Last Month 4
Dependencies (0)
None
Dev Dependencies (2)

Copyright 2014 - 2017 © taobao.org |