-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathtst.js
More file actions
86 lines (73 loc) · 2.97 KB
/
tst.js
File metadata and controls
86 lines (73 loc) · 2.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
// Runnable test to check that packages are modelled correctly.
let util = require('util');
function base() {
return {x: {y: 1}};
}
function arg() {
return {x: {z: 1}};
}
function checkShallow(result) {
if (result.x.y === 1 && result.x.z === 1) {
throw new Error("Merge was not shallow");
}
}
function checkDeep(result) {
if (result.x.y !== 1 || result.x.z !== 1) {
throw new Error("Merge was not deep");
}
}
// Deep if flag is given
let extend = require('extend');
let extend2 = require('extend2');
let justExtend = require('just-extend');
let nodeExtend = require('node.extend');
checkShallow(extend(base(), arg()));
checkShallow(extend2(base(), arg()));
checkShallow(justExtend(base(), arg()));
checkShallow(nodeExtend(base(), arg()));
checkDeep(extend(true, base(), arg()));
checkDeep(extend2(true, base(), arg()));
checkDeep(justExtend(true, base(), arg()));
checkDeep(nodeExtend(true, base(), arg()));
// Always deep
checkDeep(require("deep").extend(base(), arg()));
checkDeep(require("deep-assign")(base(), arg()));
checkDeep(require("deep-extend")(base(), arg()));
checkDeep(require("deep-merge")((x,y)=>y)(base(), arg()));
checkDeep(require("deepmerge")(base(), arg()));
checkDeep(require("defaults-deep")(base(), arg()));
checkDeep(require("js-extend").extend(base(), arg()));
checkDeep(require("merge").recursive(base(), arg()));
checkDeep(require("merge-deep")(base(), arg()));
checkDeep(require("merge-options")(base(), arg()));
checkDeep(require("mixin-deep")(base(), arg()));
checkDeep(require("ramda").mergeDeepLeft(base(), arg()));
checkDeep(require("ramda").mergeDeepRight(base(), arg()));
checkDeep(require("smart-extend").deep(base(), arg()));
checkDeep(require("lodash").merge(base(), arg()));
checkDeep(require("lodash").mergeWith(base(), arg()));
checkDeep(require("lodash").defaultsDeep(base(), arg()));
checkDeep(require("lodash.mergewith")(base(), arg()));
checkDeep(require("lodash.defaultsdeep")(base(), arg()));
// Always shallow
checkShallow(Object.assign(base(), arg()));
checkShallow(require("defaults")(base(), arg()));
checkShallow(require("extend-shallow")(base(), arg()));
checkShallow(require("merge")(base(), arg()));
checkShallow(require("mixin-object")(base(), arg()));
checkShallow(require("object-assign")(base(), arg()));
checkShallow(require("object.assign")(base(), arg()));
checkShallow(require("object.defaults")(base(), arg()));
checkShallow(require("smart-extend")(base(), arg()));
checkShallow(require("util-extend")(base(), arg()));
checkShallow(require("utils-merge")(base(), arg()));
checkShallow(require("xtend/mutable")(base(), arg()));
checkShallow(require('lodash').extend(base(), arg()));
// Functional shallow
checkShallow(require("xtend")(base(), arg()));
checkShallow(require("xtend/immutable")(base(), arg()));
checkShallow(require("ramda").merge(base(), arg()));
// webpack-merge. deep.
const webpackMerge = require('webpack-merge');
checkDeep(webpackMerge.merge(base(), arg()));
checkDeep(webpackMerge.mergeWithCustomize({})(base(), arg()));