1
+ /******/ ( function ( modules ) { // webpackBootstrap
2
+ /******/ // The module cache
3
+ /******/ var installedModules = { } ;
4
+ /******/
5
+ /******/ // The require function
6
+ /******/ function __webpack_require__ ( moduleId ) {
7
+ /******/
8
+ /******/ // Check if module is in cache
9
+ /******/ if ( installedModules [ moduleId ] ) {
10
+ /******/ return installedModules [ moduleId ] . exports ;
11
+ /******/ }
12
+ /******/ // Create a new module (and put it into the cache)
13
+ /******/ var module = installedModules [ moduleId ] = {
14
+ /******/ i : moduleId ,
15
+ /******/ l : false ,
16
+ /******/ exports : { }
17
+ /******/ } ;
18
+ /******/
19
+ /******/ // Execute the module function
20
+ /******/ modules [ moduleId ] . call ( module . exports , module , module . exports , __webpack_require__ ) ;
21
+ /******/
22
+ /******/ // Flag the module as loaded
23
+ /******/ module . l = true ;
24
+ /******/
25
+ /******/ // Return the exports of the module
26
+ /******/ return module . exports ;
27
+ /******/ }
28
+ /******/
29
+ /******/
30
+ /******/ // expose the modules object (__webpack_modules__)
31
+ /******/ __webpack_require__ . m = modules ;
32
+ /******/
33
+ /******/ // expose the module cache
34
+ /******/ __webpack_require__ . c = installedModules ;
35
+ /******/
36
+ /******/ // define getter function for harmony exports
37
+ /******/ __webpack_require__ . d = function ( exports , name , getter ) {
38
+ /******/ if ( ! __webpack_require__ . o ( exports , name ) ) {
39
+ /******/ Object . defineProperty ( exports , name , { enumerable : true , get : getter } ) ;
40
+ /******/ }
41
+ /******/ } ;
42
+ /******/
43
+ /******/ // define __esModule on exports
44
+ /******/ __webpack_require__ . r = function ( exports ) {
45
+ /******/ if ( typeof Symbol !== 'undefined' && Symbol . toStringTag ) {
46
+ /******/ Object . defineProperty ( exports , Symbol . toStringTag , { value : 'Module' } ) ;
47
+ /******/ }
48
+ /******/ Object . defineProperty ( exports , '__esModule' , { value : true } ) ;
49
+ /******/ } ;
50
+ /******/
51
+ /******/ // create a fake namespace object
52
+ /******/ // mode & 1: value is a module id, require it
53
+ /******/ // mode & 2: merge all properties of value into the ns
54
+ /******/ // mode & 4: return value when already ns object
55
+ /******/ // mode & 8|1: behave like require
56
+ /******/ __webpack_require__ . t = function ( value , mode ) {
57
+ /******/ if ( mode & 1 ) value = __webpack_require__ ( value ) ;
58
+ /******/ if ( mode & 8 ) return value ;
59
+ /******/ if ( ( mode & 4 ) && typeof value === 'object' && value && value . __esModule ) return value ;
60
+ /******/ var ns = Object . create ( null ) ;
61
+ /******/ __webpack_require__ . r ( ns ) ;
62
+ /******/ Object . defineProperty ( ns , 'default' , { enumerable : true , value : value } ) ;
63
+ /******/ if ( mode & 2 && typeof value != 'string' ) for ( var key in value ) __webpack_require__ . d ( ns , key , function ( key ) { return value [ key ] ; } . bind ( null , key ) ) ;
64
+ /******/ return ns ;
65
+ /******/ } ;
66
+ /******/
67
+ /******/ // getDefaultExport function for compatibility with non-harmony modules
68
+ /******/ __webpack_require__ . n = function ( module ) {
69
+ /******/ var getter = module && module . __esModule ?
70
+ /******/ function getDefault ( ) { return module [ 'default' ] ; } :
71
+ /******/ function getModuleExports ( ) { return module ; } ;
72
+ /******/ __webpack_require__ . d ( getter , 'a' , getter ) ;
73
+ /******/ return getter ;
74
+ /******/ } ;
75
+ /******/
76
+ /******/ // Object.prototype.hasOwnProperty.call
77
+ /******/ __webpack_require__ . o = function ( object , property ) { return Object . prototype . hasOwnProperty . call ( object , property ) ; } ;
78
+ /******/
79
+ /******/ // __webpack_public_path__
80
+ /******/ __webpack_require__ . p = "" ;
81
+ /******/
82
+ /******/
83
+ /******/ // Load entry module and return exports
84
+ /******/ return __webpack_require__ ( __webpack_require__ . s = 0 ) ;
85
+ /******/ } )
86
+ /************************************************************************/
87
+ /******/ ( [
88
+ /* 0 */
89
+ /***/ ( function ( module , exports , __webpack_require__ ) {
90
+
91
+ "use strict" ;
92
+
93
+ Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
94
+ var chai_1 = __webpack_require__ ( 1 ) ;
95
+ var index_1 = __webpack_require__ ( 2 ) ;
96
+ describe ( 'merge' , function ( ) {
97
+ it ( 'basic' , function ( ) {
98
+ chai_1 . assert . deepEqual ( index_1 . default ( { a : 1 } , { b : 2 } ) , { a : 1 , b : 2 } ) ;
99
+ chai_1 . assert . deepEqual ( index_1 . default ( { a : 1 } , { b : { c : { d : 2 } } } ) , { a : 1 , b : { c : { d : 2 } } } ) ;
100
+ } ) ;
101
+ it ( 'clone' , function ( ) {
102
+ var input = {
103
+ a : 1 ,
104
+ b : {
105
+ c : {
106
+ d : 2 ,
107
+ e : [ 'x' , 'y' , { z : { w : [ 'k' ] } } ]
108
+ }
109
+ } ,
110
+ f : null ,
111
+ g : undefined ,
112
+ h : true
113
+ } ;
114
+ var original = {
115
+ a : 1 ,
116
+ b : {
117
+ c : {
118
+ d : 2 ,
119
+ e : [ 'x' , 'y' , { z : { w : [ 'k' ] } } ]
120
+ }
121
+ } ,
122
+ f : null ,
123
+ g : undefined ,
124
+ h : true
125
+ } ;
126
+ var output = index_1 . default ( true , input ) ;
127
+ input . b . c . d ++ ;
128
+ input . b . c . e [ 2 ] . z . w = null ;
129
+ input . h = null ;
130
+ chai_1 . assert . deepEqual ( original , output ) ;
131
+ input = original ;
132
+ output = index_1 . default ( true , input , { a : 2 } ) ;
133
+ chai_1 . assert . deepEqual ( output . a , 2 ) ;
134
+ chai_1 . assert . deepEqual ( input . a , 1 ) ;
135
+ } ) ;
136
+ it ( 'invalid input' , function ( ) {
137
+ chai_1 . assert . deepEqual ( index_1 . default ( ) , { } ) ;
138
+ chai_1 . assert . deepEqual ( index_1 . default ( undefined ) , { } ) ;
139
+ chai_1 . assert . deepEqual ( index_1 . default ( [ ] ) , { } ) ;
140
+ chai_1 . assert . deepEqual ( index_1 . default ( true ) , { } ) ;
141
+ chai_1 . assert . deepEqual ( index_1 . default ( null , true , [ 0 , 1 , 2 ] , 3 , { a : 1 } , function ( ) { } , undefined , { b : 2 } ) , { a : 1 , b : 2 } ) ;
142
+ } ) ;
143
+ it ( 'prototype pollution attack' , function ( ) {
144
+ chai_1 . assert . deepEqual ( index_1 . default ( { } , JSON . parse ( '{"__proto__": {"a": true}}' ) ) , { } ) ;
145
+ } ) ;
146
+ } ) ;
147
+ describe ( 'merge.clone' , function ( ) {
148
+ it ( 'object' , function ( ) {
149
+ var object1 = { a : 1 , b : { c : 2 } } ;
150
+ var object2 = index_1 . default . clone ( object1 ) ;
151
+ chai_1 . assert . deepEqual ( object1 , object2 ) ;
152
+ chai_1 . assert . deepEqual ( object1 === object2 , false ) ;
153
+ chai_1 . assert . deepEqual ( object1 . b === object2 . b , false ) ;
154
+ } ) ;
155
+ it ( 'array' , function ( ) {
156
+ var object1 = [ { a : 1 , b : { c : 2 } } ] ;
157
+ var object2 = index_1 . default . clone ( object1 ) ;
158
+ chai_1 . assert . deepEqual ( object1 , object2 ) ;
159
+ chai_1 . assert . deepEqual ( object1 === object2 , false ) ;
160
+ chai_1 . assert . deepEqual ( object1 [ 0 ] === object2 [ 0 ] , false ) ;
161
+ chai_1 . assert . deepEqual ( object1 [ 0 ] . b === object2 [ 0 ] . b , false ) ;
162
+ } ) ;
163
+ it ( 'invalid input' , function ( ) {
164
+ chai_1 . assert . deepEqual ( index_1 . default . clone ( null ) , null ) ;
165
+ chai_1 . assert . deepEqual ( index_1 . default . clone ( undefined ) , undefined ) ;
166
+ chai_1 . assert . deepEqual ( index_1 . default . clone ( 1 ) , 1 ) ;
167
+ chai_1 . assert . deepEqual ( index_1 . default . clone ( 'str' ) , 'str' ) ;
168
+ } ) ;
169
+ } ) ;
170
+ describe ( 'merge.recursive' , function ( ) {
171
+ it ( 'basic' , function ( ) {
172
+ chai_1 . assert . deepEqual ( index_1 . default . recursive ( { a : { b : 1 } } , { a : { c : 1 } } ) , { a : { b : 1 , c : 1 } } ) ;
173
+ chai_1 . assert . deepEqual ( index_1 . default . recursive ( { a : { b : 1 , c : 1 } } , { a : { b : 2 } } ) , { a : { b : 2 , c : 1 } } ) ;
174
+ chai_1 . assert . deepEqual ( index_1 . default . recursive ( { a : { b : [ 1 , 2 , 3 ] , c : 1 } } , { a : { b : [ 'a' ] } } ) , { a : { b : [ 'a' ] , c : 1 } } ) ;
175
+ chai_1 . assert . deepEqual ( index_1 . default . recursive ( { a : { b : { b : 2 } , c : 1 } } , { a : { b : 2 } } ) , { a : { b : 2 , c : 1 } } ) ;
176
+ } ) ;
177
+ it ( 'clone' , function ( ) {
178
+ var test1 = { a : { b : 1 } } ;
179
+ chai_1 . assert . deepEqual ( index_1 . default . recursive ( true , test1 , { a : { c : 1 } } ) , { a : { b : 1 , c : 1 } } ) ;
180
+ chai_1 . assert . deepEqual ( { a : { b : 1 } } , test1 ) ;
181
+ var test2 = { a : { b : 1 , c : 1 } } ;
182
+ chai_1 . assert . deepEqual ( index_1 . default . recursive ( true , test2 , { a : { b : 2 } } ) , { a : { b : 2 , c : 1 } } ) ;
183
+ chai_1 . assert . deepEqual ( { a : { b : 1 , c : 1 } } , test2 ) ;
184
+ var test3 = { a : { b : [ 1 , 2 , 3 ] , c : 1 } } ;
185
+ chai_1 . assert . deepEqual ( index_1 . default . recursive ( true , test3 , { a : { b : [ 'a' ] } } ) , { a : { b : [ 'a' ] , c : 1 } } ) ;
186
+ chai_1 . assert . deepEqual ( { a : { b : [ 1 , 2 , 3 ] , c : 1 } } , test3 ) ;
187
+ var test4 = { a : { b : { b : 2 } , c : 1 } } ;
188
+ chai_1 . assert . deepEqual ( index_1 . default . recursive ( true , test4 , { a : { b : 2 } } ) , { a : { b : 2 , c : 1 } } ) ;
189
+ chai_1 . assert . deepEqual ( { a : { b : { b : 2 } , c : 1 } } , test4 ) ;
190
+ } ) ;
191
+ it ( 'prototype pollution attack' , function ( ) {
192
+ chai_1 . assert . deepEqual ( index_1 . default . recursive ( { } , JSON . parse ( '{"__proto__": {"a": true}}' ) ) , { } ) ;
193
+ } ) ;
194
+ } ) ;
195
+
196
+
197
+ /***/ } ) ,
198
+ /* 1 */
199
+ /***/ ( function ( module , exports ) {
200
+
201
+ module . exports = chai ;
202
+
203
+ /***/ } ) ,
204
+ /* 2 */
205
+ /***/ ( function ( module , exports , __webpack_require__ ) {
206
+
207
+ "use strict" ;
208
+
209
+ Object . defineProperty ( exports , "__esModule" , { value : true } ) ;
210
+ function main ( ) {
211
+ var items = [ ] ;
212
+ for ( var _i = 0 ; _i < arguments . length ; _i ++ ) {
213
+ items [ _i ] = arguments [ _i ] ;
214
+ }
215
+ return merge . apply ( void 0 , items ) ;
216
+ }
217
+ exports . default = main ;
218
+ main . clone = clone ;
219
+ main . isPlainObject = isPlainObject ;
220
+ main . recursive = recursive ;
221
+ function merge ( ) {
222
+ var items = [ ] ;
223
+ for ( var _i = 0 ; _i < arguments . length ; _i ++ ) {
224
+ items [ _i ] = arguments [ _i ] ;
225
+ }
226
+ return _merge ( items [ 0 ] === true , false , items ) ;
227
+ }
228
+ exports . merge = merge ;
229
+ function recursive ( ) {
230
+ var items = [ ] ;
231
+ for ( var _i = 0 ; _i < arguments . length ; _i ++ ) {
232
+ items [ _i ] = arguments [ _i ] ;
233
+ }
234
+ return _merge ( items [ 0 ] === true , true , items ) ;
235
+ }
236
+ exports . recursive = recursive ;
237
+ function clone ( input ) {
238
+ if ( Array . isArray ( input ) ) {
239
+ var output = [ ] ;
240
+ for ( var index = 0 ; index < input . length ; ++ index )
241
+ output . push ( clone ( input [ index ] ) ) ;
242
+ return output ;
243
+ }
244
+ else if ( isPlainObject ( input ) ) {
245
+ var output = { } ;
246
+ for ( var index in input )
247
+ output [ index ] = clone ( input [ index ] ) ;
248
+ return output ;
249
+ }
250
+ else {
251
+ return input ;
252
+ }
253
+ }
254
+ exports . clone = clone ;
255
+ function isPlainObject ( input ) {
256
+ return input && typeof input === 'object' && ! Array . isArray ( input ) ;
257
+ }
258
+ exports . isPlainObject = isPlainObject ;
259
+ function _recursiveMerge ( base , extend ) {
260
+ if ( ! isPlainObject ( base ) )
261
+ return extend ;
262
+ for ( var key in extend )
263
+ base [ key ] = ( isPlainObject ( base [ key ] ) && isPlainObject ( extend [ key ] ) ) ?
264
+ _recursiveMerge ( base [ key ] , extend [ key ] ) :
265
+ extend [ key ] ;
266
+ return base ;
267
+ }
268
+ function _merge ( isClone , isRecursive , items ) {
269
+ var result ;
270
+ if ( isClone || ! isPlainObject ( result = items . shift ( ) ) )
271
+ result = { } ;
272
+ for ( var index = 0 ; index < items . length ; ++ index ) {
273
+ var item = items [ index ] ;
274
+ if ( ! isPlainObject ( item ) )
275
+ continue ;
276
+ for ( var key in item ) {
277
+ if ( key === '__proto__' )
278
+ continue ;
279
+ var value = isClone ? clone ( item [ key ] ) : item [ key ] ;
280
+ result [ key ] = isRecursive ? _recursiveMerge ( result [ key ] , value ) : value ;
281
+ }
282
+ }
283
+ return result ;
284
+ }
285
+
286
+
287
+ /***/ } )
288
+ /******/ ] ) ;
0 commit comments