/
build.js
17931 lines (16987 loc) · 596 KB
/
build.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
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
var R = require('ramda');
var chalk = require('chalk');
var utils = require('./lib/utils');
var str2color = require('./lib/str2color');
var getFnArgs = require('./lib/get-fn-args');
var getFnName = require('./lib/get-fn-name');
var inspect = utils.inspect;
var print = utils.print;
var mapTail = function(fn, arr) {
return R.slice(0, 1, arr).concat(R.map(fn, R.tail(arr)));
};
var strRepeat = R.compose(R.join(''), R.repeat);
var lines = R.split('\n');
var unlines = R.join('\n');
var indentTailLines = function(n, str) {
return unlines(mapTail(R.concat(strRepeat(' ', n)), lines(str)));
};
module.exports = function(name, fn) {
return function(/* args */) {
if (typeof name === 'function') {
fn = name;
name = getFnName(fn);
}
var prefix = name ? str2color(name) + ' ' : '';
print(prefix + formatArgs(name, fn, arguments));
var res = fn.apply(this, arguments);
print(prefix + '=> ' + indentTailLines(name.length + 4, inspect(res)));
return res;
};
};
function formatArgs(name, fn, args) {
var fnArgNames = getFnArgs(fn);
var getArgPairs = function(i, val) {
return [ fnArgNames[i] || i.toString(), val ];
};
var pairs = R.zipWith(getArgPairs, R.range(0, args.length), args);
var argLines = R.map(R.apply(formatArg), pairs);
var space = strRepeat(' ', name.length + 1);
return unlines(mapTail(R.concat(space), argLines));
function formatArg(argName, val) {
var indentLevel = name.length + argName.length + 3;
return R.join(': ', [
chalk.green(argName),
indentTailLines(indentLevel, inspect(val))
]);
}
}
},{"./lib/get-fn-args":2,"./lib/get-fn-name":3,"./lib/str2color":4,"./lib/utils":5,"chalk":6,"ramda":14}],2:[function(require,module,exports){
var R = require('ramda');
var parseStrs = R.compose( R.defaultTo([]), R.match(/([^\s,]+)/g) );
var getParensContent = function(str) {
return R.substring(
R.strIndexOf('(', str) + 1,
R.strIndexOf(')', str),
str
);
};
module.exports = R.pipe( R.invoke('toString', []), getParensContent, parseStrs );
},{"ramda":14}],3:[function(require,module,exports){
var CHAR = 'λ';
var anonN = 0;
module.exports = function(fn) {
return fn.name || (CHAR + (++anonN));
};
},{}],4:[function(require,module,exports){
var bold = require('chalk').bold;
// deterministically color a string without reusing colors until all colors
// are used once
module.exports = (function() {
var COLORS = ['red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white'];
var unusedColors = COLORS.slice();
var colorByStr = {};
return function(str) {
var color = colorByStr[str] || (function() {
if (unusedColors.length === 0) unusedColors = COLORS.slice();
var color = strToElem(unusedColors, str);
colorByStr[str] = color;
unusedColors.splice(unusedColors.indexOf(color), 1);
return color;
}());
return bold[color](str);
};
function strToElem(arr, str) {
return arr[charCodeSum(str) % arr.length];
}
function charCodeSum(str) {
return str.split('').reduce(function(sum, c) {
return sum + c.charCodeAt();
}, 0);
}
}());
},{"chalk":6}],5:[function(require,module,exports){
var R = require('ramda');
exports.inspect = require('util-inspect');
exports.print = R.bind(console.log, console);
},{"ramda":14,"util-inspect":15}],6:[function(require,module,exports){
(function (process){
'use strict';
var escapeStringRegexp = require('escape-string-regexp');
var ansiStyles = require('ansi-styles');
var stripAnsi = require('strip-ansi');
var hasAnsi = require('has-ansi');
var supportsColor = require('supports-color');
var defineProps = Object.defineProperties;
function Chalk(options) {
// detect mode if not set manually
this.enabled = !options || options.enabled === undefined ? supportsColor : options.enabled;
}
// use bright blue on Windows as the normal blue color is illegible
if (process.platform === 'win32') {
ansiStyles.blue.open = '\u001b[94m';
}
function build(_styles) {
var builder = function builder() {
return applyStyle.apply(builder, arguments);
};
builder._styles = _styles;
builder.enabled = this.enabled;
// __proto__ is used because we must return a function, but there is
// no way to create a function with a different prototype.
builder.__proto__ = proto;
return builder;
}
var styles = (function () {
var ret = {};
Object.keys(ansiStyles).forEach(function (key) {
ansiStyles[key].closeRe = new RegExp(escapeStringRegexp(ansiStyles[key].close), 'g');
ret[key] = {
get: function () {
return build.call(this, this._styles.concat(key));
}
};
});
return ret;
})();
var proto = defineProps(function chalk() {}, styles);
function applyStyle() {
// support varags, but simply cast to string in case there's only one arg
var args = arguments;
var argsLen = args.length;
var str = argsLen !== 0 && String(arguments[0]);
if (argsLen > 1) {
// don't slice `arguments`, it prevents v8 optimizations
for (var a = 1; a < argsLen; a++) {
str += ' ' + args[a];
}
}
if (!this.enabled || !str) {
return str;
}
/*jshint validthis: true */
var nestedStyles = this._styles;
var i = nestedStyles.length;
while (i--) {
var code = ansiStyles[nestedStyles[i]];
// Replace any instances already present with a re-opening code
// otherwise only the part of the string until said closing code
// will be colored, and the rest will simply be 'plain'.
str = code.open + str.replace(code.closeRe, code.open) + code.close;
}
return str;
}
function init() {
var ret = {};
Object.keys(styles).forEach(function (name) {
ret[name] = {
get: function () {
return build.call(this, [name]);
}
};
});
return ret;
}
defineProps(Chalk.prototype, init());
module.exports = new Chalk();
module.exports.styles = ansiStyles;
module.exports.hasColor = hasAnsi;
module.exports.stripColor = stripAnsi;
module.exports.supportsColor = supportsColor;
}).call(this,require('_process'))
},{"_process":61,"ansi-styles":7,"escape-string-regexp":8,"has-ansi":9,"strip-ansi":11,"supports-color":13}],7:[function(require,module,exports){
'use strict';
var styles = module.exports = {
modifiers: {
reset: [0, 0],
bold: [1, 22], // 21 isn't widely supported and 22 does the same thing
dim: [2, 22],
italic: [3, 23],
underline: [4, 24],
inverse: [7, 27],
hidden: [8, 28],
strikethrough: [9, 29]
},
colors: {
black: [30, 39],
red: [31, 39],
green: [32, 39],
yellow: [33, 39],
blue: [34, 39],
magenta: [35, 39],
cyan: [36, 39],
white: [37, 39],
gray: [90, 39]
},
bgColors: {
bgBlack: [40, 49],
bgRed: [41, 49],
bgGreen: [42, 49],
bgYellow: [43, 49],
bgBlue: [44, 49],
bgMagenta: [45, 49],
bgCyan: [46, 49],
bgWhite: [47, 49]
}
};
// fix humans
styles.colors.grey = styles.colors.gray;
Object.keys(styles).forEach(function (groupName) {
var group = styles[groupName];
Object.keys(group).forEach(function (styleName) {
var style = group[styleName];
styles[styleName] = group[styleName] = {
open: '\u001b[' + style[0] + 'm',
close: '\u001b[' + style[1] + 'm'
};
});
Object.defineProperty(styles, groupName, {
value: group,
enumerable: false
});
});
},{}],8:[function(require,module,exports){
'use strict';
var matchOperatorsRe = /[|\\{}()[\]^$+*?.]/g;
module.exports = function (str) {
if (typeof str !== 'string') {
throw new TypeError('Expected a string');
}
return str.replace(matchOperatorsRe, '\\$&');
};
},{}],9:[function(require,module,exports){
'use strict';
var ansiRegex = require('ansi-regex');
var re = new RegExp(ansiRegex().source); // remove the `g` flag
module.exports = re.test.bind(re);
},{"ansi-regex":10}],10:[function(require,module,exports){
'use strict';
module.exports = function () {
return /(?:(?:\u001b\[)|\u009b)(?:(?:[0-9]{1,3})?(?:(?:;[0-9]{0,3})*)?[A-M|f-m])|\u001b[A-M]/g;
};
},{}],11:[function(require,module,exports){
'use strict';
var ansiRegex = require('ansi-regex')();
module.exports = function (str) {
return typeof str === 'string' ? str.replace(ansiRegex, '') : str;
};
},{"ansi-regex":12}],12:[function(require,module,exports){
module.exports=require(10)
},{"/home/simon/projects/node_modules/treis/node_modules/chalk/node_modules/has-ansi/node_modules/ansi-regex/index.js":10}],13:[function(require,module,exports){
(function (process){
'use strict';
var argv = process.argv;
module.exports = (function () {
if ('FORCE_COLOR' in process.env) {
return true;
}
if (argv.indexOf('--no-color') !== -1 ||
argv.indexOf('--no-colors') !== -1 ||
argv.indexOf('--color=false') !== -1) {
return false;
}
if (argv.indexOf('--color') !== -1 ||
argv.indexOf('--colors') !== -1 ||
argv.indexOf('--color=true') !== -1 ||
argv.indexOf('--color=always') !== -1) {
return true;
}
if (process.stdout && !process.stdout.isTTY) {
return false;
}
if (process.platform === 'win32') {
return true;
}
if ('COLORTERM' in process.env) {
return true;
}
if (process.env.TERM === 'dumb') {
return false;
}
if (/^screen|^xterm|^vt100|color|ansi|cygwin|linux/i.test(process.env.TERM)) {
return true;
}
return false;
})();
}).call(this,require('_process'))
},{"_process":61}],14:[function(require,module,exports){
// Ramda v0.13.0
// https://github.com/ramda/ramda
// (c) 2013-2015 Scott Sauyet, Michael Hurley, and David Chambers
// Ramda may be freely distributed under the MIT license.
;(function() {
'use strict';
/**
* A special placeholder value used to specify "gaps" within curried functions,
* allowing partial application of any combination of arguments,
* regardless of their positions.
*
* If `g` is a curried ternary function and `_` is `R.__`, the following are equivalent:
*
* - `g(1, 2, 3)`
* - `g(_, 2, 3)(1)`
* - `g(_, _, 3)(1)(2)`
* - `g(_, _, 3)(1, 2)`
* - `g(_, 2, _)(1, 3)`
* - `g(_, 2)(1)(3)`
* - `g(_, 2)(1, 3)`
* - `g(_, 2)(_, 3)(1)`
*
* @constant
* @memberOf R
* @category Function
* @example
*
* var greet = R.replace('{name}', R.__, 'Hello, {name}!');
* greet('Alice'); //=> 'Hello, Alice!'
*/
var __ = { ramda: 'placeholder' };
var _add = function _add(a, b) {
return a + b;
};
var _all = function _all(fn, list) {
var idx = -1;
while (++idx < list.length) {
if (!fn(list[idx])) {
return false;
}
}
return true;
};
var _any = function _any(fn, list) {
var idx = -1;
while (++idx < list.length) {
if (fn(list[idx])) {
return true;
}
}
return false;
};
var _assoc = function _assoc(prop, val, obj) {
var result = {};
for (var p in obj) {
result[p] = obj[p];
}
result[prop] = val;
return result;
};
var _cloneRegExp = function _cloneRegExp(pattern) {
return new RegExp(pattern.source, (pattern.global ? 'g' : '') + (pattern.ignoreCase ? 'i' : '') + (pattern.multiline ? 'm' : '') + (pattern.sticky ? 'y' : '') + (pattern.unicode ? 'u' : ''));
};
var _complement = function _complement(f) {
return function () {
return !f.apply(this, arguments);
};
};
/**
* Basic, right-associative composition function. Accepts two functions and returns the
* composite function; this composite function represents the operation `var h = f(g(x))`,
* where `f` is the first argument, `g` is the second argument, and `x` is whatever
* argument(s) are passed to `h`.
*
* This function's main use is to build the more general `compose` function, which accepts
* any number of functions.
*
* @private
* @category Function
* @param {Function} f A function.
* @param {Function} g A function.
* @return {Function} A new function that is the equivalent of `f(g(x))`.
* @example
*
* var double = function(x) { return x * 2; };
* var square = function(x) { return x * x; };
* var squareThenDouble = _compose(double, square);
*
* squareThenDouble(5); //≅ double(square(5)) => 50
*/
var _compose = function _compose(f, g) {
return function () {
return f.call(this, g.apply(this, arguments));
};
};
/**
* Private `concat` function to merge two array-like objects.
*
* @private
* @param {Array|Arguments} [set1=[]] An array-like object.
* @param {Array|Arguments} [set2=[]] An array-like object.
* @return {Array} A new, merged array.
* @example
*
* _concat([4, 5, 6], [1, 2, 3]); //=> [4, 5, 6, 1, 2, 3]
*/
var _concat = function _concat(set1, set2) {
set1 = set1 || [];
set2 = set2 || [];
var idx;
var len1 = set1.length;
var len2 = set2.length;
var result = [];
idx = -1;
while (++idx < len1) {
result[result.length] = set1[idx];
}
idx = -1;
while (++idx < len2) {
result[result.length] = set2[idx];
}
return result;
};
var _containsWith = function _containsWith(pred, x, list) {
var idx = -1, len = list.length;
while (++idx < len) {
if (pred(x, list[idx])) {
return true;
}
}
return false;
};
var _createMapEntry = function _createMapEntry(key, val) {
var obj = {};
obj[key] = val;
return obj;
};
/**
* Create a function which takes a comparator function and a list
* and determines the winning value by a compatator. Used internally
* by `R.maxBy` and `R.minBy`
*
* @private
* @param {Function} compatator a function to compare two items
* @category Math
* @return {Function}
*/
var _createMaxMinBy = function _createMaxMinBy(comparator) {
return function (valueComputer, list) {
if (!(list && list.length > 0)) {
return;
}
var idx = 0;
var winner = list[idx];
var computedWinner = valueComputer(winner);
var computedCurrent;
while (++idx < list.length) {
computedCurrent = valueComputer(list[idx]);
if (comparator(computedCurrent, computedWinner)) {
computedWinner = computedCurrent;
winner = list[idx];
}
}
return winner;
};
};
/**
* Optimized internal two-arity curry function.
*
* @private
* @category Function
* @param {Function} fn The function to curry.
* @return {Function} The curried function.
*/
var _curry1 = function _curry1(fn) {
return function f1(a) {
if (arguments.length === 0) {
return f1;
} else if (a === __) {
return f1;
} else {
return fn(a);
}
};
};
/**
* Optimized internal two-arity curry function.
*
* @private
* @category Function
* @param {Function} fn The function to curry.
* @return {Function} The curried function.
*/
var _curry2 = function _curry2(fn) {
return function f2(a, b) {
var n = arguments.length;
if (n === 0) {
return f2;
} else if (n === 1 && a === __) {
return f2;
} else if (n === 1) {
return _curry1(function (b) {
return fn(a, b);
});
} else if (n === 2 && a === __ && b === __) {
return f2;
} else if (n === 2 && a === __) {
return _curry1(function (a) {
return fn(a, b);
});
} else if (n === 2 && b === __) {
return _curry1(function (b) {
return fn(a, b);
});
} else {
return fn(a, b);
}
};
};
/**
* Optimized internal three-arity curry function.
*
* @private
* @category Function
* @param {Function} fn The function to curry.
* @return {Function} The curried function.
*/
var _curry3 = function _curry3(fn) {
return function f3(a, b, c) {
var n = arguments.length;
if (n === 0) {
return f3;
} else if (n === 1 && a === __) {
return f3;
} else if (n === 1) {
return _curry2(function (b, c) {
return fn(a, b, c);
});
} else if (n === 2 && a === __ && b === __) {
return f3;
} else if (n === 2 && a === __) {
return _curry2(function (a, c) {
return fn(a, b, c);
});
} else if (n === 2 && b === __) {
return _curry2(function (b, c) {
return fn(a, b, c);
});
} else if (n === 2) {
return _curry1(function (c) {
return fn(a, b, c);
});
} else if (n === 3 && a === __ && b === __ && c === __) {
return f3;
} else if (n === 3 && a === __ && b === __) {
return _curry2(function (a, b) {
return fn(a, b, c);
});
} else if (n === 3 && a === __ && c === __) {
return _curry2(function (a, c) {
return fn(a, b, c);
});
} else if (n === 3 && b === __ && c === __) {
return _curry2(function (b, c) {
return fn(a, b, c);
});
} else if (n === 3 && a === __) {
return _curry1(function (a) {
return fn(a, b, c);
});
} else if (n === 3 && b === __) {
return _curry1(function (b) {
return fn(a, b, c);
});
} else if (n === 3 && c === __) {
return _curry1(function (c) {
return fn(a, b, c);
});
} else {
return fn(a, b, c);
}
};
};
var _dissoc = function _dissoc(prop, obj) {
var result = {};
for (var p in obj) {
if (p !== prop) {
result[p] = obj[p];
}
}
return result;
};
var _filter = function _filter(fn, list) {
var idx = -1, len = list.length, result = [];
while (++idx < len) {
if (fn(list[idx])) {
result[result.length] = list[idx];
}
}
return result;
};
var _filterIndexed = function _filterIndexed(fn, list) {
var idx = -1, len = list.length, result = [];
while (++idx < len) {
if (fn(list[idx], idx, list)) {
result[result.length] = list[idx];
}
}
return result;
};
// i can't bear not to return *something*
var _forEach = function _forEach(fn, list) {
var idx = -1, len = list.length;
while (++idx < len) {
fn(list[idx]);
}
// i can't bear not to return *something*
return list;
};
/**
* @private
* @param {Function} fn The strategy for extracting function names from an object
* @return {Function} A function that takes an object and returns an array of function names.
*/
var _functionsWith = function _functionsWith(fn) {
return function (obj) {
return _filter(function (key) {
return typeof obj[key] === 'function';
}, fn(obj));
};
};
var _gt = function _gt(a, b) {
return a > b;
};
var _has = function _has(prop, obj) {
return Object.prototype.hasOwnProperty.call(obj, prop);
};
var _identity = function _identity(x) {
return x;
};
/**
* Internal implementation of `indexOf`.
* Returns the position of the first occurrence of an item in an array
* (by strict equality),
* or -1 if the item is not included in the array.
*
* @private
* @param {Array} list The array to search
* @param {*} item the item to find in the Array
* @param {Number} from (optional) the index to start searching the Array
* @return {Number} The index of the found item, or -1.
*/
var _indexOf = function _indexOf(list, item, from) {
var idx = 0, len = list.length;
if (typeof from == 'number') {
idx = from < 0 ? Math.max(0, len + from) : from;
}
while (idx < len) {
if (list[idx] === item) {
return idx;
}
++idx;
}
return -1;
};
/**
* Tests whether or not an object is an array.
*
* @private
* @param {*} val The object to test.
* @return {Boolean} `true` if `val` is an array, `false` otherwise.
* @example
*
* _isArray([]); //=> true
* _isArray(null); //=> false
* _isArray({}); //=> false
*/
var _isArray = Array.isArray || function _isArray(val) {
return val != null && val.length >= 0 && Object.prototype.toString.call(val) === '[object Array]';
};
/**
* Determine if the passed argument is an integer.
*
* @private
* @param {*} n
* @category Type
* @return {Boolean}
*/
var _isInteger = Number.isInteger || function _isInteger(n) {
return n << 0 === n;
};
/**
* Tests if a value is a thenable (promise).
*/
var _isThenable = function _isThenable(value) {
return value != null && value === Object(value) && typeof value.then === 'function';
};
var _isTransformer = function _isTransformer(obj) {
return typeof obj.step === 'function' && typeof obj.result === 'function';
};
/**
* Internal implementation of `lastIndexOf`.
* Returns the position of the last occurrence of an item in an array
* (by strict equality),
* or -1 if the item is not included in the array.
*
* @private
* @param {Array} list The array to search
* @param {*} item the item to find in the Array
* @param {Number} from (optional) the index to start searching the Array
* @return {Number} The index of the found item, or -1.
*/
var _lastIndexOf = function _lastIndexOf(list, item, from) {
var idx = list.length;
if (typeof from == 'number') {
idx = from < 0 ? idx + from + 1 : Math.min(idx, from + 1);
}
while (--idx >= 0) {
if (list[idx] === item) {
return idx;
}
}
return -1;
};
var _lt = function _lt(a, b) {
return a < b;
};
var _map = function _map(fn, list) {
var idx = -1, len = list.length, result = [];
while (++idx < len) {
result[idx] = fn(list[idx]);
}
return result;
};
var _multiply = function _multiply(a, b) {
return a * b;
};
var _nth = function _nth(n, list) {
return n < 0 ? list[list.length + n] : list[n];
};
/**
* internal path function
* Takes an array, paths, indicating the deep set of keys
* to find.
*
* @private
* @memberOf R
* @category Object
* @param {Array} paths An array of strings to map to object properties
* @param {Object} obj The object to find the path in
* @return {Array} The value at the end of the path or `undefined`.
* @example
*
* _path(['a', 'b'], {a: {b: 2}}); //=> 2
*/
var _path = function _path(paths, obj) {
if (obj == null || paths.length === 0) {
return;
} else {
var val = obj;
for (var idx = 0, len = paths.length; idx < len && val != null; idx += 1) {
val = val[paths[idx]];
}
return val;
}
};
var _prepend = function _prepend(el, list) {
return _concat([el], list);
};
var _reduced = function (x) {
return x && x.__transducers_reduced__ ? x : {
value: x,
__transducers_reduced__: true
};
};
/**
* internal helper for `where`
*
* @private
* @see R.where
*/
var _satisfiesSpec = function _satisfiesSpec(spec, parsedSpec, testObj) {
if (spec === testObj) {
return true;
}
if (testObj == null) {
return false;
}
parsedSpec.fn = parsedSpec.fn || [];
parsedSpec.obj = parsedSpec.obj || [];
var key, val, idx = -1, fnLen = parsedSpec.fn.length, j = -1, objLen = parsedSpec.obj.length;
while (++idx < fnLen) {
key = parsedSpec.fn[idx];
val = spec[key];
if (!(key in testObj)) {
return false;
}
if (!val(testObj[key], testObj)) {
return false;
}
}
while (++j < objLen) {
key = parsedSpec.obj[j];
if (spec[key] !== testObj[key]) {
return false;
}
}
return true;
};
/**
* An optimized, private array `slice` implementation.
*
* @private
* @param {Arguments|Array} args The array or arguments object to consider.
* @param {Number} [from=0] The array index to slice from, inclusive.
* @param {Number} [to=args.length] The array index to slice to, exclusive.
* @return {Array} A new, sliced array.
* @example
*
* _slice([1, 2, 3, 4, 5], 1, 3); //=> [2, 3]
*
* var firstThreeArgs = function(a, b, c, d) {
* return _slice(arguments, 0, 3);
* };
* firstThreeArgs(1, 2, 3, 4); //=> [1, 2, 3]
*/
var _slice = function _slice(args, from, to) {
switch (arguments.length) {
case 1:
return _slice(args, 0, args.length);
case 2:
return _slice(args, from, args.length);
default:
var length = Math.max(0, to - from), list = [], idx = -1;
while (++idx < length) {
list[idx] = args[from + idx];
}
return list;
}
};
var _xall = function () {
function XAll(f, xf) {
this.xf = xf;
this.f = f;
this.all = true;
}
XAll.prototype.init = function () {
return this.xf.init();
};
XAll.prototype.result = function (result) {
if (this.all) {
result = this.xf.step(result, true);
}
return this.xf.result(result);
};
XAll.prototype.step = function (result, input) {
if (!this.f(input)) {
this.all = false;
result = _reduced(this.xf.step(result, false));
}
return result;
};
return _curry2(function _xall(f, xf) {
return new XAll(f, xf);
});
}();
var _xany = function () {
function XAny(f, xf) {
this.xf = xf;
this.f = f;
this.any = false;
}
XAny.prototype.init = function () {
return this.xf.init();
};
XAny.prototype.result = function (result) {
if (!this.any) {
result = this.xf.step(result, false);
}
return this.xf.result(result);
};
XAny.prototype.step = function (result, input) {
if (this.f(input)) {
this.any = true;
result = _reduced(this.xf.step(result, true));
}
return result;
};
return _curry2(function _xany(f, xf) {
return new XAny(f, xf);
});
}();
var _xdrop = function () {
function XDrop(n, xf) {
this.xf = xf;
this.n = n;