-
Notifications
You must be signed in to change notification settings - Fork 1
/
index.js
416 lines (323 loc) · 14.5 KB
/
index.js
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
module.exports =
/******/ (function(modules) { // webpackBootstrap
/******/ // The module cache
/******/ var installedModules = {};
/******/
/******/ // The require function
/******/ function __webpack_require__(moduleId) {
/******/
/******/ // Check if module is in cache
/******/ if(installedModules[moduleId])
/******/ return installedModules[moduleId].exports;
/******/
/******/ // Create a new module (and put it into the cache)
/******/ var module = installedModules[moduleId] = {
/******/ exports: {},
/******/ id: moduleId,
/******/ loaded: false
/******/ };
/******/
/******/ // Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
/******/
/******/ // Flag the module as loaded
/******/ module.loaded = true;
/******/
/******/ // Return the exports of the module
/******/ return module.exports;
/******/ }
/******/
/******/
/******/ // expose the modules object (__webpack_modules__)
/******/ __webpack_require__.m = modules;
/******/
/******/ // expose the module cache
/******/ __webpack_require__.c = installedModules;
/******/
/******/ // __webpack_public_path__
/******/ __webpack_require__.p = "";
/******/
/******/ // Load entry module and return exports
/******/ return __webpack_require__(0);
/******/ })
/************************************************************************/
/******/ ([
/* 0 */
/*!*******************!*\
!*** multi index ***!
\*******************/
/***/ (function(module, exports, __webpack_require__) {
module.exports = __webpack_require__(/*! ./src/index.js */1);
/***/ }),
/* 1 */
/*!**********************!*\
!*** ./src/index.js ***!
\**********************/
/***/ (function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Examples = exports.Defaults = undefined;
var _Composite = __webpack_require__(/*! ./Composite */ 2);
Object.keys(_Composite).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function get() {
return _Composite[key];
}
});
});
var _Walk = __webpack_require__(/*! ./Walk */ 4);
Object.keys(_Walk).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function get() {
return _Walk[key];
}
});
});
var _KeysMethod = __webpack_require__(/*! ./Default/KeysMethod */ 7);
var _KeysMethod2 = _interopRequireDefault(_KeysMethod);
var _LeafCondition = __webpack_require__(/*! ./Default/LeafCondition */ 5);
var _LeafCondition2 = _interopRequireDefault(_LeafCondition);
var _MutationMethod = __webpack_require__(/*! ./Default/MutationMethod */ 6);
var _MutationMethod2 = _interopRequireDefault(_MutationMethod);
var _ReducerMethod = __webpack_require__(/*! ./Default/ReducerMethod */ 8);
var _ReducerMethod2 = _interopRequireDefault(_ReducerMethod);
var _WalkFunction = __webpack_require__(/*! ./Example/WalkFunction */ 9);
var _WalkFunction2 = _interopRequireDefault(_WalkFunction);
var _Composite2 = _interopRequireDefault(_Composite);
var _Walk2 = _interopRequireDefault(_Walk);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var Defaults = exports.Defaults = { KeysMethod: _KeysMethod2.default, LeafCondition: _LeafCondition2.default, MutationMethod: _MutationMethod2.default, ReducerMethod: _ReducerMethod2.default };
var Examples = exports.Examples = { WalkFunction: _WalkFunction2.default };
exports.default = { Walk: _Walk2.default, Composite: _Composite2.default, Defaults: Defaults, Examples: Examples };
/***/ }),
/* 2 */
/*!**************************!*\
!*** ./src/Composite.js ***!
\**************************/
/***/ (function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Composite = undefined;
var _InitDefault = __webpack_require__(/*! ./InitDefault */ 3);
var _InitDefault2 = _interopRequireDefault(_InitDefault);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
var Composite = exports.Composite = function Composite(parameters) {
var defaults = (0, _InitDefault2.default)(parameters);
var reducerMethod = defaults.reducerMethod();
return function (leafCallback) {
return function () {
for (var _len = arguments.length, data = Array(_len), _key = 0; _key < _len; _key++) {
data[_key] = arguments[_key];
}
return defaults.keysMethod().apply(undefined, data).reduce(function (result, key) {
var value = defaults.walkMethod()(parameters)(leafCallback).apply(undefined, _toConsumableArray(defaults.mutationMethod()(key).apply(undefined, data)));
return reducerMethod.add(result, value, key);
}, reducerMethod.init.apply(reducerMethod, data));
};
};
};
exports.default = Composite;
/***/ }),
/* 3 */
/*!****************************!*\
!*** ./src/InitDefault.js ***!
\****************************/
/***/ (function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
var _Walk = __webpack_require__(/*! ./Walk */ 4);
var _Walk2 = _interopRequireDefault(_Walk);
var _Composite = __webpack_require__(/*! ./Composite */ 2);
var _Composite2 = _interopRequireDefault(_Composite);
var _LeafCondition = __webpack_require__(/*! ./Default/LeafCondition */ 5);
var _LeafCondition2 = _interopRequireDefault(_LeafCondition);
var _MutationMethod = __webpack_require__(/*! ./Default/MutationMethod */ 6);
var _MutationMethod2 = _interopRequireDefault(_MutationMethod);
var _KeysMethod = __webpack_require__(/*! ./Default/KeysMethod */ 7);
var _KeysMethod2 = _interopRequireDefault(_KeysMethod);
var _ReducerMethod = __webpack_require__(/*! ./Default/ReducerMethod */ 8);
var _ReducerMethod2 = _interopRequireDefault(_ReducerMethod);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var InitDefault = function InitDefault(_ref) {
var _leafCondition = _ref.leafCondition,
_mutationMethod = _ref.mutationMethod,
_walkMethod = _ref.walkMethod,
_compositeMethod = _ref.compositeMethod,
_keysMethod = _ref.keysMethod,
_reducerMethod = _ref.reducerMethod;
return {
walkMethod: function walkMethod() {
return typeof _walkMethod === 'function' ? _walkMethod : _Walk2.default;
},
compositeMethod: function compositeMethod() {
return typeof _compositeMethod === 'function' ? _compositeMethod : _Composite2.default;
},
leafCondition: function leafCondition() {
return typeof _leafCondition === 'function' ? _leafCondition : _LeafCondition2.default;
},
mutationMethod: function mutationMethod() {
return typeof _mutationMethod === 'function' ? _mutationMethod : _MutationMethod2.default;
},
keysMethod: function keysMethod() {
return typeof _keysMethod === 'function' ? _keysMethod : _KeysMethod2.default;
},
reducerMethod: function reducerMethod() {
return (typeof _reducerMethod === 'undefined' ? 'undefined' : _typeof(_reducerMethod)) === 'object' && typeof _reducerMethod.add === 'function' && typeof _reducerMethod.init === 'function' ? _reducerMethod : _ReducerMethod2.default;
}
};
};
exports.default = InitDefault;
/***/ }),
/* 4 */
/*!*********************!*\
!*** ./src/Walk.js ***!
\*********************/
/***/ (function(module, exports, __webpack_require__) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Walk = undefined;
var _InitDefault = __webpack_require__(/*! ./InitDefault */ 3);
var _InitDefault2 = _interopRequireDefault(_InitDefault);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var Walk = exports.Walk = function Walk(parameters) {
var defaults = (0, _InitDefault2.default)(parameters);
return function (leafCallback) {
return function () {
return defaults.leafCondition().apply(undefined, arguments) ? leafCallback.apply(undefined, arguments) : defaults.compositeMethod()(parameters)(leafCallback).apply(undefined, arguments);
};
};
};
exports.default = Walk;
/***/ }),
/* 5 */
/*!**************************************!*\
!*** ./src/Default/LeafCondition.js ***!
\**************************************/
/***/ (function(module, exports) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
var LeafCondition = function LeafCondition(data) {
return data === null || (typeof data === 'undefined' ? 'undefined' : _typeof(data)) !== 'object';
};
exports.default = LeafCondition;
/***/ }),
/* 6 */
/*!***************************************!*\
!*** ./src/Default/MutationMethod.js ***!
\***************************************/
/***/ (function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };
var _LeafCondition = __webpack_require__(/*! ./LeafCondition */ 5);
var _LeafCondition2 = _interopRequireDefault(_LeafCondition);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var MutationMethod = function MutationMethod(key) {
return function () {
for (var _len = arguments.length, data = Array(_len), _key = 0; _key < _len; _key++) {
data[_key] = arguments[_key];
}
return data.map(function (argument) {
return _LeafCondition2.default.apply(undefined, data) || (typeof argument === 'undefined' ? 'undefined' : _typeof(argument)) !== 'object' || !argument.hasOwnProperty(key) ? undefined : argument[key];
});
};
};
exports.default = MutationMethod;
/***/ }),
/* 7 */
/*!***********************************!*\
!*** ./src/Default/KeysMethod.js ***!
\***********************************/
/***/ (function(module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var KeysMethod = function KeysMethod(data) {
return Object.keys(data);
};
exports.default = KeysMethod;
/***/ }),
/* 8 */
/*!**************************************!*\
!*** ./src/Default/ReducerMethod.js ***!
\**************************************/
/***/ (function(module, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }
var ReducerMethod = {
add: function add(result, value, key) {
return Array.isArray(result) ? [].concat(_toConsumableArray(result), [value]) : _extends({}, result, _defineProperty({}, key, value));
},
init: function init(data) {
return Array.isArray(data) ? [] : {};
}
};
exports.default = ReducerMethod;
/***/ }),
/* 9 */
/*!*************************************!*\
!*** ./src/Example/WalkFunction.js ***!
\*************************************/
/***/ (function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };
var _index = __webpack_require__(/*! ../index */ 1);
var WalkFunction = function WalkFunction() {
var indices = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [0];
var parameters = arguments[1];
return (0, _index.Walk)(_extends({
walkMethod: function walkMethod(parameters) {
return WalkFunction(indices, parameters);
},
leafCondition: function leafCondition() {
for (var _len = arguments.length, data = Array(_len), _key = 0; _key < _len; _key++) {
data[_key] = arguments[_key];
}
if (!_index.Defaults.LeafCondition.apply(_index.Defaults, data)) {
return false;
}
data.map(function (argument, i) {
if (argument !== undefined && indices.indexOf(i) !== -1 && typeof argument !== 'function') {
throw {
message: "Leaf data could be only function",
data: argument,
index: i
};
}
});
return true;
}
}, parameters));
};
exports.default = WalkFunction;
/***/ })
/******/ ]);
//# sourceMappingURL=index.js.map