-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathf-empower.js
More file actions
2486 lines (2210 loc) · 53 KB
/
Copy pathf-empower.js
File metadata and controls
2486 lines (2210 loc) · 53 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
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
/**
* F-EMPOWER
* A set of functions to harness the power functional programming in JS.
* Author: Ivan Fedorov <sharp.maestro@gmail.com>
* License: MIT
*/
const hasOwnProperty = {}.hasOwnProperty
const THRESHOLD_LARGE_ARRAY_SIZE = 64000
const Errors = {
NO_KEY_VALUE_PAIR_IN_HASH: new Error('No key value pair in a criterion obj'),
NOT_FUNCTION: new TypeError('Something is not function'),
UNEXPECTED_TYPE: new TypeError('Unexpected type')
}
function ReducedClass(val) {
this.val = val
}
function Reduced(val) {
return new ReducedClass(val)
}
var to_string = Object.prototype.toString,
native_last_index_of = Array.prototype.lastIndexOf,
native_index_of = Array.prototype.indexOf,
is_array = Array.isArray
/**
* Simple and full slice
*/
function __slice(array_like) {
var len = array_like.length,
result = new Array(len)
while (--len > -1) {
result[len] = array_like[len]
}
return result
}
/**
* Quick and unsafe slice
*/
function _slice(array_like, start, end) {
let idx = start - 1,
len = array_like.length
end = end == null ? len : end
const result = new Array(end - start)
while (++idx < end) {
result[idx - start] = array_like[idx]
}
return result
}
function slice(array_like, start, end) {
const length = array_like == null ? 0 : array_like.length
if (!length) {
return []
}
start = start == null ? 0 : start
end = end == undefined ? length : end
end = end > length ? length : end
return _slice(array_like, start, end)
}
function bind(fn, this_arg) {
return function() {
return fn.apply(this_arg, arguments)
}
}
function partial(fn, args) {
args = rest(arguments)
return function() {
return fn.apply(null, args.concat(__slice(arguments)))
}
}
/**
* @param {function} fn - payload function
* @param {Array} args
*/
function apply(fn, args) {
return fn.apply(this, args)
}
function add2(a, b) {
return a + b
}
function and2(a, b) {
return a && b
}
function and_r(a, b) {
return (a && b) || Reduced(false)
}
function bind_all() {
var props = butlast(arguments),
this_arg = last(arguments)
each2(function(prop) {
this_arg[prop] = bind(this_arg[prop], this_arg)
}, props)
}
function _assert_all_functions(functions) {
each2(function (item) {
if (not_function(item)) {
throw Errors.NOT_FUNCTION
}
}, functions)
}
function compose(functions) {
functions = arguments
_assert_all_functions(functions)
return function(memo) {
memo = arguments
var idx = functions.length
while (--idx > -1) {
memo = [functions[idx].apply(null, memo)]
}
return first(memo)
}
}
function complement(predicate) {
return function() {
return !predicate.apply(null, arguments)
}
}
function debounce(debounce_timeout, payload_fn) {
if (arguments.length === 1) {
payload_fn = debounce_timeout
debounce_timeout = 0
}
var last_result = void 0,
last_args = null,
last_timeout_id = null,
last_this = null
function _exec_payload() {
return last_result = payload_fn.apply(last_this, last_args)
}
return function() {
last_args = __slice(arguments)
last_this = this
clearTimeout(last_timeout_id)
last_timeout_id = delay(debounce_timeout, _exec_payload)
return last_result
}
}
function delay(delay_ms, fn) {
if (arguments.length === 1) {
fn = delay_ms
delay_ms = 0
}
return setTimeout(fn, delay_ms)
}
function flow(functions) {
functions = arguments
_assert_all_functions(functions)
return function() {
var memo = arguments,
len = functions.length,
i = -1
while (++i < len) {
memo = [functions[i].apply(null, memo)]
}
return first(memo)
}
}
/**
* Returns a function that dispatches a call to all functions from `fns`
*/
function multicall(fns) {
fns = compact(fns)
return function() {
for (var i = -1, len = fns.length; ++i < len;) {
fns[i].apply(this, arguments)
}
}
}
function no_operation() {}
function partialr(fn, right_args) {
right_args = _slice(arguments, 1)
return function() {
return apply(fn, cat(arguments, right_args))
}
}
function periodically(interval, countdown, fn) {
var interval_id
if (not_number(countdown) || (countdown < 1)) {
throw new Error('Bad countdown')
}
return interval_id = set_interval(interval, function() {
fn()
countdown = countdown - 1
if (0 === countdown) {
return clearInterval(interval_id)
}
})
}
/**
* Wraps function `fn` is such way that its this context will be passed as first argument
*/
function pbind(fn) {
return function() {
return fn.apply(null, unshift(__slice(arguments), this))
}
}
/**
* `ms` first wrapper of setInterval
*/
function set_interval(ms, fn) {
if (!fn) {
fn = ms
ms = 0
}
return setInterval(fn, ms)
}
function throttle(throttle_millis, fn) {
var locked = false,
should_call = false,
last_args = null,
last_result = null
function void_main() {
delay(throttle_millis, function() {
if (should_call) {
last_result = fn.apply(null, last_args)
should_call = false
void_main()
} else {
locked = false
}
})
}
return function() {
last_args = __slice(arguments)
if (locked) {
should_call = true
return last_result
} else {
locked = true
last_result = fn.apply(null, last_args)
void_main()
return last_result
}
}
}
/**
* Checks if value is atomic, useful when you want to know if it is safe to copy by link
*/
function is_atomic(val) {
switch (type_of2(val)) {
case '[object Object]':
case '[object Array]':
case '[object Date]':
return false
default:
return true
}
}
function is_arguments(v) {
return '[object Arguments]' === type_of2(v)
}
function is_array_like(v) {
return is_number(v.length)
}
function is_boolean(v) {
return 'boolean' === (typeof v)
}
function is_date(val) {
return '[object Date]' === (type_of2(val))
}
function is_defined(subj) {
return 'undefined' !== (typeof subj)
}
function is_empty(o) {
return 0 === (count1(o))
}
function is_empty$(o) {
return !o || (is_empty(o))
}
function is_even(num) {
return 0 === (num % 2)
}
function is_function(candidate) {
return 'function' === typeof candidate
}
function is_number(candidate) {
return 'number' === typeof candidate
}
function is_integer(n) {
return (Number(n) === n) && (n % 1 === 0)
}
function is_object(candidate) {
return 'object' === typeof candidate
}
/**
* Checks subject for being plain old JavaScript object
* @return {boolean}
*/
function is_plain_object(subject) {
var ctor = null,
is_defnd = 'undefined' !== typeof subject,
is_objct = is_defnd && ('[object Object]' === to_string.call(subject)) && !(is_function(subject))
//
if (!is_objct || (!hasOwnProperty.call(subject, 'constructor') &&
((ctor = subject.constructor) && (is_function(ctor)) && !(ctor instanceof ctor)))) {
return false
}
var latest_key
for (var key in subject) {
latest_key = key
}
return not_defined(key) || hasOwnProperty.call(subject, latest_key)
}
function is_mergeable(item) {
return is_array(item) || is_plain_object(item)
}
function is_regexp(item) {
return '[object RegExp]' === type_of2(item)
}
const not_regexp = complement(is_regexp)
function is_string(item) {
return 'string' === type_of(item)
}
function is_subset(subset, superset) {
return is_empty(difference(subset, superset))
}
function is_zero(candidate) {
return candidate === 0
}
var not_array = complement(is_array),
not_boolean = complement(is_boolean),
not_date = complement(is_date),
not_defined = complement(is_defined),
not_empty = complement(is_empty),
not_empty$ = complement(is_empty$),
not_function = complement(is_function),
not_mergeable = complement(is_mergeable),
not_number = complement(is_number),
not_object = complement(is_object),
not_string = complement(is_string),
not_subset = complement(is_subset),
not_zero = complement(is_zero)
function butlast(arr) {
return _slice(arr, 0, arr.length - 1)
}
/**
* Concatenates arbitrary number of arrays or array-like objects
* @signature {Array<Array>} ...arrs
*/
function cat() {
const arrs = __slice(arguments),
res = [],
arrs_count = arrs.length
let i = -1
while (++i < arrs_count) {
let arr = arrs[i],
arr_len = arr.length,
k = -1
while (++k < arr_len) {
res.push(arr[k])
}
}
return res
}
function contains(searched_item, arr) {
return index_of(searched_item, arr) > -1
}
const not_contains = complement(contains)
function a_contains(arr, searched_item) {
return index_of(searched_item, arr) > -1
}
function a_each(arr, fn) {
each(fn, arr)
}
function a_each_idx(arr, fn) {
each_idx(fn, arr)
}
function a_filter(arr, fn) {
return filter(fn, arr)
}
function a_find_index(arr, pred) {
return find_index(pred, arr)
}
function a_index_of(arr, item) {
return arr.indexOf(item)
}
function a_map(arr, fn) {
return map(fn, arr)
}
function a_reduce(arr, val, fn) {
if (is_function(val)) {
return reduce(val, arr)
} else {
return reduce(fn, val, arr)
}
}
function a_reject(arr, fn) {
return reject(fn, arr)
}
function any(pred, arr) {
if (arguments.length === 1) {
arr = pred
pred = true
}
return -1 < find_index_fn(pred, arr)
}
/**
* @return {Array} Returns new array withouh any falsee members
*/
function compact(arr) {
return filter_fn(x => x, arr)
}
function count(pred, arr) {
if (!arr) {
return count1(pred)
} else if (!pred) {
return arr.length
} else {
if (is_function(pred)) {
return count_pred(pred, arr)
} else {
return count_obj(pred, arr)
}
}
}
function count1(o) {
if (is_array_like(o)) {
return o.length
} else {
return (keys(o)).length
}
}
function count_obj(pred_obj, arr) {
return reduce(((cnt, item) => o_match(pred_obj, item) ? cnt + 1 : cnt), 0, arr)
}
function count_pred(pred, arr) {
var cnt = 0,
idx = arr.length
while (--idx > -1) {
if (pred(arr[idx])) {
++cnt
}
}
return cnt
}
function drop(items_number_to_drop, array_like) {
return _slice(array_like, items_number_to_drop)
}
function drop_last(chars_to_drop, string) {
var len = string.length
if (chars_to_drop > len) {
return ''
} else {
return string.substring(0, len - chars_to_drop)
}
}
function each(fn, arr) {
switch (arguments.length) {
case 0:
case 1:
throw new Error('Each doesn\'t have a signature of that arity')
case 2:
return each2(fn, arr)
case 3:
return each3(fn, arr, arguments[2])
default:
return eachn.apply(null, arguments)
}
}
function each2(fn, arr) {
for (var i = -1, len = arr.length; ++i < len;) {
fn(arr[i])
}
}
function each3(fn, arr1, arr2) {
var length_of_shortest = Math.min(arr1.length, arr2.length)
for (var i = -1; ++i < length_of_shortest;) {
fn(arr1[i], arr2[i])
}
}
function calc_shortest_length(arrs) {
return apply(Math.min, map2(count1, arrs))
}
/**
* Variant of `each` that traverses `n` arrays with `fn`
* fn, array1, array2, array3...
*/
function eachn(fn) {
var args = arguments,
arrs = rest(args),
shortest_len = calc_shortest_length(arrs),
local_pluck = pluck,
local_apply = apply,
i = -1
while (++i < shortest_len) {
local_apply(fn, local_pluck(i, arrs))
}
}
function each_idx(fn, arr) {
if (arguments.length === 2) {
each_idx2(fn, arr)
} else {
each_idxn.apply(null, arguments)
}
}
function each_idx2(fn, arr) {
var len = arr.length,
i = -1
while (++i < len) {
fn(arr[i], i)
}
}
function each_idxn(fn, arrs) {
arrs = rest(arguments)
var shortest_len = calc_shortest_length(arrs),
local_pluck = pluck,
local_apply = apply,
i = -1,
args
while (++i < shortest_len) {
args = local_pluck(i, arrs)
args.push(i)
local_apply(fn, args)
}
}
function check_keys(obj, keys_to_check) {
return every(wrap_invoke_obj(obj), keys_to_check)
}
function check_true(val) {
return val === true
}
function every(pred, arr) {
if (!arr) {
arr = pred
pred = check_true
}
if (is_empty(arr)) {
return true
}
return every_fn(pred, arr)
}
function every_fn(fn, arr) {
return a_reduce(arr, true, function(v1, v2) {
return (v1 && fn(v2)) || Reduced(false)
})
}
function filter(some_criteria, arr) {
switch (typeof some_criteria) {
case 'string':
return filter_prop(some_criteria, arr)
case 'function':
return filter_fn(some_criteria, arr)
case 'object':
if (is_regexp(some_criteria)) {
return filter_re(some_criteria, arr)
} else {
switch (keys(some_criteria).length) {
case 0:
throw Errors.NO_KEY_VALUE_PAIR_IN_HASH
case 1:
return filter_obj_1kv(some_criteria, arr)
case 2:
return filter_obj_2kv(some_criteria, arr)
default:
return filter_obj(some_criteria, arr)
}
}
default:
throw Errors.UNEXPECTED_TYPE
}
}
function filter_fn(fn, arr) {
var res = [],
len = arr.length,
i = -1,
item
while (++i < len) {
item = arr[i]
if (fn(item)) {
res.push(item)
}
}
return res
}
function filter_prop(prop_name, arr) {
var res = [],
len = arr.length,
i = -1,
item
while (++i < len) {
item = arr[i]
if (item[prop_name]) {
res.push(item)
}
}
return res
}
function filter_obj_1kv(obj, arr) {
const [key, val] = read_1kv(obj)
const results = []
const len = arr.length
var i = -1
while (++i < len) {
if (arr[i][key] === val) {
results.push(arr[i])
}
}
return results
}
function filter_obj_2kv(obj, arr) {
const [key1, key2] = keys(obj),
[val1, val2] = [obj[key1], obj[key2]],
results = [],
len = arr.length
var i = -1, item
while (++i < len) {
item = arr[i]
if (item[key1] === val1 && item[key2] === val2) {
results.push(item)
}
}
return results
}
function filter_obj(obj, arr) {
return filter_fn(item => o_match(obj, item), arr)
}
function filter_re(regex, strings) {
return filter_fn(str => regex.test(str), strings)
}
function find(some_criteria, arr) {
var item_idx = find_index(some_criteria, arr)
if (item_idx > -1) {
return arr[item_idx]
}
}
function find_index(pred, arr) {
switch (typeof pred) {
case 'string':
return find_index_prop(pred, arr)
case 'function':
return find_index_fn(pred, arr)
case 'boolean':
case 'number':
return index_of(pred, arr)
case 'object':
switch (count1(keys(pred))) {
case 0:
throw Errors.NO_KEY_VALUE_PAIR_IN_HASH
case 1:
return find_index_obj_1kv(pred, arr)
case 2:
return find_index_obj_2kv(pred, arr)
default:
return find_index_obj(pred, arr)
}
default:
throw Errors.UNEXPECTED_TYPE
}
}
function find_index_fn(fn, arr) {
var len = arr.length,
idx = -1
while (++idx < len) {
if (fn(arr[idx])) {
return idx
}
}
return -1
}
function find_index_prop(prop_name, arr) {
var len = arr.length,
idx = -1
while (++idx < len) {
if (arr[idx][prop_name]) {
return idx
}
}
return -1
}
function find_index_obj_1kv(obj_with_1kv_pair, arr) {
const [key, val] = read_1kv(obj_with_1kv_pair)
const len = arr.length
var idx = -1
while (++idx < len) {
if (arr[idx][key] === val) {
return idx
}
}
return -1
}
function find_index_obj_2kv(obj_with_2kv_pair, arr) {
const [key1, key2] = keys(obj_with_2kv_pair)
const [val1, val2] = [obj_with_2kv_pair[key1], obj_with_2kv_pair[key2]]
const len = arr.length
var idx = -1
while (++idx < len) {
let item = arr[idx]
if (item[key1] === val1 && item[key2] === val2) {
return idx
}
}
return -1
}
function find_index_obj(obj, arr) {
return find_index_fn(item => o_match(obj, item), arr)
}
function first(arr) {
return arr[0]
}
function equal_bool(b1, b2) {
return b1 === b2
}
function equal_number(n1, n2) {
return n1 === n2
}
function dispatch_find_index_matcher(pred) {
switch (typeof pred) {
case 'function':
return pred
case 'boolean':
return partial(equal_bool, pred)
case 'number':
return partial(equal_number, pred)
default:
throw new Error('No matcher for ' + (typeof pred) + ' yet')
}
}
function find_index_last(pred, arr) {
return find_index_last_iter(dispatch_find_index_matcher(pred), arr)
}
function find_index_last_iter(iter_fn, arr) {
var i = arr.length
while (--i > -1) {
if (iter_fn(arr[i], i, arr)) {
return i
}
}
return -1
}
function flatten(arr) {
if (is_empty(arr)) {
return []
} else {
return apply(cat, arr)
}
}
function index_of(item, arr, from_index) {
return native_index_of.call(arr, item, from_index)
}
function last_index_of(item, arr, from_index) {
return native_last_index_of.call(arr, item, from_index)
}
function insert_at(items, idx, item) {
items.splice(idx, 0, item)
return items
}
function last(list) {
return list[dec(count1(list))]
}
function list() {
var args = arguments
return args.length > 0 ? __slice(args) : []
}
/**
* Returns a list from its arguments, without falsee values
* @signature ...args
*/
function list_compact() {
return compact(arguments)
}
function next(arr, item) {
return arr[index_of(item, arr) + 1]
}
function prev(arr, item) {
return arr[index_of(item, arr) - 1]
}
function type_of(mixed) {
return typeof mixed
}
function type_of2(val) {
return to_string.call(val)
}
/**
* @signature arr
* @signature criterion, arr
*/
function sort(criterion, arr) {
switch (arguments.length) {
case 1:
return criterion.sort()
case 2:
if (2 > arr.length) {
return slice(arr)
}
switch (type_of(criterion)) {
case 'string':
return sort_prop(criterion, arr)
case 'array':
throw new Error('f-empower.sort: array type criterias aren\'t supported yet')
case 'function':
return sort_fn(criterion, arr)
}
}
}
/**
* WARNING: immutable
*/
function sort_prop(prop, arr) {
var sort_suitable_arr = map(partial(_suit_sort, prop), arr),
need_string_comparison = is_string(arr[0][prop]),
compare_fn = need_string_comparison && _compare_string || _compare_numeric
return pluck('val', sort_suitable_arr.sort(compare_fn))
}
function _suit_sort(prop, obj) {
return {
val: obj,
criteria: obj[prop]
}
}
function _compare_numeric(obj1, obj2) {
return obj1.criteria - obj2.criteria
}
var native_locale_compare = String.prototype.localeCompare
function _compare_string(obj1, obj2) {
return native_locale_compare.call(obj1.criteria, obj2.criteria)
}
function sort_fn(compare_fn, arr) {
return arr.sort(compare_fn)
}
function map(mapper, arr) {
switch (arguments.length) {
case 0:
case 1:
throw new Error('`map` doesn\'t have a signature of that arity (0 or 1)')
case 2:
switch (typeof mapper) {
case 'function':
return map2(mapper, arr)
case 'string':
return pluck(mapper, arr)
case 'object':
return o_map(mapper, arr)
}
break
case 3:
return map3(mapper, arr, arguments[2])
default:
return mapn(mapper, rest(arguments))
}
}
function _async_mapper(err_fn, map_fn, accumulator, report_arr, item, idx) {
return map_fn(item, function(err, res) {
if (err) {
err_fn(err)
return
}
accumulator[idx] = res
report_arr[idx] = true
})
}
/**
* Does asynchronous map of an array
* @param {function} map_fn(object: item, onresult: function(err, res))
* @param {Array} items
* @param {function(err, res)} on_res
*/
function map_async(map_fn, items, on_res) {
const len = items.length,
help_arr = repeat(len, false),
res_arr = make_array(len)
const int_id = set_interval(2, function() {
if (every(help_arr)) {
clearInterval(int_id)
return on_res(null, res_arr)
}
})
function err_fn(err) {
clearInterval(int_id)
return on_res(err)
}
return each_idx2(partial(_async_mapper, err_fn, map_fn, res_arr, help_arr), items)
}
/**
* Special array creation helper.