Skip to content

Commit d04f06c

Browse files
committed
inline utils
1 parent 209ed07 commit d04f06c

File tree

3 files changed

+15
-36
lines changed

3 files changed

+15
-36
lines changed

index.js

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,23 @@
77

88
'use strict';
99

10-
var utils = require('./utils');
10+
var union = require('arr-union');
11+
var clone = require('clone-deep');
12+
var typeOf = require('kind-of');
1113

1214
module.exports = function mergeDeep(orig, objects) {
13-
if (!utils.isObject(orig) && !Array.isArray(orig)) {
15+
if (!isObject(orig) && !Array.isArray(orig)) {
1416
orig = {};
1517
}
1618

17-
var target = utils.clone(orig);
19+
var target = clone(orig);
1820
var len = arguments.length;
1921
var idx = 0;
2022

2123
while (++idx < len) {
2224
var val = arguments[idx];
2325

24-
if (utils.isObject(val) || Array.isArray(val)) {
26+
if (isObject(val) || Array.isArray(val)) {
2527
merge(target, val);
2628
}
2729
}
@@ -37,12 +39,12 @@ function merge(target, obj) {
3739
var oldVal = obj[key];
3840
var newVal = target[key];
3941

40-
if (utils.isObject(newVal) && utils.isObject(oldVal)) {
42+
if (isObject(newVal) && isObject(oldVal)) {
4143
target[key] = merge(newVal, oldVal);
4244
} else if (Array.isArray(newVal)) {
43-
target[key] = utils.union([], newVal, oldVal);
45+
target[key] = union([], newVal, oldVal);
4446
} else {
45-
target[key] = utils.clone(oldVal);
47+
target[key] = clone(oldVal);
4648
}
4749
}
4850
return target;
@@ -51,3 +53,7 @@ function merge(target, obj) {
5153
function hasOwn(obj, key) {
5254
return Object.prototype.hasOwnProperty.call(obj, key);
5355
}
56+
57+
function isObject(val) {
58+
return typeOf(val) === 'object' || typeOf(val) === 'function';
59+
}

package.json

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@
1010
},
1111
"license": "MIT",
1212
"files": [
13-
"index.js",
14-
"utils.js"
13+
"index.js"
1514
],
1615
"main": "index.js",
1716
"engines": {
@@ -23,8 +22,7 @@
2322
"dependencies": {
2423
"arr-union": "^3.1.0",
2524
"clone-deep": "^0.2.4",
26-
"kind-of": "^3.0.2",
27-
"lazy-cache": "^1.0.3"
25+
"kind-of": "^3.0.2"
2826
},
2927
"devDependencies": {
3028
"gulp-format-md": "^0.1.7",

utils.js

Lines changed: 0 additions & 25 deletions
This file was deleted.

0 commit comments

Comments
 (0)