aboutsummaryrefslogtreecommitdiff
path: root/node_modules/deep-extend/lib
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/deep-extend/lib')
-rw-r--r--node_modules/deep-extend/lib/deep-extend.js16
1 files changed, 11 insertions, 5 deletions
diff --git a/node_modules/deep-extend/lib/deep-extend.js b/node_modules/deep-extend/lib/deep-extend.js
index 08f70ed76..651fd8d3e 100644
--- a/node_modules/deep-extend/lib/deep-extend.js
+++ b/node_modules/deep-extend/lib/deep-extend.js
@@ -5,7 +5,7 @@
*
* The MIT License (MIT)
*
- * Copyright (c) 2013-2015 Viacheslav Lotsmanov
+ * Copyright (c) 2013-2018 Viacheslav Lotsmanov
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
@@ -37,7 +37,9 @@ function isSpecificValue(val) {
function cloneSpecificValue(val) {
if (val instanceof Buffer) {
- var x = new Buffer(val.length);
+ var x = Buffer.alloc
+ ? Buffer.alloc(val.length)
+ : new Buffer(val.length);
val.copy(x);
return x;
} else if (val instanceof Date) {
@@ -70,6 +72,10 @@ function deepCloneArray(arr) {
return clone;
}
+function safeGetProperty(object, property) {
+ return property === '__proto__' ? undefined : object[property];
+}
+
/**
* Extening object that entered in first argument.
*
@@ -102,8 +108,8 @@ var deepExtend = module.exports = function (/*obj_1, [obj_2], [obj_N]*/) {
}
Object.keys(obj).forEach(function (key) {
- src = target[key]; // source value
- val = obj[key]; // new value
+ src = safeGetProperty(target, key); // source value
+ val = safeGetProperty(obj, key); // new value
// recursion prevention
if (val === target) {
@@ -141,4 +147,4 @@ var deepExtend = module.exports = function (/*obj_1, [obj_2], [obj_N]*/) {
});
return target;
-}
+};