Skip to content

Commit 8f464c8

Browse files
committed
disallow constructor and prototype keys
1 parent 9925af7 commit 8f464c8

File tree

5 files changed

+34
-20
lines changed

5 files changed

+34
-20
lines changed

.travis.yml

-2
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,3 @@ node_js:
1010
- '8'
1111
- '7'
1212
- '6'
13-
- '5'
14-
- '4'

.verb.md

+7
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## Heads up!
2+
3+
[Please update][update] to version 2.0.1 or later, a critical bug was fixed in that version.
4+
15
## Usage
26

37
```js
@@ -6,3 +10,6 @@ const res = mixin({ a: { foo: true } }, { a: { bar: true } }, { a: { baz: true }
610
console.log(res);
711
//=> { a: { foo: true, bar: true, baz: true } }
812
```
13+
14+
15+
[update]: https://gist.github.com/jonschlinkert/9a62534c4f8bc76aee6058caa3f05fd6

README.md

+12-8
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
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)
22

33
> Deeply mix the properties of objects into the first object. Like merge-deep, but doesn't clone. No dependencies.
44
@@ -12,6 +12,10 @@ Install with [npm](https://www.npmjs.com/):
1212
$ npm install --save mixin-deep
1313
```
1414

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+
1519
## Usage
1620

1721
```js
@@ -65,24 +69,24 @@ You might also be interested in these projects:
6569

6670
### Contributors
6771

68-
| **Commits** | **Contributor** |
69-
| --- | --- |
70-
| 26 | [jonschlinkert](https://github.com/jonschlinkert) |
71-
| 2 | [doowb](https://github.com/doowb) |
72+
| **Commits** | **Contributor** |
73+
| --- | --- |
74+
| 28 | [jonschlinkert](https://github.com/jonschlinkert) |
75+
| 2 | [doowb](https://github.com/doowb) |
7276

7377
### Author
7478

7579
**Jon Schlinkert**
7680

77-
* [LinkedIn Profile](https://linkedin.com/in/jonschlinkert)
7881
* [GitHub Profile](https://github.com/jonschlinkert)
7982
* [Twitter Profile](https://twitter.com/jonschlinkert)
83+
* [LinkedIn Profile](https://linkedin.com/in/jonschlinkert)
8084

8185
### License
8286

83-
Copyright © 2018, [Jon Schlinkert](https://github.com/jonschlinkert).
87+
Copyright © 2019, [Jon Schlinkert](https://github.com/jonschlinkert).
8488
Released under the [MIT License](LICENSE).
8589

8690
***
8791

88-
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.6.0, on July 11, 2018._
92+
_This file was generated by [verb-generate-readme](https://github.com/verbose/verb-generate-readme), v0.8.0, on June 19, 2019._

index.js

+11-7
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
11
'use strict';
22

3-
function mixinDeep(target, ...rest) {
3+
const isObject = val => {
4+
return typeof val === 'function' || (typeof val === 'object' && val !== null && !Array.isArray(val));
5+
};
6+
7+
const isValidKey = key => {
8+
return key !== '__proto__' && key !== 'constructor' && key !== 'prototype';
9+
};
10+
11+
const mixinDeep = (target, ...rest) => {
412
for (let obj of rest) {
513
if (isObject(obj)) {
614
for (let key in obj) {
7-
if (key !== '__proto__') {
15+
if (isValidKey(key)) {
816
mixin(target, obj[key], key);
917
}
1018
}
1119
}
1220
}
1321
return target;
14-
}
22+
};
1523

1624
function mixin(target, val, key) {
1725
let obj = target[key];
@@ -22,10 +30,6 @@ function mixin(target, val, key) {
2230
}
2331
}
2432

25-
function isObject(val) {
26-
return typeof val === 'function' || (typeof val === 'object' && val !== null && !Array.isArray(val));
27-
}
28-
2933
/**
3034
* Expose mixinDeep
3135
* @type {Function}

package.json

+4-3
Original file line numberDiff line numberDiff line change
@@ -14,16 +14,17 @@
1414
],
1515
"main": "index.js",
1616
"engines": {
17-
"node": ">=4"
17+
"node": ">=6"
1818
},
1919
"scripts": {
2020
"test": "mocha"
2121
},
2222
"devDependencies": {
23-
"gulp-format-md": "^1.0.0",
24-
"mocha": "^5.2.0"
23+
"gulp-format-md": "^2.0.0",
24+
"mocha": "^6.1.4"
2525
},
2626
"keywords": [
27+
"assign",
2728
"deep",
2829
"extend",
2930
"key",

0 commit comments

Comments
 (0)