@cdk8s/projen-common 0.0.452 → 0.0.454
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.
- package/.jsii +26 -25
- package/.projenrc.ts +1 -1
- package/lib/projects/jsii.js +17 -14
- package/lib/projects/node.js +7 -7
- package/lib/projects/typescript.js +7 -7
- package/node_modules/deepmerge/.editorconfig +7 -0
- package/node_modules/deepmerge/.eslintcache +1 -0
- package/node_modules/deepmerge/changelog.md +167 -0
- package/node_modules/deepmerge/dist/cjs.js +133 -0
- package/node_modules/deepmerge/dist/umd.js +139 -0
- package/node_modules/deepmerge/index.d.ts +20 -0
- package/node_modules/deepmerge/index.js +106 -0
- package/node_modules/deepmerge/license.txt +21 -0
- package/node_modules/deepmerge/package.json +42 -0
- package/node_modules/deepmerge/readme.md +264 -0
- package/node_modules/deepmerge/rollup.config.js +22 -0
- package/package.json +7 -4
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
# [4.3.1](https://github.com/TehShrike/deepmerge/releases/tag/v4.3.1)
|
|
2
|
+
|
|
3
|
+
- Fix type definition for arrayMerge options. [#239](https://github.com/TehShrike/deepmerge/pull/239)
|
|
4
|
+
|
|
5
|
+
# [4.3.0](https://github.com/TehShrike/deepmerge/releases/tag/v4.3.0)
|
|
6
|
+
|
|
7
|
+
- Avoid thrown errors if the target doesn't have `propertyIsEnumerable`. [#252](https://github.com/TehShrike/deepmerge/pull/252)
|
|
8
|
+
|
|
9
|
+
# [4.2.2](https://github.com/TehShrike/deepmerge/releases/tag/v4.2.2)
|
|
10
|
+
|
|
11
|
+
- `isMergeableObject` is now only called if there are two values that could be merged. [a34dd4d2](https://github.com/TehShrike/deepmerge/commit/a34dd4d25bf5e250653540a2022bc832c7b00a19)
|
|
12
|
+
|
|
13
|
+
# [4.2.1](https://github.com/TehShrike/deepmerge/releases/tag/v4.2.1)
|
|
14
|
+
|
|
15
|
+
- Fix: falsey values can now be merged. [#170](https://github.com/TehShrike/deepmerge/issues/170)
|
|
16
|
+
|
|
17
|
+
# [4.2.0](https://github.com/TehShrike/deepmerge/releases/tag/v4.2.0)
|
|
18
|
+
|
|
19
|
+
- Properties are now only overwritten if they exist on the target object and are enumerable. [#164](https://github.com/TehShrike/deepmerge/pull/164)
|
|
20
|
+
|
|
21
|
+
Technically this could probably be a patch release since "which properties get overwritten" wasn't documented and accidentally overwriting a built-in function or some function up the property chain would almost certainly be undesirable, but it feels like a gray area, so here we are with a feature version bump.
|
|
22
|
+
|
|
23
|
+
# [4.1.2](https://github.com/TehShrike/deepmerge/releases/tag/v4.1.2)
|
|
24
|
+
|
|
25
|
+
- Rolled back #167 since `Object.assign` breaks ES5 support. [55067352](https://github.com/TehShrike/deepmerge/commit/55067352a92c65a6c44a5165f3387720aae1e192)
|
|
26
|
+
|
|
27
|
+
# [4.1.1](https://github.com/TehShrike/deepmerge/releases/tag/v4.1.1)
|
|
28
|
+
|
|
29
|
+
- The `options` argument is no longer mutated [#167](https://github.com/TehShrike/deepmerge/pull/167)
|
|
30
|
+
|
|
31
|
+
# [4.1.0](https://github.com/TehShrike/deepmerge/releases/tag/v4.1.0)
|
|
32
|
+
|
|
33
|
+
- `cloneUnlessOtherwiseSpecified` is now exposed to the `arrayMerge` function [#165](https://github.com/TehShrike/deepmerge/pull/165)
|
|
34
|
+
|
|
35
|
+
# [4.0.0](https://github.com/TehShrike/deepmerge/releases/tag/v4.0.0)
|
|
36
|
+
|
|
37
|
+
- The `main` entry point in `package.json` is now a CommonJS module instead of a UMD module [#155](https://github.com/TehShrike/deepmerge/pull/155)
|
|
38
|
+
|
|
39
|
+
# [3.3.0](https://github.com/TehShrike/deepmerge/releases/tag/v3.3.0)
|
|
40
|
+
|
|
41
|
+
- Enumerable Symbol properties are now copied [#151](https://github.com/TehShrike/deepmerge/pull/151)
|
|
42
|
+
|
|
43
|
+
# [3.2.1](https://github.com/TehShrike/deepmerge/releases/tag/v3.2.1)
|
|
44
|
+
|
|
45
|
+
- bumping dev dependency versions to try to shut up bogus security warnings from Github/npm [#149](https://github.com/TehShrike/deepmerge/pull/149)
|
|
46
|
+
|
|
47
|
+
# [3.2.0](https://github.com/TehShrike/deepmerge/releases/tag/v3.2.0)
|
|
48
|
+
|
|
49
|
+
- feature: added the [`customMerge`](https://github.com/TehShrike/deepmerge#custommerge) option [#133](https://github.com/TehShrike/deepmerge/pull/133)
|
|
50
|
+
|
|
51
|
+
# [3.1.0](https://github.com/TehShrike/deepmerge/releases/tag/v3.1.0)
|
|
52
|
+
|
|
53
|
+
- typescript typing: make the `all` function generic [#129](https://github.com/TehShrike/deepmerge/pull/129)
|
|
54
|
+
|
|
55
|
+
# [3.0.0](https://github.com/TehShrike/deepmerge/releases/tag/v3.0.0)
|
|
56
|
+
|
|
57
|
+
- drop ES module build [#123](https://github.com/TehShrike/deepmerge/issues/123)
|
|
58
|
+
|
|
59
|
+
# [2.2.1](https://github.com/TehShrike/deepmerge/releases/tag/v2.2.1)
|
|
60
|
+
|
|
61
|
+
- bug: typescript export type was wrong [#121](https://github.com/TehShrike/deepmerge/pull/121)
|
|
62
|
+
|
|
63
|
+
# [2.2.0](https://github.com/TehShrike/deepmerge/releases/tag/v2.2.0)
|
|
64
|
+
|
|
65
|
+
- feature: added TypeScript typings [#119](https://github.com/TehShrike/deepmerge/pull/119)
|
|
66
|
+
|
|
67
|
+
# [2.1.1](https://github.com/TehShrike/deepmerge/releases/tag/v2.1.1)
|
|
68
|
+
|
|
69
|
+
- documentation: Rename "methods" to "api", note ESM syntax [#103](https://github.com/TehShrike/deepmerge/pull/103)
|
|
70
|
+
- documentation: Fix grammar [#107](https://github.com/TehShrike/deepmerge/pull/107)
|
|
71
|
+
- documentation: Restructure headers for clarity + some wording tweaks [108](https://github.com/TehShrike/deepmerge/pull/108) + [109](https://github.com/TehShrike/deepmerge/pull/109)
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
# [2.1.0](https://github.com/TehShrike/deepmerge/releases/tag/v2.1.0)
|
|
75
|
+
|
|
76
|
+
- feature: Support a custom `isMergeableObject` function [#96](https://github.com/TehShrike/deepmerge/pull/96)
|
|
77
|
+
- documentation: note a Webpack bug that some users might need to work around [#100](https://github.com/TehShrike/deepmerge/pull/100)
|
|
78
|
+
|
|
79
|
+
# [2.0.1](https://github.com/TehShrike/deepmerge/releases/tag/v2.0.1)
|
|
80
|
+
|
|
81
|
+
- documentation: fix the old array merge algorithm in the readme. [#84](https://github.com/TehShrike/deepmerge/pull/84)
|
|
82
|
+
|
|
83
|
+
# [2.0.0](https://github.com/TehShrike/deepmerge/releases/tag/v2.0.0)
|
|
84
|
+
|
|
85
|
+
- breaking: the array merge algorithm has changed from a complicated thing to `target.concat(source).map(element => cloneUnlessOtherwiseSpecified(element, optionsArgument))`
|
|
86
|
+
- breaking: The `clone` option now defaults to `true`
|
|
87
|
+
- feature: `merge.all` now accepts an array of any size, even 0 or 1 elements
|
|
88
|
+
|
|
89
|
+
See [pull request 77](https://github.com/TehShrike/deepmerge/pull/77).
|
|
90
|
+
|
|
91
|
+
# [1.5.2](https://github.com/TehShrike/deepmerge/releases/tag/v1.5.2)
|
|
92
|
+
|
|
93
|
+
- fix: no longer attempts to merge React elements [#76](https://github.com/TehShrike/deepmerge/issues/76)
|
|
94
|
+
|
|
95
|
+
# [1.5.1](https://github.com/TehShrike/deepmerge/releases/tag/v1.5.1)
|
|
96
|
+
|
|
97
|
+
- bower support: officially dropping bower support. If you use bower, please depend on the [unpkg distribution](https://unpkg.com/deepmerge/dist/umd.js). See [#63](https://github.com/TehShrike/deepmerge/issues/63)
|
|
98
|
+
|
|
99
|
+
# [1.5.0](https://github.com/TehShrike/deepmerge/releases/tag/v1.5.0)
|
|
100
|
+
|
|
101
|
+
- bug fix: merging objects into arrays was allowed, and doesn't make any sense. [#65](https://github.com/TehShrike/deepmerge/issues/65) published as a feature release instead of a patch because it is a decent behavior change.
|
|
102
|
+
|
|
103
|
+
# [1.4.4](https://github.com/TehShrike/deepmerge/releases/tag/v1.4.4)
|
|
104
|
+
|
|
105
|
+
- bower support: updated `main` in bower.json
|
|
106
|
+
|
|
107
|
+
# [1.4.3](https://github.com/TehShrike/deepmerge/releases/tag/v1.4.3)
|
|
108
|
+
|
|
109
|
+
- bower support: inline is-mergeable-object in a new CommonJS build, so that people using both bower and CommonJS can bundle the library [0b34e6](https://github.com/TehShrike/deepmerge/commit/0b34e6e95f989f2fc8091d25f0d291c08f3d2d24)
|
|
110
|
+
|
|
111
|
+
# [1.4.2](https://github.com/TehShrike/deepmerge/releases/tag/v1.4.2)
|
|
112
|
+
|
|
113
|
+
- performance: bump is-mergeable-object dependency version for a slight performance improvement [5906c7](https://github.com/TehShrike/deepmerge/commit/5906c765d691d48e83d76efbb0d4b9ca150dc12c)
|
|
114
|
+
|
|
115
|
+
# [1.4.1](https://github.com/TehShrike/deepmerge/releases/tag/v1.4.1)
|
|
116
|
+
|
|
117
|
+
- documentation: fix unpkg link [acc45b](https://github.com/TehShrike/deepmerge/commit/acc45be85519c1df906a72ecb24764b622d18d47)
|
|
118
|
+
|
|
119
|
+
# [1.4.0](https://github.com/TehShrike/deepmerge/releases/tag/v1.4.0)
|
|
120
|
+
|
|
121
|
+
- api: instead of only exporting a UMD module, expose a UMD module with `pkg.main`, a CJS module with `pkg.browser`, and an ES module with `pkg.module` [#62](https://github.com/TehShrike/deepmerge/pull/62)
|
|
122
|
+
|
|
123
|
+
# [1.3.2](https://github.com/TehShrike/deepmerge/releases/tag/v1.3.2)
|
|
124
|
+
|
|
125
|
+
- documentation: note the minified/gzipped file sizes [56](https://github.com/TehShrike/deepmerge/pull/56)
|
|
126
|
+
- documentation: make data structures more readable in merge example: pull request [57](https://github.com/TehShrike/deepmerge/pull/57)
|
|
127
|
+
|
|
128
|
+
# [1.3.1](https://github.com/TehShrike/deepmerge/releases/tag/v1.3.1)
|
|
129
|
+
|
|
130
|
+
- documentation: clarify and test some array merging documentation: pull request [51](https://github.com/TehShrike/deepmerge/pull/51)
|
|
131
|
+
|
|
132
|
+
# [1.3.0](https://github.com/TehShrike/deepmerge/releases/tag/v1.3.0)
|
|
133
|
+
|
|
134
|
+
- feature: `merge.all`, a merge function that merges any number of objects: pull request [50](https://github.com/TehShrike/deepmerge/pull/50)
|
|
135
|
+
|
|
136
|
+
# [1.2.0](https://github.com/TehShrike/deepmerge/releases/tag/v1.2.0)
|
|
137
|
+
|
|
138
|
+
- fix: an error that would be thrown when an array would be merged onto a truthy non-array value: pull request [46](https://github.com/TehShrike/deepmerge/pull/46)
|
|
139
|
+
- feature: the ability to clone: Issue [28](https://github.com/TehShrike/deepmerge/issues/28), pull requests [44](https://github.com/TehShrike/deepmerge/pull/44) and [48](https://github.com/TehShrike/deepmerge/pull/48)
|
|
140
|
+
- maintenance: added tests + travis to `.npmignore`: pull request [47](https://github.com/TehShrike/deepmerge/pull/47)
|
|
141
|
+
|
|
142
|
+
# [1.1.1](https://github.com/TehShrike/deepmerge/releases/tag/v1.1.1)
|
|
143
|
+
|
|
144
|
+
- fix an issue where an error was thrown when merging an array onto a non-array: [Pull request 46](https://github.com/TehShrike/deepmerge/pull/46)
|
|
145
|
+
|
|
146
|
+
# [1.1.0](https://github.com/TehShrike/deepmerge/releases/tag/v1.1.0)
|
|
147
|
+
|
|
148
|
+
- allow consumers to specify their own array merging algorithm: [Pull request 37](https://github.com/TehShrike/deepmerge/pull/37)
|
|
149
|
+
|
|
150
|
+
# [1.0.3](https://github.com/TehShrike/deepmerge/releases/tag/v1.0.3)
|
|
151
|
+
|
|
152
|
+
- adding bower.json back: [Issue 38](https://github.com/TehShrike/deepmerge/pull/38)
|
|
153
|
+
- updating keywords and Github links in package.json [bc3898e](https://github.com/TehShrike/deepmerge/commit/bc3898e587a56f74591328f40f656b0152c1d5eb)
|
|
154
|
+
|
|
155
|
+
# [1.0.2](https://github.com/TehShrike/deepmerge/releases/tag/v1.0.2)
|
|
156
|
+
|
|
157
|
+
- Updating the readme: dropping bower, testing that the example works: [7102fc](https://github.com/TehShrike/deepmerge/commit/7102fcc4ddec11e2d33205866f9f18df14e5aeb5)
|
|
158
|
+
|
|
159
|
+
# [1.0.1](https://github.com/TehShrike/deepmerge/releases/tag/v1.0.1)
|
|
160
|
+
|
|
161
|
+
- `null`, dates, and regular expressions are now properly merged in arrays: [Issue 18](https://github.com/TehShrike/deepmerge/pull/18), plus commit: [ef1c6b](https://github.com/TehShrike/deepmerge/commit/ef1c6bac8350ba12a24966f0bc7da02560827586)
|
|
162
|
+
|
|
163
|
+
# 1.0.0
|
|
164
|
+
|
|
165
|
+
- Should only be a patch change, because this module is READY. [Issue 15](https://github.com/TehShrike/deepmerge/issues/15)
|
|
166
|
+
- Regular expressions are now treated like primitive values when merging: [Issue 30](https://github.com/TehShrike/deepmerge/pull/30)
|
|
167
|
+
- Dates are now treated like primitives when merging: [Issue 31](https://github.com/TehShrike/deepmerge/issues/31)
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var isMergeableObject = function isMergeableObject(value) {
|
|
4
|
+
return isNonNullObject(value)
|
|
5
|
+
&& !isSpecial(value)
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
function isNonNullObject(value) {
|
|
9
|
+
return !!value && typeof value === 'object'
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
function isSpecial(value) {
|
|
13
|
+
var stringValue = Object.prototype.toString.call(value);
|
|
14
|
+
|
|
15
|
+
return stringValue === '[object RegExp]'
|
|
16
|
+
|| stringValue === '[object Date]'
|
|
17
|
+
|| isReactElement(value)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
// see https://github.com/facebook/react/blob/b5ac963fb791d1298e7f396236383bc955f916c1/src/isomorphic/classic/element/ReactElement.js#L21-L25
|
|
21
|
+
var canUseSymbol = typeof Symbol === 'function' && Symbol.for;
|
|
22
|
+
var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for('react.element') : 0xeac7;
|
|
23
|
+
|
|
24
|
+
function isReactElement(value) {
|
|
25
|
+
return value.$$typeof === REACT_ELEMENT_TYPE
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function emptyTarget(val) {
|
|
29
|
+
return Array.isArray(val) ? [] : {}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function cloneUnlessOtherwiseSpecified(value, options) {
|
|
33
|
+
return (options.clone !== false && options.isMergeableObject(value))
|
|
34
|
+
? deepmerge(emptyTarget(value), value, options)
|
|
35
|
+
: value
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function defaultArrayMerge(target, source, options) {
|
|
39
|
+
return target.concat(source).map(function(element) {
|
|
40
|
+
return cloneUnlessOtherwiseSpecified(element, options)
|
|
41
|
+
})
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
function getMergeFunction(key, options) {
|
|
45
|
+
if (!options.customMerge) {
|
|
46
|
+
return deepmerge
|
|
47
|
+
}
|
|
48
|
+
var customMerge = options.customMerge(key);
|
|
49
|
+
return typeof customMerge === 'function' ? customMerge : deepmerge
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function getEnumerableOwnPropertySymbols(target) {
|
|
53
|
+
return Object.getOwnPropertySymbols
|
|
54
|
+
? Object.getOwnPropertySymbols(target).filter(function(symbol) {
|
|
55
|
+
return Object.propertyIsEnumerable.call(target, symbol)
|
|
56
|
+
})
|
|
57
|
+
: []
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
function getKeys(target) {
|
|
61
|
+
return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target))
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function propertyIsOnObject(object, property) {
|
|
65
|
+
try {
|
|
66
|
+
return property in object
|
|
67
|
+
} catch(_) {
|
|
68
|
+
return false
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
// Protects from prototype poisoning and unexpected merging up the prototype chain.
|
|
73
|
+
function propertyIsUnsafe(target, key) {
|
|
74
|
+
return propertyIsOnObject(target, key) // Properties are safe to merge if they don't exist in the target yet,
|
|
75
|
+
&& !(Object.hasOwnProperty.call(target, key) // unsafe if they exist up the prototype chain,
|
|
76
|
+
&& Object.propertyIsEnumerable.call(target, key)) // and also unsafe if they're nonenumerable.
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
function mergeObject(target, source, options) {
|
|
80
|
+
var destination = {};
|
|
81
|
+
if (options.isMergeableObject(target)) {
|
|
82
|
+
getKeys(target).forEach(function(key) {
|
|
83
|
+
destination[key] = cloneUnlessOtherwiseSpecified(target[key], options);
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
getKeys(source).forEach(function(key) {
|
|
87
|
+
if (propertyIsUnsafe(target, key)) {
|
|
88
|
+
return
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) {
|
|
92
|
+
destination[key] = getMergeFunction(key, options)(target[key], source[key], options);
|
|
93
|
+
} else {
|
|
94
|
+
destination[key] = cloneUnlessOtherwiseSpecified(source[key], options);
|
|
95
|
+
}
|
|
96
|
+
});
|
|
97
|
+
return destination
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function deepmerge(target, source, options) {
|
|
101
|
+
options = options || {};
|
|
102
|
+
options.arrayMerge = options.arrayMerge || defaultArrayMerge;
|
|
103
|
+
options.isMergeableObject = options.isMergeableObject || isMergeableObject;
|
|
104
|
+
// cloneUnlessOtherwiseSpecified is added to `options` so that custom arrayMerge()
|
|
105
|
+
// implementations can use it. The caller may not replace it.
|
|
106
|
+
options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified;
|
|
107
|
+
|
|
108
|
+
var sourceIsArray = Array.isArray(source);
|
|
109
|
+
var targetIsArray = Array.isArray(target);
|
|
110
|
+
var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;
|
|
111
|
+
|
|
112
|
+
if (!sourceAndTargetTypesMatch) {
|
|
113
|
+
return cloneUnlessOtherwiseSpecified(source, options)
|
|
114
|
+
} else if (sourceIsArray) {
|
|
115
|
+
return options.arrayMerge(target, source, options)
|
|
116
|
+
} else {
|
|
117
|
+
return mergeObject(target, source, options)
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
deepmerge.all = function deepmergeAll(array, options) {
|
|
122
|
+
if (!Array.isArray(array)) {
|
|
123
|
+
throw new Error('first argument should be an array')
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
return array.reduce(function(prev, next) {
|
|
127
|
+
return deepmerge(prev, next, options)
|
|
128
|
+
}, {})
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
var deepmerge_1 = deepmerge;
|
|
132
|
+
|
|
133
|
+
module.exports = deepmerge_1;
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
(function (global, factory) {
|
|
2
|
+
typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() :
|
|
3
|
+
typeof define === 'function' && define.amd ? define(factory) :
|
|
4
|
+
(global = global || self, global.deepmerge = factory());
|
|
5
|
+
}(this, function () { 'use strict';
|
|
6
|
+
|
|
7
|
+
var isMergeableObject = function isMergeableObject(value) {
|
|
8
|
+
return isNonNullObject(value)
|
|
9
|
+
&& !isSpecial(value)
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
function isNonNullObject(value) {
|
|
13
|
+
return !!value && typeof value === 'object'
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
function isSpecial(value) {
|
|
17
|
+
var stringValue = Object.prototype.toString.call(value);
|
|
18
|
+
|
|
19
|
+
return stringValue === '[object RegExp]'
|
|
20
|
+
|| stringValue === '[object Date]'
|
|
21
|
+
|| isReactElement(value)
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
// see https://github.com/facebook/react/blob/b5ac963fb791d1298e7f396236383bc955f916c1/src/isomorphic/classic/element/ReactElement.js#L21-L25
|
|
25
|
+
var canUseSymbol = typeof Symbol === 'function' && Symbol.for;
|
|
26
|
+
var REACT_ELEMENT_TYPE = canUseSymbol ? Symbol.for('react.element') : 0xeac7;
|
|
27
|
+
|
|
28
|
+
function isReactElement(value) {
|
|
29
|
+
return value.$$typeof === REACT_ELEMENT_TYPE
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function emptyTarget(val) {
|
|
33
|
+
return Array.isArray(val) ? [] : {}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function cloneUnlessOtherwiseSpecified(value, options) {
|
|
37
|
+
return (options.clone !== false && options.isMergeableObject(value))
|
|
38
|
+
? deepmerge(emptyTarget(value), value, options)
|
|
39
|
+
: value
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function defaultArrayMerge(target, source, options) {
|
|
43
|
+
return target.concat(source).map(function(element) {
|
|
44
|
+
return cloneUnlessOtherwiseSpecified(element, options)
|
|
45
|
+
})
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function getMergeFunction(key, options) {
|
|
49
|
+
if (!options.customMerge) {
|
|
50
|
+
return deepmerge
|
|
51
|
+
}
|
|
52
|
+
var customMerge = options.customMerge(key);
|
|
53
|
+
return typeof customMerge === 'function' ? customMerge : deepmerge
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function getEnumerableOwnPropertySymbols(target) {
|
|
57
|
+
return Object.getOwnPropertySymbols
|
|
58
|
+
? Object.getOwnPropertySymbols(target).filter(function(symbol) {
|
|
59
|
+
return Object.propertyIsEnumerable.call(target, symbol)
|
|
60
|
+
})
|
|
61
|
+
: []
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
function getKeys(target) {
|
|
65
|
+
return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target))
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function propertyIsOnObject(object, property) {
|
|
69
|
+
try {
|
|
70
|
+
return property in object
|
|
71
|
+
} catch(_) {
|
|
72
|
+
return false
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
// Protects from prototype poisoning and unexpected merging up the prototype chain.
|
|
77
|
+
function propertyIsUnsafe(target, key) {
|
|
78
|
+
return propertyIsOnObject(target, key) // Properties are safe to merge if they don't exist in the target yet,
|
|
79
|
+
&& !(Object.hasOwnProperty.call(target, key) // unsafe if they exist up the prototype chain,
|
|
80
|
+
&& Object.propertyIsEnumerable.call(target, key)) // and also unsafe if they're nonenumerable.
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function mergeObject(target, source, options) {
|
|
84
|
+
var destination = {};
|
|
85
|
+
if (options.isMergeableObject(target)) {
|
|
86
|
+
getKeys(target).forEach(function(key) {
|
|
87
|
+
destination[key] = cloneUnlessOtherwiseSpecified(target[key], options);
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
getKeys(source).forEach(function(key) {
|
|
91
|
+
if (propertyIsUnsafe(target, key)) {
|
|
92
|
+
return
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) {
|
|
96
|
+
destination[key] = getMergeFunction(key, options)(target[key], source[key], options);
|
|
97
|
+
} else {
|
|
98
|
+
destination[key] = cloneUnlessOtherwiseSpecified(source[key], options);
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
return destination
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
function deepmerge(target, source, options) {
|
|
105
|
+
options = options || {};
|
|
106
|
+
options.arrayMerge = options.arrayMerge || defaultArrayMerge;
|
|
107
|
+
options.isMergeableObject = options.isMergeableObject || isMergeableObject;
|
|
108
|
+
// cloneUnlessOtherwiseSpecified is added to `options` so that custom arrayMerge()
|
|
109
|
+
// implementations can use it. The caller may not replace it.
|
|
110
|
+
options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified;
|
|
111
|
+
|
|
112
|
+
var sourceIsArray = Array.isArray(source);
|
|
113
|
+
var targetIsArray = Array.isArray(target);
|
|
114
|
+
var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray;
|
|
115
|
+
|
|
116
|
+
if (!sourceAndTargetTypesMatch) {
|
|
117
|
+
return cloneUnlessOtherwiseSpecified(source, options)
|
|
118
|
+
} else if (sourceIsArray) {
|
|
119
|
+
return options.arrayMerge(target, source, options)
|
|
120
|
+
} else {
|
|
121
|
+
return mergeObject(target, source, options)
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
deepmerge.all = function deepmergeAll(array, options) {
|
|
126
|
+
if (!Array.isArray(array)) {
|
|
127
|
+
throw new Error('first argument should be an array')
|
|
128
|
+
}
|
|
129
|
+
|
|
130
|
+
return array.reduce(function(prev, next) {
|
|
131
|
+
return deepmerge(prev, next, options)
|
|
132
|
+
}, {})
|
|
133
|
+
};
|
|
134
|
+
|
|
135
|
+
var deepmerge_1 = deepmerge;
|
|
136
|
+
|
|
137
|
+
return deepmerge_1;
|
|
138
|
+
|
|
139
|
+
}));
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
declare function deepmerge<T>(x: Partial<T>, y: Partial<T>, options?: deepmerge.Options): T;
|
|
2
|
+
declare function deepmerge<T1, T2>(x: Partial<T1>, y: Partial<T2>, options?: deepmerge.Options): T1 & T2;
|
|
3
|
+
|
|
4
|
+
declare namespace deepmerge {
|
|
5
|
+
export interface Options {
|
|
6
|
+
arrayMerge?(target: any[], source: any[], options?: ArrayMergeOptions): any[];
|
|
7
|
+
clone?: boolean;
|
|
8
|
+
customMerge?: (key: string, options?: Options) => ((x: any, y: any) => any) | undefined;
|
|
9
|
+
isMergeableObject?(value: object): boolean;
|
|
10
|
+
}
|
|
11
|
+
export interface ArrayMergeOptions {
|
|
12
|
+
isMergeableObject(value: object): boolean;
|
|
13
|
+
cloneUnlessOtherwiseSpecified(value: object, options?: Options): object;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function all (objects: object[], options?: Options): object;
|
|
17
|
+
export function all<T> (objects: Partial<T>[], options?: Options): T;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export = deepmerge;
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
var defaultIsMergeableObject = require('is-mergeable-object')
|
|
2
|
+
|
|
3
|
+
function emptyTarget(val) {
|
|
4
|
+
return Array.isArray(val) ? [] : {}
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
function cloneUnlessOtherwiseSpecified(value, options) {
|
|
8
|
+
return (options.clone !== false && options.isMergeableObject(value))
|
|
9
|
+
? deepmerge(emptyTarget(value), value, options)
|
|
10
|
+
: value
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
function defaultArrayMerge(target, source, options) {
|
|
14
|
+
return target.concat(source).map(function(element) {
|
|
15
|
+
return cloneUnlessOtherwiseSpecified(element, options)
|
|
16
|
+
})
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
function getMergeFunction(key, options) {
|
|
20
|
+
if (!options.customMerge) {
|
|
21
|
+
return deepmerge
|
|
22
|
+
}
|
|
23
|
+
var customMerge = options.customMerge(key)
|
|
24
|
+
return typeof customMerge === 'function' ? customMerge : deepmerge
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
function getEnumerableOwnPropertySymbols(target) {
|
|
28
|
+
return Object.getOwnPropertySymbols
|
|
29
|
+
? Object.getOwnPropertySymbols(target).filter(function(symbol) {
|
|
30
|
+
return Object.propertyIsEnumerable.call(target, symbol)
|
|
31
|
+
})
|
|
32
|
+
: []
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
function getKeys(target) {
|
|
36
|
+
return Object.keys(target).concat(getEnumerableOwnPropertySymbols(target))
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
function propertyIsOnObject(object, property) {
|
|
40
|
+
try {
|
|
41
|
+
return property in object
|
|
42
|
+
} catch(_) {
|
|
43
|
+
return false
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
// Protects from prototype poisoning and unexpected merging up the prototype chain.
|
|
48
|
+
function propertyIsUnsafe(target, key) {
|
|
49
|
+
return propertyIsOnObject(target, key) // Properties are safe to merge if they don't exist in the target yet,
|
|
50
|
+
&& !(Object.hasOwnProperty.call(target, key) // unsafe if they exist up the prototype chain,
|
|
51
|
+
&& Object.propertyIsEnumerable.call(target, key)) // and also unsafe if they're nonenumerable.
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
function mergeObject(target, source, options) {
|
|
55
|
+
var destination = {}
|
|
56
|
+
if (options.isMergeableObject(target)) {
|
|
57
|
+
getKeys(target).forEach(function(key) {
|
|
58
|
+
destination[key] = cloneUnlessOtherwiseSpecified(target[key], options)
|
|
59
|
+
})
|
|
60
|
+
}
|
|
61
|
+
getKeys(source).forEach(function(key) {
|
|
62
|
+
if (propertyIsUnsafe(target, key)) {
|
|
63
|
+
return
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
if (propertyIsOnObject(target, key) && options.isMergeableObject(source[key])) {
|
|
67
|
+
destination[key] = getMergeFunction(key, options)(target[key], source[key], options)
|
|
68
|
+
} else {
|
|
69
|
+
destination[key] = cloneUnlessOtherwiseSpecified(source[key], options)
|
|
70
|
+
}
|
|
71
|
+
})
|
|
72
|
+
return destination
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
function deepmerge(target, source, options) {
|
|
76
|
+
options = options || {}
|
|
77
|
+
options.arrayMerge = options.arrayMerge || defaultArrayMerge
|
|
78
|
+
options.isMergeableObject = options.isMergeableObject || defaultIsMergeableObject
|
|
79
|
+
// cloneUnlessOtherwiseSpecified is added to `options` so that custom arrayMerge()
|
|
80
|
+
// implementations can use it. The caller may not replace it.
|
|
81
|
+
options.cloneUnlessOtherwiseSpecified = cloneUnlessOtherwiseSpecified
|
|
82
|
+
|
|
83
|
+
var sourceIsArray = Array.isArray(source)
|
|
84
|
+
var targetIsArray = Array.isArray(target)
|
|
85
|
+
var sourceAndTargetTypesMatch = sourceIsArray === targetIsArray
|
|
86
|
+
|
|
87
|
+
if (!sourceAndTargetTypesMatch) {
|
|
88
|
+
return cloneUnlessOtherwiseSpecified(source, options)
|
|
89
|
+
} else if (sourceIsArray) {
|
|
90
|
+
return options.arrayMerge(target, source, options)
|
|
91
|
+
} else {
|
|
92
|
+
return mergeObject(target, source, options)
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
deepmerge.all = function deepmergeAll(array, options) {
|
|
97
|
+
if (!Array.isArray(array)) {
|
|
98
|
+
throw new Error('first argument should be an array')
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
return array.reduce(function(prev, next) {
|
|
102
|
+
return deepmerge(prev, next, options)
|
|
103
|
+
}, {})
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
module.exports = deepmerge
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License (MIT)
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2012 James Halliday, Josh Duff, and other contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "deepmerge",
|
|
3
|
+
"description": "A library for deep (recursive) merging of Javascript objects",
|
|
4
|
+
"keywords": [
|
|
5
|
+
"merge",
|
|
6
|
+
"deep",
|
|
7
|
+
"extend",
|
|
8
|
+
"copy",
|
|
9
|
+
"clone",
|
|
10
|
+
"recursive"
|
|
11
|
+
],
|
|
12
|
+
"version": "4.3.1",
|
|
13
|
+
"homepage": "https://github.com/TehShrike/deepmerge",
|
|
14
|
+
"repository": {
|
|
15
|
+
"type": "git",
|
|
16
|
+
"url": "git://github.com/TehShrike/deepmerge.git"
|
|
17
|
+
},
|
|
18
|
+
"main": "dist/cjs.js",
|
|
19
|
+
"engines": {
|
|
20
|
+
"node": ">=0.10.0"
|
|
21
|
+
},
|
|
22
|
+
"scripts": {
|
|
23
|
+
"build": "rollup -c",
|
|
24
|
+
"test": "npm run build && tape test/*.js && jsmd readme.md && npm run test:typescript",
|
|
25
|
+
"test:typescript": "tsc --noEmit test/typescript.ts && ts-node test/typescript.ts",
|
|
26
|
+
"size": "npm run build && uglifyjs --compress --mangle -- ./dist/umd.js | gzip -c | wc -c"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@types/node": "^8.10.54",
|
|
30
|
+
"is-mergeable-object": "1.1.0",
|
|
31
|
+
"is-plain-object": "^5.0.0",
|
|
32
|
+
"jsmd": "^1.0.2",
|
|
33
|
+
"rollup": "^1.23.1",
|
|
34
|
+
"rollup-plugin-commonjs": "^10.1.0",
|
|
35
|
+
"rollup-plugin-node-resolve": "^5.2.0",
|
|
36
|
+
"tape": "^4.11.0",
|
|
37
|
+
"ts-node": "7.0.1",
|
|
38
|
+
"typescript": "=2.2.2",
|
|
39
|
+
"uglify-js": "^3.6.1"
|
|
40
|
+
},
|
|
41
|
+
"license": "MIT"
|
|
42
|
+
}
|