mixin-deep 1.1.0 → 1.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (4) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +36 -23
  3. package/index.js +41 -20
  4. package/package.json +32 -18
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2014-2015, Jon Schlinkert.
3
+ Copyright (c) 2014-2015, 2017, Jon Schlinkert
4
4
 
5
5
  Permission is hereby granted, free of charge, to any person obtaining a copy
6
6
  of this software and associated documentation files (the "Software"), to deal
package/README.md CHANGED
@@ -1,11 +1,13 @@
1
- # mixin-deep [![NPM version](https://badge.fury.io/js/mixin-deep.svg)](http://badge.fury.io/js/mixin-deep)
1
+ # mixin-deep [![NPM version](https://img.shields.io/npm/v/mixin-deep.svg?style=flat)](https://www.npmjs.com/package/mixin-deep) [![NPM monthly downloads](https://img.shields.io/npm/dm/mixin-deep.svg?style=flat)](https://npmjs.org/package/mixin-deep) [![NPM total downloads](https://img.shields.io/npm/dt/mixin-deep.svg?style=flat)](https://npmjs.org/package/mixin-deep) [![Linux Build Status](https://img.shields.io/travis/jonschlinkert/mixin-deep.svg?style=flat&label=Travis)](https://travis-ci.org/jonschlinkert/mixin-deep)
2
2
 
3
3
  > Deeply mix the properties of objects into the first object. Like merge-deep, but doesn't clone.
4
4
 
5
- ## Install with [npm](npmjs.org)
5
+ ## Install
6
6
 
7
- ```bash
8
- npm i mixin-deep --save
7
+ Install with [npm](https://www.npmjs.com/):
8
+
9
+ ```sh
10
+ $ npm install --save mixin-deep
9
11
  ```
10
12
 
11
13
  ## Usage
@@ -17,38 +19,49 @@ mixinDeep({a: {aa: 'aa'}}, {a: {bb: 'bb'}}, {a: {cc: 'cc'}});
17
19
  //=> { a: { aa: 'aa', bb: 'bb', cc: 'cc' } }
18
20
  ```
19
21
 
