mixin-deep 1.3.0 → 2.0.1

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 +23 -11
  3. package/index.js +20 -31
  4. package/package.json +6 -10
package/LICENSE CHANGED
@@ -1,6 +1,6 @@
1
1
  The MIT License (MIT)
2
2
 
3
- Copyright (c) 2014-2015, 2017, Jon Schlinkert.
3
+ Copyright (c) 2014-present, 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,6 +1,6 @@
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)
1
+ # mixin-deep [![Donate](https://img.shields.io/badge/Donate-PayPal-green.svg)](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=W8YFZ425KND68) [![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
- > Deeply mix the properties of objects into the first object. Like merge-deep, but doesn't clone.
3
+ > Deeply mix the properties of objects into the first object. Like merge-deep, but doesn't clone. No dependencies.
4
4
 
5
5
  Please consider following this project's author, [Jon Schlinkert](https://github.com/jonschlinkert), and consider starring the project to show your :heart: and support.
6
6
 
@@ -12,13 +12,17 @@ Install with [npm](https://www.npmjs.com/):
12
12
  $ npm install --save mixin-deep
13
13
  ```
14
14
 
15
+ ## Heads up!
16
+
17
+ [Please update](https://gist.github.com/jonschlinkert/9a62534c4f8bc76aee6058caa3f05fd6) to version 2.0.1 or later, a critical bug was fixed in that version.
18
+
15
19
  ## Usage
16
20
 
17
21
  ```js
18
- var mixinDeep = require('mixin-deep');
19
-
20
- mixinDeep({a: {aa: 'aa'}}, {a: {bb: 'bb'}}, {a: {cc: 'cc'}});
21
- //=> { a: { aa: 'aa', bb: 'bb', cc: 'cc' } }
22
+ const mixin = require('mixin-deep');
23
+ const res = mixin({ a: { foo: true } }, { a: { bar: true } }, { a: { baz: true } });
24
+ console.log(res);
25
+ //=> { a: { foo: true, bar: true, baz: true } }
22
26
  ```
23
27
 
24
28
  ## About
@@ -40,6 +44,7 @@ $ npm install && npm test
40
44
  ```
41
45
 
42
46
  </details>
47
+
43
48
  <details>
44
49
  <summary><strong>Building docs</strong></summary>
45
50
 
@@ -62,19 +67,26 @@ You might also be interested in these projects:
62
67
  * [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.")
63
68
  * [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.")
64
69
 
70
+ ### Contributors
71
+
72
+ | **Commits** | **Contributor** |
73
+ | --- | --- |
74
+ | 28 | [jonschlinkert](https://github.com/jonschlinkert) |
75
+ | 2 | [doowb](https://github.com/doowb) |
76
+
65
77
  ### Author
66
78
 
67
79
  **Jon Schlinkert**
68
80
 
69
- * [linkedin/in/jonschlinkert](https://linkedin.com/in/jonschlinkert)
70
- * [github/jonschlinkert](https://github.com/jonschlinkert)
71
- * [twitter/jonschlinkert](https://twitter.com/jonschlinkert)
81
+ * [GitHub Profile](https://github.com/jonschlinkert)
82
+ * [Twitter Profile](https://twitter.com/jonschlinkert)
83
+ * [LinkedIn Profile](https://linkedin.com/in/jonschlinkert)
72
84
 
73
85
  ### License
74
86
 
75
- Copyright © 2017, [Jon Schlinkert](https://github.com/jonschlinkert).
87
+ Copyright © 2019, [Jon Schlinkert](https://github.com/jonschlinkert).
76
88
  Released under the [MIT License](LICENSE).
77
89
 
78
90
  ***
79
91
 
80
- _This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on December 09, 2017._
92
+ _This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.8.0, on June 19, 2019._
package/index.js CHANGED
@@ -1,49 +1,38 @@
1
1
  'use strict';
2
2
 
3
- var isExtendable = require('is-extendable');
4
- var forIn = require('for-in');
3
+ const isObject = val => {
4
+ return typeof val === 'function' || (typeof val === 'object' && val !== null && !Array.isArray(val));
5
+ };
5
6
 
6
- function mixinDeep(target, objects) {
7
- var len = arguments.length, i = 0;
8
- while (++i < len) {
9
- var obj = arguments[i];
7
+ const isValidKey = key => {
8
+ return key !== '__proto__' && key !== 'constructor' && key !== 'prototype';
9
+ };
10
+
11
+ const mixinDeep = (target, ...rest) => {
12
+ for (let obj of rest) {
10
13
  if (isObject(obj)) {
11
- forIn(obj, copy, target);
14
+ for (let key in obj) {
15
+ if (isValidKey(key)) {
16
+ mixin(target, obj[key], key);
17
+ }
18
+ }
12
19
  }
13
20
  }
14
21
  return target;
15
- }
16
-
17
- /**
18
- * Copy properties from the source object to the
19
- * target object.
20
- *
21
- * @param {*} `val`
22
- * @param {String} `key`
23
- */
22
+ };
24
23
 
25
- function copy(val, key) {
26
- var obj = this[key];
24
+ function mixin(target, val, key) {
25
+ let obj = target[key];
27
26
  if (isObject(val) && isObject(obj)) {
28
27
  mixinDeep(obj, val);
29
28
  } else {
30
- this[key] = val;
29
+ target[key] = val;
31
30
  }
32
31
  }
33
32
 
34
33
  /**
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`
34
+ * Expose mixinDeep
35
+ * @type {Function}
47
36
  */
48
37
 
49
38
  module.exports = mixinDeep;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "mixin-deep",
3
- "description": "Deeply mix the properties of objects into the first object. Like merge-deep, but doesn't clone.",
4
- "version": "1.3.0",
3
+ "description": "Deeply mix the properties of objects into the first object. Like merge-deep, but doesn't clone. No dependencies.",
4
+ "version": "2.0.1",
5
5
  "homepage": "https://github.com/jonschlinkert/mixin-deep",
6
6
  "author": "Jon Schlinkert (https://github.com/jonschlinkert)",
7
7
  "repository": "jonschlinkert/mixin-deep",
@@ -14,21 +14,17 @@
14
14
  ],
15
15
  "main": "index.js",
16
16
  "engines": {
17
- "node": ">=0.10.0"
17
+ "node": ">=6"
18
18
  },
19
19
  "scripts": {
20
20
  "test": "mocha"
21
21
  },
22
- "dependencies": {
23
- "for-in": "^1.0.2",
24
- "is-extendable": "^1.0.1"
25
- },
26
22
  "devDependencies": {
27
- "gulp-format-md": "^1.0.0",
28
- "mocha": "^3.5.3",
29
- "should": "^13.1.3"
23
+ "gulp-format-md": "^2.0.0",
24
+ "mocha": "^6.1.4"
30
25
  },
31
26
  "keywords": [
27
+ "assign",
32
28
  "deep",
33
29
  "extend",
34
30
  "key",