-
Notifications
You must be signed in to change notification settings - Fork 2
/
tests.js
executable file
·8344 lines (6904 loc) · 270 KB
/
tests.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
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
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 */
/*!**********************!*\
!*** ./src/tests.js ***!
\**********************/
/***/ (function(module, exports, __webpack_require__) {
'use strict';
var _Reducer = __webpack_require__(/*! ./Test/Reducer */ 41);
var _Reducer2 = _interopRequireDefault(_Reducer);
var _Middleware = __webpack_require__(/*! ./Test/Middleware */ 74);
var _Middleware2 = _interopRequireDefault(_Middleware);
var _Equality = __webpack_require__(/*! ./Test/Equality */ 75);
var _Equality2 = _interopRequireDefault(_Equality);
var _Subscribe = __webpack_require__(/*! ./Test/Subscribe */ 76);
var _Subscribe2 = _interopRequireDefault(_Subscribe);
var _Redux = __webpack_require__(/*! ./Test/Redux */ 77);
var _Redux2 = _interopRequireDefault(_Redux);
var _Memoize = __webpack_require__(/*! ./Test/Memoize */ 78);
var _Memoize2 = _interopRequireDefault(_Memoize);
var _ReduxThunk = __webpack_require__(/*! ./Test/ReduxThunk */ 80);
var _ReduxThunk2 = _interopRequireDefault(_ReduxThunk);
var _Prettify = __webpack_require__(/*! ./Test/Prettify */ 82);
var _Prettify2 = _interopRequireDefault(_Prettify);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var tests = function tests() {
(0, _Reducer2.default)();
(0, _Middleware2.default)();
(0, _Equality2.default)();
(0, _Subscribe2.default)();
(0, _Redux2.default)();
(0, _Memoize2.default)();
(0, _ReduxThunk2.default)();
(0, _Prettify2.default)();
};
tests();
/***/ }),
/* 1 */
/*!**********************!*\
!*** ./src/index.js ***!
\**********************/
/***/ (function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Composite = exports.Defaults = undefined;
var _Structure = __webpack_require__(/*! ./Structure */ 2);
Object.keys(_Structure).forEach(function (key) {
if (key === "default" || key === "__esModule") return;
Object.defineProperty(exports, key, {
enumerable: true,
get: function get() {
return _Structure[key];
}
});
});
var _Composite = __webpack_require__(/*! ./Composite */ 3);
var _Composite2 = _interopRequireDefault(_Composite);
var _Structure2 = _interopRequireDefault(_Structure);
var _Reducer = __webpack_require__(/*! ./Composite/Reducer */ 6);
var _Reducer2 = _interopRequireDefault(_Reducer);
var _Middleware = __webpack_require__(/*! ./Composite/Middleware */ 9);
var _Middleware2 = _interopRequireDefault(_Middleware);
var _Equality = __webpack_require__(/*! ./Composite/Equality */ 11);
var _Equality2 = _interopRequireDefault(_Equality);
var _Subscribe = __webpack_require__(/*! ./Composite/Subscribe */ 12);
var _Subscribe2 = _interopRequireDefault(_Subscribe);
var _Redux = __webpack_require__(/*! ./Composite/Redux */ 13);
var _Redux2 = _interopRequireDefault(_Redux);
var _Memoize = __webpack_require__(/*! ./Composite/Memoize */ 14);
var _Memoize2 = _interopRequireDefault(_Memoize);
var _Redux3 = __webpack_require__(/*! ./Redux */ 15);
var _Redux4 = _interopRequireDefault(_Redux3);
var _Memoize3 = __webpack_require__(/*! ./Memoize */ 16);
var _Memoize4 = _interopRequireDefault(_Memoize3);
var _Reduce = __webpack_require__(/*! ./Prettify/Reduce */ 17);
var _Reduce2 = _interopRequireDefault(_Reduce);
var _Expand = __webpack_require__(/*! ./Prettify/Expand */ 18);
var _Expand2 = _interopRequireDefault(_Expand);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var Defaults = exports.Defaults = { Reducer: _Reducer2.default, Middleware: _Middleware2.default, Equality: _Equality2.default, Subscribe: _Subscribe2.default, Redux: _Redux2.default, Memoize: _Memoize2.default, Init: { Store: _Redux4.default, Memoize: _Memoize4.default }, Prettify: { Reduce: _Reduce2.default, Expand: _Expand2.default } };
var Composite = exports.Composite = function Composite(parameters) {
return new _Composite2.default(parameters);
};
exports.default = { Composite: Composite, Structure: _Structure2.default, Defaults: Defaults, Wrappers: _Composite.Wrappers };
/***/ }),
/* 2 */
/*!**************************!*\
!*** ./src/Structure.js ***!
\**************************/
/***/ (function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Structure = undefined;
var _Composite = __webpack_require__(/*! ./Composite */ 3);
var _Composite2 = _interopRequireDefault(_Composite);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var Structure = exports.Structure = function Structure(structure) {
return new _Composite2.default({ structure: structure });
};
exports.default = Structure;
/***/ }),
/* 3 */
/*!**************************!*\
!*** ./src/Composite.js ***!
\**************************/
/***/ (function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.Wrappers = undefined;
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 _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 _WalkComposite = __webpack_require__(/*! ./Helper/WalkComposite */ 4);
var _WalkComposite2 = _interopRequireDefault(_WalkComposite);
var _Reducer = __webpack_require__(/*! ./Composite/Reducer */ 6);
var _Reducer2 = _interopRequireDefault(_Reducer);
var _Middleware = __webpack_require__(/*! ./Composite/Middleware */ 9);
var _Middleware2 = _interopRequireDefault(_Middleware);
var _Equality = __webpack_require__(/*! ./Composite/Equality */ 11);
var _Equality2 = _interopRequireDefault(_Equality);
var _Subscribe = __webpack_require__(/*! ./Composite/Subscribe */ 12);
var _Subscribe2 = _interopRequireDefault(_Subscribe);
var _Redux = __webpack_require__(/*! ./Composite/Redux */ 13);
var _Redux2 = _interopRequireDefault(_Redux);
var _Memoize = __webpack_require__(/*! ./Composite/Memoize */ 14);
var _Memoize2 = _interopRequireDefault(_Memoize);
var _Redux3 = __webpack_require__(/*! ./Redux */ 15);
var _Redux4 = _interopRequireDefault(_Redux3);
var _Memoize3 = __webpack_require__(/*! ./Memoize */ 16);
var _Memoize4 = _interopRequireDefault(_Memoize3);
var _Reduce = __webpack_require__(/*! ./Prettify/Reduce */ 17);
var _Reduce2 = _interopRequireDefault(_Reduce);
var _Expand = __webpack_require__(/*! ./Prettify/Expand */ 18);
var _Expand2 = _interopRequireDefault(_Expand);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
var defaultEquality = function defaultEquality(prev, next) {
return prev === next;
};
var defaultMiddleware = function defaultMiddleware() {
return function (next) {
return function (action) {
return next(action);
};
};
};
var applyMiddleware = function applyMiddleware(middlewares) {
if (middlewares.length === 0) {
return defaultMiddleware;
} else if (middlewares.length === 1) {
return middlewares[0];
}
return function (_ref) {
var dispatch = _ref.dispatch,
getState = _ref.getState;
var chain = middlewares.map(function (middleware) {
return middleware({ dispatch: dispatch, getState: getState });
}).reverse();
return function (next) {
return chain.reduce(function (resultMiddleware, middleware) {
return middleware(resultMiddleware);
}, next);
};
};
};
var Wrappers = exports.Wrappers = {
Subscribe: function Subscribe(originalSubscribe, equality) {
return function (dispatch, getState) {
var subscribe = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined;
return function (listeners) {
if (listeners === undefined) {
return function () {};
}
var initializedSubscribe = originalSubscribe(dispatch, getState)(listeners);
var state = getState();
var listener = function listener() {
var next = getState();
if (!(equality === undefined ? defaultEquality : equality)(state, next)) {
state = next;
initializedSubscribe();
}
};
return typeof subscribe === 'function' ? subscribe(listener) : listener;
};
};
},
Memoize: function Memoize(originalMemoize, equality) {
return function (getState) {
var resolvedMemoize = originalMemoize(getState);
return _extends({}, resolvedMemoize, {
memoize: function memoize(callback) {
var state = undefined,
result = undefined;
return function () {
var next = getState();
if (!(equality === undefined ? defaultEquality : equality)(state, next)) {
state = next;
result = resolvedMemoize.memoize(callback).apply(undefined, arguments);
}
return result;
};
}
});
};
}
};
var Composite = function Composite(data) {
var _this = this;
_classCallCheck(this, Composite);
var structure = data.structure,
reducer = data.reducer,
middleware = data.middleware,
equality = data.equality,
subscribe = data.subscribe,
redux = data.redux,
memoize = data.memoize;
if (structure === undefined && typeof reducer !== 'function') {
throw {
message: "Not valid parameters: should be either structure or reducer"
};
}
var compositeStructure = structure === undefined ? undefined : (0, _WalkComposite2.default)({}, true)(function (leaf) {
if (typeof leaf === 'function') {
return new Composite({ reducer: leaf });
}
if (leaf instanceof Composite && typeof leaf.uglify === 'function') {
leaf.uglify();
}
return leaf;
})(structure);
var injection = function injection(parameter, withStructure, withoutStructure, wrapper) {
if (typeof parameter === 'function') {
return structure === undefined ? parameter : parameter(compositeStructure);
}
var beforeWrapper = structure === undefined ? withoutStructure : withStructure(compositeStructure);
return wrapper === undefined ? beforeWrapper : wrapper(beforeWrapper);
};
this.reducer = injection(reducer, _Reducer2.default);
this.middleware = injection(structure === undefined && (typeof middleware === 'undefined' ? 'undefined' : _typeof(middleware)) === 'object' && Array.isArray(middleware) ? applyMiddleware(middleware.filter(function (oneMiddleware) {
return typeof oneMiddleware === 'function';
})) : middleware, _Middleware2.default, defaultMiddleware);
this.equality = injection(equality, _Equality2.default, defaultEquality);
this.subscribe = injection(subscribe, _Subscribe2.default, function (dispatch, getState) {
return function (listener) {
return function () {
return listener({ dispatch: dispatch, getState: getState });
};
};
}, function (equality) {
return function (originalSubscriber) {
return Wrappers.Subscribe(originalSubscriber, equality);
};
}(this.equality));
this.redux = injection(redux, _Redux2.default, function (dispatch, getState, subscribe) {
return {
redux: { dispatch: dispatch, getState: getState, subscribe: subscribe }
};
});
this.memoize = injection(memoize, _Memoize2.default, function (getState) {
return { memoize: function memoize(callback) {
return callback;
} };
}, function (equality) {
return function (originalMemoize) {
return Wrappers.Memoize(originalMemoize, equality);
};
}(this.equality));
var Prettify = function Prettify() {
var _ref2 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
reduce = _ref2.reduce,
expand = _ref2.expand;
reduce = typeof reduce === 'function' ? reduce : _Reduce2.default;
expand = typeof expand === 'function' ? expand : _Expand2.default;
var r = _this.reducer;
var m = _this.middleware;
_this.reducer = function (state, action) {
return r(state, expand(action));
};
_this.middleware = function (store) {
return function (next) {
return function (action) {
return m(store)(function (action) {
return next(reduce(action));
})(action);
};
};
};
_this.uglify = function () {
_this.reducer = r;
_this.middleware = m;
delete _this.uglify;
};
};
var Init = function Init(reduxStore, initRedux, initMemoize) {
return function (composite) {
var _ref3 = function (store) {
return store(composite)(reduxStore);
}(initRedux),
store = _ref3.store,
structure = _ref3.structure;
composite.memoize = function (memoize) {
return memoize(composite.memoize, store);
}(initMemoize);
delete composite.reducer;
delete composite.middleware;
delete composite.redux;
delete composite.equality;
composite.store = structure;
composite.getState = store.getState;
composite.dispatch = store.dispatch;
composite.subscribe = store.subscribe;
return composite;
};
};
this.createStore = function () {
var _ref4 = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {},
_ref4$createStore = _ref4.createStore,
createStore = _ref4$createStore === undefined ? undefined : _ref4$createStore,
_ref4$init = _ref4.init,
init = _ref4$init === undefined ? {} : _ref4$init,
_ref4$prettify = _ref4.prettify,
prettify = _ref4$prettify === undefined ? {} : _ref4$prettify;
return function (reducer, preloadedState, enhancer) {
// Prettify
if ((typeof prettify === 'undefined' ? 'undefined' : _typeof(prettify)) === 'object') {
var reduce = typeof prettify.reduce === 'function' ? prettify.reduce : _Reduce2.default;
var expand = typeof prettify.expand === 'function' ? prettify.expand : _Expand2.default;
Prettify({ reduce: reduce, expand: expand });
}
// Create Store
if (typeof createStore !== 'function') {
createStore = __webpack_require__(/*! redux */ 19).createStore;
}
reducer = typeof reducer === 'function' ? reducer(_this.reducer) : _this.reducer;
if (typeof preloadedState === 'function' && enhancer === undefined) {
enhancer = preloadedState;
preloadedState = undefined;
}
enhancer = typeof enhancer === 'function' ? enhancer(_this.middleware) : __webpack_require__(/*! redux */ 19).applyMiddleware(_this.middleware);
var Store = createStore(reducer, preloadedState, enhancer);
// Init
var initRedux = typeof init.store === 'function' ? init.store : _Redux4.default;
var initMemoize = typeof init.memoize === 'function' ? init.memoize : _Memoize4.default;
Init(Store, initRedux, initMemoize)(_this);
// Clean-up
delete _this.createStore;
return Store;
};
};
};
exports.default = Composite;
/***/ }),
/* 4 */
/*!*************************************!*\
!*** ./src/Helper/WalkComposite.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 _walkComposite = __webpack_require__(/*! walk-composite */ 5);
var _Composite = __webpack_require__(/*! ../Composite */ 3);
var _Composite2 = _interopRequireDefault(_Composite);
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var WalkComposite = function WalkComposite() {
var parameters = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
var allowFunction = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : false;
return (0, _walkComposite.Walk)(_extends({
leafCondition: function leafCondition(data) {
var isLeaf = _walkComposite.Defaults.LeafCondition(data);
if (!(data instanceof _Composite2.default) && isLeaf && (!allowFunction || typeof data !== 'function')) {
throw {
message: "Structure leafs could be only instance of Composite or reducer function"
};
}
return isLeaf || data instanceof _Composite2.default;
},
walkMethod: function walkMethod(parameters) {
return WalkComposite(parameters, allowFunction);
}
}, parameters));
};
exports.default = WalkComposite;
/***/ }),
/* 5 */
/*!***********************************!*\
!*** ./~/walk-composite/index.js ***!
\***********************************/
/***/ (function(module, exports) {
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, key, value);
}, 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, key, value) {
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
/***/ }),
/* 6 */
/*!**********************************!*\
!*** ./src/Composite/Reducer.js ***!
\**********************************/
/***/ (function(module, exports, __webpack_require__) {
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
var _WalkComposite = __webpack_require__(/*! ../Helper/WalkComposite */ 4);
var _WalkComposite2 = _interopRequireDefault(_WalkComposite);
var _ReduxAction = __webpack_require__(/*! ../Helper/ReduxAction */ 7);
var _DefaultMutationMethod = __webpack_require__(/*! ../Helper/DefaultMutationMethod */ 8);
var _DefaultMutationMethod2 = _interopRequireDefault(_DefaultMutationMethod);