20
- ## Related projects
22
+ ## About
23
+
24
+ ### Related projects
25
+
26
+ * [defaults-deep](https://www.npmjs.com/package/defaults-deep): Like `extend` but recursively copies only the missing properties/values to the target object. | [homepage](https://github.com/jonschlinkert/defaults-deep "Like `extend` but recursively copies only the missing properties/values to the target object.")
27
+ * [extend-shallow](https://www.npmjs.com/package/extend-shallow): Extend an object with the properties of additional objects. node.js/javascript util. | [homepage](https://github.com/jonschlinkert/extend-shallow "Extend an object with the properties of additional objects. node.js/javascript util.")
28
+ * [merge-deep](https://www.npmjs.com/package/merge-deep): Recursively merge values in a javascript object. | [homepage](https://github.com/jonschlinkert/merge-deep "Recursively merge values in a javascript object.")
29
+ * [mixin-object](https://www.npmjs.com/package/mixin-object): Mixin the own and inherited properties of other objects onto the first object. Pass an… [more](https://github.com/jonschlinkert/mixin-object) | [homepage](https://github.com/jonschlinkert/mixin-object "Mixin the own and inherited properties of other objects onto the first object. Pass an empty object as the first arg to shallow clone.")
30
+
31
+ ### Contributing
21
32
 
22
- * [assign-deep](https://github.com/jonschlinkert/assign-deep): Deeply assign the enumerable properties of source objects to a destination object. If a callback… [more](https://github.com/jonschlinkert/assign-deep)
23
- * [extend-shallow](https://github.com/jonschlinkert/extend-shallow): Extend an object with the properties of additional objects. node.js/javascript util.
24
- * [merge-deep](https://github.com/jonschlinkert/merge-deep): Recursively merge values in a javascript object.
33
+ Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](../../issues/new).
25
34
 
26
- ## Running tests
35
+ ### Building docs
27
36
 
28
- Install dev dependencies:
37
+ _(This project's readme.md is generated by [verb](https://github.com/verbose/verb-generate-readme), please don't edit the readme directly. Any changes to the readme must be made in the [.verb.md](.verb.md) readme template.)_
29
38
 
30
- ```bash
31
- npm i -d && npm test
39
+ To generate the readme, run the following command:
40
+
41
+ ```sh
42
+ $ npm install -g verbose/verb#dev verb-generate-readme && verb
32
43
  ```
33
44
 
34
- ## Contributing
45
+ ### Running tests
46
+
47
+ Running and reviewing unit tests is a great way to get familiarized with a library and its API. You can install dependencies and run tests with the following command:
35
48
 
36
- Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/mixin-deep/issues)
49
+ ```sh
50
+ $ npm install && npm test
51
+ ```
37
52
 
38
- ## Author
53
+ ### Author
39
54
 
40
55
  **Jon Schlinkert**
41
56
 
42
- + [github/jonschlinkert](https://github.com/jonschlinkert)
43
- + [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
57
+ * [github/jonschlinkert](https://github.com/jonschlinkert)
58
+ * [twitter/jonschlinkert](https://twitter.com/jonschlinkert)
44
59
 
45
- ## License
60
+ ### License
46
61
 
47
- Copyright (c) 2015 Jon Schlinkert
48
- Released under the MIT license.
62
+ Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).
63
+ Released under the [MIT License](LICENSE).
49
64
 
50
65
  ***
51
66
 
52
- _This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on April 29, 2015._
53
-
54
- <!-- reflinks generated by verb-reflinks plugin -->
67
+ _This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.4.2, on March 02, 2017._
package/index.js CHANGED
@@ -1,28 +1,49 @@
1
1
  'use strict';
2
2
 
3
- var isObject = require('is-plain-object');
4
- var forOwn = require('for-own');
5
-
6
- module.exports = function deepMixin(o, objects) {
7
- if (!isObject(o)) return {};
8
- if (!isObject(objects)) return o;
9
-
10
- var len = arguments.length - 1;
11
- for (var i = 0; i < len; i++) {
12
- var obj = arguments[i + 1];
3
+ var isExtendable = require('is-extendable');
4
+ var forIn = require('for-in');
13
5
 
6
+ function mixinDeep(target, objects) {
7
+ var len = arguments.length, i = 0;
8
+ while (++i < len) {
9
+ var obj = arguments[i];
14
10
  if (isObject(obj)) {
15
- forOwn(obj, copy, o);
11
+ forIn(obj, copy, target);
16
12
  }
17
13
  }
14
+ return target;
15
+ }
18
16
 
19
- function copy(value, key) {
20
- var obj = this[key];
21
- if (isObject(value) && isObject(obj)) {
22
- deepMixin(obj, value);
23
- } else {
24
- this[key] = value;
25
- }
17
+ /**
18
+ * Copy properties from the source object to the
19
+ * target object.
20
+ *
21
+ * @param {*} `val`
22
+ * @param {String} `key`
23
+ */
24
+
25
+ function copy(val, key) {
26
+ var obj = this[key];
27
+ if (isObject(val) && isObject(obj)) {
28
+ mixinDeep(obj, val);
29
+ } else {
30
+ this[key] = val;
26
31
  }
27
- return o;
28
- };
32
+ }
33
+
34
+ /**
35
+ * Returns true if `val` is an object or function.
36
+ *
37
+ * @param {any} val
38
+ * @return {Boolean}
39
+ */
40
+
41
+ function isObject(val) {
42
+ return isExtendable(val) && !Array.isArray(val);
43
+ }
44
+
45
+ /**
46
+ * Expose `mixinDeep`
47
+ */
48
+
49
+ module.exports = mixinDeep;
package/package.json CHANGED
@@ -1,23 +1,14 @@
1
1
  {
2
2
  "name": "mixin-deep",
3
3
  "description": "Deeply mix the properties of objects into the first object. Like merge-deep, but doesn't clone.",
4
- "version": "1.1.0",
4
+ "version": "1.2.0",
5
5
  "homepage": "https://github.com/jonschlinkert/mixin-deep",
6
- "author": {
7
- "name": "Jon Schlinkert",
8
- "url": "https://github.com/jonschlinkert"
9
- },
10
- "repository": {
11
- "type": "git",
12
- "url": "git://github.com/jonschlinkert/mixin-deep.git"
13
- },
6
+ "author": "Jon Schlinkert (https://github.com/jonschlinkert)",
7
+ "repository": "jonschlinkert/mixin-deep",
14
8
  "bugs": {
15
9
  "url": "https://github.com/jonschlinkert/mixin-deep/issues"
16
10
  },
17
- "license": {
18
- "type": "MIT",
19
- "url": "https://github.com/jonschlinkert/mixin-deep/blob/master/LICENSE"
20
- },
11
+ "license": "MIT",
21
12
  "files": [
22
13
  "index.js"
23
14
  ],
@@ -29,14 +20,16 @@
29
20
  "test": "mocha"
30
21
  },
31
22
  "dependencies": {
32
- "for-own": "^0.1.3",
33
- "is-plain-object": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.0.tgz"
23
+ "for-in": "^1.0.2",
24
+ "is-extendable": "^0.1.1"
34
25
  },
35
26
  "devDependencies": {
36
- "mocha": "^2.2.4",
37
- "should": "^6.0.1"
27
+ "gulp-format-md": "^0.1.11",
28
+ "mocha": "^3.2.0",
29
+ "should": "^11.2.0"
38
30
  },
39
31
  "keywords": [
32
+ "deep",
40
33
  "extend",
41
34
  "key",
42
35
  "keys",
@@ -47,5 +40,26 @@
47
40
  "properties",
48
41
  "util",
49
42
  "values"
50
- ]
43
+ ],
44
+ "verb": {
45
+ "toc": false,
46
+ "layout": "default",
47
+ "tasks": [
48
+ "readme"
49
+ ],
50
+ "plugins": [
51
+ "gulp-format-md"
52
+ ],
53
+ "related": {
54
+ "list": [
55
+ "defaults-deep",
56
+ "extend-shallow",
57
+ "merge-deep",
58
+ "mixin-object"
59
+ ]
60
+ },
61
+ "lint": {
62
+ "reflinks": true
63
+ }
64
+ }
51
65
  }