Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zoubin/mixy
Sugar methods to manipulate objects
https://github.com/zoubin/mixy
Last synced: 8 days ago
JSON representation
Sugar methods to manipulate objects
- Host: GitHub
- URL: https://github.com/zoubin/mixy
- Owner: zoubin
- License: mit
- Created: 2015-11-30T01:59:22.000Z (almost 9 years ago)
- Default Branch: master
- Last Pushed: 2015-11-30T06:38:04.000Z (almost 9 years ago)
- Last Synced: 2024-09-26T07:35:38.946Z (about 2 months ago)
- Language: JavaScript
- Size: 6.84 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: changelog.md
- License: LICENSE
Awesome Lists containing this project
README
# mixy
Sugar methods to manipulate objects.[![version](https://img.shields.io/npm/v/mixy.svg)](https://www.npmjs.org/package/mixy)
[![status](https://travis-ci.org/zoubin/mixy.svg?branch=master)](https://travis-ci.org/zoubin/mixy)
[![coverage](https://img.shields.io/coveralls/zoubin/mixy.svg)](https://coveralls.io/github/zoubin/mixy)
[![devDependencies](https://david-dm.org/zoubin/mixy/dev-status.svg)](https://david-dm.org/zoubin/mixy#info=devDependencies)## Methods
```javascript
var mixy = require('mixy')
// actually `mix === mixy`
var mix = mixy.mix```
* [`mix`](#mix)
* [`fill`](#fill)
* [`pick`](#pick)
* [`exclude`](#exclude)
* [`del`](#del)### mix
Signature: `r = mix(r, ...sources)`Mix own properties from all `sources` into the receiver object `r`.
```javascript
var o = { x: 1 }
mix(o, { x: 2 }, null, { y: 3 }, { x: 4 })
// o == { x: 4, y: 3 }```
### fill
Signature: `r = fill(r, defaults)`Mix own properties from `defaults` into the receiver object `r`, except those `r` already owns.
```javascript
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 }```
### pick
Signature: `o = pick(keys, ...sources)`Pick properties specified in `keys` from `sources` to create the returned object.
```javascript
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 }```
### exclude
Signature: `o = exclude(keys, ...sources)`Pick properties from `sources` to create the returned object, except those specified in `keys`.
```javascript
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 }```
### del
Signature: `o = del(keys, target)`Delete `keys` from `target`,
and return a new object containing those deleted `key-value`s.
If none is deleted, `null` will be returned.```javascript
var o = del('y', { x: 1, y: 2 })
// o == { y: 2 }var o = del('z', { x: 1, y: 2 })
// o == nullo = del(['x', 'y'], { x: 1, y: 2, z: 3 })
// o == { x: 1, y: 2 }```