1 | (function(modules) {
|
2 |
|
3 | var installedModules = {};
|
4 |
|
5 |
|
6 | function __webpack_require__(moduleId) {
|
7 |
|
8 |
|
9 | if(installedModules[moduleId])
|
10 | return installedModules[moduleId].exports;
|
11 |
|
12 |
|
13 | var module = installedModules[moduleId] = {
|
14 | i: moduleId,
|
15 | l: false,
|
16 | exports: {}
|
17 | };
|
18 |
|
19 |
|
20 | modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
|
21 |
|
22 |
|
23 | module.l = true;
|
24 |
|
25 |
|
26 | return module.exports;
|
27 | }
|
28 |
|
29 |
|
30 |
|
31 | __webpack_require__.m = modules;
|
32 |
|
33 |
|
34 | __webpack_require__.c = installedModules;
|
35 |
|
36 |
|
37 | __webpack_require__.i = function(value) { return value; };
|
38 |
|
39 |
|
40 | __webpack_require__.d = function(exports, name, getter) {
|
41 | if(!__webpack_require__.o(exports, name)) {
|
42 | Object.defineProperty(exports, name, {
|
43 | configurable: false,
|
44 | enumerable: true,
|
45 | get: getter
|
46 | /******/ });
|
47 | /******/ }
|
48 | /******/ };
|
49 | /******/
|
50 | /******/ // getDefaultExport function for compatibility with non-harmony modules
|
51 | /******/ __webpack_require__.n = function(module) {
|
52 | var getter = module && module.__esModule ?
|
53 | function getDefault() { return module['default']; } :
|
54 | function getModuleExports() { return module; };
|
55 | __webpack_require__.d(getter, 'a', getter);
|
56 | return getter;
|
57 | };
|
58 |
|
59 |
|
60 | __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
|
61 |
|
62 |
|
63 | __webpack_require__.p = "";
|
64 |
|
65 |
|
66 | return __webpack_require__(__webpack_require__.s = 336);
|
67 | })
|
68 |
|
69 | ([
|
70 |
|
71 | (function(module, exports, __webpack_require__) {
|
72 |
|
73 | var _curry1 = __webpack_require__(1);
|
74 | var _isPlaceholder = __webpack_require__(35);
|
75 |
|
76 |
|
77 |
|
78 |
|
79 |
|
80 |
|
81 |
|
82 |
|
83 |
|
84 |
|
85 | module.exports = function _curry2(fn) {
|
86 | return function f2(a, b) {
|
87 | switch (arguments.length) {
|
88 | case 0:
|
89 | return f2;
|
90 | case 1:
|
91 | return _isPlaceholder(a) ? f2
|
92 | : _curry1(function(_b) { return fn(a, _b); });
|
93 | default:
|
94 | return _isPlaceholder(a) && _isPlaceholder(b) ? f2
|
95 | : _isPlaceholder(a) ? _curry1(function(_a) { return fn(_a, b); })
|
96 | : _isPlaceholder(b) ? _curry1(function(_b) { return fn(a, _b); })
|
97 | : fn(a, b);
|
98 | }
|
99 | };
|
100 | };
|
101 |
|
102 |
|
103 | }),
|
104 |
|
105 | (function(module, exports, __webpack_require__) {
|
106 |
|
107 | var _isPlaceholder = __webpack_require__(35);
|
108 |
|
109 |
|
110 |
|
111 |
|
112 |
|
113 |
|
114 |
|
115 |
|
116 |
|
117 |
|
118 | module.exports = function _curry1(fn) {
|
119 | return function f1(a) {
|
120 | if (arguments.length === 0 || _isPlaceholder(a)) {
|
121 | return f1;
|
122 | } else {
|
123 | return fn.apply(this, arguments);
|
124 | }
|
125 | };
|
126 | };
|
127 |
|
128 |
|
129 | }),
|
130 |
|
131 | (function(module, exports, __webpack_require__) {
|
132 |
|
133 | var _curry1 = __webpack_require__(1);
|
134 | var _curry2 = __webpack_require__(0);
|
135 | var _isPlaceholder = __webpack_require__(35);
|
136 |
|
137 |
|
138 |
|
139 |
|
140 |
|
141 |
|
142 |
|
143 |
|
144 |
|
145 |
|
146 | module.exports = function _curry3(fn) {
|
147 | return function f3(a, b, c) {
|
148 | switch (arguments.length) {
|
149 | case 0:
|
150 | return f3;
|
151 | case 1:
|
152 | return _isPlaceholder(a) ? f3
|
153 | : _curry2(function(_b, _c) { return fn(a, _b, _c); });
|
154 | case 2:
|
155 | return _isPlaceholder(a) && _isPlaceholder(b) ? f3
|
156 | : _isPlaceholder(a) ? _curry2(function(_a, _c) { return fn(_a, b, _c); })
|
157 | : _isPlaceholder(b) ? _curry2(function(_b, _c) { return fn(a, _b, _c); })
|
158 | : _curry1(function(_c) { return fn(a, b, _c); });
|
159 | default:
|
160 | return _isPlaceholder(a) && _isPlaceholder(b) && _isPlaceholder(c) ? f3
|
161 | : _isPlaceholder(a) && _isPlaceholder(b) ? _curry2(function(_a, _b) { return fn(_a, _b, c); })
|
162 | : _isPlaceholder(a) && _isPlaceholder(c) ? _curry2(function(_a, _c) { return fn(_a, b, _c); })
|
163 | : _isPlaceholder(b) && _isPlaceholder(c) ? _curry2(function(_b, _c) { return fn(a, _b, _c); })
|
164 | : _isPlaceholder(a) ? _curry1(function(_a) { return fn(_a, b, c); })
|
165 | : _isPlaceholder(b) ? _curry1(function(_b) { return fn(a, _b, c); })
|
166 | : _isPlaceholder(c) ? _curry1(function(_c) { return fn(a, b, _c); })
|
167 | : fn(a, b, c);
|
168 | }
|
169 | };
|
170 | };
|
171 |
|
172 |
|
173 | }),
|
174 |
|
175 | (function(module, exports, __webpack_require__) {
|
176 |
|
177 | var _isArray = __webpack_require__(15);
|
178 | var _isTransformer = __webpack_require__(53);
|
179 |
|
180 |
|
181 |
|
182 |
|
183 |
|
184 |
|
185 |
|
186 |
|
187 |
|
188 |
|
189 |
|
190 |
|
191 |
|
192 |
|
193 |
|
194 |
|
195 | module.exports = function _dispatchable(methodNames, xf, fn) {
|
196 | return function() {
|
197 | if (arguments.length === 0) {
|
198 | return fn();
|
199 | }
|
200 | var args = Array.prototype.slice.call(arguments, 0);
|
201 | var obj = args.pop();
|
202 | if (!_isArray(obj)) {
|
203 | var idx = 0;
|
204 | while (idx < methodNames.length) {
|
205 | if (typeof obj[methodNames[idx]] === 'function') {
|
206 | return obj[methodNames[idx]].apply(obj, args);
|
207 | }
|
208 | idx += 1;
|
209 | }
|
210 | if (_isTransformer(obj)) {
|
211 | var transducer = xf.apply(null, args);
|
212 | return transducer(obj);
|
213 | }
|
214 | }
|
215 | return fn.apply(this, arguments);
|
216 | };
|
217 | };
|
218 |
|
219 |
|
220 | }),
|
221 |
|
222 | (function(module, exports) {
|
223 |
|
224 | module.exports = {
|
225 | init: function() {
|
226 | return this.xf['@@transducer/init']();
|
227 | },
|
228 | result: function(result) {
|
229 | return this.xf['@@transducer/result'](result);
|
230 | }
|
231 | };
|
232 |
|
233 |
|
234 | }),
|
235 |
|
236 | (function(module, exports, __webpack_require__) {
|
237 |
|
238 | var _arity = __webpack_require__(11);
|
239 | var _curry1 = __webpack_require__(1);
|
240 | var _curry2 = __webpack_require__(0);
|
241 | var _curryN = __webpack_require__(33);
|
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 | module.exports = _curry2(function curryN(length, fn) {
|
287 | if (length === 1) {
|
288 | return _curry1(fn);
|
289 | }
|
290 | return _arity(length, _curryN(length, [], fn));
|
291 | });
|
292 |
|
293 |
|
294 | }),
|
295 |
|
296 | (function(module, exports) {
|
297 |
|
298 | module.exports = function _has(prop, obj) {
|
299 | return Object.prototype.hasOwnProperty.call(obj, prop);
|
300 | };
|
301 |
|
302 |
|
303 | }),
|
304 |
|
305 | (function(module, exports, __webpack_require__) {
|
306 |
|
307 | var _curry2 = __webpack_require__(0);
|
308 | var _dispatchable = __webpack_require__(3);
|
309 | var _map = __webpack_require__(37);
|
310 | var _reduce = __webpack_require__(8);
|
311 | var _xmap = __webpack_require__(227);
|
312 | var curryN = __webpack_require__(5);
|
313 | var keys = __webpack_require__(12);
|
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 | module.exports = _curry2(_dispatchable(['map'], _xmap, function map(fn, functor) {
|
352 | switch (Object.prototype.toString.call(functor)) {
|
353 | case '[object Function]':
|
354 | return curryN(functor.length, function() {
|
355 | return fn.call(this, functor.apply(this, arguments));
|
356 | });
|
357 | case '[object Object]':
|
358 | return _reduce(function(acc, key) {
|
359 | acc[key] = fn(functor[key]);
|
360 | return acc;
|
361 | }, {}, keys(functor));
|
362 | default:
|
363 | return _map(fn, functor);
|
364 | }
|
365 | }));
|
366 |
|
367 |
|
368 | }),
|
369 |
|
370 | (function(module, exports, __webpack_require__) {
|
371 |
|
372 | var _xwrap = __webpack_require__(90);
|
373 | var bind = __webpack_require__(65);
|
374 | var isArrayLike = __webpack_require__(23);
|
375 |
|
376 |
|
377 | module.exports = (function() {
|
378 | function _arrayReduce(xf, acc, list) {
|
379 | var idx = 0;
|
380 | var len = list.length;
|
381 | while (idx < len) {
|
382 | acc = xf['@@transducer/step'](acc, list[idx]);
|
383 | if (acc && acc['@@transducer/reduced']) {
|
384 | acc = acc['@@transducer/value'];
|
385 | break;
|
386 | }
|
387 | idx += 1;
|
388 | }
|
389 | return xf['@@transducer/result'](acc);
|
390 | }
|
391 |
|
392 | function _iterableReduce(xf, acc, iter) {
|
393 | var step = iter.next();
|
394 | while (!step.done) {
|
395 | acc = xf['@@transducer/step'](acc, step.value);
|
396 | if (acc && acc['@@transducer/reduced']) {
|
397 | acc = acc['@@transducer/value'];
|
398 | break;
|
399 | }
|
400 | step = iter.next();
|
401 | }
|
402 | return xf['@@transducer/result'](acc);
|
403 | }
|
404 |
|
405 | function _methodReduce(xf, acc, obj) {
|
406 | return xf['@@transducer/result'](obj.reduce(bind(xf['@@transducer/step'], xf), acc));
|
407 | }
|
408 |
|
409 | var symIterator = (typeof Symbol !== 'undefined') ? Symbol.iterator : '@@iterator';
|
410 | return function _reduce(fn, acc, list) {
|
411 | if (typeof fn === 'function') {
|
412 | fn = _xwrap(fn);
|
413 | }
|
414 | if (isArrayLike(list)) {
|
415 | return _arrayReduce(fn, acc, list);
|
416 | }
|
417 | if (typeof list.reduce === 'function') {
|
418 | return _methodReduce(fn, acc, list);
|
419 | }
|
420 | if (list[symIterator] != null) {
|
421 | return _iterableReduce(fn, acc, list[symIterator]());
|
422 | }
|
423 | if (typeof list.next === 'function') {
|
424 | return _iterableReduce(fn, acc, list);
|
425 | }
|
426 | throw new TypeError('reduce: list must be array or iterable');
|
427 | };
|
428 | }());
|
429 |
|
430 |
|
431 | }),
|
432 |
|
433 | (function(module, exports) {
|
434 |
|
435 |
|
436 |
|
437 |
|
438 |
|
439 |
|
440 |
|
441 |
|
442 |
|
443 |
|
444 |
|
445 |
|
446 | module.exports = function _concat(set1, set2) {
|
447 | set1 = set1 || [];
|
448 | set2 = set2 || [];
|
449 | var idx;
|
450 | var len1 = set1.length;
|
451 | var len2 = set2.length;
|
452 | var result = [];
|
453 |
|
454 | idx = 0;
|
455 | while (idx < len1) {
|
456 | result[result.length] = set1[idx];
|
457 | idx += 1;
|
458 | }
|
459 | idx = 0;
|
460 | while (idx < len2) {
|
461 | result[result.length] = set2[idx];
|
462 | idx += 1;
|
463 | }
|
464 | return result;
|
465 | };
|
466 |
|
467 |
|
468 | }),
|
469 |
|
470 | (function(module, exports, __webpack_require__) {
|
471 |
|
472 | var _curry2 = __webpack_require__(0);
|
473 | var _equals = __webpack_require__(202);
|
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 | module.exports = _curry2(function equals(a, b) {
|
502 | return _equals(a, b, [], []);
|
503 | });
|
504 |
|
505 |
|
506 | }),
|
507 |
|
508 | (function(module, exports) {
|
509 |
|
510 | module.exports = function _arity(n, fn) {
|
511 |
|
512 | switch (n) {
|
513 | case 0: return function() { return fn.apply(this, arguments); };
|
514 | case 1: return function(a0) { return fn.apply(this, arguments); };
|
515 | case 2: return function(a0, a1) { return fn.apply(this, arguments); };
|
516 | case 3: return function(a0, a1, a2) { return fn.apply(this, arguments); };
|
517 | case 4: return function(a0, a1, a2, a3) { return fn.apply(this, arguments); };
|
518 | case 5: return function(a0, a1, a2, a3, a4) { return fn.apply(this, arguments); };
|
519 | case 6: return function(a0, a1, a2, a3, a4, a5) { return fn.apply(this, arguments); };
|
520 | case 7: return function(a0, a1, a2, a3, a4, a5, a6) { return fn.apply(this, arguments); };
|
521 | case 8: return function(a0, a1, a2, a3, a4, a5, a6, a7) { return fn.apply(this, arguments); };
|
522 | case 9: return function(a0, a1, a2, a3, a4, a5, a6, a7, a8) { return fn.apply(this, arguments); };
|
523 | case 10: return function(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9) { return fn.apply(this, arguments); };
|
524 | default: throw new Error('First argument to _arity must be a non-negative integer no greater than ten');
|
525 | }
|
526 | };
|
527 |
|
528 |
|
529 | }),
|
530 |
|
531 | (function(module, exports, __webpack_require__) {
|
532 |
|
533 | var _curry1 = __webpack_require__(1);
|
534 | var _has = __webpack_require__(6);
|
535 | var _isArguments = __webpack_require__(83);
|
536 |
|
537 |
|
538 |
|
539 |
|
540 |
|
541 |
|
542 |
|
543 |
|
544 |
|
545 |
|
546 |
|
547 |
|
548 |
|
549 |
|
550 |
|
551 |
|
552 |
|
553 |
|
554 |
|
555 | module.exports = (function() {
|
556 |
|
557 | var hasEnumBug = !({toString: null}).propertyIsEnumerable('toString');
|
558 | var nonEnumerableProps = ['constructor', 'valueOf', 'isPrototypeOf', 'toString',
|
559 | 'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString'];
|
560 |
|
561 | var hasArgsEnumBug = (function() {
|
562 | 'use strict';
|
563 | return arguments.propertyIsEnumerable('length');
|
564 | }());
|
565 |
|
566 | var contains = function contains(list, item) {
|
567 | var idx = 0;
|
568 | while (idx < list.length) {
|
569 | if (list[idx] === item) {
|
570 | return true;
|
571 | }
|
572 | idx += 1;
|
573 | }
|
574 | return false;
|
575 | };
|
576 |
|
577 | return typeof Object.keys === 'function' && !hasArgsEnumBug ?
|
578 | _curry1(function keys(obj) {
|
579 | return Object(obj) !== obj ? [] : Object.keys(obj);
|
580 | }) :
|
581 | _curry1(function keys(obj) {
|
582 | if (Object(obj) !== obj) {
|
583 | return [];
|
584 | }
|
585 | var prop, nIdx;
|
586 | var ks = [];
|
587 | var checkArgsLength = hasArgsEnumBug && _isArguments(obj);
|
588 | for (prop in obj) {
|
589 | if (_has(prop, obj) && (!checkArgsLength || prop !== 'length')) {
|
590 | ks[ks.length] = prop;
|
591 | }
|
592 | }
|
593 | if (hasEnumBug) {
|
594 | nIdx = nonEnumerableProps.length - 1;
|
595 | while (nIdx >= 0) {
|
596 | prop = nonEnumerableProps[nIdx];
|
597 | if (_has(prop, obj) && !contains(ks, prop)) {
|
598 | ks[ks.length] = prop;
|
599 | }
|
600 | nIdx -= 1;
|
601 | }
|
602 | }
|
603 | return ks;
|
604 | });
|
605 | }());
|
606 |
|
607 |
|
608 | }),
|
609 |
|
610 | (function(module, exports, __webpack_require__) {
|
611 |
|
612 | var _curry3 = __webpack_require__(2);
|
613 | var _reduce = __webpack_require__(8);
|
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 | module.exports = _curry3(_reduce);
|
660 |
|
661 |
|
662 | }),
|
663 |
|
664 | (function(module, exports) {
|
665 |
|
666 |
|
667 |
|
668 |
|
669 |
|
670 |
|
671 |
|
672 |
|
673 |
|
674 |
|
675 | var CryptoJS = CryptoJS || (function (Math, undefined) {
|
676 | |
677 |
|
678 |
|
679 | var C = {};
|
680 |
|
681 | |
682 |
|
683 |
|
684 | var C_lib = C.lib = {};
|
685 |
|
686 | |
687 |
|
688 |
|
689 | var Base = C_lib.Base = (function () {
|
690 | function F() {}
|
691 |
|
692 | return {
|
693 | |
694 |
|
695 |
|
696 |
|
697 |
|
698 |
|
699 |
|
700 |
|
701 |
|
702 |
|
703 |
|
704 |
|
705 |
|
706 |
|
707 |
|
708 |
|
709 |
|
710 |
|
711 | extend: function (overrides) {
|
712 |
|
713 | F.prototype = this;
|
714 | var subtype = new F();
|
715 |
|
716 |
|
717 | if (overrides) {
|
718 | subtype.mixIn(overrides);
|
719 | }
|
720 |
|
721 |
|
722 | if (!subtype.hasOwnProperty('init')) {
|
723 | subtype.init = function () {
|
724 | subtype.$super.init.apply(this, arguments);
|
725 | };
|
726 | }
|
727 |
|
728 |
|
729 | subtype.init.prototype = subtype;
|
730 |
|
731 |
|
732 | subtype.$super = this;
|
733 |
|
734 | return subtype;
|
735 | },
|
736 |
|
737 | |
738 |
|
739 |
|
740 |
|
741 |
|
742 |
|
743 |
|
744 |
|
745 |
|
746 |
|
747 |
|
748 |
|
749 | create: function () {
|
750 | var instance = this.extend();
|
751 | instance.init.apply(instance, arguments);
|
752 |
|
753 | return instance;
|
754 | },
|
755 |
|
756 | |
757 |
|
758 |
|
759 |
|
760 |
|
761 |
|
762 |
|
763 |
|
764 |
|
765 |
|
766 |
|
767 |
|
768 | init: function () {
|
769 | },
|
770 |
|
771 | |
772 |
|
773 |
|
774 |
|
775 |
|
776 |
|
777 |
|
778 |
|
779 |
|
780 |
|
781 |
|
782 | mixIn: function (properties) {
|
783 | for (var propertyName in properties) {
|
784 | if (properties.hasOwnProperty(propertyName)) {
|
785 | this[propertyName] = properties[propertyName];
|
786 | }
|
787 | }
|
788 |
|
789 |
|
790 | if (properties.hasOwnProperty('toString')) {
|
791 | this.toString = properties.toString;
|
792 | }
|
793 | },
|
794 |
|
795 | |
796 |
|
797 |
|
798 |
|
799 |
|
800 |
|
801 |
|
802 |
|
803 |
|
804 | clone: function () {
|
805 | return this.init.prototype.extend(this);
|
806 | }
|
807 | };
|
808 | }());
|
809 |
|
810 | |
811 |
|
812 |
|
813 |
|
814 |
|
815 |
|
816 | var WordArray = C_lib.WordArray = Base.extend({
|
817 | |
818 |
|
819 |
|
820 |
|
821 |
|
822 |
|
823 |
|
824 |
|
825 |
|
826 |
|
827 |
|
828 |
|
829 | init: function (words, sigBytes) {
|
830 | words = this.words = words || [];
|
831 |
|
832 | if (sigBytes != undefined) {
|
833 | this.sigBytes = sigBytes;
|
834 | } else {
|
835 | this.sigBytes = words.length * 4;
|
836 | }
|
837 | },
|
838 |
|
839 | |
840 |
|
841 |
|
842 |
|
843 |
|
844 |
|
845 |
|
846 |
|
847 |
|
848 |
|
849 |
|
850 |
|
851 |
|
852 | toString: function (encoder) {
|
853 | return (encoder || Hex).stringify(this);
|
854 | },
|
855 |
|
856 | |
857 |
|
858 |
|
859 |
|
860 |
|
861 |
|
862 |
|
863 |
|
864 |
|
865 |
|
866 |
|
867 | concat: function (wordArray) {
|
868 |
|
869 | var thisWords = this.words;
|
870 | var thatWords = wordArray.words;
|
871 | var thisSigBytes = this.sigBytes;
|
872 | var thatSigBytes = wordArray.sigBytes;
|
873 |
|
874 |
|
875 | this.clamp();
|
876 |
|
877 |
|
878 | if (thisSigBytes % 4) {
|
879 |
|
880 | for (var i = 0; i < thatSigBytes; i++) {
|
881 | var thatByte = (thatWords[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
|
882 | thisWords[(thisSigBytes + i) >>> 2] |= thatByte << (24 - ((thisSigBytes + i) % 4) * 8);
|
883 | }
|
884 | } else if (thatWords.length > 0xffff) {
|
885 |
|
886 | for (var i = 0; i < thatSigBytes; i += 4) {
|
887 | thisWords[(thisSigBytes + i) >>> 2] = thatWords[i >>> 2];
|
888 | }
|
889 | } else {
|
890 |
|
891 | thisWords.push.apply(thisWords, thatWords);
|
892 | }
|
893 | this.sigBytes += thatSigBytes;
|
894 |
|
895 |
|
896 | return this;
|
897 | },
|
898 |
|
899 | |
900 |
|
901 |
|
902 |
|
903 |
|
904 |
|
905 |
|
906 | clamp: function () {
|
907 |
|
908 | var words = this.words;
|
909 | var sigBytes = this.sigBytes;
|
910 |
|
911 |
|
912 | words[sigBytes >>> 2] &= 0xffffffff << (32 - (sigBytes % 4) * 8);
|
913 | words.length = Math.ceil(sigBytes / 4);
|
914 | },
|
915 |
|
916 | |
917 |
|
918 |
|
919 |
|
920 |
|
921 |
|
922 |
|
923 |
|
924 |
|
925 | clone: function () {
|
926 | var clone = Base.clone.call(this);
|
927 | clone.words = this.words.slice(0);
|
928 |
|
929 | return clone;
|
930 | },
|
931 |
|
932 | |
933 |
|
934 |
|
935 |
|
936 |
|
937 |
|
938 |
|
939 |
|
940 |
|
941 |
|
942 |
|
943 |
|
944 |
|
945 | random: function (nBytes) {
|
946 | var words = [];
|
947 | for (var i = 0; i < nBytes; i += 4) {
|
948 | words.push((Math.random() * 0x100000000) | 0);
|
949 | }
|
950 |
|
951 | return new WordArray.init(words, nBytes);
|
952 | }
|
953 | });
|
954 |
|
955 | |
956 |
|
957 |
|
958 | var C_enc = C.enc = {};
|
959 |
|
960 | |
961 |
|
962 |
|
963 | var Hex = C_enc.Hex = {
|
964 | |
965 |
|
966 |
|
967 |
|
968 |
|
969 |
|
970 |
|
971 |
|
972 |
|
973 |
|
974 |
|
975 |
|
976 |
|
977 | stringify: function (wordArray) {
|
978 |
|
979 | var words = wordArray.words;
|
980 | var sigBytes = wordArray.sigBytes;
|
981 |
|
982 |
|
983 | var hexChars = [];
|
984 | for (var i = 0; i < sigBytes; i++) {
|
985 | var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
|
986 | hexChars.push((bite >>> 4).toString(16));
|
987 | hexChars.push((bite & 0x0f).toString(16));
|
988 | }
|
989 |
|
990 | return hexChars.join('');
|
991 | },
|
992 |
|
993 | |
994 |
|
995 |
|
996 |
|
997 |
|
998 |
|
999 |
|
1000 |
|
1001 |
|
1002 |
|
1003 |
|
1004 |
|
1005 |
|
1006 | parse: function (hexStr) {
|
1007 |
|
1008 | var hexStrLength = hexStr.length;
|
1009 |
|
1010 |
|
1011 | var words = [];
|
1012 | for (var i = 0; i < hexStrLength; i += 2) {
|
1013 | words[i >>> 3] |= parseInt(hexStr.substr(i, 2), 16) << (24 - (i % 8) * 4);
|
1014 | }
|
1015 |
|
1016 | return new WordArray.init(words, hexStrLength / 2);
|
1017 | }
|
1018 | };
|
1019 |
|
1020 | |
1021 |
|
1022 |
|
1023 | var Latin1 = C_enc.Latin1 = {
|
1024 | |
1025 |
|
1026 |
|
1027 |
|
1028 |
|
1029 |
|
1030 |
|
1031 |
|
1032 |
|
1033 |
|
1034 |
|
1035 |
|
1036 |
|
1037 | stringify: function (wordArray) {
|
1038 |
|
1039 | var words = wordArray.words;
|
1040 | var sigBytes = wordArray.sigBytes;
|
1041 |
|
1042 |
|
1043 | var latin1Chars = [];
|
1044 | for (var i = 0; i < sigBytes; i++) {
|
1045 | var bite = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
|
1046 | latin1Chars.push(String.fromCharCode(bite));
|
1047 | }
|
1048 |
|
1049 | return latin1Chars.join('');
|
1050 | },
|
1051 |
|
1052 | |
1053 |
|
1054 |
|
1055 |
|
1056 |
|
1057 |
|
1058 |
|
1059 |
|
1060 |
|
1061 |
|
1062 |
|
1063 |
|
1064 |
|
1065 | parse: function (latin1Str) {
|
1066 |
|
1067 | var latin1StrLength = latin1Str.length;
|
1068 |
|
1069 |
|
1070 | var words = [];
|
1071 | for (var i = 0; i < latin1StrLength; i++) {
|
1072 | words[i >>> 2] |= (latin1Str.charCodeAt(i) & 0xff) << (24 - (i % 4) * 8);
|
1073 | }
|
1074 |
|
1075 | return new WordArray.init(words, latin1StrLength);
|
1076 | }
|
1077 | };
|
1078 |
|
1079 | |
1080 |
|
1081 |
|
1082 | var Utf8 = C_enc.Utf8 = {
|
1083 | |
1084 |
|
1085 |
|
1086 |
|
1087 |
|
1088 |
|
1089 |
|
1090 |
|
1091 |
|
1092 |
|
1093 |
|
1094 |
|
1095 |
|
1096 | stringify: function (wordArray) {
|
1097 | try {
|
1098 | return decodeURIComponent(escape(Latin1.stringify(wordArray)));
|
1099 | } catch (e) {
|
1100 | throw new Error('Malformed UTF-8 data');
|
1101 | }
|
1102 | },
|
1103 |
|
1104 | |
1105 |
|
1106 |
|
1107 |
|
1108 |
|
1109 |
|
1110 |
|
1111 |
|
1112 |
|
1113 |
|
1114 |
|
1115 |
|
1116 |
|
1117 | parse: function (utf8Str) {
|
1118 | return Latin1.parse(unescape(encodeURIComponent(utf8Str)));
|
1119 | }
|
1120 | };
|
1121 |
|
1122 | |
1123 |
|
1124 |
|
1125 |
|
1126 |
|
1127 |
|
1128 |
|
1129 | var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm = Base.extend({
|
1130 | |
1131 |
|
1132 |
|
1133 |
|
1134 |
|
1135 |
|
1136 |
|
1137 | reset: function () {
|
1138 |
|
1139 | this._data = new WordArray.init();
|
1140 | this._nDataBytes = 0;
|
1141 | },
|
1142 |
|
1143 | |
1144 |
|
1145 |
|
1146 |
|
1147 |
|
1148 |
|
1149 |
|
1150 |
|
1151 |
|
1152 |
|
1153 | _append: function (data) {
|
1154 |
|
1155 | if (typeof data == 'string') {
|
1156 | data = Utf8.parse(data);
|
1157 | }
|
1158 |
|
1159 |
|
1160 | this._data.concat(data);
|
1161 | this._nDataBytes += data.sigBytes;
|
1162 | },
|
1163 |
|
1164 | |
1165 |
|
1166 |
|
1167 |
|
1168 |
|
1169 |
|
1170 |
|
1171 |
|
1172 |
|
1173 |
|
1174 |
|
1175 |
|
1176 |
|
1177 |
|
1178 | _process: function (doFlush) {
|
1179 |
|
1180 | var data = this._data;
|
1181 | var dataWords = data.words;
|
1182 | var dataSigBytes = data.sigBytes;
|
1183 | var blockSize = this.blockSize;
|
1184 | var blockSizeBytes = blockSize * 4;
|
1185 |
|
1186 |
|
1187 | var nBlocksReady = dataSigBytes / blockSizeBytes;
|
1188 | if (doFlush) {
|
1189 |
|
1190 | nBlocksReady = Math.ceil(nBlocksReady);
|
1191 | } else {
|
1192 |
|
1193 |
|
1194 | nBlocksReady = Math.max((nBlocksReady | 0) - this._minBufferSize, 0);
|
1195 | }
|
1196 |
|
1197 |
|
1198 | var nWordsReady = nBlocksReady * blockSize;
|
1199 |
|
1200 |
|
1201 | var nBytesReady = Math.min(nWordsReady * 4, dataSigBytes);
|
1202 |
|
1203 |
|
1204 | if (nWordsReady) {
|
1205 | for (var offset = 0; offset < nWordsReady; offset += blockSize) {
|
1206 |
|
1207 | this._doProcessBlock(dataWords, offset);
|
1208 | }
|
1209 |
|
1210 |
|
1211 | var processedWords = dataWords.splice(0, nWordsReady);
|
1212 | data.sigBytes -= nBytesReady;
|
1213 | }
|
1214 |
|
1215 |
|
1216 | return new WordArray.init(processedWords, nBytesReady);
|
1217 | },
|
1218 |
|
1219 | |
1220 |
|
1221 |
|
1222 |
|
1223 |
|
1224 |
|
1225 |
|
1226 |
|
1227 |
|
1228 | clone: function () {
|
1229 | var clone = Base.clone.call(this);
|
1230 | clone._data = this._data.clone();
|
1231 |
|
1232 | return clone;
|
1233 | },
|
1234 |
|
1235 | _minBufferSize: 0
|
1236 | });
|
1237 |
|
1238 | |
1239 |
|
1240 |
|
1241 |
|
1242 |
|
1243 | var Hasher = C_lib.Hasher = BufferedBlockAlgorithm.extend({
|
1244 | |
1245 |
|
1246 |
|
1247 | cfg: Base.extend(),
|
1248 |
|
1249 | |
1250 |
|
1251 |
|
1252 |
|
1253 |
|
1254 |
|
1255 |
|
1256 |
|
1257 |
|
1258 | init: function (cfg) {
|
1259 |
|
1260 | this.cfg = this.cfg.extend(cfg);
|
1261 |
|
1262 |
|
1263 | this.reset();
|
1264 | },
|
1265 |
|
1266 | |
1267 |
|
1268 |
|
1269 |
|
1270 |
|
1271 |
|
1272 |
|
1273 | reset: function () {
|
1274 |
|
1275 | BufferedBlockAlgorithm.reset.call(this);
|
1276 |
|
1277 |
|
1278 | this._doReset();
|
1279 | },
|
1280 |
|
1281 | |
1282 |
|
1283 |
|
1284 |
|
1285 |
|
1286 |
|
1287 |
|
1288 |
|
1289 |
|
1290 |
|
1291 |
|
1292 |
|
1293 | update: function (messageUpdate) {
|
1294 |
|
1295 | this._append(messageUpdate);
|
1296 |
|
1297 |
|
1298 | this._process();
|
1299 |
|
1300 |
|
1301 | return this;
|
1302 | },
|
1303 |
|
1304 | |
1305 |
|
1306 |
|
1307 |
|
1308 |
|
1309 |
|
1310 |
|
1311 |
|
1312 |
|
1313 |
|
1314 |
|
1315 |
|
1316 |
|
1317 |
|
1318 | finalize: function (messageUpdate) {
|
1319 |
|
1320 | if (messageUpdate) {
|
1321 | this._append(messageUpdate);
|
1322 | }
|
1323 |
|
1324 |
|
1325 | var hash = this._doFinalize();
|
1326 |
|
1327 | return hash;
|
1328 | },
|
1329 |
|
1330 | blockSize: 512/32,
|
1331 |
|
1332 | |
1333 |
|
1334 |
|
1335 |
|
1336 |
|
1337 |
|
1338 |
|
1339 |
|
1340 |
|
1341 |
|
1342 |
|
1343 |
|
1344 |
|
1345 | _createHelper: function (hasher) {
|
1346 | return function (message, cfg) {
|
1347 | return new hasher.init(cfg).finalize(message);
|
1348 | };
|
1349 | },
|
1350 |
|
1351 | |
1352 |
|
1353 |
|
1354 |
|
1355 |
|
1356 |
|
1357 |
|
1358 |
|
1359 |
|
1360 |
|
1361 |
|
1362 |
|
1363 |
|
1364 | _createHmacHelper: function (hasher) {
|
1365 | return function (message, key) {
|
1366 | return new C_algo.HMAC.init(hasher, key).finalize(message);
|
1367 | };
|
1368 | }
|
1369 | });
|
1370 |
|
1371 | |
1372 |
|
1373 |
|
1374 | var C_algo = C.algo = {};
|
1375 |
|
1376 | return C;
|
1377 | }(Math));
|
1378 |
|
1379 | exports.CryptoJS = CryptoJS;
|
1380 |
|
1381 |
|
1382 | }),
|
1383 |
|
1384 | (function(module, exports) {
|
1385 |
|
1386 |
|
1387 |
|
1388 |
|
1389 |
|
1390 |
|
1391 |
|
1392 |
|
1393 |
|
1394 |
|
1395 |
|
1396 |
|
1397 |
|
1398 | module.exports = Array.isArray || function _isArray(val) {
|
1399 | return (val != null &&
|
1400 | val.length >= 0 &&
|
1401 | Object.prototype.toString.call(val) === '[object Array]');
|
1402 | };
|
1403 |
|
1404 |
|
1405 | }),
|
1406 |
|
1407 | (function(module, exports) {
|
1408 |
|
1409 | module.exports = function _reduced(x) {
|
1410 | return x && x['@@transducer/reduced'] ? x :
|
1411 | {
|
1412 | '@@transducer/value': x,
|
1413 | '@@transducer/reduced': true
|
1414 | };
|
1415 | };
|
1416 |
|
1417 |
|
1418 | }),
|
1419 |
|
1420 | (function(module, exports, __webpack_require__) {
|
1421 |
|
1422 | var _indexOf = __webpack_require__(82);
|
1423 |
|
1424 |
|
1425 | module.exports = function _contains(a, list) {
|
1426 | return _indexOf(list, a, 0) >= 0;
|
1427 | };
|
1428 |
|
1429 |
|
1430 | }),
|
1431 |
|
1432 | (function(module, exports, __webpack_require__) {
|
1433 |
|
1434 | var _checkForMethod = __webpack_require__(21);
|
1435 | var _curry3 = __webpack_require__(2);
|
1436 |
|
1437 |
|
1438 |
|
1439 |
|
1440 |
|
1441 |
|
1442 |
|
1443 |
|
1444 |
|
1445 |
|
1446 |
|
1447 |
|
1448 |
|
1449 |
|
1450 |
|
1451 |
|
1452 |
|
1453 |
|
1454 |
|
1455 |
|
1456 |
|
1457 |
|
1458 |
|
1459 |
|
1460 |
|
1461 |
|
1462 | module.exports = _curry3(_checkForMethod('slice', function slice(fromIndex, toIndex, list) {
|
1463 | return Array.prototype.slice.call(list, fromIndex, toIndex);
|
1464 | }));
|
1465 |
|
1466 |
|
1467 | }),
|
1468 |
|
1469 | (function(module, exports, __webpack_require__) {
|
1470 |
|
1471 | var _curry1 = __webpack_require__(1);
|
1472 |
|
1473 |
|
1474 |
|
1475 |
|
1476 |
|
1477 |
|
1478 |
|
1479 |
|
1480 |
|
1481 |
|
1482 |
|
1483 |
|
1484 |
|
1485 |
|
1486 |
|
1487 |
|
1488 |
|
1489 |
|
1490 |
|
1491 |
|
1492 |
|
1493 | module.exports = _curry1(function always(val) {
|
1494 | return function() {
|
1495 | return val;
|
1496 | };
|
1497 | });
|
1498 |
|
1499 |
|
1500 | }),
|
1501 |
|
1502 | (function(module, exports, __webpack_require__) {
|
1503 |
|
1504 | var _curry2 = __webpack_require__(0);
|
1505 |
|
1506 |
|
1507 |
|
1508 |
|
1509 |
|
1510 |
|
1511 |
|
1512 |
|
1513 |
|
1514 |
|
1515 |
|
1516 |
|
1517 |
|
1518 |
|
1519 |
|
1520 |
|
1521 |
|
1522 |
|
1523 |
|
1524 | module.exports = _curry2(function max(a, b) { return b > a ? b : a; });
|
1525 |
|
1526 |
|
1527 | }),
|
1528 |
|
1529 | (function(module, exports, __webpack_require__) {
|
1530 |
|
1531 | var _isArray = __webpack_require__(15);
|
1532 |
|
1533 |
|
1534 |
|
1535 |
|
1536 |
|
1537 |
|
1538 |
|
1539 |
|
1540 |
|
1541 |
|
1542 |
|
1543 |
|
1544 | module.exports = function _checkForMethod(methodname, fn) {
|
1545 | return function() {
|
1546 | var length = arguments.length;
|
1547 | if (length === 0) {
|
1548 | return fn();
|
1549 | }
|
1550 | var obj = arguments[length - 1];
|
1551 | return (_isArray(obj) || typeof obj[methodname] !== 'function') ?
|
1552 | fn.apply(this, arguments) :
|
1553 | obj[methodname].apply(obj, Array.prototype.slice.call(arguments, 0, length - 1));
|
1554 | };
|
1555 | };
|
1556 |
|
1557 |
|
1558 | }),
|
1559 |
|
1560 | (function(module, exports, __webpack_require__) {
|
1561 |
|
1562 | var _curry2 = __webpack_require__(0);
|
1563 | var _isFunction = __webpack_require__(34);
|
1564 | var curryN = __webpack_require__(5);
|
1565 | var toString = __webpack_require__(27);
|
1566 |
|
1567 |
|
1568 |
|
1569 |
|
1570 |
|
1571 |
|
1572 |
|
1573 |
|
1574 |
|
1575 |
|
1576 |
|
1577 |
|
1578 |
|
1579 |
|
1580 |
|
1581 |
|
1582 |
|
1583 |
|
1584 |
|
1585 |
|
1586 |
|
1587 |
|
1588 |
|
1589 |
|
1590 |
|
1591 |
|
1592 |
|
1593 |
|
1594 | module.exports = _curry2(function invoker(arity, method) {
|
1595 | return curryN(arity + 1, function() {
|
1596 | var target = arguments[arity];
|
1597 | if (target != null && _isFunction(target[method])) {
|
1598 | return target[method].apply(target, Array.prototype.slice.call(arguments, 0, arity));
|
1599 | }
|
1600 | throw new TypeError(toString(target) + ' does not have a method named "' + method + '"');
|
1601 | });
|
1602 | });
|
1603 |
|
1604 |
|
1605 | }),
|
1606 |
|
1607 | (function(module, exports, __webpack_require__) {
|
1608 |
|
1609 | var _curry1 = __webpack_require__(1);
|
1610 | var _isArray = __webpack_require__(15);
|
1611 | var _isString = __webpack_require__(36);
|
1612 |
|
1613 |
|
1614 |
|
1615 |
|
1616 |
|
1617 |
|
1618 |
|
1619 |
|
1620 |
|
1621 |
|
1622 |
|
1623 |
|
1624 |
|
1625 |
|
1626 |
|
1627 |
|
1628 |
|
1629 |
|
1630 |
|
1631 |
|
1632 |
|
1633 |
|
1634 | module.exports = _curry1(function isArrayLike(x) {
|
1635 | if (_isArray(x)) { return true; }
|
1636 | if (!x) { return false; }
|
1637 | if (typeof x !== 'object') { return false; }
|
1638 | if (_isString(x)) { return false; }
|
1639 | if (x.nodeType === 1) { return !!x.length; }
|
1640 | if (x.length === 0) { return true; }
|
1641 | if (x.length > 0) {
|
1642 | return x.hasOwnProperty(0) && x.hasOwnProperty(x.length - 1);
|
1643 | }
|
1644 | return false;
|
1645 | });
|
1646 |
|
1647 |
|
1648 | }),
|
1649 |
|
1650 | (function(module, exports, __webpack_require__) {
|
1651 |
|
1652 | var _curry2 = __webpack_require__(0);
|
1653 | var _isString = __webpack_require__(36);
|
1654 |
|
1655 |
|
1656 |
|
1657 |
|
1658 |
|
1659 |
|
1660 |
|
1661 |
|
1662 |
|
1663 |
|
1664 |
|
1665 |
|
1666 |
|
1667 |
|
1668 |
|
1669 |
|
1670 |
|
1671 |
|
1672 |
|
1673 |
|
1674 |
|
1675 |
|
1676 |
|
1677 |
|
1678 |
|
1679 |
|
1680 |
|
1681 |
|
1682 | module.exports = _curry2(function nth(offset, list) {
|
1683 | var idx = offset < 0 ? list.length + offset : offset;
|
1684 | return _isString(list) ? list.charAt(idx) : list[idx];
|
1685 | });
|
1686 |
|
1687 |
|
1688 | }),
|
1689 |
|
1690 | (function(module, exports, __webpack_require__) {
|
1691 |
|
1692 | var _curry2 = __webpack_require__(0);
|
1693 |
|
1694 |
|
1695 |
|
1696 |
|
1697 |
|
1698 |
|
1699 |
|
1700 |
|
1701 |
|
1702 |
|
1703 |
|
1704 |
|
1705 |
|
1706 |
|
1707 |
|
1708 |
|
1709 |
|
1710 |
|
1711 |
|
1712 |
|
1713 | module.exports = _curry2(function path(paths, obj) {
|
1714 | var val = obj;
|
1715 | var idx = 0;
|
1716 | while (idx < paths.length) {
|
1717 | if (val == null) {
|
1718 | return;
|
1719 | }
|
1720 | val = val[paths[idx]];
|
1721 | idx += 1;
|
1722 | }
|
1723 | return val;
|
1724 | });
|
1725 |
|
1726 |
|
1727 | }),
|
1728 |
|
1729 | (function(module, exports, __webpack_require__) {
|
1730 |
|
1731 | var _curry2 = __webpack_require__(0);
|
1732 | var map = __webpack_require__(7);
|
1733 | var prop = __webpack_require__(54);
|
1734 |
|
1735 |
|
1736 |
|
1737 |
|
1738 |
|
1739 |
|
1740 |
|
1741 |
|
1742 |
|
1743 |
|
1744 |
|
1745 |
|
1746 |
|
1747 |
|
1748 |
|
1749 |
|
1750 |
|
1751 |
|
1752 |
|
1753 |
|
1754 |
|
1755 |
|
1756 | module.exports = _curry2(function pluck(p, list) {
|
1757 | return map(prop(p), list);
|
1758 | });
|
1759 |
|
1760 |
|
1761 | }),
|
1762 |
|
1763 | (function(module, exports, __webpack_require__) {
|
1764 |
|
1765 | var _curry1 = __webpack_require__(1);
|
1766 | var _toString = __webpack_require__(214);
|
1767 |
|
1768 |
|
1769 |
|
1770 |
|
1771 |
|
1772 |
|
1773 |
|
1774 |
|
1775 |
|
1776 |
|
1777 |
|
1778 |
|
1779 |
|
1780 |
|
1781 |
|
1782 |
|
1783 |
|
1784 |
|
1785 |
|
1786 |
|
1787 |
|
1788 |
|
1789 |
|
1790 |
|
1791 |
|
1792 |
|
1793 |
|
1794 |
|
1795 |
|
1796 |
|
1797 |
|
1798 |
|
1799 |
|
1800 |
|
1801 |
|
1802 |
|
1803 |
|
1804 |
|
1805 | module.exports = _curry1(function toString(val) { return _toString(val, []); });
|
1806 |
|
1807 |
|
1808 | }),
|
1809 |
|
1810 | (function(module, exports, __webpack_require__) {
|
1811 |
|
1812 | "use strict";
|
1813 |
|
1814 |
|
1815 |
|
1816 | var TYPED_OK = (typeof Uint8Array !== 'undefined') &&
|
1817 | (typeof Uint16Array !== 'undefined') &&
|
1818 | (typeof Int32Array !== 'undefined');
|
1819 |
|
1820 |
|
1821 | exports.assign = function (obj /*from1, from2, from3, ...*/) {
|
1822 | var sources = Array.prototype.slice.call(arguments, 1);
|
1823 | while (sources.length) {
|
1824 | var source = sources.shift();
|
1825 | if (!source) { continue; }
|
1826 |
|
1827 | if (typeof source !== 'object') {
|
1828 | throw new TypeError(source + 'must be non-object');
|
1829 | }
|
1830 |
|
1831 | for (var p in source) {
|
1832 | if (source.hasOwnProperty(p)) {
|
1833 | obj[p] = source[p];
|
1834 | }
|
1835 | }
|
1836 | }
|
1837 |
|
1838 | return obj;
|
1839 | };
|
1840 |
|
1841 |
|
1842 |
|
1843 | exports.shrinkBuf = function (buf, size) {
|
1844 | if (buf.length === size) { return buf; }
|
1845 | if (buf.subarray) { return buf.subarray(0, size); }
|
1846 | buf.length = size;
|
1847 | return buf;
|
1848 | };
|
1849 |
|
1850 |
|
1851 | var fnTyped = {
|
1852 | arraySet: function (dest, src, src_offs, len, dest_offs) {
|
1853 | if (src.subarray && dest.subarray) {
|
1854 | dest.set(src.subarray(src_offs, src_offs + len), dest_offs);
|
1855 | return;
|
1856 | }
|
1857 |
|
1858 | for (var i = 0; i < len; i++) {
|
1859 | dest[dest_offs + i] = src[src_offs + i];
|
1860 | }
|
1861 | },
|
1862 |
|
1863 | flattenChunks: function (chunks) {
|
1864 | var i, l, len, pos, chunk, result;
|
1865 |
|
1866 |
|
1867 | len = 0;
|
1868 | for (i = 0, l = chunks.length; i < l; i++) {
|
1869 | len += chunks[i].length;
|
1870 | }
|
1871 |
|
1872 |
|
1873 | result = new Uint8Array(len);
|
1874 | pos = 0;
|
1875 | for (i = 0, l = chunks.length; i < l; i++) {
|
1876 | chunk = chunks[i];
|
1877 | result.set(chunk, pos);
|
1878 | pos += chunk.length;
|
1879 | }
|
1880 |
|
1881 | return result;
|
1882 | }
|
1883 | };
|
1884 |
|
1885 | var fnUntyped = {
|
1886 | arraySet: function (dest, src, src_offs, len, dest_offs) {
|
1887 | for (var i = 0; i < len; i++) {
|
1888 | dest[dest_offs + i] = src[src_offs + i];
|
1889 | }
|
1890 | },
|
1891 |
|
1892 | flattenChunks: function (chunks) {
|
1893 | return [].concat.apply([], chunks);
|
1894 | }
|
1895 | };
|
1896 |
|
1897 |
|
1898 |
|
1899 |
|
1900 | exports.setTyped = function (on) {
|
1901 | if (on) {
|
1902 | exports.Buf8 = Uint8Array;
|
1903 | exports.Buf16 = Uint16Array;
|
1904 | exports.Buf32 = Int32Array;
|
1905 | exports.assign(exports, fnTyped);
|
1906 | } else {
|
1907 | exports.Buf8 = Array;
|
1908 | exports.Buf16 = Array;
|
1909 | exports.Buf32 = Array;
|
1910 | exports.assign(exports, fnUntyped);
|
1911 | }
|
1912 | };
|
1913 |
|
1914 | exports.setTyped(TYPED_OK);
|
1915 |
|
1916 |
|
1917 | }),
|
1918 |
|
1919 | (function(module, exports, __webpack_require__) {
|
1920 |
|
1921 | var _curry2 = __webpack_require__(0);
|
1922 |
|
1923 |
|
1924 |
|
1925 |
|
1926 |
|
1927 |
|
1928 |
|
1929 |
|
1930 |
|
1931 |
|
1932 |
|
1933 |
|
1934 |
|
1935 |
|
1936 |
|
1937 |
|
1938 |
|
1939 |
|
1940 |
|
1941 | module.exports = _curry2(function add(a, b) {
|
1942 | return Number(a) + Number(b);
|
1943 | });
|
1944 |
|
1945 |
|
1946 | }),
|
1947 |
|
1948 | (function(module, exports, __webpack_require__) {
|
1949 |
|
1950 | var _curry3 = __webpack_require__(2);
|
1951 |
|
1952 |
|
1953 |
|
1954 |
|
1955 |
|
1956 |
|
1957 |
|
1958 |
|
1959 |
|
1960 |
|
1961 |
|
1962 |
|
1963 |
|
1964 |
|
1965 |
|
1966 |
|
1967 |
|
1968 |
|
1969 |
|
1970 |
|
1971 |
|
1972 |
|
1973 | module.exports = _curry3(function assoc(prop, val, obj) {
|
1974 | var result = {};
|
1975 | for (var p in obj) {
|
1976 | result[p] = obj[p];
|
1977 | }
|
1978 | result[prop] = val;
|
1979 | return result;
|
1980 | });
|
1981 |
|
1982 |
|
1983 | }),
|
1984 |
|
1985 | (function(module, exports, __webpack_require__) {
|
1986 |
|
1987 | var _curry1 = __webpack_require__(1);
|
1988 | var curryN = __webpack_require__(5);
|
1989 |
|
1990 |
|
1991 |
|
1992 |
|
1993 |
|
1994 |
|
1995 |
|
1996 |
|
1997 |
|
1998 |
|
1999 |
|
2000 |
|
2001 |
|
2002 |
|
2003 |
|
2004 |
|
2005 |
|
2006 |
|
2007 |
|
2008 |
|
2009 |
|
2010 |
|
2011 |
|
2012 |
|
2013 |
|
2014 |
|
2015 |
|
2016 |
|
2017 |
|
2018 |
|
2019 |
|
2020 |
|
2021 |
|
2022 |
|
2023 |
|
2024 |
|
2025 |
|
2026 |
|
2027 |
|
2028 |
|
2029 |
|
2030 |
|
2031 |
|
2032 | module.exports = _curry1(function curry(fn) {
|
2033 | return curryN(fn.length, fn);
|
2034 | });
|
2035 |
|
2036 |
|
2037 | }),
|
2038 |
|
2039 | (function(module, exports, __webpack_require__) {
|
2040 |
|
2041 | var _curry1 = __webpack_require__(1);
|
2042 | var curry = __webpack_require__(31);
|
2043 |
|
2044 |
|
2045 |
|
2046 |
|
2047 |
|
2048 |
|
2049 |
|
2050 |
|
2051 |
|
2052 |
|
2053 |
|
2054 |
|
2055 |
|
2056 |
|
2057 |
|
2058 |
|
2059 |
|
2060 |
|
2061 |
|
2062 |
|
2063 |
|
2064 |
|
2065 | module.exports = _curry1(function flip(fn) {
|
2066 | return curry(function(a, b) {
|
2067 | var args = Array.prototype.slice.call(arguments, 0);
|
2068 | args[0] = b;
|
2069 | args[1] = a;
|
2070 | return fn.apply(this, args);
|
2071 | });
|
2072 | });
|
2073 |
|
2074 |
|
2075 | }),
|
2076 |
|
2077 | (function(module, exports, __webpack_require__) {
|
2078 |
|
2079 | var _arity = __webpack_require__(11);
|
2080 | var _isPlaceholder = __webpack_require__(35);
|
2081 |
|
2082 |
|
2083 |
|
2084 |
|
2085 |
|
2086 |
|
2087 |
|
2088 |
|
2089 |
|
2090 |
|
2091 |
|
2092 |
|
2093 | module.exports = function _curryN(length, received, fn) {
|
2094 | return function() {
|
2095 | var combined = [];
|
2096 | var argsIdx = 0;
|
2097 | var left = length;
|
2098 | var combinedIdx = 0;
|
2099 | while (combinedIdx < received.length || argsIdx < arguments.length) {
|
2100 | var result;
|
2101 | if (combinedIdx < received.length &&
|
2102 | (!_isPlaceholder(received[combinedIdx]) ||
|
2103 | argsIdx >= arguments.length)) {
|
2104 | result = received[combinedIdx];
|
2105 | } else {
|
2106 | result = arguments[argsIdx];
|
2107 | argsIdx += 1;
|
2108 | }
|
2109 | combined[combinedIdx] = result;
|
2110 | if (!_isPlaceholder(result)) {
|
2111 | left -= 1;
|
2112 | }
|
2113 | combinedIdx += 1;
|
2114 | }
|
2115 | return left <= 0 ? fn.apply(this, combined)
|
2116 | : _arity(left, _curryN(length, combined, fn));
|
2117 | };
|
2118 | };
|
2119 |
|
2120 |
|
2121 | }),
|
2122 |
|
2123 | (function(module, exports) {
|
2124 |
|
2125 | module.exports = function _isFunction(x) {
|
2126 | return Object.prototype.toString.call(x) === '[object Function]';
|
2127 | };
|
2128 |
|
2129 |
|
2130 | }),
|
2131 |
|
2132 | (function(module, exports) {
|
2133 |
|
2134 | module.exports = function _isPlaceholder(a) {
|
2135 | return a != null &&
|
2136 | typeof a === 'object' &&
|
2137 | a['@@functional/placeholder'] === true;
|
2138 | };
|
2139 |
|
2140 |
|
2141 | }),
|
2142 |
|
2143 | (function(module, exports) {
|
2144 |
|
2145 | module.exports = function _isString(x) {
|
2146 | return Object.prototype.toString.call(x) === '[object String]';
|
2147 | };
|
2148 |
|
2149 |
|
2150 | }),
|
2151 |
|
2152 | (function(module, exports) {
|
2153 |
|
2154 | module.exports = function _map(fn, functor) {
|
2155 | var idx = 0;
|
2156 | var len = functor.length;
|
2157 | var result = Array(len);
|
2158 | while (idx < len) {
|
2159 | result[idx] = fn(functor[idx]);
|
2160 | idx += 1;
|
2161 | }
|
2162 | return result;
|
2163 | };
|
2164 |
|
2165 |
|
2166 | }),
|
2167 |
|
2168 | (function(module, exports, __webpack_require__) {
|
2169 |
|
2170 | var _curry2 = __webpack_require__(0);
|
2171 | var map = __webpack_require__(7);
|
2172 |
|
2173 |
|
2174 |
|
2175 |
|
2176 |
|
2177 |
|
2178 |
|
2179 |
|
2180 |
|
2181 |
|
2182 |
|
2183 |
|
2184 |
|
2185 |
|
2186 |
|
2187 |
|
2188 |
|
2189 |
|
2190 |
|
2191 |
|
2192 |
|
2193 |
|
2194 |
|
2195 |
|
2196 |
|
2197 | module.exports = _curry2(function lens(getter, setter) {
|
2198 | return function(toFunctorFn) {
|
2199 | return function(target) {
|
2200 | return map(
|
2201 | function(focus) {
|
2202 | return setter(focus, target);
|
2203 | },
|
2204 | toFunctorFn(getter(target))
|
2205 | );
|
2206 | };
|
2207 | };
|
2208 | });
|
2209 |
|
2210 |
|
2211 | }),
|
2212 |
|
2213 | (function(module, exports, __webpack_require__) {
|
2214 |
|
2215 | var _curry1 = __webpack_require__(1);
|
2216 | var liftN = __webpack_require__(95);
|
2217 |
|
2218 |
|
2219 |
|
2220 |
|
2221 |
|
2222 |
|
2223 |
|
2224 |
|
2225 |
|
2226 |
|
2227 |
|
2228 |
|
2229 |
|
2230 |
|
2231 |
|
2232 |
|
2233 |
|
2234 |
|
2235 |
|
2236 |
|
2237 |
|
2238 |
|
2239 |
|
2240 |
|
2241 | module.exports = _curry1(function lift(fn) {
|
2242 | return liftN(fn.length, fn);
|
2243 | });
|
2244 |
|
2245 |
|
2246 | }),
|
2247 |
|
2248 | (function(module, exports, __webpack_require__) {
|
2249 |
|
2250 | var _curry2 = __webpack_require__(0);
|
2251 |
|
2252 |
|
2253 |
|
2254 |
|
2255 |
|
2256 |
|
2257 |
|
2258 |
|
2259 |
|
2260 |
|
2261 |
|
2262 |
|
2263 |
|
2264 |
|
2265 |
|
2266 |
|
2267 |
|
2268 |
|
2269 |
|
2270 |
|
2271 |
|
2272 |
|
2273 |
|
2274 |
|
2275 |
|
2276 |
|
2277 |
|
2278 |
|
2279 |
|
2280 |
|
2281 |
|
2282 | module.exports = _curry2(function nAry(n, fn) {
|
2283 | switch (n) {
|
2284 | case 0: return function() {return fn.call(this);};
|
2285 | case 1: return function(a0) {return fn.call(this, a0);};
|
2286 | case 2: return function(a0, a1) {return fn.call(this, a0, a1);};
|
2287 | case 3: return function(a0, a1, a2) {return fn.call(this, a0, a1, a2);};
|
2288 | case 4: return function(a0, a1, a2, a3) {return fn.call(this, a0, a1, a2, a3);};
|
2289 | case 5: return function(a0, a1, a2, a3, a4) {return fn.call(this, a0, a1, a2, a3, a4);};
|
2290 | case 6: return function(a0, a1, a2, a3, a4, a5) {return fn.call(this, a0, a1, a2, a3, a4, a5);};
|
2291 | case 7: return function(a0, a1, a2, a3, a4, a5, a6) {return fn.call(this, a0, a1, a2, a3, a4, a5, a6);};
|
2292 | case 8: return function(a0, a1, a2, a3, a4, a5, a6, a7) {return fn.call(this, a0, a1, a2, a3, a4, a5, a6, a7);};
|
2293 | case 9: return function(a0, a1, a2, a3, a4, a5, a6, a7, a8) {return fn.call(this, a0, a1, a2, a3, a4, a5, a6, a7, a8);};
|
2294 | case 10: return function(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9) {return fn.call(this, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9);};
|
2295 | default: throw new Error('First argument to nAry must be a non-negative integer no greater than ten');
|
2296 | }
|
2297 | });
|
2298 |
|
2299 |
|
2300 | }),
|
2301 |
|
2302 | (function(module, exports, __webpack_require__) {
|
2303 |
|
2304 | var _curryN = __webpack_require__(33);
|
2305 | var _dispatchable = __webpack_require__(3);
|
2306 | var _has = __webpack_require__(6);
|
2307 | var _reduce = __webpack_require__(8);
|
2308 | var _xreduceBy = __webpack_require__(228);
|
2309 |
|
2310 |
|
2311 |
|
2312 |
|
2313 |
|
2314 |
|
2315 |
|
2316 |
|
2317 |
|
2318 |
|
2319 |
|
2320 |
|
2321 |
|
2322 |
|
2323 |
|
2324 |
|
2325 |
|
2326 |
|
2327 |
|
2328 |
|
2329 |
|
2330 |
|
2331 |
|
2332 |
|
2333 |
|
2334 |
|
2335 |
|
2336 |
|
2337 |
|
2338 |
|
2339 |
|
2340 |
|
2341 |
|
2342 |
|
2343 |
|
2344 |
|
2345 |
|
2346 |
|
2347 |
|
2348 |
|
2349 |
|
2350 |
|
2351 |
|
2352 |
|
2353 |
|
2354 |
|
2355 | module.exports = _curryN(4, [], _dispatchable([], _xreduceBy,
|
2356 | function reduceBy(valueFn, valueAcc, keyFn, list) {
|
2357 | return _reduce(function(acc, elt) {
|
2358 | var key = keyFn(elt);
|
2359 | acc[key] = valueFn(_has(key, acc) ? acc[key] : valueAcc, elt);
|
2360 | return acc;
|
2361 | }, {}, list);
|
2362 | }));
|
2363 |
|
2364 |
|
2365 | }),
|
2366 |
|
2367 | (function(module, exports, __webpack_require__) {
|
2368 |
|
2369 | var _complement = __webpack_require__(79);
|
2370 | var _curry2 = __webpack_require__(0);
|
2371 | var filter = __webpack_require__(48);
|
2372 |
|
2373 |
|
2374 |
|
2375 |
|
2376 |
|
2377 |
|
2378 |
|
2379 |
|
2380 |
|
2381 |
|
2382 |
|
2383 |
|
2384 |
|
2385 |
|
2386 |
|
2387 |
|
2388 |
|
2389 |
|
2390 |
|
2391 |
|
2392 |
|
2393 |
|
2394 |
|
2395 |
|
2396 | module.exports = _curry2(function reject(pred, filterable) {
|
2397 | return filter(_complement(pred), filterable);
|
2398 | });
|
2399 |
|
2400 |
|
2401 | }),
|
2402 |
|
2403 | (function(module, exports, __webpack_require__) {
|
2404 |
|
2405 | var _curry1 = __webpack_require__(1);
|
2406 | var _isString = __webpack_require__(36);
|
2407 |
|
2408 |
|
2409 |
|
2410 |
|
2411 |
|
2412 |
|
2413 |
|
2414 |
|
2415 |
|
2416 |
|
2417 |
|
2418 |
|
2419 |
|
2420 |
|
2421 |
|
2422 |
|
2423 |
|
2424 |
|
2425 |
|
2426 |
|
2427 |
|
2428 |
|
2429 |
|
2430 |
|
2431 |
|
2432 |
|
2433 | module.exports = _curry1(function reverse(list) {
|
2434 | return _isString(list) ? list.split('').reverse().join('') :
|
2435 | Array.prototype.slice.call(list, 0).reverse();
|
2436 | });
|
2437 |
|
2438 |
|
2439 | }),
|
2440 |
|
2441 | (function(module, exports, __webpack_require__) {
|
2442 |
|
2443 | var _concat = __webpack_require__(9);
|
2444 | var _curry2 = __webpack_require__(0);
|
2445 | var _reduce = __webpack_require__(8);
|
2446 | var map = __webpack_require__(7);
|
2447 |
|
2448 |
|
2449 |
|
2450 |
|
2451 |
|
2452 |
|
2453 |
|
2454 |
|
2455 |
|
2456 |
|
2457 |
|
2458 |
|
2459 |
|
2460 |
|
2461 |
|
2462 |
|
2463 |
|
2464 |
|
2465 |
|
2466 |
|
2467 |
|
2468 |
|
2469 |
|
2470 | module.exports = _curry2(function ap(applicative, fn) {
|
2471 | return (
|
2472 | typeof applicative.ap === 'function' ?
|
2473 | applicative.ap(fn) :
|
2474 | typeof applicative === 'function' ?
|
2475 | function(x) { return applicative(x)(fn(x)); } :
|
2476 |
|
2477 | _reduce(function(acc, f) { return _concat(acc, map(f, fn)); }, [], applicative)
|
2478 | );
|
2479 | });
|
2480 |
|
2481 |
|
2482 | }),
|
2483 |
|
2484 | (function(module, exports, __webpack_require__) {
|
2485 |
|
2486 | var _curry2 = __webpack_require__(0);
|
2487 | var _dispatchable = __webpack_require__(3);
|
2488 | var _makeFlat = __webpack_require__(87);
|
2489 | var _xchain = __webpack_require__(217);
|
2490 | var map = __webpack_require__(7);
|
2491 |
|
2492 |
|
2493 |
|
2494 |
|
2495 |
|
2496 |
|
2497 |
|
2498 |
|
2499 |
|
2500 |
|
2501 |
|
2502 |
|
2503 |
|
2504 |
|
2505 |
|
2506 |
|
2507 |
|
2508 |
|
2509 |
|
2510 |
|
2511 |
|
2512 |
|
2513 |
|
2514 |
|
2515 | module.exports = _curry2(_dispatchable(['chain'], _xchain, function chain(fn, monad) {
|
2516 | if (typeof monad === 'function') {
|
2517 | return function(x) { return fn(monad(x))(x); };
|
2518 | }
|
2519 | return _makeFlat(false)(map(fn, monad));
|
2520 | }));
|
2521 |
|
2522 |
|
2523 | }),
|
2524 |
|
2525 | (function(module, exports, __webpack_require__) {
|
2526 |
|
2527 | var pipe = __webpack_require__(104);
|
2528 | var reverse = __webpack_require__(43);
|
2529 |
|
2530 |
|
2531 |
|
2532 |
|
2533 |
|
2534 |
|
2535 |
|
2536 |
|
2537 |
|
2538 |
|
2539 |
|
2540 |
|
2541 |
|
2542 |
|
2543 |
|
2544 |
|
2545 |
|
2546 |
|
2547 |
|
2548 |
|
2549 |
|
2550 |
|
2551 |
|
2552 |
|
2553 |
|
2554 |
|
2555 | module.exports = function compose() {
|
2556 | if (arguments.length === 0) {
|
2557 | throw new Error('compose requires at least one argument');
|
2558 | }
|
2559 | return pipe.apply(this, reverse(arguments));
|
2560 | };
|
2561 |
|
2562 |
|
2563 | }),
|
2564 |
|
2565 | (function(module, exports, __webpack_require__) {
|
2566 |
|
2567 | var _curry2 = __webpack_require__(0);
|
2568 | var _isArray = __webpack_require__(15);
|
2569 | var _isFunction = __webpack_require__(34);
|
2570 | var toString = __webpack_require__(27);
|
2571 |
|
2572 |
|
2573 |
|
2574 |
|
2575 |
|
2576 |
|
2577 |
|
2578 |
|
2579 |
|
2580 |
|
2581 |
|
2582 |
|
2583 |
|
2584 |
|
2585 |
|
2586 |
|
2587 |
|
2588 |
|
2589 |
|
2590 |
|
2591 |
|
2592 |
|
2593 |
|
2594 |
|
2595 |
|
2596 |
|
2597 |
|
2598 |
|
2599 | module.exports = _curry2(function concat(a, b) {
|
2600 | if (a == null || !_isFunction(a.concat)) {
|
2601 | throw new TypeError(toString(a) + ' does not have a method named "concat"');
|
2602 | }
|
2603 | if (_isArray(a) && !_isArray(b)) {
|
2604 | throw new TypeError(toString(b) + ' is not an array');
|
2605 | }
|
2606 | return a.concat(b);
|
2607 | });
|
2608 |
|
2609 |
|
2610 | }),
|
2611 |
|
2612 | (function(module, exports, __webpack_require__) {
|
2613 |
|
2614 | var _curry2 = __webpack_require__(0);
|
2615 | var _dispatchable = __webpack_require__(3);
|
2616 | var _filter = __webpack_require__(81);
|
2617 | var _isObject = __webpack_require__(86);
|
2618 | var _reduce = __webpack_require__(8);
|
2619 | var _xfilter = __webpack_require__(222);
|
2620 | var keys = __webpack_require__(12);
|
2621 |
|
2622 |
|
2623 |
|
2624 |
|
2625 |
|
2626 |
|
2627 |
|
2628 |
|
2629 |
|
2630 |
|
2631 |
|
2632 |
|
2633 |
|
2634 |
|
2635 |
|
2636 |
|
2637 |
|
2638 |
|
2639 |
|
2640 |
|
2641 |
|
2642 |
|
2643 |
|
2644 |
|
2645 |
|
2646 |
|
2647 |
|
2648 |
|
2649 | module.exports = _curry2(_dispatchable(['filter'], _xfilter, function(pred, filterable) {
|
2650 | return (
|
2651 | _isObject(filterable) ?
|
2652 | _reduce(function(acc, key) {
|
2653 | if (pred(filterable[key])) {
|
2654 | acc[key] = filterable[key];
|
2655 | }
|
2656 | return acc;
|
2657 | }, {}, keys(filterable)) :
|
2658 |
|
2659 | _filter(pred, filterable)
|
2660 | );
|
2661 | }));
|
2662 |
|
2663 |
|
2664 | }),
|
2665 |
|
2666 | (function(module, exports, __webpack_require__) {
|
2667 |
|
2668 | var _curry1 = __webpack_require__(1);
|
2669 | var _identity = __webpack_require__(52);
|
2670 |
|
2671 |
|
2672 |
|
2673 |
|
2674 |
|
2675 |
|
2676 |
|
2677 |
|
2678 |
|
2679 |
|
2680 |
|
2681 |
|
2682 |
|
2683 |
|
2684 |
|
2685 |
|
2686 |
|
2687 |
|
2688 |
|
2689 |
|
2690 |
|
2691 | module.exports = _curry1(_identity);
|
2692 |
|
2693 |
|
2694 | }),
|
2695 |
|
2696 | (function(module, exports, __webpack_require__) {
|
2697 |
|
2698 | var _objectAssign = __webpack_require__(207);
|
2699 |
|
2700 | module.exports =
|
2701 | typeof Object.assign === 'function' ? Object.assign : _objectAssign;
|
2702 |
|
2703 |
|
2704 | }),
|
2705 |
|
2706 | (function(module, exports) {
|
2707 |
|
2708 | module.exports = function _containsWith(pred, x, list) {
|
2709 | var idx = 0;
|
2710 | var len = list.length;
|
2711 |
|
2712 | while (idx < len) {
|
2713 | if (pred(x, list[idx])) {
|
2714 | return true;
|
2715 | }
|
2716 | idx += 1;
|
2717 | }
|
2718 | return false;
|
2719 | };
|
2720 |
|
2721 |
|
2722 | }),
|
2723 |
|
2724 | (function(module, exports) {
|
2725 |
|
2726 | module.exports = function _identity(x) { return x; };
|
2727 |
|
2728 |
|
2729 | }),
|
2730 |
|
2731 | (function(module, exports) {
|
2732 |
|
2733 | module.exports = function _isTransformer(obj) {
|
2734 | return typeof obj['@@transducer/step'] === 'function';
|
2735 | };
|
2736 |
|
2737 |
|
2738 | }),
|
2739 |
|
2740 | (function(module, exports, __webpack_require__) {
|
2741 |
|
2742 | var _curry2 = __webpack_require__(0);
|
2743 |
|
2744 |
|
2745 |
|
2746 |
|
2747 |
|
2748 |
|
2749 |
|
2750 |
|
2751 |
|
2752 |
|
2753 |
|
2754 |
|
2755 |
|
2756 |
|
2757 |
|
2758 |
|
2759 |
|
2760 |
|
2761 |
|
2762 |
|
2763 | module.exports = _curry2(function prop(p, obj) { return obj[p]; });
|
2764 |
|
2765 |
|
2766 | }),
|
2767 |
|
2768 | (function(module, exports, __webpack_require__) {
|
2769 |
|
2770 | var _checkForMethod = __webpack_require__(21);
|
2771 | var _curry1 = __webpack_require__(1);
|
2772 | var slice = __webpack_require__(18);
|
2773 |
|
2774 |
|
2775 |
|
2776 |
|
2777 |
|
2778 |
|
2779 |
|
2780 |
|
2781 |
|
2782 |
|
2783 |
|
2784 |
|
2785 |
|
2786 |
|
2787 |
|
2788 |
|
2789 |
|
2790 |
|
2791 |
|
2792 |
|
2793 |
|
2794 |
|
2795 |
|
2796 |
|
2797 |
|
2798 |
|
2799 |
|
2800 |
|
2801 |
|
2802 | module.exports = _curry1(_checkForMethod('tail', slice(1, Infinity)));
|
2803 |
|
2804 |
|
2805 | }),
|
2806 |
|
2807 | (function(module, exports, __webpack_require__) {
|
2808 |
|
2809 | var _curry1 = __webpack_require__(1);
|
2810 |
|
2811 |
|
2812 |
|
2813 |
|
2814 |
|
2815 |
|
2816 |
|
2817 |
|
2818 |
|
2819 |
|
2820 |
|
2821 |
|
2822 |
|
2823 |
|
2824 |
|
2825 |
|
2826 |
|
2827 |
|
2828 |
|
2829 |
|
2830 |
|
2831 |
|
2832 |
|
2833 |
|
2834 |
|
2835 | module.exports = _curry1(function type(val) {
|
2836 | return val === null ? 'Null' :
|
2837 | val === undefined ? 'Undefined' :
|
2838 | Object.prototype.toString.call(val).slice(8, -1);
|
2839 | });
|
2840 |
|
2841 |
|
2842 | }),
|
2843 |
|
2844 | (function(module, exports, __webpack_require__) {
|
2845 |
|
2846 | var identity = __webpack_require__(49);
|
2847 | var uniqBy = __webpack_require__(112);
|
2848 |
|
2849 |
|
2850 |
|
2851 |
|
2852 |
|
2853 |
|
2854 |
|
2855 |
|
2856 |
|
2857 |
|
2858 |
|
2859 |
|
2860 |
|
2861 |
|
2862 |
|
2863 |
|
2864 |
|
2865 |
|
2866 |
|
2867 | module.exports = uniqBy(identity);
|
2868 |
|
2869 |
|
2870 | }),
|
2871 |
|
2872 | (function(module, exports, __webpack_require__) {
|
2873 |
|
2874 | var _containsWith = __webpack_require__(51);
|
2875 | var _curry2 = __webpack_require__(0);
|
2876 |
|
2877 |
|
2878 |
|
2879 |
|
2880 |
|
2881 |
|
2882 |
|
2883 |
|
2884 |
|
2885 |
|
2886 |
|
2887 |
|
2888 |
|
2889 |
|
2890 |
|
2891 |
|
2892 |
|
2893 |
|
2894 |
|
2895 |
|
2896 |
|
2897 |
|
2898 |
|
2899 |
|
2900 | module.exports = _curry2(function uniqWith(pred, list) {
|
2901 | var idx = 0;
|
2902 | var len = list.length;
|
2903 | var result = [];
|
2904 | var item;
|
2905 | while (idx < len) {
|
2906 | item = list[idx];
|
2907 | if (!_containsWith(pred, item, result)) {
|
2908 | result[result.length] = item;
|
2909 | }
|
2910 | idx += 1;
|
2911 | }
|
2912 | return result;
|
2913 | });
|
2914 |
|
2915 |
|
2916 | }),
|
2917 |
|
2918 | (function(module, exports, __webpack_require__) {
|
2919 |
|
2920 | (function(){
|
2921 |
|
2922 |
|
2923 |
|
2924 |
|
2925 |
|
2926 |
|
2927 |
|
2928 |
|
2929 | var dbits;
|
2930 |
|
2931 |
|
2932 | var canary = 0xdeadbeefcafe;
|
2933 | var j_lm = ((canary&0xffffff)==0xefcafe);
|
2934 |
|
2935 |
|
2936 | function BigInteger(a,b,c) {
|
2937 | if(a != null)
|
2938 | if("number" == typeof a) this.fromNumber(a,b,c);
|
2939 | else if(b == null && "string" != typeof a) this.fromString(a,256);
|
2940 | else this.fromString(a,b);
|
2941 | }
|
2942 |
|
2943 |
|
2944 | function nbi() { return new BigInteger(null); }
|
2945 |
|
2946 |
|
2947 |
|
2948 |
|
2949 |
|
2950 |
|
2951 |
|
2952 |
|
2953 |
|
2954 | function am1(i,x,w,j,c,n) {
|
2955 | while(--n >= 0) {
|
2956 | var v = x*this[i++]+w[j]+c;
|
2957 | c = Math.floor(v/0x4000000);
|
2958 | w[j++] = v&0x3ffffff;
|
2959 | }
|
2960 | return c;
|
2961 | }
|
2962 |
|
2963 |
|
2964 |
|
2965 | function am2(i,x,w,j,c,n) {
|
2966 | var xl = x&0x7fff, xh = x>>15;
|
2967 | while(--n >= 0) {
|
2968 | var l = this[i]&0x7fff;
|
2969 | var h = this[i++]>>15;
|
2970 | var m = xh*l+h*xl;
|
2971 | l = xl*l+((m&0x7fff)<<15)+w[j]+(c&0x3fffffff);
|
2972 | c = (l>>>30)+(m>>>15)+xh*h+(c>>>30);
|
2973 | w[j++] = l&0x3fffffff;
|
2974 | }
|
2975 | return c;
|
2976 | }
|
2977 |
|
2978 |
|
2979 | function am3(i,x,w,j,c,n) {
|
2980 | var xl = x&0x3fff, xh = x>>14;
|
2981 | while(--n >= 0) {
|
2982 | var l = this[i]&0x3fff;
|
2983 | var h = this[i++]>>14;
|
2984 | var m = xh*l+h*xl;
|
2985 | l = xl*l+((m&0x3fff)<<14)+w[j]+c;
|
2986 | c = (l>>28)+(m>>14)+xh*h;
|
2987 | w[j++] = l&0xfffffff;
|
2988 | }
|
2989 | return c;
|
2990 | }
|
2991 | var inBrowser = typeof navigator !== "undefined";
|
2992 | if(inBrowser && j_lm && (navigator.appName == "Microsoft Internet Explorer")) {
|
2993 | BigInteger.prototype.am = am2;
|
2994 | dbits = 30;
|
2995 | }
|
2996 | else if(inBrowser && j_lm && (navigator.appName != "Netscape")) {
|
2997 | BigInteger.prototype.am = am1;
|
2998 | dbits = 26;
|
2999 | }
|
3000 | else {
|
3001 | BigInteger.prototype.am = am3;
|
3002 | dbits = 28;
|
3003 | }
|
3004 |
|
3005 | BigInteger.prototype.DB = dbits;
|
3006 | BigInteger.prototype.DM = ((1<<dbits)-1);
|
3007 | BigInteger.prototype.DV = (1<<dbits);
|
3008 |
|
3009 | var BI_FP = 52;
|
3010 | BigInteger.prototype.FV = Math.pow(2,BI_FP);
|
3011 | BigInteger.prototype.F1 = BI_FP-dbits;
|
3012 | BigInteger.prototype.F2 = 2*dbits-BI_FP;
|
3013 |
|
3014 |
|
3015 | var BI_RM = "0123456789abcdefghijklmnopqrstuvwxyz";
|
3016 | var BI_RC = new Array();
|
3017 | var rr,vv;
|
3018 | rr = "0".charCodeAt(0);
|
3019 | for(vv = 0; vv <= 9; ++vv) BI_RC[rr++] = vv;
|
3020 | rr = "a".charCodeAt(0);
|
3021 | for(vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv;
|
3022 | rr = "A".charCodeAt(0);
|
3023 | for(vv = 10; vv < 36; ++vv) BI_RC[rr++] = vv;
|
3024 |
|
3025 | function int2char(n) { return BI_RM.charAt(n); }
|
3026 | function intAt(s,i) {
|
3027 | var c = BI_RC[s.charCodeAt(i)];
|
3028 | return (c==null)?-1:c;
|
3029 | }
|
3030 |
|
3031 |
|
3032 | function bnpCopyTo(r) {
|
3033 | for(var i = this.t-1; i >= 0; --i) r[i] = this[i];
|
3034 | r.t = this.t;
|
3035 | r.s = this.s;
|
3036 | }
|
3037 |
|
3038 |
|
3039 | function bnpFromInt(x) {
|
3040 | this.t = 1;
|
3041 | this.s = (x<0)?-1:0;
|
3042 | if(x > 0) this[0] = x;
|
3043 | else if(x < -1) this[0] = x+this.DV;
|
3044 | else this.t = 0;
|
3045 | }
|
3046 |
|
3047 |
|
3048 | function nbv(i) { var r = nbi(); r.fromInt(i); return r; }
|
3049 |
|
3050 |
|
3051 | function bnpFromString(s,b) {
|
3052 | var k;
|
3053 | if(b == 16) k = 4;
|
3054 | else if(b == 8) k = 3;
|
3055 | else if(b == 256) k = 8;
|
3056 | else if(b == 2) k = 1;
|
3057 | else if(b == 32) k = 5;
|
3058 | else if(b == 4) k = 2;
|
3059 | else { this.fromRadix(s,b); return; }
|
3060 | this.t = 0;
|
3061 | this.s = 0;
|
3062 | var i = s.length, mi = false, sh = 0;
|
3063 | while(--i >= 0) {
|
3064 | var x = (k==8)?s[i]&0xff:intAt(s,i);
|
3065 | if(x < 0) {
|
3066 | if(s.charAt(i) == "-") mi = true;
|
3067 | continue;
|
3068 | }
|
3069 | mi = false;
|
3070 | if(sh == 0)
|
3071 | this[this.t++] = x;
|
3072 | else if(sh+k > this.DB) {
|
3073 | this[this.t-1] |= (x&((1<<(this.DB-sh))-1))<<sh;
|
3074 | this[this.t++] = (x>>(this.DB-sh));
|
3075 | }
|
3076 | else
|
3077 | this[this.t-1] |= x<<sh;
|
3078 | sh += k;
|
3079 | if(sh >= this.DB) sh -= this.DB;
|
3080 | }
|
3081 | if(k == 8 && (s[0]&0x80) != 0) {
|
3082 | this.s = -1;
|
3083 | if(sh > 0) this[this.t-1] |= ((1<<(this.DB-sh))-1)<<sh;
|
3084 | }
|
3085 | this.clamp();
|
3086 | if(mi) BigInteger.ZERO.subTo(this,this);
|
3087 | }
|
3088 |
|
3089 |
|
3090 | function bnpClamp() {
|
3091 | var c = this.s&this.DM;
|
3092 | while(this.t > 0 && this[this.t-1] == c) --this.t;
|
3093 | }
|
3094 |
|
3095 |
|
3096 | function bnToString(b) {
|
3097 | if(this.s < 0) return "-"+this.negate().toString(b);
|
3098 | var k;
|
3099 | if(b == 16) k = 4;
|
3100 | else if(b == 8) k = 3;
|
3101 | else if(b == 2) k = 1;
|
3102 | else if(b == 32) k = 5;
|
3103 | else if(b == 4) k = 2;
|
3104 | else return this.toRadix(b);
|
3105 | var km = (1<<k)-1, d, m = false, r = "", i = this.t;
|
3106 | var p = this.DB-(i*this.DB)%k;
|
3107 | if(i-- > 0) {
|
3108 | if(p < this.DB && (d = this[i]>>p) > 0) { m = true; r = int2char(d); }
|
3109 | while(i >= 0) {
|
3110 | if(p < k) {
|
3111 | d = (this[i]&((1<<p)-1))<<(k-p);
|
3112 | d |= this[--i]>>(p+=this.DB-k);
|
3113 | }
|
3114 | else {
|
3115 | d = (this[i]>>(p-=k))&km;
|
3116 | if(p <= 0) { p += this.DB; --i; }
|
3117 | }
|
3118 | if(d > 0) m = true;
|
3119 | if(m) r += int2char(d);
|
3120 | }
|
3121 | }
|
3122 | return m?r:"0";
|
3123 | }
|
3124 |
|
3125 |
|
3126 | function bnNegate() { var r = nbi(); BigInteger.ZERO.subTo(this,r); return r; }
|
3127 |
|
3128 |
|
3129 | function bnAbs() { return (this.s<0)?this.negate():this; }
|
3130 |
|
3131 |
|
3132 | function bnCompareTo(a) {
|
3133 | var r = this.s-a.s;
|
3134 | if(r != 0) return r;
|
3135 | var i = this.t;
|
3136 | r = i-a.t;
|
3137 | if(r != 0) return (this.s<0)?-r:r;
|
3138 | while(--i >= 0) if((r=this[i]-a[i]) != 0) return r;
|
3139 | return 0;
|
3140 | }
|
3141 |
|
3142 |
|
3143 | function nbits(x) {
|
3144 | var r = 1, t;
|
3145 | if((t=x>>>16) != 0) { x = t; r += 16; }
|
3146 | if((t=x>>8) != 0) { x = t; r += 8; }
|
3147 | if((t=x>>4) != 0) { x = t; r += 4; }
|
3148 | if((t=x>>2) != 0) { x = t; r += 2; }
|
3149 | if((t=x>>1) != 0) { x = t; r += 1; }
|
3150 | return r;
|
3151 | }
|
3152 |
|
3153 |
|
3154 | function bnBitLength() {
|
3155 | if(this.t <= 0) return 0;
|
3156 | return this.DB*(this.t-1)+nbits(this[this.t-1]^(this.s&this.DM));
|
3157 | }
|
3158 |
|
3159 |
|
3160 | function bnpDLShiftTo(n,r) {
|
3161 | var i;
|
3162 | for(i = this.t-1; i >= 0; --i) r[i+n] = this[i];
|
3163 | for(i = n-1; i >= 0; --i) r[i] = 0;
|
3164 | r.t = this.t+n;
|
3165 | r.s = this.s;
|
3166 | }
|
3167 |
|
3168 |
|
3169 | function bnpDRShiftTo(n,r) {
|
3170 | for(var i = n; i < this.t; ++i) r[i-n] = this[i];
|
3171 | r.t = Math.max(this.t-n,0);
|
3172 | r.s = this.s;
|
3173 | }
|
3174 |
|
3175 |
|
3176 | function bnpLShiftTo(n,r) {
|
3177 | var bs = n%this.DB;
|
3178 | var cbs = this.DB-bs;
|
3179 | var bm = (1<<cbs)-1;
|
3180 | var ds = Math.floor(n/this.DB), c = (this.s<<bs)&this.DM, i;
|
3181 | for(i = this.t-1; i >= 0; --i) {
|
3182 | r[i+ds+1] = (this[i]>>cbs)|c;
|
3183 | c = (this[i]&bm)<<bs;
|
3184 | }
|
3185 | for(i = ds-1; i >= 0; --i) r[i] = 0;
|
3186 | r[ds] = c;
|
3187 | r.t = this.t+ds+1;
|
3188 | r.s = this.s;
|
3189 | r.clamp();
|
3190 | }
|
3191 |
|
3192 |
|
3193 | function bnpRShiftTo(n,r) {
|
3194 | r.s = this.s;
|
3195 | var ds = Math.floor(n/this.DB);
|
3196 | if(ds >= this.t) { r.t = 0; return; }
|
3197 | var bs = n%this.DB;
|
3198 | var cbs = this.DB-bs;
|
3199 | var bm = (1<<bs)-1;
|
3200 | r[0] = this[ds]>>bs;
|
3201 | for(var i = ds+1; i < this.t; ++i) {
|
3202 | r[i-ds-1] |= (this[i]&bm)<<cbs;
|
3203 | r[i-ds] = this[i]>>bs;
|
3204 | }
|
3205 | if(bs > 0) r[this.t-ds-1] |= (this.s&bm)<<cbs;
|
3206 | r.t = this.t-ds;
|
3207 | r.clamp();
|
3208 | }
|
3209 |
|
3210 |
|
3211 | function bnpSubTo(a,r) {
|
3212 | var i = 0, c = 0, m = Math.min(a.t,this.t);
|
3213 | while(i < m) {
|
3214 | c += this[i]-a[i];
|
3215 | r[i++] = c&this.DM;
|
3216 | c >>= this.DB;
|
3217 | }
|
3218 | if(a.t < this.t) {
|
3219 | c -= a.s;
|
3220 | while(i < this.t) {
|
3221 | c += this[i];
|
3222 | r[i++] = c&this.DM;
|
3223 | c >>= this.DB;
|
3224 | }
|
3225 | c += this.s;
|
3226 | }
|
3227 | else {
|
3228 | c += this.s;
|
3229 | while(i < a.t) {
|
3230 | c -= a[i];
|
3231 | r[i++] = c&this.DM;
|
3232 | c >>= this.DB;
|
3233 | }
|
3234 | c -= a.s;
|
3235 | }
|
3236 | r.s = (c<0)?-1:0;
|
3237 | if(c < -1) r[i++] = this.DV+c;
|
3238 | else if(c > 0) r[i++] = c;
|
3239 | r.t = i;
|
3240 | r.clamp();
|
3241 | }
|
3242 |
|
3243 |
|
3244 |
|
3245 | function bnpMultiplyTo(a,r) {
|
3246 | var x = this.abs(), y = a.abs();
|
3247 | var i = x.t;
|
3248 | r.t = i+y.t;
|
3249 | while(--i >= 0) r[i] = 0;
|
3250 | for(i = 0; i < y.t; ++i) r[i+x.t] = x.am(0,y[i],r,i,0,x.t);
|
3251 | r.s = 0;
|
3252 | r.clamp();
|
3253 | if(this.s != a.s) BigInteger.ZERO.subTo(r,r);
|
3254 | }
|
3255 |
|
3256 |
|
3257 | function bnpSquareTo(r) {
|
3258 | var x = this.abs();
|
3259 | var i = r.t = 2*x.t;
|
3260 | while(--i >= 0) r[i] = 0;
|
3261 | for(i = 0; i < x.t-1; ++i) {
|
3262 | var c = x.am(i,x[i],r,2*i,0,1);
|
3263 | if((r[i+x.t]+=x.am(i+1,2*x[i],r,2*i+1,c,x.t-i-1)) >= x.DV) {
|
3264 | r[i+x.t] -= x.DV;
|
3265 | r[i+x.t+1] = 1;
|
3266 | }
|
3267 | }
|
3268 | if(r.t > 0) r[r.t-1] += x.am(i,x[i],r,2*i,0,1);
|
3269 | r.s = 0;
|
3270 | r.clamp();
|
3271 | }
|
3272 |
|
3273 |
|
3274 |
|
3275 | function bnpDivRemTo(m,q,r) {
|
3276 | var pm = m.abs();
|
3277 | if(pm.t <= 0) return;
|
3278 | var pt = this.abs();
|
3279 | if(pt.t < pm.t) {
|
3280 | if(q != null) q.fromInt(0);
|
3281 | if(r != null) this.copyTo(r);
|
3282 | return;
|
3283 | }
|
3284 | if(r == null) r = nbi();
|
3285 | var y = nbi(), ts = this.s, ms = m.s;
|
3286 | var nsh = this.DB-nbits(pm[pm.t-1]);
|
3287 | if(nsh > 0) { pm.lShiftTo(nsh,y); pt.lShiftTo(nsh,r); }
|
3288 | else { pm.copyTo(y); pt.copyTo(r); }
|
3289 | var ys = y.t;
|
3290 | var y0 = y[ys-1];
|
3291 | if(y0 == 0) return;
|
3292 | var yt = y0*(1<<this.F1)+((ys>1)?y[ys-2]>>this.F2:0);
|
3293 | var d1 = this.FV/yt, d2 = (1<<this.F1)/yt, e = 1<<this.F2;
|
3294 | var i = r.t, j = i-ys, t = (q==null)?nbi():q;
|
3295 | y.dlShiftTo(j,t);
|
3296 | if(r.compareTo(t) >= 0) {
|
3297 | r[r.t++] = 1;
|
3298 | r.subTo(t,r);
|
3299 | }
|
3300 | BigInteger.ONE.dlShiftTo(ys,t);
|
3301 | t.subTo(y,y);
|
3302 | while(y.t < ys) y[y.t++] = 0;
|
3303 | while(--j >= 0) {
|
3304 |
|
3305 | var qd = (r[--i]==y0)?this.DM:Math.floor(r[i]*d1+(r[i-1]+e)*d2);
|
3306 | if((r[i]+=y.am(0,qd,r,j,0,ys)) < qd) {
|
3307 | y.dlShiftTo(j,t);
|
3308 | r.subTo(t,r);
|
3309 | while(r[i] < --qd) r.subTo(t,r);
|
3310 | }
|
3311 | }
|
3312 | if(q != null) {
|
3313 | r.drShiftTo(ys,q);
|
3314 | if(ts != ms) BigInteger.ZERO.subTo(q,q);
|
3315 | }
|
3316 | r.t = ys;
|
3317 | r.clamp();
|
3318 | if(nsh > 0) r.rShiftTo(nsh,r);
|
3319 | if(ts < 0) BigInteger.ZERO.subTo(r,r);
|
3320 | }
|
3321 |
|
3322 |
|
3323 | function bnMod(a) {
|
3324 | var r = nbi();
|
3325 | this.abs().divRemTo(a,null,r);
|
3326 | if(this.s < 0 && r.compareTo(BigInteger.ZERO) > 0) a.subTo(r,r);
|
3327 | return r;
|
3328 | }
|
3329 |
|
3330 |
|
3331 | function Classic(m) { this.m = m; }
|
3332 | function cConvert(x) {
|
3333 | if(x.s < 0 || x.compareTo(this.m) >= 0) return x.mod(this.m);
|
3334 | else return x;
|
3335 | }
|
3336 | function cRevert(x) { return x; }
|
3337 | function cReduce(x) { x.divRemTo(this.m,null,x); }
|
3338 | function cMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); }
|
3339 | function cSqrTo(x,r) { x.squareTo(r); this.reduce(r); }
|
3340 |
|
3341 | Classic.prototype.convert = cConvert;
|
3342 | Classic.prototype.revert = cRevert;
|
3343 | Classic.prototype.reduce = cReduce;
|
3344 | Classic.prototype.mulTo = cMulTo;
|
3345 | Classic.prototype.sqrTo = cSqrTo;
|
3346 |
|
3347 |
|
3348 |
|
3349 |
|
3350 |
|
3351 |
|
3352 |
|
3353 |
|
3354 |
|
3355 |
|
3356 |
|
3357 | function bnpInvDigit() {
|
3358 | if(this.t < 1) return 0;
|
3359 | var x = this[0];
|
3360 | if((x&1) == 0) return 0;
|
3361 | var y = x&3;
|
3362 | y = (y*(2-(x&0xf)*y))&0xf;
|
3363 | y = (y*(2-(x&0xff)*y))&0xff;
|
3364 | y = (y*(2-(((x&0xffff)*y)&0xffff)))&0xffff;
|
3365 |
|
3366 |
|
3367 | y = (y*(2-x*y%this.DV))%this.DV;
|
3368 |
|
3369 | return (y>0)?this.DV-y:-y;
|
3370 | }
|
3371 |
|
3372 |
|
3373 | function Montgomery(m) {
|
3374 | this.m = m;
|
3375 | this.mp = m.invDigit();
|
3376 | this.mpl = this.mp&0x7fff;
|
3377 | this.mph = this.mp>>15;
|
3378 | this.um = (1<<(m.DB-15))-1;
|
3379 | this.mt2 = 2*m.t;
|
3380 | }
|
3381 |
|
3382 |
|
3383 | function montConvert(x) {
|
3384 | var r = nbi();
|
3385 | x.abs().dlShiftTo(this.m.t,r);
|
3386 | r.divRemTo(this.m,null,r);
|
3387 | if(x.s < 0 && r.compareTo(BigInteger.ZERO) > 0) this.m.subTo(r,r);
|
3388 | return r;
|
3389 | }
|
3390 |
|
3391 |
|
3392 | function montRevert(x) {
|
3393 | var r = nbi();
|
3394 | x.copyTo(r);
|
3395 | this.reduce(r);
|
3396 | return r;
|
3397 | }
|
3398 |
|
3399 |
|
3400 | function montReduce(x) {
|
3401 | while(x.t <= this.mt2)
|
3402 | x[x.t++] = 0;
|
3403 | for(var i = 0; i < this.m.t; ++i) {
|
3404 |
|
3405 | var j = x[i]&0x7fff;
|
3406 | var u0 = (j*this.mpl+(((j*this.mph+(x[i]>>15)*this.mpl)&this.um)<<15))&x.DM;
|
3407 |
|
3408 | j = i+this.m.t;
|
3409 | x[j] += this.m.am(0,u0,x,i,0,this.m.t);
|
3410 |
|
3411 | while(x[j] >= x.DV) { x[j] -= x.DV; x[++j]++; }
|
3412 | }
|
3413 | x.clamp();
|
3414 | x.drShiftTo(this.m.t,x);
|
3415 | if(x.compareTo(this.m) >= 0) x.subTo(this.m,x);
|
3416 | }
|
3417 |
|
3418 |
|
3419 | function montSqrTo(x,r) { x.squareTo(r); this.reduce(r); }
|
3420 |
|
3421 |
|
3422 | function montMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); }
|
3423 |
|
3424 | Montgomery.prototype.convert = montConvert;
|
3425 | Montgomery.prototype.revert = montRevert;
|
3426 | Montgomery.prototype.reduce = montReduce;
|
3427 | Montgomery.prototype.mulTo = montMulTo;
|
3428 | Montgomery.prototype.sqrTo = montSqrTo;
|
3429 |
|
3430 |
|
3431 | function bnpIsEven() { return ((this.t>0)?(this[0]&1):this.s) == 0; }
|
3432 |
|
3433 |
|
3434 | function bnpExp(e,z) {
|
3435 | if(e > 0xffffffff || e < 1) return BigInteger.ONE;
|
3436 | var r = nbi(), r2 = nbi(), g = z.convert(this), i = nbits(e)-1;
|
3437 | g.copyTo(r);
|
3438 | while(--i >= 0) {
|
3439 | z.sqrTo(r,r2);
|
3440 | if((e&(1<<i)) > 0) z.mulTo(r2,g,r);
|
3441 | else { var t = r; r = r2; r2 = t; }
|
3442 | }
|
3443 | return z.revert(r);
|
3444 | }
|
3445 |
|
3446 |
|
3447 | function bnModPowInt(e,m) {
|
3448 | var z;
|
3449 | if(e < 256 || m.isEven()) z = new Classic(m); else z = new Montgomery(m);
|
3450 | return this.exp(e,z);
|
3451 | }
|
3452 |
|
3453 |
|
3454 | BigInteger.prototype.copyTo = bnpCopyTo;
|
3455 | BigInteger.prototype.fromInt = bnpFromInt;
|
3456 | BigInteger.prototype.fromString = bnpFromString;
|
3457 | BigInteger.prototype.clamp = bnpClamp;
|
3458 | BigInteger.prototype.dlShiftTo = bnpDLShiftTo;
|
3459 | BigInteger.prototype.drShiftTo = bnpDRShiftTo;
|
3460 | BigInteger.prototype.lShiftTo = bnpLShiftTo;
|
3461 | BigInteger.prototype.rShiftTo = bnpRShiftTo;
|
3462 | BigInteger.prototype.subTo = bnpSubTo;
|
3463 | BigInteger.prototype.multiplyTo = bnpMultiplyTo;
|
3464 | BigInteger.prototype.squareTo = bnpSquareTo;
|
3465 | BigInteger.prototype.divRemTo = bnpDivRemTo;
|
3466 | BigInteger.prototype.invDigit = bnpInvDigit;
|
3467 | BigInteger.prototype.isEven = bnpIsEven;
|
3468 | BigInteger.prototype.exp = bnpExp;
|
3469 |
|
3470 |
|
3471 | BigInteger.prototype.toString = bnToString;
|
3472 | BigInteger.prototype.negate = bnNegate;
|
3473 | BigInteger.prototype.abs = bnAbs;
|
3474 | BigInteger.prototype.compareTo = bnCompareTo;
|
3475 | BigInteger.prototype.bitLength = bnBitLength;
|
3476 | BigInteger.prototype.mod = bnMod;
|
3477 | BigInteger.prototype.modPowInt = bnModPowInt;
|
3478 |
|
3479 |
|
3480 | BigInteger.ZERO = nbv(0);
|
3481 | BigInteger.ONE = nbv(1);
|
3482 |
|
3483 |
|
3484 |
|
3485 |
|
3486 |
|
3487 |
|
3488 |
|
3489 |
|
3490 |
|
3491 |
|
3492 |
|
3493 | function bnClone() { var r = nbi(); this.copyTo(r); return r; }
|
3494 |
|
3495 |
|
3496 | function bnIntValue() {
|
3497 | if(this.s < 0) {
|
3498 | if(this.t == 1) return this[0]-this.DV;
|
3499 | else if(this.t == 0) return -1;
|
3500 | }
|
3501 | else if(this.t == 1) return this[0];
|
3502 | else if(this.t == 0) return 0;
|
3503 |
|
3504 | return ((this[1]&((1<<(32-this.DB))-1))<<this.DB)|this[0];
|
3505 | }
|
3506 |
|
3507 |
|
3508 | function bnByteValue() { return (this.t==0)?this.s:(this[0]<<24)>>24; }
|
3509 |
|
3510 |
|
3511 | function bnShortValue() { return (this.t==0)?this.s:(this[0]<<16)>>16; }
|
3512 |
|
3513 |
|
3514 | function bnpChunkSize(r) { return Math.floor(Math.LN2*this.DB/Math.log(r)); }
|
3515 |
|
3516 |
|
3517 | function bnSigNum() {
|
3518 | if(this.s < 0) return -1;
|
3519 | else if(this.t <= 0 || (this.t == 1 && this[0] <= 0)) return 0;
|
3520 | else return 1;
|
3521 | }
|
3522 |
|
3523 |
|
3524 | function bnpToRadix(b) {
|
3525 | if(b == null) b = 10;
|
3526 | if(this.signum() == 0 || b < 2 || b > 36) return "0";
|
3527 | var cs = this.chunkSize(b);
|
3528 | var a = Math.pow(b,cs);
|
3529 | var d = nbv(a), y = nbi(), z = nbi(), r = "";
|
3530 | this.divRemTo(d,y,z);
|
3531 | while(y.signum() > 0) {
|
3532 | r = (a+z.intValue()).toString(b).substr(1) + r;
|
3533 | y.divRemTo(d,y,z);
|
3534 | }
|
3535 | return z.intValue().toString(b) + r;
|
3536 | }
|
3537 |
|
3538 |
|
3539 | function bnpFromRadix(s,b) {
|
3540 | this.fromInt(0);
|
3541 | if(b == null) b = 10;
|
3542 | var cs = this.chunkSize(b);
|
3543 | var d = Math.pow(b,cs), mi = false, j = 0, w = 0;
|
3544 | for(var i = 0; i < s.length; ++i) {
|
3545 | var x = intAt(s,i);
|
3546 | if(x < 0) {
|
3547 | if(s.charAt(i) == "-" && this.signum() == 0) mi = true;
|
3548 | continue;
|
3549 | }
|
3550 | w = b*w+x;
|
3551 | if(++j >= cs) {
|
3552 | this.dMultiply(d);
|
3553 | this.dAddOffset(w,0);
|
3554 | j = 0;
|
3555 | w = 0;
|
3556 | }
|
3557 | }
|
3558 | if(j > 0) {
|
3559 | this.dMultiply(Math.pow(b,j));
|
3560 | this.dAddOffset(w,0);
|
3561 | }
|
3562 | if(mi) BigInteger.ZERO.subTo(this,this);
|
3563 | }
|
3564 |
|
3565 |
|
3566 | function bnpFromNumber(a,b,c) {
|
3567 | if("number" == typeof b) {
|
3568 |
|
3569 | if(a < 2) this.fromInt(1);
|
3570 | else {
|
3571 | this.fromNumber(a,c);
|
3572 | if(!this.testBit(a-1))
|
3573 | this.bitwiseTo(BigInteger.ONE.shiftLeft(a-1),op_or,this);
|
3574 | if(this.isEven()) this.dAddOffset(1,0);
|
3575 | while(!this.isProbablePrime(b)) {
|
3576 | this.dAddOffset(2,0);
|
3577 | if(this.bitLength() > a) this.subTo(BigInteger.ONE.shiftLeft(a-1),this);
|
3578 | }
|
3579 | }
|
3580 | }
|
3581 | else {
|
3582 |
|
3583 | var x = new Array(), t = a&7;
|
3584 | x.length = (a>>3)+1;
|
3585 | b.nextBytes(x);
|
3586 | if(t > 0) x[0] &= ((1<<t)-1); else x[0] = 0;
|
3587 | this.fromString(x,256);
|
3588 | }
|
3589 | }
|
3590 |
|
3591 |
|
3592 | function bnToByteArray() {
|
3593 | var i = this.t, r = new Array();
|
3594 | r[0] = this.s;
|
3595 | var p = this.DB-(i*this.DB)%8, d, k = 0;
|
3596 | if(i-- > 0) {
|
3597 | if(p < this.DB && (d = this[i]>>p) != (this.s&this.DM)>>p)
|
3598 | r[k++] = d|(this.s<<(this.DB-p));
|
3599 | while(i >= 0) {
|
3600 | if(p < 8) {
|
3601 | d = (this[i]&((1<<p)-1))<<(8-p);
|
3602 | d |= this[--i]>>(p+=this.DB-8);
|
3603 | }
|
3604 | else {
|
3605 | d = (this[i]>>(p-=8))&0xff;
|
3606 | if(p <= 0) { p += this.DB; --i; }
|
3607 | }
|
3608 | if((d&0x80) != 0) d |= -256;
|
3609 | if(k == 0 && (this.s&0x80) != (d&0x80)) ++k;
|
3610 | if(k > 0 || d != this.s) r[k++] = d;
|
3611 | }
|
3612 | }
|
3613 | return r;
|
3614 | }
|
3615 |
|
3616 | function bnEquals(a) { return(this.compareTo(a)==0); }
|
3617 | function bnMin(a) { return(this.compareTo(a)<0)?this:a; }
|
3618 | function bnMax(a) { return(this.compareTo(a)>0)?this:a; }
|
3619 |
|
3620 |
|
3621 | function bnpBitwiseTo(a,op,r) {
|
3622 | var i, f, m = Math.min(a.t,this.t);
|
3623 | for(i = 0; i < m; ++i) r[i] = op(this[i],a[i]);
|
3624 | if(a.t < this.t) {
|
3625 | f = a.s&this.DM;
|
3626 | for(i = m; i < this.t; ++i) r[i] = op(this[i],f);
|
3627 | r.t = this.t;
|
3628 | }
|
3629 | else {
|
3630 | f = this.s&this.DM;
|
3631 | for(i = m; i < a.t; ++i) r[i] = op(f,a[i]);
|
3632 | r.t = a.t;
|
3633 | }
|
3634 | r.s = op(this.s,a.s);
|
3635 | r.clamp();
|
3636 | }
|
3637 |
|
3638 |
|
3639 | function op_and(x,y) { return x&y; }
|
3640 | function bnAnd(a) { var r = nbi(); this.bitwiseTo(a,op_and,r); return r; }
|
3641 |
|
3642 |
|
3643 | function op_or(x,y) { return x|y; }
|
3644 | function bnOr(a) { var r = nbi(); this.bitwiseTo(a,op_or,r); return r; }
|
3645 |
|
3646 |
|
3647 | function op_xor(x,y) { return x^y; }
|
3648 | function bnXor(a) { var r = nbi(); this.bitwiseTo(a,op_xor,r); return r; }
|
3649 |
|
3650 |
|
3651 | function op_andnot(x,y) { return x&~y; }
|
3652 | function bnAndNot(a) { var r = nbi(); this.bitwiseTo(a,op_andnot,r); return r; }
|
3653 |
|
3654 |
|
3655 | function bnNot() {
|
3656 | var r = nbi();
|
3657 | for(var i = 0; i < this.t; ++i) r[i] = this.DM&~this[i];
|
3658 | r.t = this.t;
|
3659 | r.s = ~this.s;
|
3660 | return r;
|
3661 | }
|
3662 |
|
3663 |
|
3664 | function bnShiftLeft(n) {
|
3665 | var r = nbi();
|
3666 | if(n < 0) this.rShiftTo(-n,r); else this.lShiftTo(n,r);
|
3667 | return r;
|
3668 | }
|
3669 |
|
3670 |
|
3671 | function bnShiftRight(n) {
|
3672 | var r = nbi();
|
3673 | if(n < 0) this.lShiftTo(-n,r); else this.rShiftTo(n,r);
|
3674 | return r;
|
3675 | }
|
3676 |
|
3677 |
|
3678 | function lbit(x) {
|
3679 | if(x == 0) return -1;
|
3680 | var r = 0;
|
3681 | if((x&0xffff) == 0) { x >>= 16; r += 16; }
|
3682 | if((x&0xff) == 0) { x >>= 8; r += 8; }
|
3683 | if((x&0xf) == 0) { x >>= 4; r += 4; }
|
3684 | if((x&3) == 0) { x >>= 2; r += 2; }
|
3685 | if((x&1) == 0) ++r;
|
3686 | return r;
|
3687 | }
|
3688 |
|
3689 |
|
3690 | function bnGetLowestSetBit() {
|
3691 | for(var i = 0; i < this.t; ++i)
|
3692 | if(this[i] != 0) return i*this.DB+lbit(this[i]);
|
3693 | if(this.s < 0) return this.t*this.DB;
|
3694 | return -1;
|
3695 | }
|
3696 |
|
3697 |
|
3698 | function cbit(x) {
|
3699 | var r = 0;
|
3700 | while(x != 0) { x &= x-1; ++r; }
|
3701 | return r;
|
3702 | }
|
3703 |
|
3704 |
|
3705 | function bnBitCount() {
|
3706 | var r = 0, x = this.s&this.DM;
|
3707 | for(var i = 0; i < this.t; ++i) r += cbit(this[i]^x);
|
3708 | return r;
|
3709 | }
|
3710 |
|
3711 |
|
3712 | function bnTestBit(n) {
|
3713 | var j = Math.floor(n/this.DB);
|
3714 | if(j >= this.t) return(this.s!=0);
|
3715 | return((this[j]&(1<<(n%this.DB)))!=0);
|
3716 | }
|
3717 |
|
3718 |
|
3719 | function bnpChangeBit(n,op) {
|
3720 | var r = BigInteger.ONE.shiftLeft(n);
|
3721 | this.bitwiseTo(r,op,r);
|
3722 | return r;
|
3723 | }
|
3724 |
|
3725 |
|
3726 | function bnSetBit(n) { return this.changeBit(n,op_or); }
|
3727 |
|
3728 |
|
3729 | function bnClearBit(n) { return this.changeBit(n,op_andnot); }
|
3730 |
|
3731 |
|
3732 | function bnFlipBit(n) { return this.changeBit(n,op_xor); }
|
3733 |
|
3734 |
|
3735 | function bnpAddTo(a,r) {
|
3736 | var i = 0, c = 0, m = Math.min(a.t,this.t);
|
3737 | while(i < m) {
|
3738 | c += this[i]+a[i];
|
3739 | r[i++] = c&this.DM;
|
3740 | c >>= this.DB;
|
3741 | }
|
3742 | if(a.t < this.t) {
|
3743 | c += a.s;
|
3744 | while(i < this.t) {
|
3745 | c += this[i];
|
3746 | r[i++] = c&this.DM;
|
3747 | c >>= this.DB;
|
3748 | }
|
3749 | c += this.s;
|
3750 | }
|
3751 | else {
|
3752 | c += this.s;
|
3753 | while(i < a.t) {
|
3754 | c += a[i];
|
3755 | r[i++] = c&this.DM;
|
3756 | c >>= this.DB;
|
3757 | }
|
3758 | c += a.s;
|
3759 | }
|
3760 | r.s = (c<0)?-1:0;
|
3761 | if(c > 0) r[i++] = c;
|
3762 | else if(c < -1) r[i++] = this.DV+c;
|
3763 | r.t = i;
|
3764 | r.clamp();
|
3765 | }
|
3766 |
|
3767 |
|
3768 | function bnAdd(a) { var r = nbi(); this.addTo(a,r); return r; }
|
3769 |
|
3770 |
|
3771 | function bnSubtract(a) { var r = nbi(); this.subTo(a,r); return r; }
|
3772 |
|
3773 |
|
3774 | function bnMultiply(a) { var r = nbi(); this.multiplyTo(a,r); return r; }
|
3775 |
|
3776 |
|
3777 | function bnSquare() { var r = nbi(); this.squareTo(r); return r; }
|
3778 |
|
3779 |
|
3780 | function bnDivide(a) { var r = nbi(); this.divRemTo(a,r,null); return r; }
|
3781 |
|
3782 |
|
3783 | function bnRemainder(a) { var r = nbi(); this.divRemTo(a,null,r); return r; }
|
3784 |
|
3785 |
|
3786 | function bnDivideAndRemainder(a) {
|
3787 | var q = nbi(), r = nbi();
|
3788 | this.divRemTo(a,q,r);
|
3789 | return new Array(q,r);
|
3790 | }
|
3791 |
|
3792 |
|
3793 | function bnpDMultiply(n) {
|
3794 | this[this.t] = this.am(0,n-1,this,0,0,this.t);
|
3795 | ++this.t;
|
3796 | this.clamp();
|
3797 | }
|
3798 |
|
3799 |
|
3800 | function bnpDAddOffset(n,w) {
|
3801 | if(n == 0) return;
|
3802 | while(this.t <= w) this[this.t++] = 0;
|
3803 | this[w] += n;
|
3804 | while(this[w] >= this.DV) {
|
3805 | this[w] -= this.DV;
|
3806 | if(++w >= this.t) this[this.t++] = 0;
|
3807 | ++this[w];
|
3808 | }
|
3809 | }
|
3810 |
|
3811 |
|
3812 | function NullExp() {}
|
3813 | function nNop(x) { return x; }
|
3814 | function nMulTo(x,y,r) { x.multiplyTo(y,r); }
|
3815 | function nSqrTo(x,r) { x.squareTo(r); }
|
3816 |
|
3817 | NullExp.prototype.convert = nNop;
|
3818 | NullExp.prototype.revert = nNop;
|
3819 | NullExp.prototype.mulTo = nMulTo;
|
3820 | NullExp.prototype.sqrTo = nSqrTo;
|
3821 |
|
3822 |
|
3823 | function bnPow(e) { return this.exp(e,new NullExp()); }
|
3824 |
|
3825 |
|
3826 |
|
3827 | function bnpMultiplyLowerTo(a,n,r) {
|
3828 | var i = Math.min(this.t+a.t,n);
|
3829 | r.s = 0;
|
3830 | r.t = i;
|
3831 | while(i > 0) r[--i] = 0;
|
3832 | var j;
|
3833 | for(j = r.t-this.t; i < j; ++i) r[i+this.t] = this.am(0,a[i],r,i,0,this.t);
|
3834 | for(j = Math.min(a.t,n); i < j; ++i) this.am(0,a[i],r,i,0,n-i);
|
3835 | r.clamp();
|
3836 | }
|
3837 |
|
3838 |
|
3839 |
|
3840 | function bnpMultiplyUpperTo(a,n,r) {
|
3841 | --n;
|
3842 | var i = r.t = this.t+a.t-n;
|
3843 | r.s = 0;
|
3844 | while(--i >= 0) r[i] = 0;
|
3845 | for(i = Math.max(n-this.t,0); i < a.t; ++i)
|
3846 | r[this.t+i-n] = this.am(n-i,a[i],r,0,0,this.t+i-n);
|
3847 | r.clamp();
|
3848 | r.drShiftTo(1,r);
|
3849 | }
|
3850 |
|
3851 |
|
3852 | function Barrett(m) {
|
3853 |
|
3854 | this.r2 = nbi();
|
3855 | this.q3 = nbi();
|
3856 | BigInteger.ONE.dlShiftTo(2*m.t,this.r2);
|
3857 | this.mu = this.r2.divide(m);
|
3858 | this.m = m;
|
3859 | }
|
3860 |
|
3861 | function barrettConvert(x) {
|
3862 | if(x.s < 0 || x.t > 2*this.m.t) return x.mod(this.m);
|
3863 | else if(x.compareTo(this.m) < 0) return x;
|
3864 | else { var r = nbi(); x.copyTo(r); this.reduce(r); return r; }
|
3865 | }
|
3866 |
|
3867 | function barrettRevert(x) { return x; }
|
3868 |
|
3869 |
|
3870 | function barrettReduce(x) {
|
3871 | x.drShiftTo(this.m.t-1,this.r2);
|
3872 | if(x.t > this.m.t+1) { x.t = this.m.t+1; x.clamp(); }
|
3873 | this.mu.multiplyUpperTo(this.r2,this.m.t+1,this.q3);
|
3874 | this.m.multiplyLowerTo(this.q3,this.m.t+1,this.r2);
|
3875 | while(x.compareTo(this.r2) < 0) x.dAddOffset(1,this.m.t+1);
|
3876 | x.subTo(this.r2,x);
|
3877 | while(x.compareTo(this.m) >= 0) x.subTo(this.m,x);
|
3878 | }
|
3879 |
|
3880 |
|
3881 | function barrettSqrTo(x,r) { x.squareTo(r); this.reduce(r); }
|
3882 |
|
3883 |
|
3884 | function barrettMulTo(x,y,r) { x.multiplyTo(y,r); this.reduce(r); }
|
3885 |
|
3886 | Barrett.prototype.convert = barrettConvert;
|
3887 | Barrett.prototype.revert = barrettRevert;
|
3888 | Barrett.prototype.reduce = barrettReduce;
|
3889 | Barrett.prototype.mulTo = barrettMulTo;
|
3890 | Barrett.prototype.sqrTo = barrettSqrTo;
|
3891 |
|
3892 |
|
3893 | function bnModPow(e,m) {
|
3894 | var i = e.bitLength(), k, r = nbv(1), z;
|
3895 | if(i <= 0) return r;
|
3896 | else if(i < 18) k = 1;
|
3897 | else if(i < 48) k = 3;
|
3898 | else if(i < 144) k = 4;
|
3899 | else if(i < 768) k = 5;
|
3900 | else k = 6;
|
3901 | if(i < 8)
|
3902 | z = new Classic(m);
|
3903 | else if(m.isEven())
|
3904 | z = new Barrett(m);
|
3905 | else
|
3906 | z = new Montgomery(m);
|
3907 |
|
3908 |
|
3909 | var g = new Array(), n = 3, k1 = k-1, km = (1<<k)-1;
|
3910 | g[1] = z.convert(this);
|
3911 | if(k > 1) {
|
3912 | var g2 = nbi();
|
3913 | z.sqrTo(g[1],g2);
|
3914 | while(n <= km) {
|
3915 | g[n] = nbi();
|
3916 | z.mulTo(g2,g[n-2],g[n]);
|
3917 | n += 2;
|
3918 | }
|
3919 | }
|
3920 |
|
3921 | var j = e.t-1, w, is1 = true, r2 = nbi(), t;
|
3922 | i = nbits(e[j])-1;
|
3923 | while(j >= 0) {
|
3924 | if(i >= k1) w = (e[j]>>(i-k1))&km;
|
3925 | else {
|
3926 | w = (e[j]&((1<<(i+1))-1))<<(k1-i);
|
3927 | if(j > 0) w |= e[j-1]>>(this.DB+i-k1);
|
3928 | }
|
3929 |
|
3930 | n = k;
|
3931 | while((w&1) == 0) { w >>= 1; --n; }
|
3932 | if((i -= n) < 0) { i += this.DB; --j; }
|
3933 | if(is1) {
|
3934 | g[w].copyTo(r);
|
3935 | is1 = false;
|
3936 | }
|
3937 | else {
|
3938 | while(n > 1) { z.sqrTo(r,r2); z.sqrTo(r2,r); n -= 2; }
|
3939 | if(n > 0) z.sqrTo(r,r2); else { t = r; r = r2; r2 = t; }
|
3940 | z.mulTo(r2,g[w],r);
|
3941 | }
|
3942 |
|
3943 | while(j >= 0 && (e[j]&(1<<i)) == 0) {
|
3944 | z.sqrTo(r,r2); t = r; r = r2; r2 = t;
|
3945 | if(--i < 0) { i = this.DB-1; --j; }
|
3946 | }
|
3947 | }
|
3948 | return z.revert(r);
|
3949 | }
|
3950 |
|
3951 |
|
3952 | function bnGCD(a) {
|
3953 | var x = (this.s<0)?this.negate():this.clone();
|
3954 | var y = (a.s<0)?a.negate():a.clone();
|
3955 | if(x.compareTo(y) < 0) { var t = x; x = y; y = t; }
|
3956 | var i = x.getLowestSetBit(), g = y.getLowestSetBit();
|
3957 | if(g < 0) return x;
|
3958 | if(i < g) g = i;
|
3959 | if(g > 0) {
|
3960 | x.rShiftTo(g,x);
|
3961 | y.rShiftTo(g,y);
|
3962 | }
|
3963 | while(x.signum() > 0) {
|
3964 | if((i = x.getLowestSetBit()) > 0) x.rShiftTo(i,x);
|
3965 | if((i = y.getLowestSetBit()) > 0) y.rShiftTo(i,y);
|
3966 | if(x.compareTo(y) >= 0) {
|
3967 | x.subTo(y,x);
|
3968 | x.rShiftTo(1,x);
|
3969 | }
|
3970 | else {
|
3971 | y.subTo(x,y);
|
3972 | y.rShiftTo(1,y);
|
3973 | }
|
3974 | }
|
3975 | if(g > 0) y.lShiftTo(g,y);
|
3976 | return y;
|
3977 | }
|
3978 |
|
3979 |
|
3980 | function bnpModInt(n) {
|
3981 | if(n <= 0) return 0;
|
3982 | var d = this.DV%n, r = (this.s<0)?n-1:0;
|
3983 | if(this.t > 0)
|
3984 | if(d == 0) r = this[0]%n;
|
3985 | else for(var i = this.t-1; i >= 0; --i) r = (d*r+this[i])%n;
|
3986 | return r;
|
3987 | }
|
3988 |
|
3989 |
|
3990 | function bnModInverse(m) {
|
3991 | var ac = m.isEven();
|
3992 | if((this.isEven() && ac) || m.signum() == 0) return BigInteger.ZERO;
|
3993 | var u = m.clone(), v = this.clone();
|
3994 | var a = nbv(1), b = nbv(0), c = nbv(0), d = nbv(1);
|
3995 | while(u.signum() != 0) {
|
3996 | while(u.isEven()) {
|
3997 | u.rShiftTo(1,u);
|
3998 | if(ac) {
|
3999 | if(!a.isEven() || !b.isEven()) { a.addTo(this,a); b.subTo(m,b); }
|
4000 | a.rShiftTo(1,a);
|
4001 | }
|
4002 | else if(!b.isEven()) b.subTo(m,b);
|
4003 | b.rShiftTo(1,b);
|
4004 | }
|
4005 | while(v.isEven()) {
|
4006 | v.rShiftTo(1,v);
|
4007 | if(ac) {
|
4008 | if(!c.isEven() || !d.isEven()) { c.addTo(this,c); d.subTo(m,d); }
|
4009 | c.rShiftTo(1,c);
|
4010 | }
|
4011 | else if(!d.isEven()) d.subTo(m,d);
|
4012 | d.rShiftTo(1,d);
|
4013 | }
|
4014 | if(u.compareTo(v) >= 0) {
|
4015 | u.subTo(v,u);
|
4016 | if(ac) a.subTo(c,a);
|
4017 | b.subTo(d,b);
|
4018 | }
|
4019 | else {
|
4020 | v.subTo(u,v);
|
4021 | if(ac) c.subTo(a,c);
|
4022 | d.subTo(b,d);
|
4023 | }
|
4024 | }
|
4025 | if(v.compareTo(BigInteger.ONE) != 0) return BigInteger.ZERO;
|
4026 | if(d.compareTo(m) >= 0) return d.subtract(m);
|
4027 | if(d.signum() < 0) d.addTo(m,d); else return d;
|
4028 | if(d.signum() < 0) return d.add(m); else return d;
|
4029 | }
|
4030 |
|
4031 | var lowprimes = [2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97,101,103,107,109,113,127,131,137,139,149,151,157,163,167,173,179,181,191,193,197,199,211,223,227,229,233,239,241,251,257,263,269,271,277,281,283,293,307,311,313,317,331,337,347,349,353,359,367,373,379,383,389,397,401,409,419,421,431,433,439,443,449,457,461,463,467,479,487,491,499,503,509,521,523,541,547,557,563,569,571,577,587,593,599,601,607,613,617,619,631,641,643,647,653,659,661,673,677,683,691,701,709,719,727,733,739,743,751,757,761,769,773,787,797,809,811,821,823,827,829,839,853,857,859,863,877,881,883,887,907,911,919,929,937,941,947,953,967,971,977,983,991,997];
|
4032 | var lplim = (1<<26)/lowprimes[lowprimes.length-1];
|
4033 |
|
4034 |
|
4035 | function bnIsProbablePrime(t) {
|
4036 | var i, x = this.abs();
|
4037 | if(x.t == 1 && x[0] <= lowprimes[lowprimes.length-1]) {
|
4038 | for(i = 0; i < lowprimes.length; ++i)
|
4039 | if(x[0] == lowprimes[i]) return true;
|
4040 | return false;
|
4041 | }
|
4042 | if(x.isEven()) return false;
|
4043 | i = 1;
|
4044 | while(i < lowprimes.length) {
|
4045 | var m = lowprimes[i], j = i+1;
|
4046 | while(j < lowprimes.length && m < lplim) m *= lowprimes[j++];
|
4047 | m = x.modInt(m);
|
4048 | while(i < j) if(m%lowprimes[i++] == 0) return false;
|
4049 | }
|
4050 | return x.millerRabin(t);
|
4051 | }
|
4052 |
|
4053 |
|
4054 | function bnpMillerRabin(t) {
|
4055 | var n1 = this.subtract(BigInteger.ONE);
|
4056 | var k = n1.getLowestSetBit();
|
4057 | if(k <= 0) return false;
|
4058 | var r = n1.shiftRight(k);
|
4059 | t = (t+1)>>1;
|
4060 | if(t > lowprimes.length) t = lowprimes.length;
|
4061 | var a = nbi();
|
4062 | for(var i = 0; i < t; ++i) {
|
4063 |
|
4064 | a.fromInt(lowprimes[Math.floor(Math.random()*lowprimes.length)]);
|
4065 | var y = a.modPow(r,this);
|
4066 | if(y.compareTo(BigInteger.ONE) != 0 && y.compareTo(n1) != 0) {
|
4067 | var j = 1;
|
4068 | while(j++ < k && y.compareTo(n1) != 0) {
|
4069 | y = y.modPowInt(2,this);
|
4070 | if(y.compareTo(BigInteger.ONE) == 0) return false;
|
4071 | }
|
4072 | if(y.compareTo(n1) != 0) return false;
|
4073 | }
|
4074 | }
|
4075 | return true;
|
4076 | }
|
4077 |
|
4078 | // protected
|
4079 | BigInteger.prototype.chunkSize = bnpChunkSize;
|
4080 | BigInteger.prototype.toRadix = bnpToRadix;
|
4081 | BigInteger.prototype.fromRadix = bnpFromRadix;
|
4082 | BigInteger.prototype.fromNumber = bnpFromNumber;
|
4083 | BigInteger.prototype.bitwiseTo = bnpBitwiseTo;
|
4084 | BigInteger.prototype.changeBit = bnpChangeBit;
|
4085 | BigInteger.prototype.addTo = bnpAddTo;
|
4086 | BigInteger.prototype.dMultiply = bnpDMultiply;
|
4087 | BigInteger.prototype.dAddOffset = bnpDAddOffset;
|
4088 | BigInteger.prototype.multiplyLowerTo = bnpMultiplyLowerTo;
|
4089 | BigInteger.prototype.multiplyUpperTo = bnpMultiplyUpperTo;
|
4090 | BigInteger.prototype.modInt = bnpModInt;
|
4091 | BigInteger.prototype.millerRabin = bnpMillerRabin;
|
4092 |
|
4093 | // public
|
4094 | BigInteger.prototype.clone = bnClone;
|
4095 | BigInteger.prototype.intValue = bnIntValue;
|
4096 | BigInteger.prototype.byteValue = bnByteValue;
|
4097 | BigInteger.prototype.shortValue = bnShortValue;
|
4098 | BigInteger.prototype.signum = bnSigNum;
|
4099 | BigInteger.prototype.toByteArray = bnToByteArray;
|
4100 | BigInteger.prototype.equals = bnEquals;
|
4101 | BigInteger.prototype.min = bnMin;
|
4102 | BigInteger.prototype.max = bnMax;
|
4103 | BigInteger.prototype.and = bnAnd;
|
4104 | BigInteger.prototype.or = bnOr;
|
4105 | BigInteger.prototype.xor = bnXor;
|
4106 | BigInteger.prototype.andNot = bnAndNot;
|
4107 | BigInteger.prototype.not = bnNot;
|
4108 | BigInteger.prototype.shiftLeft = bnShiftLeft;
|
4109 | BigInteger.prototype.shiftRight = bnShiftRight;
|
4110 | BigInteger.prototype.getLowestSetBit = bnGetLowestSetBit;
|
4111 | BigInteger.prototype.bitCount = bnBitCount;
|
4112 | BigInteger.prototype.testBit = bnTestBit;
|
4113 | BigInteger.prototype.setBit = bnSetBit;
|
4114 | BigInteger.prototype.clearBit = bnClearBit;
|
4115 | BigInteger.prototype.flipBit = bnFlipBit;
|
4116 | BigInteger.prototype.add = bnAdd;
|
4117 | BigInteger.prototype.subtract = bnSubtract;
|
4118 | BigInteger.prototype.multiply = bnMultiply;
|
4119 | BigInteger.prototype.divide = bnDivide;
|
4120 | BigInteger.prototype.remainder = bnRemainder;
|
4121 | BigInteger.prototype.divideAndRemainder = bnDivideAndRemainder;
|
4122 | BigInteger.prototype.modPow = bnModPow;
|
4123 | BigInteger.prototype.modInverse = bnModInverse;
|
4124 | BigInteger.prototype.pow = bnPow;
|
4125 | BigInteger.prototype.gcd = bnGCD;
|
4126 | BigInteger.prototype.isProbablePrime = bnIsProbablePrime;
|
4127 |
|
4128 | // JSBN-specific extension
|
4129 | BigInteger.prototype.square = bnSquare;
|
4130 |
|
4131 | // Expose the Barrett function
|
4132 | BigInteger.prototype.Barrett = Barrett
|
4133 |
|
4134 | // BigInteger interfaces not implemented in jsbn:
|
4135 |
|
4136 | // BigInteger(int signum, byte[] magnitude)
|
4137 | // double doubleValue()
|
4138 | // float floatValue()
|
4139 | // int hashCode()
|
4140 | // long longValue()
|
4141 | // static BigInteger valueOf(long val)
|
4142 |
|
4143 | // Random number generator - requires a PRNG backend, e.g. prng4.js
|
4144 |
|
4145 | // For best results, put code like
|
4146 | // <body onClick='rng_seed_time();' onKeyPress='rng_seed_time();'>
|
4147 | // in your main HTML document.
|
4148 |
|
4149 | var rng_state;
|
4150 | var rng_pool;
|
4151 | var rng_pptr;
|
4152 |
|
4153 | // Mix in a 32-bit integer into the pool
|
4154 | function rng_seed_int(x) {
|
4155 | rng_pool[rng_pptr++] ^= x & 255;
|
4156 | rng_pool[rng_pptr++] ^= (x >> 8) & 255;
|
4157 | rng_pool[rng_pptr++] ^= (x >> 16) & 255;
|
4158 | rng_pool[rng_pptr++] ^= (x >> 24) & 255;
|
4159 | if(rng_pptr >= rng_psize) rng_pptr -= rng_psize;
|
4160 | }
|
4161 |
|
4162 | // Mix in the current time (w/milliseconds) into the pool
|
4163 | function rng_seed_time() {
|
4164 | rng_seed_int(new Date().getTime());
|
4165 | }
|
4166 |
|
4167 | // Initialize the pool with junk if needed.
|
4168 | if(rng_pool == null) {
|
4169 | rng_pool = new Array();
|
4170 | rng_pptr = 0;
|
4171 | var t;
|
4172 | if(typeof window !== "undefined" && window.crypto) {
|
4173 | if (window.crypto.getRandomValues) {
|
4174 | // Use webcrypto if available
|
4175 | var ua = new Uint8Array(32);
|
4176 | window.crypto.getRandomValues(ua);
|
4177 | for(t = 0; t < 32; ++t)
|
4178 | rng_pool[rng_pptr++] = ua[t];
|
4179 | }
|
4180 | else if(navigator.appName == "Netscape" && navigator.appVersion < "5") {
|
4181 | // Extract entropy (256 bits) from NS4 RNG if available
|
4182 | var z = window.crypto.random(32);
|
4183 | for(t = 0; t < z.length; ++t)
|
4184 | rng_pool[rng_pptr++] = z.charCodeAt(t) & 255;
|
4185 | }
|
4186 | }
|
4187 | while(rng_pptr < rng_psize) { // extract some randomness from Math.random()
|
4188 | t = Math.floor(65536 * Math.random());
|
4189 | rng_pool[rng_pptr++] = t >>> 8;
|
4190 | rng_pool[rng_pptr++] = t & 255;
|
4191 | }
|
4192 | rng_pptr = 0;
|
4193 | rng_seed_time();
|
4194 | //rng_seed_int(window.screenX);
|
4195 | //rng_seed_int(window.screenY);
|
4196 | }
|
4197 |
|
4198 | function rng_get_byte() {
|
4199 | if(rng_state == null) {
|
4200 | rng_seed_time();
|
4201 | rng_state = prng_newstate();
|
4202 | rng_state.init(rng_pool);
|
4203 | for(rng_pptr = 0; rng_pptr < rng_pool.length; ++rng_pptr)
|
4204 | rng_pool[rng_pptr] = 0;
|
4205 | rng_pptr = 0;
|
4206 | //rng_pool = null;
|
4207 | }
|
4208 | // TODO: allow reseeding after first request
|
4209 | return rng_state.next();
|
4210 | }
|
4211 |
|
4212 | function rng_get_bytes(ba) {
|
4213 | var i;
|
4214 | for(i = 0; i < ba.length; ++i) ba[i] = rng_get_byte();
|
4215 | }
|
4216 |
|
4217 | function SecureRandom() {}
|
4218 |
|
4219 | SecureRandom.prototype.nextBytes = rng_get_bytes;
|
4220 |
|
4221 | // prng4.js - uses Arcfour as a PRNG
|
4222 |
|
4223 | function Arcfour() {
|
4224 | this.i = 0;
|
4225 | this.j = 0;
|
4226 | this.S = new Array();
|
4227 | }
|
4228 |
|
4229 | // Initialize arcfour context from key, an array of ints, each from [0..255]
|
4230 | function ARC4init(key) {
|
4231 | var i, j, t;
|
4232 | for(i = 0; i < 256; ++i)
|
4233 | this.S[i] = i;
|
4234 | j = 0;
|
4235 | for(i = 0; i < 256; ++i) {
|
4236 | j = (j + this.S[i] + key[i % key.length]) & 255;
|
4237 | t = this.S[i];
|
4238 | this.S[i] = this.S[j];
|
4239 | this.S[j] = t;
|
4240 | }
|
4241 | this.i = 0;
|
4242 | this.j = 0;
|
4243 | }
|
4244 |
|
4245 | function ARC4next() {
|
4246 | var t;
|
4247 | this.i = (this.i + 1) & 255;
|
4248 | this.j = (this.j + this.S[this.i]) & 255;
|
4249 | t = this.S[this.i];
|
4250 | this.S[this.i] = this.S[this.j];
|
4251 | this.S[this.j] = t;
|
4252 | return this.S[(t + this.S[this.i]) & 255];
|
4253 | }
|
4254 |
|
4255 | Arcfour.prototype.init = ARC4init;
|
4256 | Arcfour.prototype.next = ARC4next;
|
4257 |
|
4258 | // Plug in your RNG constructor here
|
4259 | function prng_newstate() {
|
4260 | return new Arcfour();
|
4261 | }
|
4262 |
|
4263 | // Pool size must be a multiple of 4 and greater than 32.
|
4264 | // An array of bytes the size of the pool will be passed to init()
|
4265 | var rng_psize = 256;
|
4266 |
|
4267 | if (true) {
|
4268 | exports = module.exports = {
|
4269 | default: BigInteger,
|
4270 | BigInteger: BigInteger,
|
4271 | SecureRandom: SecureRandom,
|
4272 | };
|
4273 | } else {
|
4274 | this.jsbn = {
|
4275 | BigInteger: BigInteger,
|
4276 | SecureRandom: SecureRandom
|
4277 | };
|
4278 | }
|
4279 |
|
4280 | }).call(this);
|
4281 |
|
4282 |
|
4283 | /***/ }),
|
4284 | /* 60 */
|
4285 | /***/ (function(module, exports, __webpack_require__) {
|
4286 |
|
4287 | var _concat = __webpack_require__(9);
|
4288 | var _curry3 = __webpack_require__(2);
|
4289 |
|
4290 |
|
4291 | /**
|
4292 | * Applies a function to the value at the given index of an array, returning a
|
4293 | * new copy of the array with the element at the given index replaced with the
|
4294 | * result of the function application.
|
4295 | *
|
4296 | * @func
|
4297 | * @memberOf R
|
4298 | * @since v0.14.0
|
4299 | * @category List
|
4300 | * @sig (a -> a) -> Number -> [a] -> [a]
|
4301 | * @param {Function} fn The function to apply.
|
4302 | * @param {Number} idx The index.
|
4303 | * @param {Array|Arguments} list An array-like object whose value
|
4304 | * at the supplied index will be replaced.
|
4305 | * @return {Array} A copy of the supplied array-like object with
|
4306 | * the element at index `idx` replaced with the value
|
4307 | * returned by applying `fn` to the existing element.
|
4308 | * @see R.update
|
4309 | * @example
|
4310 | *
|
4311 | * R.adjust(R.add(10), 1, [1, 2, 3]); //=> [1, 12, 3]
|
4312 | * R.adjust(R.add(10))(1)([1, 2, 3]); //=> [1, 12, 3]
|
4313 | * @symb R.adjust(f, -1, [a, b]) = [a, f(b)]
|
4314 | * @symb R.adjust(f, 0, [a, b]) = [f(a), b]
|
4315 | */
|
4316 | module.exports = _curry3(function adjust(fn, idx, list) {
|
4317 | if (idx >= list.length || idx < -list.length) {
|
4318 | return list;
|
4319 | }
|
4320 | var start = idx < 0 ? list.length : 0;
|
4321 | var _idx = start + idx;
|
4322 | var _list = _concat(list);
|
4323 | _list[_idx] = fn(list[_idx]);
|
4324 | return _list;
|
4325 | });
|
4326 |
|
4327 |
|
4328 | /***/ }),
|
4329 | /* 61 */
|
4330 | /***/ (function(module, exports, __webpack_require__) {
|
4331 |
|
4332 | var _curry2 = __webpack_require__(0);
|
4333 |
|
4334 |
|
4335 | /**
|
4336 | * Returns `true` if both arguments are `true`; `false` otherwise.
|
4337 | *
|
4338 | * @func
|
4339 | * @memberOf R
|
4340 | * @since v0.1.0
|
4341 | * @category Logic
|
4342 | * @sig a -> b -> a | b
|
4343 | * @param {Any} a
|
4344 | * @param {Any} b
|
4345 | * @return {Any} the first argument if it is falsy, otherwise the second argument.
|
4346 | * @see R.both
|
4347 | * @example
|
4348 | *
|
4349 | * R.and(true, true); //=> true
|
4350 | * R.and(true, false); //=> false
|
4351 | * R.and(false, true); //=> false
|
4352 | * R.and(false, false); //=> false
|
4353 | */
|
4354 | module.exports = _curry2(function and(a, b) {
|
4355 | return a && b;
|
4356 | });
|
4357 |
|
4358 |
|
4359 | /***/ }),
|
4360 | /* 62 */
|
4361 | /***/ (function(module, exports, __webpack_require__) {
|
4362 |
|
4363 | var _curry2 = __webpack_require__(0);
|
4364 | var _dispatchable = __webpack_require__(3);
|
4365 | var _xany = __webpack_require__(88);
|
4366 |
|
4367 |
|
4368 | /**
|
4369 | * Returns `true` if at least one of elements of the list match the predicate,
|
4370 | * `false` otherwise.
|
4371 | *
|
4372 | * Dispatches to the `any` method of the second argument, if present.
|
4373 | *
|
4374 | * Acts as a transducer if a transformer is given in list position.
|
4375 | *
|
4376 | * @func
|
4377 | * @memberOf R
|
4378 | * @since v0.1.0
|
4379 | * @category List
|
4380 | * @sig (a -> Boolean) -> [a] -> Boolean
|
4381 | * @param {Function} fn The predicate function.
|
4382 | * @param {Array} list The array to consider.
|
4383 | * @return {Boolean} `true` if the predicate is satisfied by at least one element, `false`
|
4384 | * otherwise.
|
4385 | * @see R.all, R.none, R.transduce
|
4386 | * @example
|
4387 | *
|
4388 | * var lessThan0 = R.flip(R.lt)(0);
|
4389 | * var lessThan2 = R.flip(R.lt)(2);
|
4390 | * R.any(lessThan0)([1, 2]); //=> false
|
4391 | * R.any(lessThan2)([1, 2]); //=> true
|
4392 | */
|
4393 | module.exports = _curry2(_dispatchable(['any'], _xany, function any(fn, list) {
|
4394 | var idx = 0;
|
4395 | while (idx < list.length) {
|
4396 | if (fn(list[idx])) {
|
4397 | return true;
|
4398 | }
|
4399 | idx += 1;
|
4400 | }
|
4401 | return false;
|
4402 | }));
|
4403 |
|
4404 |
|
4405 | /***/ }),
|
4406 | /* 63 */
|
4407 | /***/ (function(module, exports, __webpack_require__) {
|
4408 |
|
4409 | var _curry2 = __webpack_require__(0);
|
4410 |
|
4411 |
|
4412 | /**
|
4413 | * Applies function `fn` to the argument list `args`. This is useful for
|
4414 | * creating a fixed-arity function from a variadic function. `fn` should be a
|
4415 | * bound function if context is significant.
|
4416 | *
|
4417 | * @func
|
4418 | * @memberOf R
|
4419 | * @since v0.7.0
|
4420 | * @category Function
|
4421 | * @sig (*... -> a) -> [*] -> a
|
4422 | * @param {Function} fn The function which will be called with `args`
|
4423 | * @param {Array} args The arguments to call `fn` with
|
4424 | * @return {*} result The result, equivalent to `fn(...args)`
|
4425 | * @see R.call, R.unapply
|
4426 | * @example
|
4427 | *
|
4428 | * var nums = [1, 2, 3, -99, 42, 6, 7];
|
4429 | * R.apply(Math.max, nums); //=> 42
|
4430 | * @symb R.apply(f, [a, b, c]) = f(a, b, c)
|
4431 | */
|
4432 | module.exports = _curry2(function apply(fn, args) {
|
4433 | return fn.apply(this, args);
|
4434 | });
|
4435 |
|
4436 |
|
4437 | /***/ }),
|
4438 | /* 64 */
|
4439 | /***/ (function(module, exports, __webpack_require__) {
|
4440 |
|
4441 | var _curry3 = __webpack_require__(2);
|
4442 | var _has = __webpack_require__(6);
|
4443 | var _isArray = __webpack_require__(15);
|
4444 | var _isInteger = __webpack_require__(84);
|
4445 | var assoc = __webpack_require__(30);
|
4446 |
|
4447 |
|
4448 | /**
|
4449 | * Makes a shallow clone of an object, setting or overriding the nodes required
|
4450 | * to create the given path, and placing the specific value at the tail end of
|
4451 | * that path. Note that this copies and flattens prototype properties onto the
|
4452 | * new object as well. All non-primitive properties are copied by reference.
|
4453 | *
|
4454 | * @func
|
4455 | * @memberOf R
|
4456 | * @since v0.8.0
|
4457 | * @category Object
|
4458 | * @typedefn Idx = String | Int
|
4459 | * @sig [Idx] -> a -> {a} -> {a}
|
4460 | * @param {Array} path the path to set
|
4461 | * @param {*} val The new value
|
4462 | * @param {Object} obj The object to clone
|
4463 | * @return {Object} A new object equivalent to the original except along the specified path.
|
4464 | * @see R.dissocPath
|
4465 | * @example
|
4466 | *
|
4467 | * R.assocPath(['a', 'b', 'c'], 42, {a: {b: {c: 0}}}); //=> {a: {b: {c: 42}}}
|
4468 | *
|
4469 | * // Any missing or non-object keys in path will be overridden
|
4470 | * R.assocPath(['a', 'b', 'c'], 42, {a: 5}); //=> {a: {b: {c: 42}}}
|
4471 | */
|
4472 | module.exports = _curry3(function assocPath(path, val, obj) {
|
4473 | if (path.length === 0) {
|
4474 | return val;
|
4475 | }
|
4476 | var idx = path[0];
|
4477 | if (path.length > 1) {
|
4478 | var nextObj = _has(idx, obj) ? obj[idx] : _isInteger(path[1]) ? [] : {};
|
4479 | val = assocPath(Array.prototype.slice.call(path, 1), val, nextObj);
|
4480 | }
|
4481 | if (_isInteger(idx) && _isArray(obj)) {
|
4482 | var arr = [].concat(obj);
|
4483 | arr[idx] = val;
|
4484 | return arr;
|
4485 | } else {
|
4486 | return assoc(idx, val, obj);
|
4487 | }
|
4488 | });
|
4489 |
|
4490 |
|
4491 | /***/ }),
|
4492 | /* 65 */
|
4493 | /***/ (function(module, exports, __webpack_require__) {
|
4494 |
|
4495 | var _arity = __webpack_require__(11);
|
4496 | var _curry2 = __webpack_require__(0);
|
4497 |
|
4498 |
|
4499 | /**
|
4500 | * Creates a function that is bound to a context.
|
4501 | * Note: `R.bind` does not provide the additional argument-binding capabilities of
|
4502 | * [Function.prototype.bind](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind).
|
4503 | *
|
4504 | * @func
|
4505 | * @memberOf R
|
4506 | * @since v0.6.0
|
4507 | * @category Function
|
4508 | * @category Object
|
4509 | * @sig (* -> *) -> {*} -> (* -> *)
|
4510 | * @param {Function} fn The function to bind to context
|
4511 | * @param {Object} thisObj The context to bind `fn` to
|
4512 | * @return {Function} A function that will execute in the context of `thisObj`.
|
4513 | * @see R.partial
|
4514 | * @example
|
4515 | *
|
4516 | * var log = R.bind(console.log, console);
|
4517 | * R.pipe(R.assoc('a', 2), R.tap(log), R.assoc('a', 3))({a: 1}); //=> {a: 3}
|
4518 | * // logs {a: 2}
|
4519 | * @symb R.bind(f, o)(a, b) = f.call(o, a, b)
|
4520 | */
|
4521 | module.exports = _curry2(function bind(fn, thisObj) {
|
4522 | return _arity(fn.length, function() {
|
4523 | return fn.apply(thisObj, arguments);
|
4524 | });
|
4525 | });
|
4526 |
|
4527 |
|
4528 | /***/ }),
|
4529 | /* 66 */
|
4530 | /***/ (function(module, exports, __webpack_require__) {
|
4531 |
|
4532 | var chain = __webpack_require__(45);
|
4533 | var compose = __webpack_require__(46);
|
4534 | var map = __webpack_require__(7);
|
4535 |
|
4536 |
|
4537 | /**
|
4538 | * Returns the right-to-left Kleisli composition of the provided functions,
|
4539 | * each of which must return a value of a type supported by [`chain`](#chain).
|
4540 | *
|
4541 | * `R.composeK(h, g, f)` is equivalent to `R.compose(R.chain(h), R.chain(g), R.chain(f))`.
|
4542 | *
|
4543 | * @func
|
4544 | * @memberOf R
|
4545 | * @since v0.16.0
|
4546 | * @category Function
|
4547 | * @sig Chain m => ((y -> m z), (x -> m y), ..., (a -> m b)) -> (a -> m z)
|
4548 | * @param {...Function} ...functions The functions to compose
|
4549 | * @return {Function}
|
4550 | * @see R.pipeK
|
4551 | * @example
|
4552 | *
|
4553 | * // get :: String -> Object -> Maybe *
|
4554 | * var get = R.curry((propName, obj) => Maybe(obj[propName]))
|
4555 | *
|
4556 | * // getStateCode :: Maybe String -> Maybe String
|
4557 | * var getStateCode = R.composeK(
|
4558 | * R.compose(Maybe.of, R.toUpper),
|
4559 | * get('state'),
|
4560 | * get('address'),
|
4561 | * get('user'),
|
4562 | * );
|
4563 | * getStateCode({"user":{"address":{"state":"ny"}}}); //=> Maybe.Just("NY")
|
4564 | * getStateCode({}); //=> Maybe.Nothing()
|
4565 | * @symb R.composeK(f, g, h)(a) = R.chain(f, R.chain(g, h(a)))
|
4566 | */
|
4567 | module.exports = function composeK() {
|
4568 | if (arguments.length === 0) {
|
4569 | throw new Error('composeK requires at least one argument');
|
4570 | }
|
4571 | var init = Array.prototype.slice.call(arguments);
|
4572 | var last = init.pop();
|
4573 | return compose(compose.apply(this, map(chain, init)), last);
|
4574 | };
|
4575 |
|
4576 |
|
4577 | /***/ }),
|
4578 | /* 67 */
|
4579 | /***/ (function(module, exports, __webpack_require__) {
|
4580 |
|
4581 | var _curry2 = __webpack_require__(0);
|
4582 | var curry = __webpack_require__(31);
|
4583 | var nAry = __webpack_require__(40);
|
4584 |
|
4585 |
|
4586 | /**
|
4587 | * Wraps a constructor function inside a curried function that can be called
|
4588 | * with the same arguments and returns the same type. The arity of the function
|
4589 | * returned is specified to allow using variadic constructor functions.
|
4590 | *
|
4591 | * @func
|
4592 | * @memberOf R
|
4593 | * @since v0.4.0
|
4594 | * @category Function
|
4595 | * @sig Number -> (* -> {*}) -> (* -> {*})
|
4596 | * @param {Number} n The arity of the constructor function.
|
4597 | * @param {Function} Fn The constructor function to wrap.
|
4598 | * @return {Function} A wrapped, curried constructor function.
|
4599 | * @example
|
4600 | *
|
4601 | * // Variadic Constructor function
|
4602 | * function Salad() {
|
4603 | * this.ingredients = arguments;
|
4604 | * };
|
4605 | * Salad.prototype.recipe = function() {
|
4606 | * var instructions = R.map((ingredient) => (
|
4607 | * 'Add a whollop of ' + ingredient, this.ingredients)
|
4608 | * )
|
4609 | * return R.join('\n', instructions)
|
4610 | * }
|
4611 | *
|
4612 | * var ThreeLayerSalad = R.constructN(3, Salad)
|
4613 | *
|
4614 | * // Notice we no longer need the 'new' keyword, and the constructor is curried for 3 arguments.
|
4615 | * var salad = ThreeLayerSalad('Mayonnaise')('Potato Chips')('Ketchup')
|
4616 | * console.log(salad.recipe());
|
4617 | * // Add a whollop of Mayonnaise
|
4618 | * // Add a whollop of Potato Chips
|
4619 | * // Add a whollop of Potato Ketchup
|
4620 | */
|
4621 | module.exports = _curry2(function constructN(n, Fn) {
|
4622 | if (n > 10) {
|
4623 | throw new Error('Constructor with greater than ten arguments');
|
4624 | }
|
4625 | if (n === 0) {
|
4626 | return function() { return new Fn(); };
|
4627 | }
|
4628 | return curry(nAry(n, function($0, $1, $2, $3, $4, $5, $6, $7, $8, $9) {
|
4629 | switch (arguments.length) {
|
4630 | case 1: return new Fn($0);
|
4631 | case 2: return new Fn($0, $1);
|
4632 | case 3: return new Fn($0, $1, $2);
|
4633 | case 4: return new Fn($0, $1, $2, $3);
|
4634 | case 5: return new Fn($0, $1, $2, $3, $4);
|
4635 | case 6: return new Fn($0, $1, $2, $3, $4, $5);
|
4636 | case 7: return new Fn($0, $1, $2, $3, $4, $5, $6);
|
4637 | case 8: return new Fn($0, $1, $2, $3, $4, $5, $6, $7);
|
4638 | case 9: return new Fn($0, $1, $2, $3, $4, $5, $6, $7, $8);
|
4639 | case 10: return new Fn($0, $1, $2, $3, $4, $5, $6, $7, $8, $9);
|
4640 | }
|
4641 | }));
|
4642 | });
|
4643 |
|
4644 |
|
4645 | /***/ }),
|
4646 | /* 68 */
|
4647 | /***/ (function(module, exports, __webpack_require__) {
|
4648 |
|
4649 | var _curry2 = __webpack_require__(0);
|
4650 | var _map = __webpack_require__(37);
|
4651 | var curryN = __webpack_require__(5);
|
4652 | var max = __webpack_require__(20);
|
4653 | var pluck = __webpack_require__(26);
|
4654 | var reduce = __webpack_require__(13);
|
4655 |
|
4656 |
|
4657 | /**
|
4658 | * Accepts a converging function and a list of branching functions and returns
|
4659 | * a new function. When invoked, this new function is applied to some
|
4660 | * arguments, each branching function is applied to those same arguments. The
|
4661 | * results of each branching function are passed as arguments to the converging
|
4662 | * function to produce the return value.
|
4663 | *
|
4664 | * @func
|
4665 | * @memberOf R
|
4666 | * @since v0.4.2
|
4667 | * @category Function
|
4668 | * @sig (x1 -> x2 -> ... -> z) -> [(a -> b -> ... -> x1), (a -> b -> ... -> x2), ...] -> (a -> b -> ... -> z)
|
4669 | * @param {Function} after A function. `after` will be invoked with the return values of
|
4670 | * `fn1` and `fn2` as its arguments.
|
4671 | * @param {Array} functions A list of functions.
|
4672 | * @return {Function} A new function.
|
4673 | * @see R.useWith
|
4674 | * @example
|
4675 | *
|
4676 | * var average = R.converge(R.divide, [R.sum, R.length])
|
4677 | * average([1, 2, 3, 4, 5, 6, 7]) //=> 4
|
4678 | *
|
4679 | * var strangeConcat = R.converge(R.concat, [R.toUpper, R.toLower])
|
4680 | * strangeConcat("Yodel") //=> "YODELyodel"
|
4681 | *
|
4682 | * @symb R.converge(f, [g, h])(a, b) = f(g(a, b), h(a, b))
|
4683 | */
|
4684 | module.exports = _curry2(function converge(after, fns) {
|
4685 | return curryN(reduce(max, 0, pluck('length', fns)), function() {
|
4686 | var args = arguments;
|
4687 | var context = this;
|
4688 | return after.apply(context, _map(function(fn) {
|
4689 | return fn.apply(context, args);
|
4690 | }, fns));
|
4691 | });
|
4692 | });
|
4693 |
|
4694 |
|
4695 | /***/ }),
|
4696 | /* 69 */
|
4697 | /***/ (function(module, exports, __webpack_require__) {
|
4698 |
|
4699 | var _curry2 = __webpack_require__(0);
|
4700 |
|
4701 |
|
4702 | /**
|
4703 | * Returns the second argument if it is not `null`, `undefined` or `NaN`
|
4704 | * otherwise the first argument is returned.
|
4705 | *
|
4706 | * @func
|
4707 | * @memberOf R
|
4708 | * @since v0.10.0
|
4709 | * @category Logic
|
4710 | * @sig a -> b -> a | b
|
4711 | * @param {a} default The default value.
|
4712 | * @param {b} val `val` will be returned instead of `default` unless `val` is `null`, `undefined` or `NaN`.
|
4713 | * @return {*} The second value if it is not `null`, `undefined` or `NaN`, otherwise the default value
|
4714 | * @example
|
4715 | *
|
4716 | * var defaultTo42 = R.defaultTo(42);
|
4717 | *
|
4718 | * defaultTo42(null); //=> 42
|
4719 | * defaultTo42(undefined); //=> 42
|
4720 | * defaultTo42('Ramda'); //=> 'Ramda'
|
4721 | * // parseInt('string') results in NaN
|
4722 | * defaultTo42(parseInt('string')); //=> 42
|
4723 | */
|
4724 | module.exports = _curry2(function defaultTo(d, v) {
|
4725 | return v == null || v !== v ? d : v;
|
4726 | });
|
4727 |
|
4728 |
|
4729 | /***/ }),
|
4730 | /* 70 */
|
4731 | /***/ (function(module, exports, __webpack_require__) {
|
4732 |
|
4733 | var _contains = __webpack_require__(17);
|
4734 | var _curry2 = __webpack_require__(0);
|
4735 |
|
4736 |
|
4737 | /**
|
4738 | * Finds the set (i.e. no duplicates) of all elements in the first list not
|
4739 | * contained in the second list. Objects and Arrays are compared are compared
|
4740 | * in terms of value equality, not reference equality.
|
4741 | *
|
4742 | * @func
|
4743 | * @memberOf R
|
4744 | * @since v0.1.0
|
4745 | * @category Relation
|
4746 | * @sig [*] -> [*] -> [*]
|
4747 | * @param {Array} list1 The first list.
|
4748 | * @param {Array} list2 The second list.
|
4749 | * @return {Array} The elements in `list1` that are not in `list2`.
|
4750 | * @see R.differenceWith, R.symmetricDifference, R.symmetricDifferenceWith
|
4751 | * @example
|
4752 | *
|
4753 | * R.difference([1,2,3,4], [7,6,5,4,3]); //=> [1,2]
|
4754 | * R.difference([7,6,5,4,3], [1,2,3,4]); //=> [7,6,5]
|
4755 | * R.difference([{a: 1}, {b: 2}], [{a: 1}, {c: 3}]) //=> [{b: 2}]
|
4756 | */
|
4757 | module.exports = _curry2(function difference(first, second) {
|
4758 | var out = [];
|
4759 | var idx = 0;
|
4760 | var firstLen = first.length;
|
4761 | while (idx < firstLen) {
|
4762 | if (!_contains(first[idx], second) && !_contains(first[idx], out)) {
|
4763 | out[out.length] = first[idx];
|
4764 | }
|
4765 | idx += 1;
|
4766 | }
|
4767 | return out;
|
4768 | });
|
4769 |
|
4770 |
|
4771 | /***/ }),
|
4772 | /* 71 */
|
4773 | /***/ (function(module, exports, __webpack_require__) {
|
4774 |
|
4775 | var _containsWith = __webpack_require__(51);
|
4776 | var _curry3 = __webpack_require__(2);
|
4777 |
|
4778 |
|
4779 | /**
|
4780 | * Finds the set (i.e. no duplicates) of all elements in the first list not
|
4781 | * contained in the second list. Duplication is determined according to the
|
4782 | * value returned by applying the supplied predicate to two list elements.
|
4783 | *
|
4784 | * @func
|
4785 | * @memberOf R
|
4786 | * @since v0.1.0
|
4787 | * @category Relation
|
4788 | * @sig ((a, a) -> Boolean) -> [a] -> [a] -> [a]
|
4789 | * @param {Function} pred A predicate used to test whether two items are equal.
|
4790 | * @param {Array} list1 The first list.
|
4791 | * @param {Array} list2 The second list.
|
4792 | * @return {Array} The elements in `list1` that are not in `list2`.
|
4793 | * @see R.difference, R.symmetricDifference, R.symmetricDifferenceWith
|
4794 | * @example
|
4795 | *
|
4796 | * var cmp = (x, y) => x.a === y.a;
|
4797 | * var l1 = [{a: 1}, {a: 2}, {a: 3}];
|
4798 | * var l2 = [{a: 3}, {a: 4}];
|
4799 | * R.differenceWith(cmp, l1, l2); //=> [{a: 1}, {a: 2}]
|
4800 | */
|
4801 | module.exports = _curry3(function differenceWith(pred, first, second) {
|
4802 | var out = [];
|
4803 | var idx = 0;
|
4804 | var firstLen = first.length;
|
4805 | while (idx < firstLen) {
|
4806 | if (!_containsWith(pred, first[idx], second) &&
|
4807 | !_containsWith(pred, first[idx], out)) {
|
4808 | out.push(first[idx]);
|
4809 | }
|
4810 | idx += 1;
|
4811 | }
|
4812 | return out;
|
4813 | });
|
4814 |
|
4815 |
|
4816 | /***/ }),
|
4817 | /* 72 */
|
4818 | /***/ (function(module, exports, __webpack_require__) {
|
4819 |
|
4820 | var _curry2 = __webpack_require__(0);
|
4821 |
|
4822 |
|
4823 | /**
|
4824 | * Returns a new object that does not contain a `prop` property.
|
4825 | *
|
4826 | * @func
|
4827 | * @memberOf R
|
4828 | * @since v0.10.0
|
4829 | * @category Object
|
4830 | * @sig String -> {k: v} -> {k: v}
|
4831 | * @param {String} prop The name of the property to dissociate
|
4832 | * @param {Object} obj The object to clone
|
4833 | * @return {Object} A new object equivalent to the original but without the specified property
|
4834 | * @see R.assoc
|
4835 | * @example
|
4836 | *
|
4837 | * R.dissoc('b', {a: 1, b: 2, c: 3}); //=> {a: 1, c: 3}
|
4838 | */
|
4839 | module.exports = _curry2(function dissoc(prop, obj) {
|
4840 | var result = {};
|
4841 | for (var p in obj) {
|
4842 | result[p] = obj[p];
|
4843 | }
|
4844 | delete result[prop];
|
4845 | return result;
|
4846 | });
|
4847 |
|
4848 |
|
4849 | /***/ }),
|
4850 | /* 73 */
|
4851 | /***/ (function(module, exports, __webpack_require__) {
|
4852 |
|
4853 | var _curry2 = __webpack_require__(0);
|
4854 | var _dispatchable = __webpack_require__(3);
|
4855 | var _xdrop = __webpack_require__(218);
|
4856 | var slice = __webpack_require__(18);
|
4857 |
|
4858 |
|
4859 | /**
|
4860 | * Returns all but the first `n` elements of the given list, string, or
|
4861 | * transducer/transformer (or object with a `drop` method).
|
4862 | *
|
4863 | * Dispatches to the `drop` method of the second argument, if present.
|
4864 | *
|
4865 | * @func
|
4866 | * @memberOf R
|
4867 | * @since v0.1.0
|
4868 | * @category List
|
4869 | * @sig Number -> [a] -> [a]
|
4870 | * @sig Number -> String -> String
|
4871 | * @param {Number} n
|
4872 | * @param {[a]} list
|
4873 | * @return {[a]} A copy of list without the first `n` elements
|
4874 | * @see R.take, R.transduce, R.dropLast, R.dropWhile
|
4875 | * @example
|
4876 | *
|
4877 | * R.drop(1, ['foo', 'bar', 'baz']); //=> ['bar', 'baz']
|
4878 | * R.drop(2, ['foo', 'bar', 'baz']); //=> ['baz']
|
4879 | * R.drop(3, ['foo', 'bar', 'baz']); //=> []
|
4880 | * R.drop(4, ['foo', 'bar', 'baz']); //=> []
|
4881 | * R.drop(3, 'ramda'); //=> 'da'
|
4882 | */
|
4883 | module.exports = _curry2(_dispatchable(['drop'], _xdrop, function drop(n, xs) {
|
4884 | return slice(Math.max(0, n), Infinity, xs);
|
4885 | }));
|
4886 |
|
4887 |
|
4888 | /***/ }),
|
4889 | /* 74 */
|
4890 | /***/ (function(module, exports, __webpack_require__) {
|
4891 |
|
4892 | var _curry2 = __webpack_require__(0);
|
4893 | var _dispatchable = __webpack_require__(3);
|
4894 | var _xdropRepeatsWith = __webpack_require__(89);
|
4895 | var last = __webpack_require__(93);
|
4896 |
|
4897 |
|
4898 | /**
|
4899 | * Returns a new list without any consecutively repeating elements. Equality is
|
4900 | * determined by applying the supplied predicate to each pair of consecutive elements. The
|
4901 | * first element in a series of equal elements will be preserved.
|
4902 | *
|
4903 | * Acts as a transducer if a transformer is given in list position.
|
4904 | *
|
4905 | * @func
|
4906 | * @memberOf R
|
4907 | * @since v0.14.0
|
4908 | * @category List
|
4909 | * @sig (a, a -> Boolean) -> [a] -> [a]
|
4910 | * @param {Function} pred A predicate used to test whether two items are equal.
|
4911 | * @param {Array} list The array to consider.
|
4912 | * @return {Array} `list` without repeating elements.
|
4913 | * @see R.transduce
|
4914 | * @example
|
4915 | *
|
4916 | * var l = [1, -1, 1, 3, 4, -4, -4, -5, 5, 3, 3];
|
4917 | * R.dropRepeatsWith(R.eqBy(Math.abs), l); //=> [1, 3, 4, -5, 3]
|
4918 | */
|
4919 | module.exports = _curry2(_dispatchable([], _xdropRepeatsWith, function dropRepeatsWith(pred, list) {
|
4920 | var result = [];
|
4921 | var idx = 1;
|
4922 | var len = list.length;
|
4923 | if (len !== 0) {
|
4924 | result[0] = list[0];
|
4925 | while (idx < len) {
|
4926 | if (!pred(last(result), list[idx])) {
|
4927 | result[result.length] = list[idx];
|
4928 | }
|
4929 | idx += 1;
|
4930 | }
|
4931 | }
|
4932 | return result;
|
4933 | }));
|
4934 |
|
4935 |
|
4936 |
|
4937 | /***/ }),
|
4938 | /* 75 */
|
4939 | /***/ (function(module, exports, __webpack_require__) {
|
4940 |
|
4941 | var _curry1 = __webpack_require__(1);
|
4942 | var _isArguments = __webpack_require__(83);
|
4943 | var _isArray = __webpack_require__(15);
|
4944 | var _isObject = __webpack_require__(86);
|
4945 | var _isString = __webpack_require__(36);
|
4946 |
|
4947 |
|
4948 | /**
|
4949 | * Returns the empty value of its argument's type. Ramda defines the empty
|
4950 | * value of Array (`[]`), Object (`{}`), String (`''`), and Arguments. Other
|
4951 | * types are supported if they define `<Type>.empty` and/or
|
4952 | * `<Type>.prototype.empty`.
|
4953 | *
|
4954 | * Dispatches to the `empty` method of the first argument, if present.
|
4955 | *
|
4956 | * @func
|
4957 | * @memberOf R
|
4958 | * @since v0.3.0
|
4959 | * @category Function
|
4960 | * @sig a -> a
|
4961 | * @param {*} x
|
4962 | * @return {*}
|
4963 | * @example
|
4964 | *
|
4965 | * R.empty(Just(42)); //=> Nothing()
|
4966 | * R.empty([1, 2, 3]); //=> []
|
4967 | * R.empty('unicorns'); //=> ''
|
4968 | * R.empty({x: 1, y: 2}); //=> {}
|
4969 | */
|
4970 | module.exports = _curry1(function empty(x) {
|
4971 | return (
|
4972 | (x != null && typeof x.empty === 'function') ?
|
4973 | x.empty() :
|
4974 | (x != null && x.constructor != null && typeof x.constructor.empty === 'function') ?
|
4975 | x.constructor.empty() :
|
4976 | _isArray(x) ?
|
4977 | [] :
|
4978 | _isString(x) ?
|
4979 | '' :
|
4980 | _isObject(x) ?
|
4981 | {} :
|
4982 | _isArguments(x) ?
|
4983 | (function() { return arguments; }()) :
|
4984 | // else
|
4985 | void 0
|
4986 | );
|
4987 | });
|
4988 |
|
4989 |
|
4990 | /***/ }),
|
4991 | /* 76 */
|
4992 | /***/ (function(module, exports, __webpack_require__) {
|
4993 |
|
4994 | var _curry2 = __webpack_require__(0);
|
4995 |
|
4996 |
|
4997 | /**
|
4998 | * Returns true if its arguments are identical, false otherwise. Values are
|
4999 | * identical if they reference the same memory. `NaN` is identical to `NaN`;
|
5000 | * `0` and `-0` are not identical.
|
5001 | *
|
5002 | * @func
|
5003 | * @memberOf R
|
5004 | * @since v0.15.0
|
5005 | * @category Relation
|
5006 | * @sig a -> a -> Boolean
|
5007 | * @param {*} a
|
5008 | * @param {*} b
|
5009 | * @return {Boolean}
|
5010 | * @example
|
5011 | *
|
5012 | * var o = {};
|
5013 | * R.identical(o, o); //=> true
|
5014 | * R.identical(1, 1); //=> true
|
5015 | * R.identical(1, '1'); //=> false
|
5016 | * R.identical([], []); //=> false
|
5017 | * R.identical(0, -0); //=> false
|
5018 | * R.identical(NaN, NaN); //=> true
|
5019 | */
|
5020 | module.exports = _curry2(function identical(a, b) {
|
5021 | // SameValue algorithm
|
5022 | if (a === b) { // Steps 1-5, 7-10
|
5023 | // Steps 6.b-6.e: +0 != -0
|
5024 | return a !== 0 || 1 / a === 1 / b;
|
5025 | } else {
|
5026 | // Step 6.a: NaN == NaN
|
5027 | return a !== a && b !== b;
|
5028 | }
|
5029 | });
|
5030 |
|
5031 |
|
5032 | /***/ }),
|
5033 | /* 77 */
|
5034 | /***/ (function(module, exports, __webpack_require__) {
|
5035 |
|
5036 | var _cloneRegExp = __webpack_require__(78);
|
5037 | var type = __webpack_require__(56);
|
5038 |
|
5039 |
|
5040 | /**
|
5041 | * Copies an object.
|
5042 | *
|
5043 | * @private
|
5044 | * @param {*} value The value to be copied
|
5045 | * @param {Array} refFrom Array containing the source references
|
5046 | * @param {Array} refTo Array containing the copied source references
|
5047 | * @param {Boolean} deep Whether or not to perform deep cloning.
|
5048 | * @return {*} The copied value.
|
5049 | */
|
5050 | module.exports = function _clone(value, refFrom, refTo, deep) {
|
5051 | var copy = function copy(copiedValue) {
|
5052 | var len = refFrom.length;
|
5053 | var idx = 0;
|
5054 | while (idx < len) {
|
5055 | if (value === refFrom[idx]) {
|
5056 | return refTo[idx];
|
5057 | }
|
5058 | idx += 1;
|
5059 | }
|
5060 | refFrom[idx + 1] = value;
|
5061 | refTo[idx + 1] = copiedValue;
|
5062 | for (var key in value) {
|
5063 | copiedValue[key] = deep ?
|
5064 | _clone(value[key], refFrom, refTo, true) : value[key];
|
5065 | }
|
5066 | return copiedValue;
|
5067 | };
|
5068 | switch (type(value)) {
|
5069 | case 'Object': return copy({});
|
5070 | case 'Array': return copy([]);
|
5071 | case 'Date': return new Date(value.valueOf());
|
5072 | case 'RegExp': return _cloneRegExp(value);
|
5073 | default: return value;
|
5074 | }
|
5075 | };
|
5076 |
|
5077 |
|
5078 | /***/ }),
|
5079 | /* 78 */
|
5080 | /***/ (function(module, exports) {
|
5081 |
|
5082 | module.exports = function _cloneRegExp(pattern) {
|
5083 | return new RegExp(pattern.source, (pattern.global ? 'g' : '') +
|
5084 | (pattern.ignoreCase ? 'i' : '') +
|
5085 | (pattern.multiline ? 'm' : '') +
|
5086 | (pattern.sticky ? 'y' : '') +
|
5087 | (pattern.unicode ? 'u' : ''));
|
5088 | };
|
5089 |
|
5090 |
|
5091 | /***/ }),
|
5092 | /* 79 */
|
5093 | /***/ (function(module, exports) {
|
5094 |
|
5095 | module.exports = function _complement(f) {
|
5096 | return function() {
|
5097 | return !f.apply(this, arguments);
|
5098 | };
|
5099 | };
|
5100 |
|
5101 |
|
5102 | /***/ }),
|
5103 | /* 80 */
|
5104 | /***/ (function(module, exports, __webpack_require__) {
|
5105 |
|
5106 | var _arity = __webpack_require__(11);
|
5107 | var _curry2 = __webpack_require__(0);
|
5108 |
|
5109 |
|
5110 | module.exports = function _createPartialApplicator(concat) {
|
5111 | return _curry2(function(fn, args) {
|
5112 | return _arity(Math.max(0, fn.length - args.length), function() {
|
5113 | return fn.apply(this, concat(args, arguments));
|
5114 | });
|
5115 | });
|
5116 | };
|
5117 |
|
5118 |
|
5119 | /***/ }),
|
5120 | /* 81 */
|
5121 | /***/ (function(module, exports) {
|
5122 |
|
5123 | module.exports = function _filter(fn, list) {
|
5124 | var idx = 0;
|
5125 | var len = list.length;
|
5126 | var result = [];
|
5127 |
|
5128 | while (idx < len) {
|
5129 | if (fn(list[idx])) {
|
5130 | result[result.length] = list[idx];
|
5131 | }
|
5132 | idx += 1;
|
5133 | }
|
5134 | return result;
|
5135 | };
|
5136 |
|
5137 |
|
5138 | /***/ }),
|
5139 | /* 82 */
|
5140 | /***/ (function(module, exports, __webpack_require__) {
|
5141 |
|
5142 | var equals = __webpack_require__(10);
|
5143 |
|
5144 |
|
5145 | module.exports = function _indexOf(list, a, idx) {
|
5146 | var inf, item;
|
5147 | // Array.prototype.indexOf doesn't exist below IE9
|
5148 | if (typeof list.indexOf === 'function') {
|
5149 | switch (typeof a) {
|
5150 | case 'number':
|
5151 | if (a === 0) {
|
5152 | // manually crawl the list to distinguish between +0 and -0
|
5153 | inf = 1 / a;
|
5154 | while (idx < list.length) {
|
5155 | item = list[idx];
|
5156 | if (item === 0 && 1 / item === inf) {
|
5157 | return idx;
|
5158 | }
|
5159 | idx += 1;
|
5160 | }
|
5161 | return -1;
|
5162 | } else if (a !== a) {
|
5163 | // NaN
|
5164 | while (idx < list.length) {
|
5165 | item = list[idx];
|
5166 | if (typeof item === 'number' && item !== item) {
|
5167 | return idx;
|
5168 | }
|
5169 | idx += 1;
|
5170 | }
|
5171 | return -1;
|
5172 | }
|
5173 | // non-zero numbers can utilise Set
|
5174 | return list.indexOf(a, idx);
|
5175 |
|
5176 | // all these types can utilise Set
|
5177 | case 'string':
|
5178 | case 'boolean':
|
5179 | case 'function':
|
5180 | case 'undefined':
|
5181 | return list.indexOf(a, idx);
|
5182 |
|
5183 | case 'object':
|
5184 | if (a === null) {
|
5185 | // null can utilise Set
|
5186 | return list.indexOf(a, idx);
|
5187 | }
|
5188 | }
|
5189 | }
|
5190 | // anything else not covered above, defer to R.equals
|
5191 | while (idx < list.length) {
|
5192 | if (equals(list[idx], a)) {
|
5193 | return idx;
|
5194 | }
|
5195 | idx += 1;
|
5196 | }
|
5197 | return -1;
|
5198 | };
|
5199 |
|
5200 |
|
5201 | /***/ }),
|
5202 | /* 83 */
|
5203 | /***/ (function(module, exports, __webpack_require__) {
|
5204 |
|
5205 | var _has = __webpack_require__(6);
|
5206 |
|
5207 |
|
5208 | module.exports = (function() {
|
5209 | var toString = Object.prototype.toString;
|
5210 | return toString.call(arguments) === '[object Arguments]' ?
|
5211 | function _isArguments(x) { return toString.call(x) === '[object Arguments]'; } :
|
5212 | function _isArguments(x) { return _has('callee', x); };
|
5213 | }());
|
5214 |
|
5215 |
|
5216 | /***/ }),
|
5217 | /* 84 */
|
5218 | /***/ (function(module, exports) {
|
5219 |
|
5220 | /**
|
5221 | * Determine if the passed argument is an integer.
|
5222 | *
|
5223 | * @private
|
5224 | * @param {*} n
|
5225 | * @category Type
|
5226 | * @return {Boolean}
|
5227 | */
|
5228 | module.exports = Number.isInteger || function _isInteger(n) {
|
5229 | return (n << 0) === n;
|
5230 | };
|
5231 |
|
5232 |
|
5233 | /***/ }),
|
5234 | /* 85 */
|
5235 | /***/ (function(module, exports) {
|
5236 |
|
5237 | module.exports = function _isNumber(x) {
|
5238 | return Object.prototype.toString.call(x) === '[object Number]';
|
5239 | };
|
5240 |
|
5241 |
|
5242 | /***/ }),
|
5243 | /* 86 */
|
5244 | /***/ (function(module, exports) {
|
5245 |
|
5246 | module.exports = function _isObject(x) {
|
5247 | return Object.prototype.toString.call(x) === '[object Object]';
|
5248 | };
|
5249 |
|
5250 |
|
5251 | /***/ }),
|
5252 | /* 87 */
|
5253 | /***/ (function(module, exports, __webpack_require__) {
|
5254 |
|
5255 | var isArrayLike = __webpack_require__(23);
|
5256 |
|
5257 |
|
5258 | /**
|
5259 | * `_makeFlat` is a helper function that returns a one-level or fully recursive
|
5260 | * function based on the flag passed in.
|
5261 | *
|
5262 | * @private
|
5263 | */
|
5264 | module.exports = function _makeFlat(recursive) {
|
5265 | return function flatt(list) {
|
5266 | var value, jlen, j;
|
5267 | var result = [];
|
5268 | var idx = 0;
|
5269 | var ilen = list.length;
|
5270 |
|
5271 | while (idx < ilen) {
|
5272 | if (isArrayLike(list[idx])) {
|
5273 | value = recursive ? flatt(list[idx]) : list[idx];
|
5274 | j = 0;
|
5275 | jlen = value.length;
|
5276 | while (j < jlen) {
|
5277 | result[result.length] = value[j];
|
5278 | j += 1;
|
5279 | }
|
5280 | } else {
|
5281 | result[result.length] = list[idx];
|
5282 | }
|
5283 | idx += 1;
|
5284 | }
|
5285 | return result;
|
5286 | };
|
5287 | };
|
5288 |
|
5289 |
|
5290 | /***/ }),
|
5291 | /* 88 */
|
5292 | /***/ (function(module, exports, __webpack_require__) {
|
5293 |
|
5294 | var _curry2 = __webpack_require__(0);
|
5295 | var _reduced = __webpack_require__(16);
|
5296 | var _xfBase = __webpack_require__(4);
|
5297 |
|
5298 |
|
5299 | module.exports = (function() {
|
5300 | function XAny(f, xf) {
|
5301 | this.xf = xf;
|
5302 | this.f = f;
|
5303 | this.any = false;
|
5304 | }
|
5305 | XAny.prototype['@@transducer/init'] = _xfBase.init;
|
5306 | XAny.prototype['@@transducer/result'] = function(result) {
|
5307 | if (!this.any) {
|
5308 | result = this.xf['@@transducer/step'](result, false);
|
5309 | }
|
5310 | return this.xf['@@transducer/result'](result);
|
5311 | };
|
5312 | XAny.prototype['@@transducer/step'] = function(result, input) {
|
5313 | if (this.f(input)) {
|
5314 | this.any = true;
|
5315 | result = _reduced(this.xf['@@transducer/step'](result, true));
|
5316 | }
|
5317 | return result;
|
5318 | };
|
5319 |
|
5320 | return _curry2(function _xany(f, xf) { return new XAny(f, xf); });
|
5321 | }());
|
5322 |
|
5323 |
|
5324 | /***/ }),
|
5325 | /* 89 */
|
5326 | /***/ (function(module, exports, __webpack_require__) {
|
5327 |
|
5328 | var _curry2 = __webpack_require__(0);
|
5329 | var _xfBase = __webpack_require__(4);
|
5330 |
|
5331 |
|
5332 | module.exports = (function() {
|
5333 | function XDropRepeatsWith(pred, xf) {
|
5334 | this.xf = xf;
|
5335 | this.pred = pred;
|
5336 | this.lastValue = undefined;
|
5337 | this.seenFirstValue = false;
|
5338 | }
|
5339 |
|
5340 | XDropRepeatsWith.prototype['@@transducer/init'] = _xfBase.init;
|
5341 | XDropRepeatsWith.prototype['@@transducer/result'] = _xfBase.result;
|
5342 | XDropRepeatsWith.prototype['@@transducer/step'] = function(result, input) {
|
5343 | var sameAsLast = false;
|
5344 | if (!this.seenFirstValue) {
|
5345 | this.seenFirstValue = true;
|
5346 | } else if (this.pred(this.lastValue, input)) {
|
5347 | sameAsLast = true;
|
5348 | }
|
5349 | this.lastValue = input;
|
5350 | return sameAsLast ? result : this.xf['@@transducer/step'](result, input);
|
5351 | };
|
5352 |
|
5353 | return _curry2(function _xdropRepeatsWith(pred, xf) { return new XDropRepeatsWith(pred, xf); });
|
5354 | }());
|
5355 |
|
5356 |
|
5357 | /***/ }),
|
5358 | /* 90 */
|
5359 | /***/ (function(module, exports) {
|
5360 |
|
5361 | module.exports = (function() {
|
5362 | function XWrap(fn) {
|
5363 | this.f = fn;
|
5364 | }
|
5365 | XWrap.prototype['@@transducer/init'] = function() {
|
5366 | throw new Error('init not implemented on XWrap');
|
5367 | };
|
5368 | XWrap.prototype['@@transducer/result'] = function(acc) { return acc; };
|
5369 | XWrap.prototype['@@transducer/step'] = function(acc, x) {
|
5370 | return this.f(acc, x);
|
5371 | };
|
5372 |
|
5373 | return function _xwrap(fn) { return new XWrap(fn); };
|
5374 | }());
|
5375 |
|
5376 |
|
5377 | /***/ }),
|
5378 | /* 91 */
|
5379 | /***/ (function(module, exports, __webpack_require__) {
|
5380 |
|
5381 | var _curry2 = __webpack_require__(0);
|
5382 |
|
5383 |
|
5384 | /**
|
5385 | * See if an object (`val`) is an instance of the supplied constructor. This
|
5386 | * function will check up the inheritance chain, if any.
|
5387 | *
|
5388 | * @func
|
5389 | * @memberOf R
|
5390 | * @since v0.3.0
|
5391 | * @category Type
|
5392 | * @sig (* -> {*}) -> a -> Boolean
|
5393 | * @param {Object} ctor A constructor
|
5394 | * @param {*} val The value to test
|
5395 | * @return {Boolean}
|
5396 | * @example
|
5397 | *
|
5398 | * R.is(Object, {}); //=> true
|
5399 | * R.is(Number, 1); //=> true
|
5400 | * R.is(Object, 1); //=> false
|
5401 | * R.is(String, 's'); //=> true
|
5402 | * R.is(String, new String('')); //=> true
|
5403 | * R.is(Object, new String('')); //=> true
|
5404 | * R.is(Object, 's'); //=> false
|
5405 | * R.is(Number, {}); //=> false
|
5406 | */
|
5407 | module.exports = _curry2(function is(Ctor, val) {
|
5408 | return val != null && val.constructor === Ctor || val instanceof Ctor;
|
5409 | });
|
5410 |
|
5411 |
|
5412 | /***/ }),
|
5413 | /* 92 */
|
5414 | /***/ (function(module, exports, __webpack_require__) {
|
5415 |
|
5416 | var _curry1 = __webpack_require__(1);
|
5417 | var converge = __webpack_require__(68);
|
5418 |
|
5419 |
|
5420 | /**
|
5421 | * juxt applies a list of functions to a list of values.
|
5422 | *
|
5423 | * @func
|
5424 | * @memberOf R
|
5425 | * @since v0.19.0
|
5426 | * @category Function
|
5427 | * @sig [(a, b, ..., m) -> n] -> ((a, b, ..., m) -> [n])
|
5428 | * @param {Array} fns An array of functions
|
5429 | * @return {Function} A function that returns a list of values after applying each of the original `fns` to its parameters.
|
5430 | * @see R.applySpec
|
5431 | * @example
|
5432 | *
|
5433 | * var getRange = R.juxt([Math.min, Math.max]);
|
5434 | * getRange(3, 4, 9, -3); //=> [-3, 9]
|
5435 | * @symb R.juxt([f, g, h])(a, b) = [f(a, b), g(a, b), h(a, b)]
|
5436 | */
|
5437 | module.exports = _curry1(function juxt(fns) {
|
5438 | return converge(function() { return Array.prototype.slice.call(arguments, 0); }, fns);
|
5439 | });
|
5440 |
|
5441 |
|
5442 | /***/ }),
|
5443 | /* 93 */
|
5444 | /***/ (function(module, exports, __webpack_require__) {
|
5445 |
|
5446 | var nth = __webpack_require__(24);
|
5447 |
|
5448 |
|
5449 | /**
|
5450 | * Returns the last element of the given list or string.
|
5451 | *
|
5452 | * @func
|
5453 | * @memberOf R
|
5454 | * @since v0.1.4
|
5455 | * @category List
|
5456 | * @sig [a] -> a | Undefined
|
5457 | * @sig String -> String
|
5458 | * @param {*} list
|
5459 | * @return {*}
|
5460 | * @see R.init, R.head, R.tail
|
5461 | * @example
|
5462 | *
|
5463 | * R.last(['fi', 'fo', 'fum']); //=> 'fum'
|
5464 | * R.last([]); //=> undefined
|
5465 | *
|
5466 | * R.last('abc'); //=> 'c'
|
5467 | * R.last(''); //=> ''
|
5468 | */
|
5469 | module.exports = nth(-1);
|
5470 |
|
5471 |
|
5472 | /***/ }),
|
5473 | /* 94 */
|
5474 | /***/ (function(module, exports, __webpack_require__) {
|
5475 |
|
5476 | var _curry1 = __webpack_require__(1);
|
5477 | var _isNumber = __webpack_require__(85);
|
5478 |
|
5479 |
|
5480 | /**
|
5481 | * Returns the number of elements in the array by returning `list.length`.
|
5482 | *
|
5483 | * @func
|
5484 | * @memberOf R
|
5485 | * @since v0.3.0
|
5486 | * @category List
|
5487 | * @sig [a] -> Number
|
5488 | * @param {Array} list The array to inspect.
|
5489 | * @return {Number} The length of the array.
|
5490 | * @example
|
5491 | *
|
5492 | * R.length([]); //=> 0
|
5493 | * R.length([1, 2, 3]); //=> 3
|
5494 | */
|
5495 | module.exports = _curry1(function length(list) {
|
5496 | return list != null && _isNumber(list.length) ? list.length : NaN;
|
5497 | });
|
5498 |
|
5499 |
|
5500 | /***/ }),
|
5501 | /* 95 */
|
5502 | /***/ (function(module, exports, __webpack_require__) {
|
5503 |
|
5504 | var _curry2 = __webpack_require__(0);
|
5505 | var _reduce = __webpack_require__(8);
|
5506 | var ap = __webpack_require__(44);
|
5507 | var curryN = __webpack_require__(5);
|
5508 | var map = __webpack_require__(7);
|
5509 |
|
5510 |
|
5511 | /**
|
5512 | * "lifts" a function to be the specified arity, so that it may "map over" that
|
5513 | * many lists, Functions or other objects that satisfy the [FantasyLand Apply spec](https://github.com/fantasyland/fantasy-land#apply).
|
5514 | *
|
5515 | * @func
|
5516 | * @memberOf R
|
5517 | * @since v0.7.0
|
5518 | * @category Function
|
5519 | * @sig Number -> (*... -> *) -> ([*]... -> [*])
|
5520 | * @param {Function} fn The function to lift into higher context
|
5521 | * @return {Function} The lifted function.
|
5522 | * @see R.lift, R.ap
|
5523 | * @example
|
5524 | *
|
5525 | * var madd3 = R.liftN(3, (...args) => R.sum(args));
|
5526 | * madd3([1,2,3], [1,2,3], [1]); //=> [3, 4, 5, 4, 5, 6, 5, 6, 7]
|
5527 | */
|
5528 | module.exports = _curry2(function liftN(arity, fn) {
|
5529 | var lifted = curryN(arity, fn);
|
5530 | return curryN(arity, function() {
|
5531 | return _reduce(ap, map(lifted, arguments[0]), Array.prototype.slice.call(arguments, 1));
|
5532 | });
|
5533 | });
|
5534 |
|
5535 |
|
5536 | /***/ }),
|
5537 | /* 96 */
|
5538 | /***/ (function(module, exports, __webpack_require__) {
|
5539 |
|
5540 | var _curry1 = __webpack_require__(1);
|
5541 | var sum = __webpack_require__(109);
|
5542 |
|
5543 |
|
5544 | /**
|
5545 | * Returns the mean of the given list of numbers.
|
5546 | *
|
5547 | * @func
|
5548 | * @memberOf R
|
5549 | * @since v0.14.0
|
5550 | * @category Math
|
5551 | * @sig [Number] -> Number
|
5552 | * @param {Array} list
|
5553 | * @return {Number}
|
5554 | * @example
|
5555 | *
|
5556 | * R.mean([2, 7, 9]); //=> 6
|
5557 | * R.mean([]); //=> NaN
|
5558 | */
|
5559 | module.exports = _curry1(function mean(list) {
|
5560 | return sum(list) / list.length;
|
5561 | });
|
5562 |
|
5563 |
|
5564 | /***/ }),
|
5565 | /* 97 */
|
5566 | /***/ (function(module, exports, __webpack_require__) {
|
5567 |
|
5568 | var _curry3 = __webpack_require__(2);
|
5569 | var _has = __webpack_require__(6);
|
5570 |
|
5571 |
|
5572 | /**
|
5573 | * Creates a new object with the own properties of the two provided objects. If
|
5574 | * a key exists in both objects, the provided function is applied to the key
|
5575 | * and the values associated with the key in each object, with the result being
|
5576 | * used as the value associated with the key in the returned object. The key
|
5577 | * will be excluded from the returned object if the resulting value is
|
5578 | * `undefined`.
|
5579 | *
|
5580 | * @func
|
5581 | * @memberOf R
|
5582 | * @since v0.19.0
|
5583 | * @category Object
|
5584 | * @sig (String -> a -> a -> a) -> {a} -> {a} -> {a}
|
5585 | * @param {Function} fn
|
5586 | * @param {Object} l
|
5587 | * @param {Object} r
|
5588 | * @return {Object}
|
5589 | * @see R.merge, R.mergeWith
|
5590 | * @example
|
5591 | *
|
5592 | * let concatValues = (k, l, r) => k == 'values' ? R.concat(l, r) : r
|
5593 | * R.mergeWithKey(concatValues,
|
5594 | * { a: true, thing: 'foo', values: [10, 20] },
|
5595 | * { b: true, thing: 'bar', values: [15, 35] });
|
5596 | * //=> { a: true, b: true, thing: 'bar', values: [10, 20, 15, 35] }
|
5597 | * @symb R.mergeWithKey(f, { x: 1, y: 2 }, { y: 5, z: 3 }) = { x: 1, y: f('y', 2, 5), z: 3 }
|
5598 | */
|
5599 | module.exports = _curry3(function mergeWithKey(fn, l, r) {
|
5600 | var result = {};
|
5601 | var k;
|
5602 |
|
5603 | for (k in l) {
|
5604 | if (_has(k, l)) {
|
5605 | result[k] = _has(k, r) ? fn(k, l[k], r[k]) : l[k];
|
5606 | }
|
5607 | }
|
5608 |
|
5609 | for (k in r) {
|
5610 | if (_has(k, r) && !(_has(k, result))) {
|
5611 | result[k] = r[k];
|
5612 | }
|
5613 | }
|
5614 |
|
5615 | return result;
|
5616 | });
|
5617 |
|
5618 |
|
5619 | /***/ }),
|
5620 | /* 98 */
|
5621 | /***/ (function(module, exports, __webpack_require__) {
|
5622 |
|
5623 | var _curry2 = __webpack_require__(0);
|
5624 |
|
5625 |
|
5626 | /**
|
5627 | * Multiplies two numbers. Equivalent to `a * b` but curried.
|
5628 | *
|
5629 | * @func
|
5630 | * @memberOf R
|
5631 | * @since v0.1.0
|
5632 | * @category Math
|
5633 | * @sig Number -> Number -> Number
|
5634 | * @param {Number} a The first value.
|
5635 | * @param {Number} b The second value.
|
5636 | * @return {Number} The result of `a * b`.
|
5637 | * @see R.divide
|
5638 | * @example
|
5639 | *
|
5640 | * var double = R.multiply(2);
|
5641 | * var triple = R.multiply(3);
|
5642 | * double(3); //=> 6
|
5643 | * triple(4); //=> 12
|
5644 | * R.multiply(2, 5); //=> 10
|
5645 | */
|
5646 | module.exports = _curry2(function multiply(a, b) { return a * b; });
|
5647 |
|
5648 |
|
5649 | /***/ }),
|
5650 | /* 99 */
|
5651 | /***/ (function(module, exports, __webpack_require__) {
|
5652 |
|
5653 | var _curry1 = __webpack_require__(1);
|
5654 |
|
5655 |
|
5656 | /**
|
5657 | * A function that returns the `!` of its argument. It will return `true` when
|
5658 | * passed false-y value, and `false` when passed a truth-y one.
|
5659 | *
|
5660 | * @func
|
5661 | * @memberOf R
|
5662 | * @since v0.1.0
|
5663 | * @category Logic
|
5664 | * @sig * -> Boolean
|
5665 | * @param {*} a any value
|
5666 | * @return {Boolean} the logical inverse of passed argument.
|
5667 | * @see R.complement
|
5668 | * @example
|
5669 | *
|
5670 | * R.not(true); //=> false
|
5671 | * R.not(false); //=> true
|
5672 | * R.not(0); //=> true
|
5673 | * R.not(1); //=> false
|
5674 | */
|
5675 | module.exports = _curry1(function not(a) {
|
5676 | return !a;
|
5677 | });
|
5678 |
|
5679 |
|
5680 | /***/ }),
|
5681 | /* 100 */
|
5682 | /***/ (function(module, exports, __webpack_require__) {
|
5683 |
|
5684 | var _curry2 = __webpack_require__(0);
|
5685 |
|
5686 |
|
5687 | /**
|
5688 | * Creates an object containing a single key:value pair.
|
5689 | *
|
5690 | * @func
|
5691 | * @memberOf R
|
5692 | * @since v0.18.0
|
5693 | * @category Object
|
5694 | * @sig String -> a -> {String:a}
|
5695 | * @param {String} key
|
5696 | * @param {*} val
|
5697 | * @return {Object}
|
5698 | * @see R.pair
|
5699 | * @example
|
5700 | *
|
5701 | * var matchPhrases = R.compose(
|
5702 | * R.objOf('must'),
|
5703 | * R.map(R.objOf('match_phrase'))
|
5704 | * );
|
5705 | * matchPhrases(['foo', 'bar', 'baz']); //=> {must: [{match_phrase: 'foo'}, {match_phrase: 'bar'}, {match_phrase: 'baz'}]}
|
5706 | */
|
5707 | module.exports = _curry2(function objOf(key, val) {
|
5708 | var obj = {};
|
5709 | obj[key] = val;
|
5710 | return obj;
|
5711 | });
|
5712 |
|
5713 |
|
5714 | /***/ }),
|
5715 | /* 101 */
|
5716 | /***/ (function(module, exports, __webpack_require__) {
|
5717 |
|
5718 | var _curry2 = __webpack_require__(0);
|
5719 |
|
5720 |
|
5721 | /**
|
5722 | * Returns `true` if one or both of its arguments are `true`. Returns `false`
|
5723 | * if both arguments are `false`.
|
5724 | *
|
5725 | * @func
|
5726 | * @memberOf R
|
5727 | * @since v0.1.0
|
5728 | * @category Logic
|
5729 | * @sig a -> b -> a | b
|
5730 | * @param {Any} a
|
5731 | * @param {Any} b
|
5732 | * @return {Any} the first argument if truthy, otherwise the second argument.
|
5733 | * @see R.either
|
5734 | * @example
|
5735 | *
|
5736 | * R.or(true, true); //=> true
|
5737 | * R.or(true, false); //=> true
|
5738 | * R.or(false, true); //=> true
|
5739 | * R.or(false, false); //=> false
|
5740 | */
|
5741 | module.exports = _curry2(function or(a, b) {
|
5742 | return a || b;
|
5743 | });
|
5744 |
|
5745 |
|
5746 | /***/ }),
|
5747 | /* 102 */
|
5748 | /***/ (function(module, exports, __webpack_require__) {
|
5749 |
|
5750 | var _curry3 = __webpack_require__(2);
|
5751 |
|
5752 |
|
5753 | /**
|
5754 | * Returns the result of "setting" the portion of the given data structure
|
5755 | * focused by the given lens to the result of applying the given function to
|
5756 | * the focused value.
|
5757 | *
|
5758 | * @func
|
5759 | * @memberOf R
|
5760 | * @since v0.16.0
|
5761 | * @category Object
|
5762 | * @typedefn Lens s a = Functor f => (a -> f a) -> s -> f s
|
5763 | * @sig Lens s a -> (a -> a) -> s -> s
|
5764 | * @param {Lens} lens
|
5765 | * @param {*} v
|
5766 | * @param {*} x
|
5767 | * @return {*}
|
5768 | * @see R.prop, R.lensIndex, R.lensProp
|
5769 | * @example
|
5770 | *
|
5771 | * var headLens = R.lensIndex(0);
|
5772 | *
|
5773 | * R.over(headLens, R.toUpper, ['foo', 'bar', 'baz']); //=> ['FOO', 'bar', 'baz']
|
5774 | */
|
5775 | module.exports = (function() {
|
5776 | // `Identity` is a functor that holds a single value, where `map` simply
|
5777 | // transforms the held value with the provided function.
|
5778 | var Identity = function(x) {
|
5779 | return {value: x, map: function(f) { return Identity(f(x)); }};
|
5780 | };
|
5781 |
|
5782 | return _curry3(function over(lens, f, x) {
|
5783 | // The value returned by the getter function is first transformed with `f`,
|
5784 | // then set as the value of an `Identity`. This is then mapped over with the
|
5785 | // setter function of the lens.
|
5786 | return lens(function(y) { return Identity(f(y)); })(x).value;
|
5787 | });
|
5788 | }());
|
5789 |
|
5790 |
|
5791 | /***/ }),
|
5792 | /* 103 */
|
5793 | /***/ (function(module, exports, __webpack_require__) {
|
5794 |
|
5795 | var _curry2 = __webpack_require__(0);
|
5796 |
|
5797 |
|
5798 | /**
|
5799 | * Similar to `pick` except that this one includes a `key: undefined` pair for
|
5800 | * properties that don't exist.
|
5801 | *
|
5802 | * @func
|
5803 | * @memberOf R
|
5804 | * @since v0.1.0
|
5805 | * @category Object
|
5806 | * @sig [k] -> {k: v} -> {k: v}
|
5807 | * @param {Array} names an array of String property names to copy onto a new object
|
5808 | * @param {Object} obj The object to copy from
|
5809 | * @return {Object} A new object with only properties from `names` on it.
|
5810 | * @see R.pick
|
5811 | * @example
|
5812 | *
|
5813 | * R.pickAll(['a', 'd'], {a: 1, b: 2, c: 3, d: 4}); //=> {a: 1, d: 4}
|
5814 | * R.pickAll(['a', 'e', 'f'], {a: 1, b: 2, c: 3, d: 4}); //=> {a: 1, e: undefined, f: undefined}
|
5815 | */
|
5816 | module.exports = _curry2(function pickAll(names, obj) {
|
5817 | var result = {};
|
5818 | var idx = 0;
|
5819 | var len = names.length;
|
5820 | while (idx < len) {
|
5821 | var name = names[idx];
|
5822 | result[name] = obj[name];
|
5823 | idx += 1;
|
5824 | }
|
5825 | return result;
|
5826 | });
|
5827 |
|
5828 |
|
5829 | /***/ }),
|
5830 | /* 104 */
|
5831 | /***/ (function(module, exports, __webpack_require__) {
|
5832 |
|
5833 | var _arity = __webpack_require__(11);
|
5834 | var _pipe = __webpack_require__(209);
|
5835 | var reduce = __webpack_require__(13);
|
5836 | var tail = __webpack_require__(55);
|
5837 |
|
5838 |
|
5839 | /**
|
5840 | * Performs left-to-right function composition. The leftmost function may have
|
5841 | * any arity; the remaining functions must be unary.
|
5842 | *
|
5843 | * In some libraries this function is named `sequence`.
|
5844 | *
|
5845 | * **Note:** The result of pipe is not automatically curried.
|
5846 | *
|
5847 | * @func
|
5848 | * @memberOf R
|
5849 | * @since v0.1.0
|
5850 | * @category Function
|
5851 | * @sig (((a, b, ..., n) -> o), (o -> p), ..., (x -> y), (y -> z)) -> ((a, b, ..., n) -> z)
|
5852 | * @param {...Function} functions
|
5853 | * @return {Function}
|
5854 | * @see R.compose
|
5855 | * @example
|
5856 | *
|
5857 | * var f = R.pipe(Math.pow, R.negate, R.inc);
|
5858 | *
|
5859 | * f(3, 4); // -(3^4) + 1
|
5860 | * @symb R.pipe(f, g, h)(a, b) = h(g(f(a, b)))
|
5861 | */
|
5862 | module.exports = function pipe() {
|
5863 | if (arguments.length === 0) {
|
5864 | throw new Error('pipe requires at least one argument');
|
5865 | }
|
5866 | return _arity(arguments[0].length,
|
5867 | reduce(_pipe, arguments[0], tail(arguments)));
|
5868 | };
|
5869 |
|
5870 |
|
5871 | /***/ }),
|
5872 | /* 105 */
|
5873 | /***/ (function(module, exports, __webpack_require__) {
|
5874 |
|
5875 | var _arity = __webpack_require__(11);
|
5876 | var _pipeP = __webpack_require__(210);
|
5877 | var reduce = __webpack_require__(13);
|
5878 | var tail = __webpack_require__(55);
|
5879 |
|
5880 |
|
5881 | /**
|
5882 | * Performs left-to-right composition of one or more Promise-returning
|
5883 | * functions. The leftmost function may have any arity; the remaining functions
|
5884 | * must be unary.
|
5885 | *
|
5886 | * @func
|
5887 | * @memberOf R
|
5888 | * @since v0.10.0
|
5889 | * @category Function
|
5890 | * @sig ((a -> Promise b), (b -> Promise c), ..., (y -> Promise z)) -> (a -> Promise z)
|
5891 | * @param {...Function} functions
|
5892 | * @return {Function}
|
5893 | * @see R.composeP
|
5894 | * @example
|
5895 | *
|
5896 | * // followersForUser :: String -> Promise [User]
|
5897 | * var followersForUser = R.pipeP(db.getUserById, db.getFollowers);
|
5898 | */
|
5899 | module.exports = function pipeP() {
|
5900 | if (arguments.length === 0) {
|
5901 | throw new Error('pipeP requires at least one argument');
|
5902 | }
|
5903 | return _arity(arguments[0].length,
|
5904 | reduce(_pipeP, arguments[0], tail(arguments)));
|
5905 | };
|
5906 |
|
5907 |
|
5908 | /***/ }),
|
5909 | /* 106 */
|
5910 | /***/ (function(module, exports, __webpack_require__) {
|
5911 |
|
5912 | var _concat = __webpack_require__(9);
|
5913 | var _curry2 = __webpack_require__(0);
|
5914 |
|
5915 |
|
5916 | /**
|
5917 | * Returns a new list with the given element at the front, followed by the
|
5918 | * contents of the list.
|
5919 | *
|
5920 | * @func
|
5921 | * @memberOf R
|
5922 | * @since v0.1.0
|
5923 | * @category List
|
5924 | * @sig a -> [a] -> [a]
|
5925 | * @param {*} el The item to add to the head of the output list.
|
5926 | * @param {Array} list The array to add to the tail of the output list.
|
5927 | * @return {Array} A new array.
|
5928 | * @see R.append
|
5929 | * @example
|
5930 | *
|
5931 | * R.prepend('fee', ['fi', 'fo', 'fum']); //=> ['fee', 'fi', 'fo', 'fum']
|
5932 | */
|
5933 | module.exports = _curry2(function prepend(el, list) {
|
5934 | return _concat([el], list);
|
5935 | });
|
5936 |
|
5937 |
|
5938 | /***/ }),
|
5939 | /* 107 */
|
5940 | /***/ (function(module, exports, __webpack_require__) {
|
5941 |
|
5942 | var _curry3 = __webpack_require__(2);
|
5943 |
|
5944 |
|
5945 | /**
|
5946 | * Returns a single item by iterating through the list, successively calling
|
5947 | * the iterator function and passing it an accumulator value and the current
|
5948 | * value from the array, and then passing the result to the next call.
|
5949 | *
|
5950 | * Similar to `reduce`, except moves through the input list from the right to
|
5951 | * the left.
|
5952 | *
|
5953 | * The iterator function receives two values: *(value, acc)*, while the arguments'
|
5954 | * order of `reduce`'s iterator function is *(acc, value)*.
|
5955 | *
|
5956 | * Note: `R.reduceRight` does not skip deleted or unassigned indices (sparse
|
5957 | * arrays), unlike the native `Array.prototype.reduce` method. For more details
|
5958 | * on this behavior, see:
|
5959 | * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduceRight#Description
|
5960 | *
|
5961 | * @func
|
5962 | * @memberOf R
|
5963 | * @since v0.1.0
|
5964 | * @category List
|
5965 | * @sig (a, b -> b) -> b -> [a] -> b
|
5966 | * @param {Function} fn The iterator function. Receives two values, the current element from the array
|
5967 | * and the accumulator.
|
5968 | * @param {*} acc The accumulator value.
|
5969 | * @param {Array} list The list to iterate over.
|
5970 | * @return {*} The final, accumulated value.
|
5971 | * @see R.reduce, R.addIndex
|
5972 | * @example
|
5973 | *
|
5974 | * R.reduceRight(R.subtract, 0, [1, 2, 3, 4]) // => (1 - (2 - (3 - (4 - 0)))) = -2
|
5975 | * - -2
|
5976 | * / \ / \
|
5977 | * 1 - 1 3
|
5978 | * / \ / \
|
5979 | * 2 - ==> 2 -1
|
5980 | * / \ / \
|
5981 | * 3 - 3 4
|
5982 | * / \ / \
|
5983 | * 4 0 4 0
|
5984 | *
|
5985 | * @symb R.reduceRight(f, a, [b, c, d]) = f(b, f(c, f(d, a)))
|
5986 | */
|
5987 | module.exports = _curry3(function reduceRight(fn, acc, list) {
|
5988 | var idx = list.length - 1;
|
5989 | while (idx >= 0) {
|
5990 | acc = fn(list[idx], acc);
|
5991 | idx -= 1;
|
5992 | }
|
5993 | return acc;
|
5994 | });
|
5995 |
|
5996 |
|
5997 | /***/ }),
|
5998 | /* 108 */
|
5999 | /***/ (function(module, exports, __webpack_require__) {
|
6000 |
|
6001 | var _curry2 = __webpack_require__(0);
|
6002 | var ap = __webpack_require__(44);
|
6003 | var map = __webpack_require__(7);
|
6004 | var prepend = __webpack_require__(106);
|
6005 | var reduceRight = __webpack_require__(107);
|
6006 |
|
6007 |
|
6008 | /**
|
6009 | * Transforms a [Traversable](https://github.com/fantasyland/fantasy-land#traversable)
|
6010 | * of [Applicative](https://github.com/fantasyland/fantasy-land#applicative) into an
|
6011 | * Applicative of Traversable.
|
6012 | *
|
6013 | * Dispatches to the `sequence` method of the second argument, if present.
|
6014 | *
|
6015 | * @func
|
6016 | * @memberOf R
|
6017 | * @since v0.19.0
|
6018 | * @category List
|
6019 | * @sig (Applicative f, Traversable t) => (a -> f a) -> t (f a) -> f (t a)
|
6020 | * @param {Function} of
|
6021 | * @param {*} traversable
|
6022 | * @return {*}
|
6023 | * @see R.traverse
|
6024 | * @example
|
6025 | *
|
6026 | * R.sequence(Maybe.of, [Just(1), Just(2), Just(3)]); //=> Just([1, 2, 3])
|
6027 | * R.sequence(Maybe.of, [Just(1), Just(2), Nothing()]); //=> Nothing()
|
6028 | *
|
6029 | * R.sequence(R.of, Just([1, 2, 3])); //=> [Just(1), Just(2), Just(3)]
|
6030 | * R.sequence(R.of, Nothing()); //=> [Nothing()]
|
6031 | */
|
6032 | module.exports = _curry2(function sequence(of, traversable) {
|
6033 | return typeof traversable.sequence === 'function' ?
|
6034 | traversable.sequence(of) :
|
6035 | reduceRight(function(x, acc) { return ap(map(prepend, x), acc); },
|
6036 | of([]),
|
6037 | traversable);
|
6038 | });
|
6039 |
|
6040 |
|
6041 | /***/ }),
|
6042 | /* 109 */
|
6043 | /***/ (function(module, exports, __webpack_require__) {
|
6044 |
|
6045 | var add = __webpack_require__(29);
|
6046 | var reduce = __webpack_require__(13);
|
6047 |
|
6048 |
|
6049 | /**
|
6050 | * Adds together all the elements of a list.
|
6051 | *
|
6052 | * @func
|
6053 | * @memberOf R
|
6054 | * @since v0.1.0
|
6055 | * @category Math
|
6056 | * @sig [Number] -> Number
|
6057 | * @param {Array} list An array of numbers
|
6058 | * @return {Number} The sum of all the numbers in the list.
|
6059 | * @see R.reduce
|
6060 | * @example
|
6061 | *
|
6062 | * R.sum([2,4,6,8,100,1]); //=> 121
|
6063 | */
|
6064 | module.exports = reduce(add, 0);
|
6065 |
|
6066 |
|
6067 | /***/ }),
|
6068 | /* 110 */
|
6069 | /***/ (function(module, exports, __webpack_require__) {
|
6070 |
|
6071 | var _curry2 = __webpack_require__(0);
|
6072 | var _dispatchable = __webpack_require__(3);
|
6073 | var _xtake = __webpack_require__(229);
|
6074 | var slice = __webpack_require__(18);
|
6075 |
|
6076 |
|
6077 | /**
|
6078 | * Returns the first `n` elements of the given list, string, or
|
6079 | * transducer/transformer (or object with a `take` method).
|
6080 | *
|
6081 | * Dispatches to the `take` method of the second argument, if present.
|
6082 | *
|
6083 | * @func
|
6084 | * @memberOf R
|
6085 | * @since v0.1.0
|
6086 | * @category List
|
6087 | * @sig Number -> [a] -> [a]
|
6088 | * @sig Number -> String -> String
|
6089 | * @param {Number} n
|
6090 | * @param {*} list
|
6091 | * @return {*}
|
6092 | * @see R.drop
|
6093 | * @example
|
6094 | *
|
6095 | * R.take(1, ['foo', 'bar', 'baz']); //=> ['foo']
|
6096 | * R.take(2, ['foo', 'bar', 'baz']); //=> ['foo', 'bar']
|
6097 | * R.take(3, ['foo', 'bar', 'baz']); //=> ['foo', 'bar', 'baz']
|
6098 | * R.take(4, ['foo', 'bar', 'baz']); //=> ['foo', 'bar', 'baz']
|
6099 | * R.take(3, 'ramda'); //=> 'ram'
|
6100 | *
|
6101 | * var personnel = [
|
6102 | * 'Dave Brubeck',
|
6103 | * 'Paul Desmond',
|
6104 | * 'Eugene Wright',
|
6105 | * 'Joe Morello',
|
6106 | * 'Gerry Mulligan',
|
6107 | * 'Bob Bates',
|
6108 | * 'Joe Dodge',
|
6109 | * 'Ron Crotty'
|
6110 | * ];
|
6111 | *
|
6112 | * var takeFive = R.take(5);
|
6113 | * takeFive(personnel);
|
6114 | * //=> ['Dave Brubeck', 'Paul Desmond', 'Eugene Wright', 'Joe Morello', 'Gerry Mulligan']
|
6115 | * @symb R.take(-1, [a, b]) = [a, b]
|
6116 | * @symb R.take(0, [a, b]) = []
|
6117 | * @symb R.take(1, [a, b]) = [a]
|
6118 | * @symb R.take(2, [a, b]) = [a, b]
|
6119 | */
|
6120 | module.exports = _curry2(_dispatchable(['take'], _xtake, function take(n, xs) {
|
6121 | return slice(0, n < 0 ? Infinity : n, xs);
|
6122 | }));
|
6123 |
|
6124 |
|
6125 | /***/ }),
|
6126 | /* 111 */
|
6127 | /***/ (function(module, exports, __webpack_require__) {
|
6128 |
|
6129 | var _curry2 = __webpack_require__(0);
|
6130 |
|
6131 |
|
6132 | /**
|
6133 | * Calls an input function `n` times, returning an array containing the results
|
6134 | * of those function calls.
|
6135 | *
|
6136 | * `fn` is passed one argument: The current value of `n`, which begins at `0`
|
6137 | * and is gradually incremented to `n - 1`.
|
6138 | *
|
6139 | * @func
|
6140 | * @memberOf R
|
6141 | * @since v0.2.3
|
6142 | * @category List
|
6143 | * @sig (Number -> a) -> Number -> [a]
|
6144 | * @param {Function} fn The function to invoke. Passed one argument, the current value of `n`.
|
6145 | * @param {Number} n A value between `0` and `n - 1`. Increments after each function call.
|
6146 | * @return {Array} An array containing the return values of all calls to `fn`.
|
6147 | * @example
|
6148 | *
|
6149 | * R.times(R.identity, 5); //=> [0, 1, 2, 3, 4]
|
6150 | * @symb R.times(f, 0) = []
|
6151 | * @symb R.times(f, 1) = [f(0)]
|
6152 | * @symb R.times(f, 2) = [f(0), f(1)]
|
6153 | */
|
6154 | module.exports = _curry2(function times(fn, n) {
|
6155 | var len = Number(n);
|
6156 | var idx = 0;
|
6157 | var list;
|
6158 |
|
6159 | if (len < 0 || isNaN(len)) {
|
6160 | throw new RangeError('n must be a non-negative number');
|
6161 | }
|
6162 | list = new Array(len);
|
6163 | while (idx < len) {
|
6164 | list[idx] = fn(idx);
|
6165 | idx += 1;
|
6166 | }
|
6167 | return list;
|
6168 | });
|
6169 |
|
6170 |
|
6171 | /***/ }),
|
6172 | /* 112 */
|
6173 | /***/ (function(module, exports, __webpack_require__) {
|
6174 |
|
6175 | var _Set = __webpack_require__(197);
|
6176 | var _curry2 = __webpack_require__(0);
|
6177 |
|
6178 |
|
6179 | /**
|
6180 | * Returns a new list containing only one copy of each element in the original
|
6181 | * list, based upon the value returned by applying the supplied function to
|
6182 | * each list element. Prefers the first item if the supplied function produces
|
6183 | * the same value on two items. `R.equals` is used for comparison.
|
6184 | *
|
6185 | * @func
|
6186 | * @memberOf R
|
6187 | * @since v0.16.0
|
6188 | * @category List
|
6189 | * @sig (a -> b) -> [a] -> [a]
|
6190 | * @param {Function} fn A function used to produce a value to use during comparisons.
|
6191 | * @param {Array} list The array to consider.
|
6192 | * @return {Array} The list of unique items.
|
6193 | * @example
|
6194 | *
|
6195 | * R.uniqBy(Math.abs, [-1, -5, 2, 10, 1, 2]); //=> [-1, -5, 2, 10]
|
6196 | */
|
6197 | module.exports = _curry2(function uniqBy(fn, list) {
|
6198 | var set = new _Set();
|
6199 | var result = [];
|
6200 | var idx = 0;
|
6201 | var appliedItem, item;
|
6202 |
|
6203 | while (idx < list.length) {
|
6204 | item = list[idx];
|
6205 | appliedItem = fn(item);
|
6206 | if (set.add(appliedItem)) {
|
6207 | result.push(item);
|
6208 | }
|
6209 | idx += 1;
|
6210 | }
|
6211 | return result;
|
6212 | });
|
6213 |
|
6214 |
|
6215 | /***/ }),
|
6216 | /* 113 */
|
6217 | /***/ (function(module, exports, __webpack_require__) {
|
6218 |
|
6219 | var _curry3 = __webpack_require__(2);
|
6220 | var adjust = __webpack_require__(60);
|
6221 | var always = __webpack_require__(19);
|
6222 |
|
6223 |
|
6224 | /**
|
6225 | * Returns a new copy of the array with the element at the provided index
|
6226 | * replaced with the given value.
|
6227 | *
|
6228 | * @func
|
6229 | * @memberOf R
|
6230 | * @since v0.14.0
|
6231 | * @category List
|
6232 | * @sig Number -> a -> [a] -> [a]
|
6233 | * @param {Number} idx The index to update.
|
6234 | * @param {*} x The value to exist at the given index of the returned array.
|
6235 | * @param {Array|Arguments} list The source array-like object to be updated.
|
6236 | * @return {Array} A copy of `list` with the value at index `idx` replaced with `x`.
|
6237 | * @see R.adjust
|
6238 | * @example
|
6239 | *
|
6240 | * R.update(1, 11, [0, 1, 2]); //=> [0, 11, 2]
|
6241 | * R.update(1)(11)([0, 1, 2]); //=> [0, 11, 2]
|
6242 | * @symb R.update(-1, a, [b, c]) = [b, a]
|
6243 | * @symb R.update(0, a, [b, c]) = [a, c]
|
6244 | * @symb R.update(1, a, [b, c]) = [b, a]
|
6245 | */
|
6246 | module.exports = _curry3(function update(idx, x, list) {
|
6247 | return adjust(always(x), idx, list);
|
6248 | });
|
6249 |
|
6250 |
|
6251 | /***/ }),
|
6252 | /* 114 */
|
6253 | /***/ (function(module, exports, __webpack_require__) {
|
6254 |
|
6255 | var _curry2 = __webpack_require__(0);
|
6256 | var curryN = __webpack_require__(5);
|
6257 |
|
6258 |
|
6259 | /**
|
6260 | * Accepts a function `fn` and a list of transformer functions and returns a
|
6261 | * new curried function. When the new function is invoked, it calls the
|
6262 | * function `fn` with parameters consisting of the result of calling each
|
6263 | * supplied handler on successive arguments to the new function.
|
6264 | *
|
6265 | * If more arguments are passed to the returned function than transformer
|
6266 | * functions, those arguments are passed directly to `fn` as additional
|
6267 | * parameters. If you expect additional arguments that don't need to be
|
6268 | * transformed, although you can ignore them, it's best to pass an identity
|
6269 | * function so that the new function reports the correct arity.
|
6270 | *
|
6271 | * @func
|
6272 | * @memberOf R
|
6273 | * @since v0.1.0
|
6274 | * @category Function
|
6275 | * @sig (x1 -> x2 -> ... -> z) -> [(a -> x1), (b -> x2), ...] -> (a -> b -> ... -> z)
|
6276 | * @param {Function} fn The function to wrap.
|
6277 | * @param {Array} transformers A list of transformer functions
|
6278 | * @return {Function} The wrapped function.
|
6279 | * @see R.converge
|
6280 | * @example
|
6281 | *
|
6282 | * R.useWith(Math.pow, [R.identity, R.identity])(3, 4); //=> 81
|
6283 | * R.useWith(Math.pow, [R.identity, R.identity])(3)(4); //=> 81
|
6284 | * R.useWith(Math.pow, [R.dec, R.inc])(3, 4); //=> 32
|
6285 | * R.useWith(Math.pow, [R.dec, R.inc])(3)(4); //=> 32
|
6286 | * @symb R.useWith(f, [g, h])(a, b) = f(g(a), h(b))
|
6287 | */
|
6288 | module.exports = _curry2(function useWith(fn, transformers) {
|
6289 | return curryN(transformers.length, function() {
|
6290 | var args = [];
|
6291 | var idx = 0;
|
6292 | while (idx < transformers.length) {
|
6293 | args.push(transformers[idx].call(this, arguments[idx]));
|
6294 | idx += 1;
|
6295 | }
|
6296 | return fn.apply(this, args.concat(Array.prototype.slice.call(arguments, transformers.length)));
|
6297 | });
|
6298 | });
|
6299 |
|
6300 |
|
6301 | /***/ }),
|
6302 | /* 115 */
|
6303 | /***/ (function(module, exports, __webpack_require__) {
|
6304 |
|
6305 | var _curry1 = __webpack_require__(1);
|
6306 | var keys = __webpack_require__(12);
|
6307 |
|
6308 |
|
6309 | /**
|
6310 | * Returns a list of all the enumerable own properties of the supplied object.
|
6311 | * Note that the order of the output array is not guaranteed across different
|
6312 | * JS platforms.
|
6313 | *
|
6314 | * @func
|
6315 | * @memberOf R
|
6316 | * @since v0.1.0
|
6317 | * @category Object
|
6318 | * @sig {k: v} -> [v]
|
6319 | * @param {Object} obj The object to extract values from
|
6320 | * @return {Array} An array of the values of the object's own properties.
|
6321 | * @example
|
6322 | *
|
6323 | * R.values({a: 1, b: 2, c: 3}); //=> [1, 2, 3]
|
6324 | */
|
6325 | module.exports = _curry1(function values(obj) {
|
6326 | var props = keys(obj);
|
6327 | var len = props.length;
|
6328 | var vals = [];
|
6329 | var idx = 0;
|
6330 | while (idx < len) {
|
6331 | vals[idx] = obj[props[idx]];
|
6332 | idx += 1;
|
6333 | }
|
6334 | return vals;
|
6335 | });
|
6336 |
|
6337 |
|
6338 | /***/ }),
|
6339 | /* 116 */
|
6340 | /***/ (function(module, exports, __webpack_require__) {
|
6341 |
|
6342 | var _curry2 = __webpack_require__(0);
|
6343 | var _has = __webpack_require__(6);
|
6344 |
|
6345 |
|
6346 | /**
|
6347 | * Takes a spec object and a test object; returns true if the test satisfies
|
6348 | * the spec. Each of the spec's own properties must be a predicate function.
|
6349 | * Each predicate is applied to the value of the corresponding property of the
|
6350 | * test object. `where` returns true if all the predicates return true, false
|
6351 | * otherwise.
|
6352 | *
|
6353 | * `where` is well suited to declaratively expressing constraints for other
|
6354 | * functions such as `filter` and `find`.
|
6355 | *
|
6356 | * @func
|
6357 | * @memberOf R
|
6358 | * @since v0.1.1
|
6359 | * @category Object
|
6360 | * @sig {String: (* -> Boolean)} -> {String: *} -> Boolean
|
6361 | * @param {Object} spec
|
6362 | * @param {Object} testObj
|
6363 | * @return {Boolean}
|
6364 | * @example
|
6365 | *
|
6366 | * // pred :: Object -> Boolean
|
6367 | * var pred = R.where({
|
6368 | * a: R.equals('foo'),
|
6369 | * b: R.complement(R.equals('bar')),
|
6370 | * x: R.gt(__, 10),
|
6371 | * y: R.lt(__, 20)
|
6372 | * });
|
6373 | *
|
6374 | * pred({a: 'foo', b: 'xxx', x: 11, y: 19}); //=> true
|
6375 | * pred({a: 'xxx', b: 'xxx', x: 11, y: 19}); //=> false
|
6376 | * pred({a: 'foo', b: 'bar', x: 11, y: 19}); //=> false
|
6377 | * pred({a: 'foo', b: 'xxx', x: 10, y: 19}); //=> false
|
6378 | * pred({a: 'foo', b: 'xxx', x: 11, y: 20}); //=> false
|
6379 | */
|
6380 | module.exports = _curry2(function where(spec, testObj) {
|
6381 | for (var prop in spec) {
|
6382 | if (_has(prop, spec) && !spec[prop](testObj[prop])) {
|
6383 | return false;
|
6384 | }
|
6385 | }
|
6386 | return true;
|
6387 | });
|
6388 |
|
6389 |
|
6390 | /***/ }),
|
6391 | /* 117 */
|
6392 | /***/ (function(module, __webpack_exports__, __webpack_require__) {
|
6393 |
|
6394 | "use strict";
|
6395 | /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_ramda__ = __webpack_require__(139);
|
6396 | /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_ramda___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_ramda__);
|
6397 | /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_jsbn__ = __webpack_require__(59);
|
6398 | /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1_jsbn___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_1_jsbn__);
|
6399 | /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_rusha__ = __webpack_require__(334);
|
6400 | /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2_rusha___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_2_rusha__);
|
6401 | /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__goodmind_node_cryptojs_aes__ = __webpack_require__(118);
|
6402 | /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__goodmind_node_cryptojs_aes___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_3__goodmind_node_cryptojs_aes__);
|
6403 | /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_pako_lib_inflate__ = __webpack_require__(128);
|
6404 | /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4_pako_lib_inflate___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_4_pako_lib_inflate__);
|
6405 | /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__service_secure_random__ = __webpack_require__(126);
|
6406 | /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__vendor_leemon__ = __webpack_require__(127);
|
6407 | /* unused harmony export bigint */
|
6408 | /* unused harmony export bigStringInt */
|
6409 | /* unused harmony export bytesToHex */
|
6410 | /* unused harmony export bytesFromHex */
|
6411 | /* unused harmony export bytesCmp */
|
6412 | /* unused harmony export bytesXor */
|
6413 | /* unused harmony export bytesToWords */
|
6414 | /* unused harmony export bytesFromWords */
|
6415 | /* unused harmony export bytesFromLeemonBigInt */
|
6416 | /* unused harmony export bytesToArrayBuffer */
|
6417 | /* unused harmony export convertToArrayBuffer */
|
6418 | /* unused harmony export convertToUint8Array */
|
6419 | /* unused harmony export convertToByteArray */
|
6420 | /* unused harmony export bytesFromArrayBuffer */
|
6421 | /* unused harmony export bufferConcat */
|
6422 | /* unused harmony export longToInts */
|
6423 | /* unused harmony export longToBytes */
|
6424 | /* unused harmony export longFromLem */
|
6425 | /* unused harmony export intToUint */
|
6426 | /* unused harmony export uintToInt */
|
6427 | /* harmony export (immutable) */ __webpack_exports__["c"] = sha1HashSync;
|
6428 | /* unused harmony export sha1BytesSync */
|
6429 | /* unused harmony export sha256HashSync */
|
6430 | /* unused harmony export rsaEncrypt */
|
6431 | /* unused harmony export addPadding */
|
6432 | /* harmony export (immutable) */ __webpack_exports__["d"] = aesEncryptSync;
|
6433 | /* harmony export (immutable) */ __webpack_exports__["e"] = aesDecryptSync;
|
6434 | /* unused harmony export gzipUncompress */
|
6435 | /* unused harmony export nextRandomInt */
|
6436 | /* harmony export (immutable) */ __webpack_exports__["a"] = pqPrimeFactorization;
|
6437 | /* unused harmony export pqPrimeLeemon */
|
6438 | /* harmony export (immutable) */ __webpack_exports__["b"] = bytesModPow;
|
6439 |
|
6440 |
|
6441 |
|
6442 |
|
6443 | const { CryptoJS } = __WEBPACK_IMPORTED_MODULE_3__goodmind_node_cryptojs_aes__;
|
6444 |
|
6445 |
|
6446 | // import Timer from 'hirestime' //TODO remove in prod!
|
6447 |
|
6448 |
|
6449 |
|
6450 |
|
6451 |
|
6452 | const rushaInstance = new __WEBPACK_IMPORTED_MODULE_2_rusha___default.a(1024 * 1024);
|
6453 |
|
6454 | function bigint(num) {
|
6455 | return new __WEBPACK_IMPORTED_MODULE_1_jsbn__["BigInteger"](num.toString(16), 16);
|
6456 | }
|
6457 |
|
6458 | function bigStringInt(strNum) {
|
6459 | return new __WEBPACK_IMPORTED_MODULE_1_jsbn__["BigInteger"](strNum, 10);
|
6460 | }
|
6461 |
|
6462 | const rShift32 = str => {
|
6463 | const num = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__vendor_leemon__["a" /* str2bigInt */])(str, 10, 0);
|
6464 | __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__vendor_leemon__["b" /* rightShift_ */])(num, 32);
|
6465 | return __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__vendor_leemon__["c" /* bigInt2str */])(num, 10);
|
6466 | };
|
6467 | /* unused harmony export rShift32 */
|
6468 |
|
6469 | const strDecToHex = str => __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0_ramda__["toLower"])(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__vendor_leemon__["c" /* bigInt2str */])(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__vendor_leemon__["a" /* str2bigInt */])(str, 10, 0), 16));
|
6470 | /* unused harmony export strDecToHex */
|
6471 |
|
6472 |
|
6473 | function bytesToHex(bytes = []) {
|
6474 | const arr = [];
|
6475 | for (let i = 0; i < bytes.length; i++) {
|
6476 | arr.push((bytes[i] < 16 ? '0' : '') + (bytes[i] || 0).toString(16));
|
6477 | }
|
6478 | return arr.join('');
|
6479 | }
|
6480 |
|
6481 | function bytesFromHex(hexString) {
|
6482 | const len = hexString.length;
|
6483 | let start = 0;
|
6484 | const bytes = [];
|
6485 |
|
6486 | if (hexString.length % 2) {
|
6487 | bytes.push(parseInt(hexString.charAt(0), 16));
|
6488 | start++;
|
6489 | }
|
6490 |
|
6491 | for (let i = start; i < len; i += 2) {
|
6492 | bytes.push(parseInt(hexString.substr(i, 2), 16));
|
6493 | }
|
6494 |
|
6495 | return bytes;
|
6496 | }
|
6497 |
|
6498 | function bytesCmp(bytes1, bytes2) {
|
6499 | const len = bytes1.length;
|
6500 | if (len !== bytes2.length) {
|
6501 | return false;
|
6502 | }
|
6503 |
|
6504 | for (let i = 0; i < len; i++) {
|
6505 | if (bytes1[i] !== bytes2[i]) return false;
|
6506 | }
|
6507 | return true;
|
6508 | }
|
6509 |
|
6510 | function bytesXor(bytes1, bytes2) {
|
6511 | const len = bytes1.length;
|
6512 | const bytes = [];
|
6513 |
|
6514 | for (let i = 0; i < len; ++i) {
|
6515 | bytes[i] = bytes1[i] ^ bytes2[i];
|
6516 | }
|
6517 |
|
6518 | return bytes;
|
6519 | }
|
6520 |
|
6521 | function bytesToWords(bytes) {
|
6522 | if (bytes instanceof ArrayBuffer) {
|
6523 | bytes = new Uint8Array(bytes);
|
6524 | }
|
6525 | const len = bytes.length;
|
6526 | const words = [];
|
6527 | let i;
|
6528 | for (i = 0; i < len; i++) {
|
6529 | words[i >>> 2] |= bytes[i] << 24 - i % 4 * 8;
|
6530 | }
|
6531 |
|
6532 | return new CryptoJS.lib.WordArray.init(words, len);
|
6533 | }
|
6534 |
|
6535 | function bytesFromWords(wordArray) {
|
6536 | const words = wordArray.words;
|
6537 | const sigBytes = wordArray.sigBytes;
|
6538 | const bytes = [];
|
6539 |
|
6540 | for (let i = 0; i < sigBytes; i++) {
|
6541 | bytes.push(words[i >>> 2] >>> 24 - i % 4 * 8 & 0xff);
|
6542 | }
|
6543 |
|
6544 | return bytes;
|
6545 | }
|
6546 |
|
6547 | function bytesFromLeemonBigInt(bigInt) {
|
6548 | const str = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__vendor_leemon__["c" /* bigInt2str */])(bigInt, 16);
|
6549 | return bytesFromHex(str);
|
6550 | }
|
6551 |
|
6552 | function bytesToArrayBuffer(b) {
|
6553 | return new Uint8Array(b).buffer;
|
6554 | }
|
6555 |
|
6556 | function convertToArrayBuffer(bytes) {
|
6557 | // Be careful with converting subarrays!!
|
6558 | if (bytes instanceof ArrayBuffer) {
|
6559 | return bytes;
|
6560 | }
|
6561 | if (bytes.buffer !== undefined && bytes.buffer.byteLength == bytes.length * bytes.BYTES_PER_ELEMENT) {
|
6562 | return bytes.buffer;
|
6563 | }
|
6564 | return bytesToArrayBuffer(bytes);
|
6565 | }
|
6566 |
|
6567 | function convertToUint8Array(bytes) {
|
6568 | if (bytes.buffer !== undefined) return bytes;
|
6569 | return new Uint8Array(bytes);
|
6570 | }
|
6571 |
|
6572 | function convertToByteArray(bytes) {
|
6573 | if (Array.isArray(bytes)) return bytes;
|
6574 | bytes = convertToUint8Array(bytes);
|
6575 | const newBytes = [];
|
6576 | for (let i = 0, len = bytes.length; i < len; i++) newBytes.push(bytes[i]);
|
6577 | return newBytes;
|
6578 | }
|
6579 |
|
6580 | function bytesFromArrayBuffer(buffer) {
|
6581 | const byteView = new Uint8Array(buffer);
|
6582 | const bytes = Array.from(byteView);
|
6583 | return bytes;
|
6584 | }
|
6585 |
|
6586 | function bufferConcat(buffer1, buffer2) {
|
6587 | const l1 = buffer1.byteLength || buffer1.length;
|
6588 | const l2 = buffer2.byteLength || buffer2.length;
|
6589 | const tmp = new Uint8Array(l1 + l2);
|
6590 | tmp.set(buffer1 instanceof ArrayBuffer ? new Uint8Array(buffer1) : buffer1, 0);
|
6591 | tmp.set(buffer2 instanceof ArrayBuffer ? new Uint8Array(buffer2) : buffer2, l1);
|
6592 |
|
6593 | return tmp.buffer;
|
6594 | }
|
6595 |
|
6596 | // const dividerBig = bigint(0x100000000)
|
6597 | const dividerLem = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__vendor_leemon__["a" /* str2bigInt */])('100000000', 16, 4);
|
6598 |
|
6599 | // const printTimers = (timeL, timeB, a, b, n) => setTimeout(
|
6600 | // () => console.log(`Timer L ${timeL} B ${timeB}`, ...a, ...b, n || ''),
|
6601 | // 100)
|
6602 |
|
6603 | function longToInts(sLong) {
|
6604 | /*const bigTime = Timer()
|
6605 | const divRem = bigStringInt(sLong).divideAndRemainder(dividerBig)
|
6606 | const divIntB = divRem[0].intValue()
|
6607 | const remIntB = divRem[1].intValue()
|
6608 | const resB = [
|
6609 | intToUint(divIntB),
|
6610 | intToUint(remIntB)
|
6611 | ]
|
6612 | const timeB = bigTime()*/
|
6613 |
|
6614 | // const lemTime = Timer()
|
6615 | const lemNum = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__vendor_leemon__["a" /* str2bigInt */])(sLong, 10, 6);
|
6616 | const div = new Array(lemNum.length);
|
6617 | const rem = new Array(lemNum.length);
|
6618 | __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__vendor_leemon__["d" /* divide_ */])(lemNum, dividerLem, div, rem);
|
6619 | const resL = [~~__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__vendor_leemon__["c" /* bigInt2str */])(div, 10), ~~__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__vendor_leemon__["c" /* bigInt2str */])(rem, 10)];
|
6620 | // const timeL = lemTime()
|
6621 |
|
6622 | // printTimers(timeL, timeB, resL, resB)
|
6623 | return resL;
|
6624 | }
|
6625 |
|
6626 | function longToBytes(sLong) {
|
6627 | return bytesFromWords({ words: longToInts(sLong), sigBytes: 8 }).reverse();
|
6628 | }
|
6629 |
|
6630 | function longFromLem(high, low) {
|
6631 | const highNum = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__vendor_leemon__["e" /* int2bigInt */])(high, 96, 0);
|
6632 | __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__vendor_leemon__["f" /* leftShift_ */])(highNum, 32);
|
6633 |
|
6634 | __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__vendor_leemon__["g" /* addInt_ */])(highNum, low);
|
6635 | const res = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__vendor_leemon__["c" /* bigInt2str */])(highNum, 10);
|
6636 | return res;
|
6637 | }
|
6638 |
|
6639 | function intToUint(val) {
|
6640 | val = parseInt(val); //TODO PERF parseInt is a perfomance issue
|
6641 | if (val < 0) val = val + 4294967296;
|
6642 | return val;
|
6643 | }
|
6644 |
|
6645 | function uintToInt(val) {
|
6646 | if (val > 2147483647) val = val - 4294967296;
|
6647 | return val;
|
6648 | }
|
6649 |
|
6650 | function sha1HashSync(bytes) {
|
6651 | // console.log(dT(), 'SHA-1 hash start', bytes.byteLength || bytes.length)
|
6652 | const hashBytes = rushaInstance.rawDigest(bytes).buffer;
|
6653 | // console.log(dT(), 'SHA-1 hash finish')
|
6654 |
|
6655 | return hashBytes;
|
6656 | }
|
6657 |
|
6658 | function sha1BytesSync(bytes) {
|
6659 | return bytesFromArrayBuffer(sha1HashSync(bytes));
|
6660 | }
|
6661 |
|
6662 | function sha256HashSync(bytes) {
|
6663 | // console.log(dT(), 'SHA-2 hash start', bytes.byteLength || bytes.length)
|
6664 | const hashWords = CryptoJS.SHA256(bytesToWords(bytes));
|
6665 | // console.log(dT(), 'SHA-2 hash finish')
|
6666 |
|
6667 | const hashBytes = bytesFromWords(hashWords);
|
6668 |
|
6669 | return hashBytes;
|
6670 | }
|
6671 |
|
6672 | function rsaEncrypt(publicKey, bytes) {
|
6673 | bytes = addPadding(bytes, 255);
|
6674 |
|
6675 | const N = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__vendor_leemon__["a" /* str2bigInt */])(publicKey.modulus, 16, 256);
|
6676 | const E = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__vendor_leemon__["a" /* str2bigInt */])(publicKey.exponent, 16, 256);
|
6677 | const X = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__vendor_leemon__["a" /* str2bigInt */])(bytesToHex(bytes), 16, 256);
|
6678 | const encryptedBigInt = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__vendor_leemon__["h" /* powMod */])(X, E, N),
|
6679 | encryptedBytes = bytesFromHex(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__vendor_leemon__["c" /* bigInt2str */])(encryptedBigInt, 16));
|
6680 |
|
6681 | return encryptedBytes;
|
6682 | }
|
6683 |
|
6684 | function addPadding(bytes, blockSize, zeroes) {
|
6685 | blockSize = blockSize || 16;
|
6686 | const len = bytes.byteLength || bytes.length;
|
6687 | const needPadding = blockSize - len % blockSize;
|
6688 | if (needPadding > 0 && needPadding < blockSize) {
|
6689 | const padding = new Array(needPadding);
|
6690 | if (zeroes) {
|
6691 | for (let i = 0; i < needPadding; i++) padding[i] = 0;
|
6692 | } else __WEBPACK_IMPORTED_MODULE_5__service_secure_random__["a" /* default */].nextBytes(padding);
|
6693 |
|
6694 | bytes = bytes instanceof ArrayBuffer ? bufferConcat(bytes, padding) : bytes.concat(padding);
|
6695 | }
|
6696 |
|
6697 | return bytes;
|
6698 | }
|
6699 |
|
6700 | function aesEncryptSync(bytes, keyBytes, ivBytes) {
|
6701 | const len = bytes.byteLength || bytes.length;
|
6702 |
|
6703 | // console.log(dT(), 'AES encrypt start', len/*, bytesToHex(keyBytes), bytesToHex(ivBytes)*/)
|
6704 | bytes = addPadding(bytes);
|
6705 |
|
6706 | const encryptedWords = CryptoJS.AES.encrypt(bytesToWords(bytes), bytesToWords(keyBytes), {
|
6707 | iv: bytesToWords(ivBytes),
|
6708 | padding: CryptoJS.pad.NoPadding,
|
6709 | mode: CryptoJS.mode.IGE
|
6710 | }).ciphertext;
|
6711 |
|
6712 | const encryptedBytes = bytesFromWords(encryptedWords);
|
6713 | // console.log(dT(), 'AES encrypt finish')
|
6714 |
|
6715 | return encryptedBytes;
|
6716 | }
|
6717 |
|
6718 | function aesDecryptSync(encryptedBytes, keyBytes, ivBytes) {
|
6719 |
|
6720 | // console.log(dT(), 'AES decrypt start', encryptedBytes.length)
|
6721 | const decryptedWords = CryptoJS.AES.decrypt({ ciphertext: bytesToWords(encryptedBytes) }, bytesToWords(keyBytes), {
|
6722 | iv: bytesToWords(ivBytes),
|
6723 | padding: CryptoJS.pad.NoPadding,
|
6724 | mode: CryptoJS.mode.IGE
|
6725 | });
|
6726 |
|
6727 | const bytes = bytesFromWords(decryptedWords);
|
6728 | // console.log(dT(), 'AES decrypt finish')
|
6729 |
|
6730 | return bytes;
|
6731 | }
|
6732 |
|
6733 | function gzipUncompress(bytes) {
|
6734 | // console.log('Gzip uncompress start')
|
6735 | const result = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_4_pako_lib_inflate__["inflate"])(bytes);
|
6736 | // console.log('Gzip uncompress finish')
|
6737 | return result;
|
6738 | }
|
6739 |
|
6740 | function nextRandomInt(maxValue) {
|
6741 | return Math.floor(Math.random() * maxValue);
|
6742 | }
|
6743 |
|
6744 | function pqPrimeFactorization(pqBytes) {
|
6745 | const minSize = Math.ceil(64 / __WEBPACK_IMPORTED_MODULE_6__vendor_leemon__["i" /* bpe */]) + 1;
|
6746 |
|
6747 | // const what = new BigInteger(pqBytes)
|
6748 | const hex = bytesToHex(pqBytes);
|
6749 | const lWhat = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__vendor_leemon__["a" /* str2bigInt */])(hex, 16, minSize);
|
6750 | const result = pqPrimeLeemon(lWhat);
|
6751 | return result;
|
6752 | }
|
6753 |
|
6754 | function pqPrimeLeemon(what) {
|
6755 | const minBits = 64;
|
6756 | const minLen = Math.ceil(minBits / __WEBPACK_IMPORTED_MODULE_6__vendor_leemon__["i" /* bpe */]) + 1;
|
6757 | let it = 0;
|
6758 | let q, lim;
|
6759 | const a = new Array(minLen);
|
6760 | const b = new Array(minLen);
|
6761 | const c = new Array(minLen);
|
6762 | const g = new Array(minLen);
|
6763 | const z = new Array(minLen);
|
6764 | const x = new Array(minLen);
|
6765 | const y = new Array(minLen);
|
6766 |
|
6767 | for (let i = 0; i < 3; i++) {
|
6768 | q = (nextRandomInt(128) & 15) + 17;
|
6769 | __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__vendor_leemon__["j" /* copyInt_ */])(x, nextRandomInt(1000000000) + 1);
|
6770 | __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__vendor_leemon__["k" /* copy_ */])(y, x);
|
6771 | lim = 1 << i + 18;
|
6772 |
|
6773 | for (let j = 1; j < lim; j++) {
|
6774 | ++it;
|
6775 | __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__vendor_leemon__["k" /* copy_ */])(a, x);
|
6776 | __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__vendor_leemon__["k" /* copy_ */])(b, x);
|
6777 | __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__vendor_leemon__["j" /* copyInt_ */])(c, q);
|
6778 |
|
6779 | while (!__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__vendor_leemon__["l" /* isZero */])(b)) {
|
6780 | if (b[0] & 1) {
|
6781 | __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__vendor_leemon__["m" /* add_ */])(c, a);
|
6782 | if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__vendor_leemon__["n" /* greater */])(c, what)) {
|
6783 | __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__vendor_leemon__["o" /* sub_ */])(c, what);
|
6784 | }
|
6785 | }
|
6786 | __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__vendor_leemon__["m" /* add_ */])(a, a);
|
6787 | if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__vendor_leemon__["n" /* greater */])(a, what)) {
|
6788 | __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__vendor_leemon__["o" /* sub_ */])(a, what);
|
6789 | }
|
6790 | __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__vendor_leemon__["b" /* rightShift_ */])(b, 1);
|
6791 | }
|
6792 |
|
6793 | __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__vendor_leemon__["k" /* copy_ */])(x, c);
|
6794 | if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__vendor_leemon__["n" /* greater */])(x, y)) {
|
6795 | __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__vendor_leemon__["k" /* copy_ */])(z, x);
|
6796 | __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__vendor_leemon__["o" /* sub_ */])(z, y);
|
6797 | } else {
|
6798 | __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__vendor_leemon__["k" /* copy_ */])(z, y);
|
6799 | __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__vendor_leemon__["o" /* sub_ */])(z, x);
|
6800 | }
|
6801 | __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__vendor_leemon__["p" /* eGCD_ */])(z, what, g, a, b);
|
6802 | if (!__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__vendor_leemon__["q" /* equalsInt */])(g, 1)) {
|
6803 | break;
|
6804 | }
|
6805 | if ((j & j - 1) === 0) {
|
6806 | __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__vendor_leemon__["k" /* copy_ */])(y, x);
|
6807 | }
|
6808 | }
|
6809 | if (__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__vendor_leemon__["n" /* greater */])(g, __WEBPACK_IMPORTED_MODULE_6__vendor_leemon__["r" /* one */])) {
|
6810 | break;
|
6811 | }
|
6812 | }
|
6813 |
|
6814 | __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__vendor_leemon__["d" /* divide_ */])(what, g, x, y);
|
6815 |
|
6816 | const [P, Q] = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__vendor_leemon__["n" /* greater */])(g, x) ? [x, g] : [g, x];
|
6817 |
|
6818 | // console.log(dT(), 'done', bigInt2str(what, 10), bigInt2str(P, 10), bigInt2str(Q, 10))
|
6819 |
|
6820 | return [bytesFromLeemonBigInt(P), bytesFromLeemonBigInt(Q), it];
|
6821 | }
|
6822 |
|
6823 | function bytesModPow(x, y, m) {
|
6824 | const xBigInt = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__vendor_leemon__["a" /* str2bigInt */])(bytesToHex(x), 16);
|
6825 | const yBigInt = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__vendor_leemon__["a" /* str2bigInt */])(bytesToHex(y), 16);
|
6826 | const mBigInt = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__vendor_leemon__["a" /* str2bigInt */])(bytesToHex(m), 16);
|
6827 | const resBigInt = __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__vendor_leemon__["h" /* powMod */])(xBigInt, yBigInt, mBigInt);
|
6828 |
|
6829 | return bytesFromHex(__webpack_require__.i(__WEBPACK_IMPORTED_MODULE_6__vendor_leemon__["c" /* bigInt2str */])(resBigInt, 16));
|
6830 | }
|
6831 |
|
6832 | /***/ }),
|
6833 | /* 118 */
|
6834 | /***/ (function(module, exports, __webpack_require__) {
|
6835 |
|
6836 | var CryptoJS = __webpack_require__(14).CryptoJS;
|
6837 | __webpack_require__(121);
|
6838 | __webpack_require__(124);
|
6839 | __webpack_require__(122);
|
6840 | __webpack_require__(120);
|
6841 | __webpack_require__(119);
|
6842 | __webpack_require__(125);
|
6843 | var JsonFormatter = __webpack_require__(123).JsonFormatter;
|
6844 |
|
6845 | exports.CryptoJS = CryptoJS;
|
6846 | exports.JsonFormatter = JsonFormatter;
|
6847 |
|
6848 | /***/ }),
|
6849 | /* 119 */
|
6850 | /***/ (function(module, exports, __webpack_require__) {
|
6851 |
|
6852 | var CryptoJS = __webpack_require__(14).CryptoJS;
|
6853 |
|
6854 | /*
|
6855 | CryptoJS v3.1.2
|
6856 | code.google.com/p/crypto-js
|
6857 | (c) 2009-2013 by Jeff Mott. All rights reserved.
|
6858 | code.google.com/p/crypto-js/wiki/License
|
6859 | */
|
6860 | (function () {
|
6861 | // Shortcuts
|
6862 | var C = CryptoJS;
|
6863 | var C_lib = C.lib;
|
6864 | var BlockCipher = C_lib.BlockCipher;
|
6865 | var C_algo = C.algo;
|
6866 |
|
6867 | // Lookup tables
|
6868 | var SBOX = [];
|
6869 | var INV_SBOX = [];
|
6870 | var SUB_MIX_0 = [];
|
6871 | var SUB_MIX_1 = [];
|
6872 | var SUB_MIX_2 = [];
|
6873 | var SUB_MIX_3 = [];
|
6874 | var INV_SUB_MIX_0 = [];
|
6875 | var INV_SUB_MIX_1 = [];
|
6876 | var INV_SUB_MIX_2 = [];
|
6877 | var INV_SUB_MIX_3 = [];
|
6878 |
|
6879 | // Compute lookup tables
|
6880 | (function () {
|
6881 | // Compute double table
|
6882 | var d = [];
|
6883 | for (var i = 0; i < 256; i++) {
|
6884 | if (i < 128) {
|
6885 | d[i] = i << 1;
|
6886 | } else {
|
6887 | d[i] = (i << 1) ^ 0x11b;
|
6888 | }
|
6889 | }
|
6890 |
|
6891 | // Walk GF(2^8)
|
6892 | var x = 0;
|
6893 | var xi = 0;
|
6894 | for (var i = 0; i < 256; i++) {
|
6895 | // Compute sbox
|
6896 | var sx = xi ^ (xi << 1) ^ (xi << 2) ^ (xi << 3) ^ (xi << 4);
|
6897 | sx = (sx >>> 8) ^ (sx & 0xff) ^ 0x63;
|
6898 | SBOX[x] = sx;
|
6899 | INV_SBOX[sx] = x;
|
6900 |
|
6901 | // Compute multiplication
|
6902 | var x2 = d[x];
|
6903 | var x4 = d[x2];
|
6904 | var x8 = d[x4];
|
6905 |
|
6906 | // Compute sub bytes, mix columns tables
|
6907 | var t = (d[sx] * 0x101) ^ (sx * 0x1010100);
|
6908 | SUB_MIX_0[x] = (t << 24) | (t >>> 8);
|
6909 | SUB_MIX_1[x] = (t << 16) | (t >>> 16);
|
6910 | SUB_MIX_2[x] = (t << 8) | (t >>> 24);
|
6911 | SUB_MIX_3[x] = t;
|
6912 |
|
6913 | // Compute inv sub bytes, inv mix columns tables
|
6914 | var t = (x8 * 0x1010101) ^ (x4 * 0x10001) ^ (x2 * 0x101) ^ (x * 0x1010100);
|
6915 | INV_SUB_MIX_0[sx] = (t << 24) | (t >>> 8);
|
6916 | INV_SUB_MIX_1[sx] = (t << 16) | (t >>> 16);
|
6917 | INV_SUB_MIX_2[sx] = (t << 8) | (t >>> 24);
|
6918 | INV_SUB_MIX_3[sx] = t;
|
6919 |
|
6920 | // Compute next counter
|
6921 | if (!x) {
|
6922 | x = xi = 1;
|
6923 | } else {
|
6924 | x = x2 ^ d[d[d[x8 ^ x2]]];
|
6925 | xi ^= d[d[xi]];
|
6926 | }
|
6927 | }
|
6928 | }());
|
6929 |
|
6930 | // Precomputed Rcon lookup
|
6931 | var RCON = [0x00, 0x01, 0x02, 0x04, 0x08, 0x10, 0x20, 0x40, 0x80, 0x1b, 0x36];
|
6932 |
|
6933 | /**
|
6934 | * AES block cipher algorithm.
|
6935 | */
|
6936 | var AES = C_algo.AES = BlockCipher.extend({
|
6937 | _doReset: function () {
|
6938 | // Shortcuts
|
6939 | var key = this._key;
|
6940 | var keyWords = key.words;
|
6941 | var keySize = key.sigBytes / 4;
|
6942 |
|
6943 | // Compute number of rounds
|
6944 | var nRounds = this._nRounds = keySize + 6
|
6945 |
|
6946 | // Compute number of key schedule rows
|
6947 | var ksRows = (nRounds + 1) * 4;
|
6948 |
|
6949 | // Compute key schedule
|
6950 | var keySchedule = this._keySchedule = [];
|
6951 | for (var ksRow = 0; ksRow < ksRows; ksRow++) {
|
6952 | if (ksRow < keySize) {
|
6953 | keySchedule[ksRow] = keyWords[ksRow];
|
6954 | } else {
|
6955 | var t = keySchedule[ksRow - 1];
|
6956 |
|
6957 | if (!(ksRow % keySize)) {
|
6958 | // Rot word
|
6959 | t = (t << 8) | (t >>> 24);
|
6960 |
|
6961 | // Sub word
|
6962 | t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
|
6963 |
|
6964 | // Mix Rcon
|
6965 | t ^= RCON[(ksRow / keySize) | 0] << 24;
|
6966 | } else if (keySize > 6 && ksRow % keySize == 4) {
|
6967 | // Sub word
|
6968 | t = (SBOX[t >>> 24] << 24) | (SBOX[(t >>> 16) & 0xff] << 16) | (SBOX[(t >>> 8) & 0xff] << 8) | SBOX[t & 0xff];
|
6969 | }
|
6970 |
|
6971 | keySchedule[ksRow] = keySchedule[ksRow - keySize] ^ t;
|
6972 | }
|
6973 | }
|
6974 |
|
6975 | // Compute inv key schedule
|
6976 | var invKeySchedule = this._invKeySchedule = [];
|
6977 | for (var invKsRow = 0; invKsRow < ksRows; invKsRow++) {
|
6978 | var ksRow = ksRows - invKsRow;
|
6979 |
|
6980 | if (invKsRow % 4) {
|
6981 | var t = keySchedule[ksRow];
|
6982 | } else {
|
6983 | var t = keySchedule[ksRow - 4];
|
6984 | }
|
6985 |
|
6986 | if (invKsRow < 4 || ksRow <= 4) {
|
6987 | invKeySchedule[invKsRow] = t;
|
6988 | } else {
|
6989 | invKeySchedule[invKsRow] = INV_SUB_MIX_0[SBOX[t >>> 24]] ^ INV_SUB_MIX_1[SBOX[(t >>> 16) & 0xff]] ^
|
6990 | INV_SUB_MIX_2[SBOX[(t >>> 8) & 0xff]] ^ INV_SUB_MIX_3[SBOX[t & 0xff]];
|
6991 | }
|
6992 | }
|
6993 | },
|
6994 |
|
6995 | encryptBlock: function (M, offset) {
|
6996 | this._doCryptBlock(M, offset, this._keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX);
|
6997 | },
|
6998 |
|
6999 | decryptBlock: function (M, offset) {
|
7000 | // Swap 2nd and 4th rows
|
7001 | var t = M[offset + 1];
|
7002 | M[offset + 1] = M[offset + 3];
|
7003 | M[offset + 3] = t;
|
7004 |
|
7005 | this._doCryptBlock(M, offset, this._invKeySchedule, INV_SUB_MIX_0, INV_SUB_MIX_1, INV_SUB_MIX_2, INV_SUB_MIX_3, INV_SBOX);
|
7006 |
|
7007 | // Inv swap 2nd and 4th rows
|
7008 | var t = M[offset + 1];
|
7009 | M[offset + 1] = M[offset + 3];
|
7010 | M[offset + 3] = t;
|
7011 | },
|
7012 |
|
7013 | _doCryptBlock: function (M, offset, keySchedule, SUB_MIX_0, SUB_MIX_1, SUB_MIX_2, SUB_MIX_3, SBOX) {
|
7014 | // Shortcut
|
7015 | var nRounds = this._nRounds;
|
7016 |
|
7017 | // Get input, add round key
|
7018 | var s0 = M[offset] ^ keySchedule[0];
|
7019 | var s1 = M[offset + 1] ^ keySchedule[1];
|
7020 | var s2 = M[offset + 2] ^ keySchedule[2];
|
7021 | var s3 = M[offset + 3] ^ keySchedule[3];
|
7022 |
|
7023 | // Key schedule row counter
|
7024 | var ksRow = 4;
|
7025 |
|
7026 | // Rounds
|
7027 | for (var round = 1; round < nRounds; round++) {
|
7028 | // Shift rows, sub bytes, mix columns, add round key
|
7029 | var t0 = SUB_MIX_0[s0 >>> 24] ^ SUB_MIX_1[(s1 >>> 16) & 0xff] ^ SUB_MIX_2[(s2 >>> 8) & 0xff] ^ SUB_MIX_3[s3 & 0xff] ^ keySchedule[ksRow++];
|
7030 | var t1 = SUB_MIX_0[s1 >>> 24] ^ SUB_MIX_1[(s2 >>> 16) & 0xff] ^ SUB_MIX_2[(s3 >>> 8) & 0xff] ^ SUB_MIX_3[s0 & 0xff] ^ keySchedule[ksRow++];
|
7031 | var t2 = SUB_MIX_0[s2 >>> 24] ^ SUB_MIX_1[(s3 >>> 16) & 0xff] ^ SUB_MIX_2[(s0 >>> 8) & 0xff] ^ SUB_MIX_3[s1 & 0xff] ^ keySchedule[ksRow++];
|
7032 | var t3 = SUB_MIX_0[s3 >>> 24] ^ SUB_MIX_1[(s0 >>> 16) & 0xff] ^ SUB_MIX_2[(s1 >>> 8) & 0xff] ^ SUB_MIX_3[s2 & 0xff] ^ keySchedule[ksRow++];
|
7033 |
|
7034 | // Update state
|
7035 | s0 = t0;
|
7036 | s1 = t1;
|
7037 | s2 = t2;
|
7038 | s3 = t3;
|
7039 | }
|
7040 |
|
7041 | // Shift rows, sub bytes, add round key
|
7042 | var t0 = ((SBOX[s0 >>> 24] << 24) | (SBOX[(s1 >>> 16) & 0xff] << 16) | (SBOX[(s2 >>> 8) & 0xff] << 8) | SBOX[s3 & 0xff]) ^ keySchedule[ksRow++];
|
7043 | var t1 = ((SBOX[s1 >>> 24] << 24) | (SBOX[(s2 >>> 16) & 0xff] << 16) | (SBOX[(s3 >>> 8) & 0xff] << 8) | SBOX[s0 & 0xff]) ^ keySchedule[ksRow++];
|
7044 | var t2 = ((SBOX[s2 >>> 24] << 24) | (SBOX[(s3 >>> 16) & 0xff] << 16) | (SBOX[(s0 >>> 8) & 0xff] << 8) | SBOX[s1 & 0xff]) ^ keySchedule[ksRow++];
|
7045 | var t3 = ((SBOX[s3 >>> 24] << 24) | (SBOX[(s0 >>> 16) & 0xff] << 16) | (SBOX[(s1 >>> 8) & 0xff] << 8) | SBOX[s2 & 0xff]) ^ keySchedule[ksRow++];
|
7046 |
|
7047 | // Set output
|
7048 | M[offset] = t0;
|
7049 | M[offset + 1] = t1;
|
7050 | M[offset + 2] = t2;
|
7051 | M[offset + 3] = t3;
|
7052 | },
|
7053 |
|
7054 | keySize: 256/32
|
7055 | });
|
7056 |
|
7057 | /**
|
7058 | * Shortcut functions to the cipher's object interface.
|
7059 | *
|
7060 | * @example
|
7061 | *
|
7062 | * var ciphertext = CryptoJS.AES.encrypt(message, key, cfg);
|
7063 | * var plaintext = CryptoJS.AES.decrypt(ciphertext, key, cfg);
|
7064 | */
|
7065 | C.AES = BlockCipher._createHelper(AES);
|
7066 | }());
|
7067 |
|
7068 |
|
7069 | /***/ }),
|
7070 | /* 120 */
|
7071 | /***/ (function(module, exports, __webpack_require__) {
|
7072 |
|
7073 | var CryptoJS = __webpack_require__(14).CryptoJS;
|
7074 |
|
7075 | /*
|
7076 | CryptoJS v3.1.2
|
7077 | code.google.com/p/crypto-js
|
7078 | (c) 2009-2013 by Jeff Mott. All rights reserved.
|
7079 | code.google.com/p/crypto-js/wiki/License
|
7080 | */
|
7081 | /**
|
7082 | * Cipher core components.
|
7083 | */
|
7084 | CryptoJS.lib.Cipher || (function (undefined) {
|
7085 | // Shortcuts
|
7086 | var C = CryptoJS;
|
7087 | var C_lib = C.lib;
|
7088 | var Base = C_lib.Base;
|
7089 | var WordArray = C_lib.WordArray;
|
7090 | var BufferedBlockAlgorithm = C_lib.BufferedBlockAlgorithm;
|
7091 | var C_enc = C.enc;
|
7092 | var Utf8 = C_enc.Utf8;
|
7093 | var Base64 = C_enc.Base64;
|
7094 | var C_algo = C.algo;
|
7095 | var EvpKDF = C_algo.EvpKDF;
|
7096 |
|
7097 | /**
|
7098 | * Abstract base cipher template.
|
7099 | *
|
7100 | * @property {number} keySize This cipher's key size. Default: 4 (128 bits)
|
7101 | * @property {number} ivSize This cipher's IV size. Default: 4 (128 bits)
|
7102 | * @property {number} _ENC_XFORM_MODE A constant representing encryption mode.
|
7103 | * @property {number} _DEC_XFORM_MODE A constant representing decryption mode.
|
7104 | */
|
7105 | var Cipher = C_lib.Cipher = BufferedBlockAlgorithm.extend({
|
7106 | /**
|
7107 | * Configuration options.
|
7108 | *
|
7109 | * @property {WordArray} iv The IV to use for this operation.
|
7110 | */
|
7111 | cfg: Base.extend(),
|
7112 |
|
7113 | /**
|
7114 | * Creates this cipher in encryption mode.
|
7115 | *
|
7116 | * @param {WordArray} key The key.
|
7117 | * @param {Object} cfg (Optional) The configuration options to use for this operation.
|
7118 | *
|
7119 | * @return {Cipher} A cipher instance.
|
7120 | *
|
7121 | * @static
|
7122 | *
|
7123 | * @example
|
7124 | *
|
7125 | * var cipher = CryptoJS.algo.AES.createEncryptor(keyWordArray, { iv: ivWordArray });
|
7126 | */
|
7127 | createEncryptor: function (key, cfg) {
|
7128 | return this.create(this._ENC_XFORM_MODE, key, cfg);
|
7129 | },
|
7130 |
|
7131 | /**
|
7132 | * Creates this cipher in decryption mode.
|
7133 | *
|
7134 | * @param {WordArray} key The key.
|
7135 | * @param {Object} cfg (Optional) The configuration options to use for this operation.
|
7136 | *
|
7137 | * @return {Cipher} A cipher instance.
|
7138 | *
|
7139 | * @static
|
7140 | *
|
7141 | * @example
|
7142 | *
|
7143 | * var cipher = CryptoJS.algo.AES.createDecryptor(keyWordArray, { iv: ivWordArray });
|
7144 | */
|
7145 | createDecryptor: function (key, cfg) {
|
7146 | return this.create(this._DEC_XFORM_MODE, key, cfg);
|
7147 | },
|
7148 |
|
7149 | /**
|
7150 | * Initializes a newly created cipher.
|
7151 | *
|
7152 | * @param {number} xformMode Either the encryption or decryption transormation mode constant.
|
7153 | * @param {WordArray} key The key.
|
7154 | * @param {Object} cfg (Optional) The configuration options to use for this operation.
|
7155 | *
|
7156 | * @example
|
7157 | *
|
7158 | * var cipher = CryptoJS.algo.AES.create(CryptoJS.algo.AES._ENC_XFORM_MODE, keyWordArray, { iv: ivWordArray });
|
7159 | */
|
7160 | init: function (xformMode, key, cfg) {
|
7161 | // Apply config defaults
|
7162 | this.cfg = this.cfg.extend(cfg);
|
7163 |
|
7164 | // Store transform mode and key
|
7165 | this._xformMode = xformMode;
|
7166 | this._key = key;
|
7167 |
|
7168 | // Set initial values
|
7169 | this.reset();
|
7170 | },
|
7171 |
|
7172 | /**
|
7173 | * Resets this cipher to its initial state.
|
7174 | *
|
7175 | * @example
|
7176 | *
|
7177 | * cipher.reset();
|
7178 | */
|
7179 | reset: function () {
|
7180 | // Reset data buffer
|
7181 | BufferedBlockAlgorithm.reset.call(this);
|
7182 |
|
7183 | // Perform concrete-cipher logic
|
7184 | this._doReset();
|
7185 | },
|
7186 |
|
7187 | /**
|
7188 | * Adds data to be encrypted or decrypted.
|
7189 | *
|
7190 | * @param {WordArray|string} dataUpdate The data to encrypt or decrypt.
|
7191 | *
|
7192 | * @return {WordArray} The data after processing.
|
7193 | *
|
7194 | * @example
|
7195 | *
|
7196 | * var encrypted = cipher.process('data');
|
7197 | * var encrypted = cipher.process(wordArray);
|
7198 | */
|
7199 | process: function (dataUpdate) {
|
7200 | // Append
|
7201 | this._append(dataUpdate);
|
7202 |
|
7203 | // Process available blocks
|
7204 | return this._process();
|
7205 | },
|
7206 |
|
7207 | /**
|
7208 | * Finalizes the encryption or decryption process.
|
7209 | * Note that the finalize operation is effectively a destructive, read-once operation.
|
7210 | *
|
7211 | * @param {WordArray|string} dataUpdate The final data to encrypt or decrypt.
|
7212 | *
|
7213 | * @return {WordArray} The data after final processing.
|
7214 | *
|
7215 | * @example
|
7216 | *
|
7217 | * var encrypted = cipher.finalize();
|
7218 | * var encrypted = cipher.finalize('data');
|
7219 | * var encrypted = cipher.finalize(wordArray);
|
7220 | */
|
7221 | finalize: function (dataUpdate) {
|
7222 | // Final data update
|
7223 | if (dataUpdate) {
|
7224 | this._append(dataUpdate);
|
7225 | }
|
7226 |
|
7227 | // Perform concrete-cipher logic
|
7228 | var finalProcessedData = this._doFinalize();
|
7229 |
|
7230 | return finalProcessedData;
|
7231 | },
|
7232 |
|
7233 | keySize: 128/32,
|
7234 |
|
7235 | ivSize: 128/32,
|
7236 |
|
7237 | _ENC_XFORM_MODE: 1,
|
7238 |
|
7239 | _DEC_XFORM_MODE: 2,
|
7240 |
|
7241 | /**
|
7242 | * Creates shortcut functions to a cipher's object interface.
|
7243 | *
|
7244 | * @param {Cipher} cipher The cipher to create a helper for.
|
7245 | *
|
7246 | * @return {Object} An object with encrypt and decrypt shortcut functions.
|
7247 | *
|
7248 | * @static
|
7249 | *
|
7250 | * @example
|
7251 | *
|
7252 | * var AES = CryptoJS.lib.Cipher._createHelper(CryptoJS.algo.AES);
|
7253 | */
|
7254 | _createHelper: (function () {
|
7255 | function selectCipherStrategy(key) {
|
7256 | if (typeof key == 'string') {
|
7257 | return PasswordBasedCipher;
|
7258 | } else {
|
7259 | return SerializableCipher;
|
7260 | }
|
7261 | }
|
7262 |
|
7263 | return function (cipher) {
|
7264 | return {
|
7265 | encrypt: function (message, key, cfg) {
|
7266 | return selectCipherStrategy(key).encrypt(cipher, message, key, cfg);
|
7267 | },
|
7268 |
|
7269 | decrypt: function (ciphertext, key, cfg) {
|
7270 | return selectCipherStrategy(key).decrypt(cipher, ciphertext, key, cfg);
|
7271 | }
|
7272 | };
|
7273 | };
|
7274 | }())
|
7275 | });
|
7276 |
|
7277 | /**
|
7278 | * Abstract base stream cipher template.
|
7279 | *
|
7280 | * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 1 (32 bits)
|
7281 | */
|
7282 | var StreamCipher = C_lib.StreamCipher = Cipher.extend({
|
7283 | _doFinalize: function () {
|
7284 | // Process partial blocks
|
7285 | var finalProcessedBlocks = this._process(!!'flush');
|
7286 |
|
7287 | return finalProcessedBlocks;
|
7288 | },
|
7289 |
|
7290 | blockSize: 1
|
7291 | });
|
7292 |
|
7293 | /**
|
7294 | * Mode namespace.
|
7295 | */
|
7296 | var C_mode = C.mode = {};
|
7297 |
|
7298 | /**
|
7299 | * Abstract base block cipher mode template.
|
7300 | */
|
7301 | var BlockCipherMode = C_lib.BlockCipherMode = Base.extend({
|
7302 | /**
|
7303 | * Creates this mode for encryption.
|
7304 | *
|
7305 | * @param {Cipher} cipher A block cipher instance.
|
7306 | * @param {Array} iv The IV words.
|
7307 | *
|
7308 | * @static
|
7309 | *
|
7310 | * @example
|
7311 | *
|
7312 | * var mode = CryptoJS.mode.CBC.createEncryptor(cipher, iv.words);
|
7313 | */
|
7314 | createEncryptor: function (cipher, iv) {
|
7315 | return this.Encryptor.create(cipher, iv);
|
7316 | },
|
7317 |
|
7318 | /**
|
7319 | * Creates this mode for decryption.
|
7320 | *
|
7321 | * @param {Cipher} cipher A block cipher instance.
|
7322 | * @param {Array} iv The IV words.
|
7323 | *
|
7324 | * @static
|
7325 | *
|
7326 | * @example
|
7327 | *
|
7328 | * var mode = CryptoJS.mode.CBC.createDecryptor(cipher, iv.words);
|
7329 | */
|
7330 | createDecryptor: function (cipher, iv) {
|
7331 | return this.Decryptor.create(cipher, iv);
|
7332 | },
|
7333 |
|
7334 | /**
|
7335 | * Initializes a newly created mode.
|
7336 | *
|
7337 | * @param {Cipher} cipher A block cipher instance.
|
7338 | * @param {Array} iv The IV words.
|
7339 | *
|
7340 | * @example
|
7341 | *
|
7342 | * var mode = CryptoJS.mode.CBC.Encryptor.create(cipher, iv.words);
|
7343 | */
|
7344 | init: function (cipher, iv) {
|
7345 | this._cipher = cipher;
|
7346 | this._iv = iv;
|
7347 | }
|
7348 | });
|
7349 |
|
7350 | /**
|
7351 | * Cipher Block Chaining mode.
|
7352 | */
|
7353 | var CBC = C_mode.CBC = (function () {
|
7354 | /**
|
7355 | * Abstract base CBC mode.
|
7356 | */
|
7357 | var CBC = BlockCipherMode.extend();
|
7358 |
|
7359 | /**
|
7360 | * CBC encryptor.
|
7361 | */
|
7362 | CBC.Encryptor = CBC.extend({
|
7363 | /**
|
7364 | * Processes the data block at offset.
|
7365 | *
|
7366 | * @param {Array} words The data words to operate on.
|
7367 | * @param {number} offset The offset where the block starts.
|
7368 | *
|
7369 | * @example
|
7370 | *
|
7371 | * mode.processBlock(data.words, offset);
|
7372 | */
|
7373 | processBlock: function (words, offset) {
|
7374 | // Shortcuts
|
7375 | var cipher = this._cipher;
|
7376 | var blockSize = cipher.blockSize;
|
7377 |
|
7378 | // XOR and encrypt
|
7379 | xorBlock.call(this, words, offset, blockSize);
|
7380 | cipher.encryptBlock(words, offset);
|
7381 |
|
7382 | // Remember this block to use with next block
|
7383 | this._prevBlock = words.slice(offset, offset + blockSize);
|
7384 | }
|
7385 | });
|
7386 |
|
7387 | /**
|
7388 | * CBC decryptor.
|
7389 | */
|
7390 | CBC.Decryptor = CBC.extend({
|
7391 | /**
|
7392 | * Processes the data block at offset.
|
7393 | *
|
7394 | * @param {Array} words The data words to operate on.
|
7395 | * @param {number} offset The offset where the block starts.
|
7396 | *
|
7397 | * @example
|
7398 | *
|
7399 | * mode.processBlock(data.words, offset);
|
7400 | */
|
7401 | processBlock: function (words, offset) {
|
7402 | // Shortcuts
|
7403 | var cipher = this._cipher;
|
7404 | var blockSize = cipher.blockSize;
|
7405 |
|
7406 | // Remember this block to use with next block
|
7407 | var thisBlock = words.slice(offset, offset + blockSize);
|
7408 |
|
7409 | // Decrypt and XOR
|
7410 | cipher.decryptBlock(words, offset);
|
7411 | xorBlock.call(this, words, offset, blockSize);
|
7412 |
|
7413 | // This block becomes the previous block
|
7414 | this._prevBlock = thisBlock;
|
7415 | }
|
7416 | });
|
7417 |
|
7418 | function xorBlock(words, offset, blockSize) {
|
7419 | // Shortcut
|
7420 | var iv = this._iv;
|
7421 |
|
7422 | // Choose mixing block
|
7423 | if (iv) {
|
7424 | var block = iv;
|
7425 |
|
7426 | // Remove IV for subsequent blocks
|
7427 | this._iv = undefined;
|
7428 | } else {
|
7429 | var block = this._prevBlock;
|
7430 | }
|
7431 |
|
7432 | // XOR blocks
|
7433 | for (var i = 0; i < blockSize; i++) {
|
7434 | words[offset + i] ^= block[i];
|
7435 | }
|
7436 | }
|
7437 |
|
7438 | return CBC;
|
7439 | }());
|
7440 |
|
7441 | /**
|
7442 | * Infinite Garble Extension mode.
|
7443 | */
|
7444 | var IGE = C_mode.IGE = (function () {
|
7445 | /**
|
7446 | * Abstract base IGE mode.
|
7447 | */
|
7448 | var IGE = BlockCipherMode.extend();
|
7449 |
|
7450 | /**
|
7451 | * IGE encryptor.
|
7452 | */
|
7453 | IGE.Encryptor = IGE.extend({
|
7454 | /**
|
7455 | * Processes the data block at offset.
|
7456 | *
|
7457 | * @param {Array} words The data words to operate on.
|
7458 | * @param {number} offset The offset where the block starts.
|
7459 | *
|
7460 | * @example
|
7461 | *
|
7462 | * mode.processBlock(data.words, offset);
|
7463 | */
|
7464 | processBlock: function (words, offset) {
|
7465 | // Shortcuts
|
7466 | var cipher = this._cipher;
|
7467 | var blockSize = cipher.blockSize;
|
7468 |
|
7469 | if (this._ivp === undefined) {
|
7470 | this._ivp = this._iv.slice(0, blockSize);
|
7471 | this._iv2p = this._iv.slice(blockSize, blockSize + blockSize);
|
7472 | }
|
7473 |
|
7474 |
|
7475 | // Remember this block to use with next block
|
7476 | var nextIv2p = words.slice(offset, offset + blockSize);
|
7477 |
|
7478 | // XOR with previous ciphertext
|
7479 | xorBlock(words, this._ivp, offset, blockSize);
|
7480 |
|
7481 | // Block cipher
|
7482 | cipher.encryptBlock(words, offset);
|
7483 |
|
7484 | // XOR with previous plaintext
|
7485 | xorBlock(words, this._iv2p, offset, blockSize);
|
7486 |
|
7487 | this._ivp = words.slice(offset, offset + blockSize);
|
7488 | this._iv2p = nextIv2p;
|
7489 | }
|
7490 | });
|
7491 |
|
7492 | /**
|
7493 | * IGE decryptor.
|
7494 | */
|
7495 | IGE.Decryptor = IGE.extend({
|
7496 | /**
|
7497 | * Processes the data block at offset.
|
7498 | *
|
7499 | * @param {Array} words The data words to operate on.
|
7500 | * @param {number} offset The offset where the block starts.
|
7501 | *
|
7502 | * @example
|
7503 | *
|
7504 | * mode.processBlock(data.words, offset);
|
7505 | */
|
7506 | processBlock: function (words, offset) {
|
7507 | // Shortcuts
|
7508 | var cipher = this._cipher;
|
7509 | var blockSize = cipher.blockSize;
|
7510 |
|
7511 | if (this._ivp === undefined) {
|
7512 | this._ivp = this._iv.slice(0, blockSize);
|
7513 | this._iv2p = this._iv.slice(blockSize, 2 * blockSize);
|
7514 | }
|
7515 |
|
7516 | // Remember this block to use with next block
|
7517 | var nextIvp = words.slice(offset, offset + blockSize);
|
7518 |
|
7519 | // XOR with previous ciphertext
|
7520 | xorBlock(words, this._iv2p, offset, blockSize);
|
7521 |
|
7522 | // Block cipher
|
7523 | cipher.decryptBlock(words, offset);
|
7524 |
|
7525 | // XOR with previous plaintext
|
7526 | xorBlock(words, this._ivp, offset, blockSize);
|
7527 |
|
7528 | this._ivp = nextIvp;
|
7529 | this._iv2p = words.slice(offset, offset + blockSize);
|
7530 | }
|
7531 | });
|
7532 |
|
7533 | function xorBlock(words, block, offset, blockSize) {
|
7534 | for (var i = 0; i < blockSize; i++) {
|
7535 | words[offset + i] ^= block[i];
|
7536 | }
|
7537 | }
|
7538 |
|
7539 | return IGE;
|
7540 | }());
|
7541 |
|
7542 | /**
|
7543 | * Padding namespace.
|
7544 | */
|
7545 | var C_pad = C.pad = {};
|
7546 |
|
7547 | /**
|
7548 | * PKCS #5/7 padding strategy.
|
7549 | */
|
7550 | var Pkcs7 = C_pad.Pkcs7 = {
|
7551 | /**
|
7552 | * Pads data using the algorithm defined in PKCS #5/7.
|
7553 | *
|
7554 | * @param {WordArray} data The data to pad.
|
7555 | * @param {number} blockSize The multiple that the data should be padded to.
|
7556 | *
|
7557 | * @static
|
7558 | *
|
7559 | * @example
|
7560 | *
|
7561 | * CryptoJS.pad.Pkcs7.pad(wordArray, 4);
|
7562 | */
|
7563 | pad: function (data, blockSize) {
|
7564 | // Shortcut
|
7565 | var blockSizeBytes = blockSize * 4;
|
7566 |
|
7567 | // Count padding bytes
|
7568 | var nPaddingBytes = blockSizeBytes - data.sigBytes % blockSizeBytes;
|
7569 |
|
7570 | // Create padding word
|
7571 | var paddingWord = (nPaddingBytes << 24) | (nPaddingBytes << 16) | (nPaddingBytes << 8) | nPaddingBytes;
|
7572 |
|
7573 | // Create padding
|
7574 | var paddingWords = [];
|
7575 | for (var i = 0; i < nPaddingBytes; i += 4) {
|
7576 | paddingWords.push(paddingWord);
|
7577 | }
|
7578 | var padding = WordArray.create(paddingWords, nPaddingBytes);
|
7579 |
|
7580 | // Add padding
|
7581 | data.concat(padding);
|
7582 | },
|
7583 |
|
7584 | /**
|
7585 | * Unpads data that had been padded using the algorithm defined in PKCS #5/7.
|
7586 | *
|
7587 | * @param {WordArray} data The data to unpad.
|
7588 | *
|
7589 | * @static
|
7590 | *
|
7591 | * @example
|
7592 | *
|
7593 | * CryptoJS.pad.Pkcs7.unpad(wordArray);
|
7594 | */
|
7595 | unpad: function (data) {
|
7596 | // Get number of padding bytes from last byte
|
7597 | var nPaddingBytes = data.words[(data.sigBytes - 1) >>> 2] & 0xff;
|
7598 |
|
7599 | // Remove padding
|
7600 | data.sigBytes -= nPaddingBytes;
|
7601 | }
|
7602 | };
|
7603 |
|
7604 | var NoPadding = C_pad.NoPadding = {
|
7605 | pad: function () {
|
7606 | },
|
7607 |
|
7608 | unpad: function () {
|
7609 | }
|
7610 | };
|
7611 |
|
7612 |
|
7613 | /**
|
7614 | * Abstract base block cipher template.
|
7615 | *
|
7616 | * @property {number} blockSize The number of 32-bit words this cipher operates on. Default: 4 (128 bits)
|
7617 | */
|
7618 | var BlockCipher = C_lib.BlockCipher = Cipher.extend({
|
7619 | /**
|
7620 | * Configuration options.
|
7621 | *
|
7622 | * @property {Mode} mode The block mode to use. Default: CBC
|
7623 | * @property {Padding} padding The padding strategy to use. Default: Pkcs7
|
7624 | */
|
7625 | cfg: Cipher.cfg.extend({
|
7626 | mode: CBC,
|
7627 | padding: Pkcs7
|
7628 | }),
|
7629 |
|
7630 | reset: function () {
|
7631 | // Reset cipher
|
7632 | Cipher.reset.call(this);
|
7633 |
|
7634 | // Shortcuts
|
7635 | var cfg = this.cfg;
|
7636 | var iv = cfg.iv;
|
7637 | var mode = cfg.mode;
|
7638 |
|
7639 | // Reset block mode
|
7640 | if (this._xformMode == this._ENC_XFORM_MODE) {
|
7641 | var modeCreator = mode.createEncryptor;
|
7642 | } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
|
7643 | var modeCreator = mode.createDecryptor;
|
7644 |
|
7645 | // Keep at least one block in the buffer for unpadding
|
7646 | this._minBufferSize = 1;
|
7647 | }
|
7648 | this._mode = modeCreator.call(mode, this, iv && iv.words);
|
7649 | },
|
7650 |
|
7651 | _doProcessBlock: function (words, offset) {
|
7652 | this._mode.processBlock(words, offset);
|
7653 | },
|
7654 |
|
7655 | _doFinalize: function () {
|
7656 | // Shortcut
|
7657 | var padding = this.cfg.padding;
|
7658 |
|
7659 | // Finalize
|
7660 | if (this._xformMode == this._ENC_XFORM_MODE) {
|
7661 | // Pad data
|
7662 | padding.pad(this._data, this.blockSize);
|
7663 |
|
7664 | // Process final blocks
|
7665 | var finalProcessedBlocks = this._process(!!'flush');
|
7666 | } else /* if (this._xformMode == this._DEC_XFORM_MODE) */ {
|
7667 | // Process final blocks
|
7668 | var finalProcessedBlocks = this._process(!!'flush');
|
7669 |
|
7670 | // Unpad data
|
7671 | padding.unpad(finalProcessedBlocks);
|
7672 | }
|
7673 |
|
7674 | return finalProcessedBlocks;
|
7675 | },
|
7676 |
|
7677 | blockSize: 128/32
|
7678 | });
|
7679 |
|
7680 | /**
|
7681 | * A collection of cipher parameters.
|
7682 | *
|
7683 | * @property {WordArray} ciphertext The raw ciphertext.
|
7684 | * @property {WordArray} key The key to this ciphertext.
|
7685 | * @property {WordArray} iv The IV used in the ciphering operation.
|
7686 | * @property {WordArray} salt The salt used with a key derivation function.
|
7687 | * @property {Cipher} algorithm The cipher algorithm.
|
7688 | * @property {Mode} mode The block mode used in the ciphering operation.
|
7689 | * @property {Padding} padding The padding scheme used in the ciphering operation.
|
7690 | * @property {number} blockSize The block size of the cipher.
|
7691 | * @property {Format} formatter The default formatting strategy to convert this cipher params object to a string.
|
7692 | */
|
7693 | var CipherParams = C_lib.CipherParams = Base.extend({
|
7694 | /**
|
7695 | * Initializes a newly created cipher params object.
|
7696 | *
|
7697 | * @param {Object} cipherParams An object with any of the possible cipher parameters.
|
7698 | *
|
7699 | * @example
|
7700 | *
|
7701 | * var cipherParams = CryptoJS.lib.CipherParams.create({
|
7702 | * ciphertext: ciphertextWordArray,
|
7703 | * key: keyWordArray,
|
7704 | * iv: ivWordArray,
|
7705 | * salt: saltWordArray,
|
7706 | * algorithm: CryptoJS.algo.AES,
|
7707 | * mode: CryptoJS.mode.CBC,
|
7708 | * padding: CryptoJS.pad.PKCS7,
|
7709 | * blockSize: 4,
|
7710 | * formatter: CryptoJS.format.OpenSSL
|
7711 | * });
|
7712 | */
|
7713 | init: function (cipherParams) {
|
7714 | this.mixIn(cipherParams);
|
7715 | },
|
7716 |
|
7717 | /**
|
7718 | * Converts this cipher params object to a string.
|
7719 | *
|
7720 | * @param {Format} formatter (Optional) The formatting strategy to use.
|
7721 | *
|
7722 | * @return {string} The stringified cipher params.
|
7723 | *
|
7724 | * @throws Error If neither the formatter nor the default formatter is set.
|
7725 | *
|
7726 | * @example
|
7727 | *
|
7728 | * var string = cipherParams + '';
|
7729 | * var string = cipherParams.toString();
|
7730 | * var string = cipherParams.toString(CryptoJS.format.OpenSSL);
|
7731 | */
|
7732 | toString: function (formatter) {
|
7733 | return (formatter || this.formatter).stringify(this);
|
7734 | }
|
7735 | });
|
7736 |
|
7737 | /**
|
7738 | * Format namespace.
|
7739 | */
|
7740 | var C_format = C.format = {};
|
7741 |
|
7742 | /**
|
7743 | * OpenSSL formatting strategy.
|
7744 | */
|
7745 | var OpenSSLFormatter = C_format.OpenSSL = {
|
7746 | /**
|
7747 | * Converts a cipher params object to an OpenSSL-compatible string.
|
7748 | *
|
7749 | * @param {CipherParams} cipherParams The cipher params object.
|
7750 | *
|
7751 | * @return {string} The OpenSSL-compatible string.
|
7752 | *
|
7753 | * @static
|
7754 | *
|
7755 | * @example
|
7756 | *
|
7757 | * var openSSLString = CryptoJS.format.OpenSSL.stringify(cipherParams);
|
7758 | */
|
7759 | stringify: function (cipherParams) {
|
7760 | // Shortcuts
|
7761 | var ciphertext = cipherParams.ciphertext;
|
7762 | var salt = cipherParams.salt;
|
7763 |
|
7764 | // Format
|
7765 | if (salt) {
|
7766 | var wordArray = WordArray.create([0x53616c74, 0x65645f5f]).concat(salt).concat(ciphertext);
|
7767 | } else {
|
7768 | var wordArray = ciphertext;
|
7769 | }
|
7770 |
|
7771 | return wordArray.toString(Base64);
|
7772 | },
|
7773 |
|
7774 | /**
|
7775 | * Converts an OpenSSL-compatible string to a cipher params object.
|
7776 | *
|
7777 | * @param {string} openSSLStr The OpenSSL-compatible string.
|
7778 | *
|
7779 | * @return {CipherParams} The cipher params object.
|
7780 | *
|
7781 | * @static
|
7782 | *
|
7783 | * @example
|
7784 | *
|
7785 | * var cipherParams = CryptoJS.format.OpenSSL.parse(openSSLString);
|
7786 | */
|
7787 | parse: function (openSSLStr) {
|
7788 | // Parse base64
|
7789 | var ciphertext = Base64.parse(openSSLStr);
|
7790 |
|
7791 | // Shortcut
|
7792 | var ciphertextWords = ciphertext.words;
|
7793 |
|
7794 | // Test for salt
|
7795 | if (ciphertextWords[0] == 0x53616c74 && ciphertextWords[1] == 0x65645f5f) {
|
7796 | // Extract salt
|
7797 | var salt = WordArray.create(ciphertextWords.slice(2, 4));
|
7798 |
|
7799 | // Remove salt from ciphertext
|
7800 | ciphertextWords.splice(0, 4);
|
7801 | ciphertext.sigBytes -= 16;
|
7802 | }
|
7803 |
|
7804 | return CipherParams.create({ ciphertext: ciphertext, salt: salt });
|
7805 | }
|
7806 | };
|
7807 |
|
7808 | /**
|
7809 | * A cipher wrapper that returns ciphertext as a serializable cipher params object.
|
7810 | */
|
7811 | var SerializableCipher = C_lib.SerializableCipher = Base.extend({
|
7812 | /**
|
7813 | * Configuration options.
|
7814 | *
|
7815 | * @property {Formatter} format The formatting strategy to convert cipher param objects to and from a string. Default: OpenSSL
|
7816 | */
|
7817 | cfg: Base.extend({
|
7818 | format: OpenSSLFormatter
|
7819 | }),
|
7820 |
|
7821 | /**
|
7822 | * Encrypts a message.
|
7823 | *
|
7824 | * @param {Cipher} cipher The cipher algorithm to use.
|
7825 | * @param {WordArray|string} message The message to encrypt.
|
7826 | * @param {WordArray} key The key.
|
7827 | * @param {Object} cfg (Optional) The configuration options to use for this operation.
|
7828 | *
|
7829 | * @return {CipherParams} A cipher params object.
|
7830 | *
|
7831 | * @static
|
7832 | *
|
7833 | * @example
|
7834 | *
|
7835 | * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key);
|
7836 | * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv });
|
7837 | * var ciphertextParams = CryptoJS.lib.SerializableCipher.encrypt(CryptoJS.algo.AES, message, key, { iv: iv, format: CryptoJS.format.OpenSSL });
|
7838 | */
|
7839 | encrypt: function (cipher, message, key, cfg) {
|
7840 | // Apply config defaults
|
7841 | cfg = this.cfg.extend(cfg);
|
7842 |
|
7843 | // Encrypt
|
7844 | var encryptor = cipher.createEncryptor(key, cfg);
|
7845 | var ciphertext = encryptor.finalize(message);
|
7846 |
|
7847 | // Shortcut
|
7848 | var cipherCfg = encryptor.cfg;
|
7849 |
|
7850 | // Create and return serializable cipher params
|
7851 | return CipherParams.create({
|
7852 | ciphertext: ciphertext,
|
7853 | key: key,
|
7854 | iv: cipherCfg.iv,
|
7855 | algorithm: cipher,
|
7856 | mode: cipherCfg.mode,
|
7857 | padding: cipherCfg.padding,
|
7858 | blockSize: cipher.blockSize,
|
7859 | formatter: cfg.format
|
7860 | });
|
7861 | },
|
7862 |
|
7863 | /**
|
7864 | * Decrypts serialized ciphertext.
|
7865 | *
|
7866 | * @param {Cipher} cipher The cipher algorithm to use.
|
7867 | * @param {CipherParams|string} ciphertext The ciphertext to decrypt.
|
7868 | * @param {WordArray} key The key.
|
7869 | * @param {Object} cfg (Optional) The configuration options to use for this operation.
|
7870 | *
|
7871 | * @return {WordArray} The plaintext.
|
7872 | *
|
7873 | * @static
|
7874 | *
|
7875 | * @example
|
7876 | *
|
7877 | * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, key, { iv: iv, format: CryptoJS.format.OpenSSL });
|
7878 | * var plaintext = CryptoJS.lib.SerializableCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, key, { iv: iv, format: CryptoJS.format.OpenSSL });
|
7879 | */
|
7880 | decrypt: function (cipher, ciphertext, key, cfg) {
|
7881 | // Apply config defaults
|
7882 | cfg = this.cfg.extend(cfg);
|
7883 |
|
7884 | // Convert string to CipherParams
|
7885 | ciphertext = this._parse(ciphertext, cfg.format);
|
7886 |
|
7887 | // Decrypt
|
7888 | var plaintext = cipher.createDecryptor(key, cfg).finalize(ciphertext.ciphertext);
|
7889 |
|
7890 | return plaintext;
|
7891 | },
|
7892 |
|
7893 | /**
|
7894 | * Converts serialized ciphertext to CipherParams,
|
7895 | * else assumed CipherParams already and returns ciphertext unchanged.
|
7896 | *
|
7897 | * @param {CipherParams|string} ciphertext The ciphertext.
|
7898 | * @param {Formatter} format The formatting strategy to use to parse serialized ciphertext.
|
7899 | *
|
7900 | * @return {CipherParams} The unserialized ciphertext.
|
7901 | *
|
7902 | * @static
|
7903 | *
|
7904 | * @example
|
7905 | *
|
7906 | * var ciphertextParams = CryptoJS.lib.SerializableCipher._parse(ciphertextStringOrParams, format);
|
7907 | */
|
7908 | _parse: function (ciphertext, format) {
|
7909 | if (typeof ciphertext == 'string') {
|
7910 | return format.parse(ciphertext, this);
|
7911 | } else {
|
7912 | return ciphertext;
|
7913 | }
|
7914 | }
|
7915 | });
|
7916 |
|
7917 | /**
|
7918 | * Key derivation function namespace.
|
7919 | */
|
7920 | var C_kdf = C.kdf = {};
|
7921 |
|
7922 | /**
|
7923 | * OpenSSL key derivation function.
|
7924 | */
|
7925 | var OpenSSLKdf = C_kdf.OpenSSL = {
|
7926 | /**
|
7927 | * Derives a key and IV from a password.
|
7928 | *
|
7929 | * @param {string} password The password to derive from.
|
7930 | * @param {number} keySize The size in words of the key to generate.
|
7931 | * @param {number} ivSize The size in words of the IV to generate.
|
7932 | * @param {WordArray|string} salt (Optional) A 64-bit salt to use. If omitted, a salt will be generated randomly.
|
7933 | *
|
7934 | * @return {CipherParams} A cipher params object with the key, IV, and salt.
|
7935 | *
|
7936 | * @static
|
7937 | *
|
7938 | * @example
|
7939 | *
|
7940 | * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32);
|
7941 | * var derivedParams = CryptoJS.kdf.OpenSSL.execute('Password', 256/32, 128/32, 'saltsalt');
|
7942 | */
|
7943 | execute: function (password, keySize, ivSize, salt) {
|
7944 | // Generate random salt
|
7945 | if (!salt) {
|
7946 | salt = WordArray.random(64/8);
|
7947 | }
|
7948 |
|
7949 | // Derive key and IV
|
7950 | var key = EvpKDF.create({ keySize: keySize + ivSize }).compute(password, salt);
|
7951 |
|
7952 | // Separate key and IV
|
7953 | var iv = WordArray.create(key.words.slice(keySize), ivSize * 4);
|
7954 | key.sigBytes = keySize * 4;
|
7955 |
|
7956 | // Return params
|
7957 | return CipherParams.create({ key: key, iv: iv, salt: salt });
|
7958 | }
|
7959 | };
|
7960 |
|
7961 | /**
|
7962 | * A serializable cipher wrapper that derives the key from a password,
|
7963 | * and returns ciphertext as a serializable cipher params object.
|
7964 | */
|
7965 | var PasswordBasedCipher = C_lib.PasswordBasedCipher = SerializableCipher.extend({
|
7966 | /**
|
7967 | * Configuration options.
|
7968 | *
|
7969 | * @property {KDF} kdf The key derivation function to use to generate a key and IV from a password. Default: OpenSSL
|
7970 | */
|
7971 | cfg: SerializableCipher.cfg.extend({
|
7972 | kdf: OpenSSLKdf
|
7973 | }),
|
7974 |
|
7975 | /**
|
7976 | * Encrypts a message using a password.
|
7977 | *
|
7978 | * @param {Cipher} cipher The cipher algorithm to use.
|
7979 | * @param {WordArray|string} message The message to encrypt.
|
7980 | * @param {string} password The password.
|
7981 | * @param {Object} cfg (Optional) The configuration options to use for this operation.
|
7982 | *
|
7983 | * @return {CipherParams} A cipher params object.
|
7984 | *
|
7985 | * @static
|
7986 | *
|
7987 | * @example
|
7988 | *
|
7989 | * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password');
|
7990 | * var ciphertextParams = CryptoJS.lib.PasswordBasedCipher.encrypt(CryptoJS.algo.AES, message, 'password', { format: CryptoJS.format.OpenSSL });
|
7991 | */
|
7992 | encrypt: function (cipher, message, password, cfg) {
|
7993 | // Apply config defaults
|
7994 | cfg = this.cfg.extend(cfg);
|
7995 |
|
7996 | // Derive key and other params
|
7997 | var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize);
|
7998 |
|
7999 | // Add IV to config
|
8000 | cfg.iv = derivedParams.iv;
|
8001 |
|
8002 | // Encrypt
|
8003 | var ciphertext = SerializableCipher.encrypt.call(this, cipher, message, derivedParams.key, cfg);
|
8004 |
|
8005 | // Mix in derived params
|
8006 | ciphertext.mixIn(derivedParams);
|
8007 |
|
8008 | return ciphertext;
|
8009 | },
|
8010 |
|
8011 | /**
|
8012 | * Decrypts serialized ciphertext using a password.
|
8013 | *
|
8014 | * @param {Cipher} cipher The cipher algorithm to use.
|
8015 | * @param {CipherParams|string} ciphertext The ciphertext to decrypt.
|
8016 | * @param {string} password The password.
|
8017 | * @param {Object} cfg (Optional) The configuration options to use for this operation.
|
8018 | *
|
8019 | * @return {WordArray} The plaintext.
|
8020 | *
|
8021 | * @static
|
8022 | *
|
8023 | * @example
|
8024 | *
|
8025 | * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, formattedCiphertext, 'password', { format: CryptoJS.format.OpenSSL });
|
8026 | * var plaintext = CryptoJS.lib.PasswordBasedCipher.decrypt(CryptoJS.algo.AES, ciphertextParams, 'password', { format: CryptoJS.format.OpenSSL });
|
8027 | */
|
8028 | decrypt: function (cipher, ciphertext, password, cfg) {
|
8029 | // Apply config defaults
|
8030 | cfg = this.cfg.extend(cfg);
|
8031 |
|
8032 | // Convert string to CipherParams
|
8033 | ciphertext = this._parse(ciphertext, cfg.format);
|
8034 |
|
8035 | // Derive key and other params
|
8036 | var derivedParams = cfg.kdf.execute(password, cipher.keySize, cipher.ivSize, ciphertext.salt);
|
8037 |
|
8038 | // Add IV to config
|
8039 | cfg.iv = derivedParams.iv;
|
8040 |
|
8041 | // Decrypt
|
8042 | var plaintext = SerializableCipher.decrypt.call(this, cipher, ciphertext, derivedParams.key, cfg);
|
8043 |
|
8044 | return plaintext;
|
8045 | }
|
8046 | });
|
8047 | }());
|
8048 |
|
8049 |
|
8050 | /***/ }),
|
8051 | /* 121 */
|
8052 | /***/ (function(module, exports, __webpack_require__) {
|
8053 |
|
8054 | var CryptoJS = __webpack_require__(14).CryptoJS;
|
8055 |
|
8056 | /*
|
8057 | CryptoJS v3.1.2
|
8058 | code.google.com/p/crypto-js
|
8059 | (c) 2009-2013 by Jeff Mott. All rights reserved.
|
8060 | code.google.com/p/crypto-js/wiki/License
|
8061 | */
|
8062 | (function () {
|
8063 | // Shortcuts
|
8064 | var C = CryptoJS;
|
8065 | var C_lib = C.lib;
|
8066 | var WordArray = C_lib.WordArray;
|
8067 | var C_enc = C.enc;
|
8068 |
|
8069 | /**
|
8070 | * Base64 encoding strategy.
|
8071 | */
|
8072 | var Base64 = C_enc.Base64 = {
|
8073 | /**
|
8074 | * Converts a word array to a Base64 string.
|
8075 | *
|
8076 | * @param {WordArray} wordArray The word array.
|
8077 | *
|
8078 | * @return {string} The Base64 string.
|
8079 | *
|
8080 | * @static
|
8081 | *
|
8082 | * @example
|
8083 | *
|
8084 | * var base64String = CryptoJS.enc.Base64.stringify(wordArray);
|
8085 | */
|
8086 | stringify: function (wordArray) {
|
8087 | // Shortcuts
|
8088 | var words = wordArray.words;
|
8089 | var sigBytes = wordArray.sigBytes;
|
8090 | var map = this._map;
|
8091 |
|
8092 | // Clamp excess bits
|
8093 | wordArray.clamp();
|
8094 |
|
8095 | // Convert
|
8096 | var base64Chars = [];
|
8097 | for (var i = 0; i < sigBytes; i += 3) {
|
8098 | var byte1 = (words[i >>> 2] >>> (24 - (i % 4) * 8)) & 0xff;
|
8099 | var byte2 = (words[(i + 1) >>> 2] >>> (24 - ((i + 1) % 4) * 8)) & 0xff;
|
8100 | var byte3 = (words[(i + 2) >>> 2] >>> (24 - ((i + 2) % 4) * 8)) & 0xff;
|
8101 |
|
8102 | var triplet = (byte1 << 16) | (byte2 << 8) | byte3;
|
8103 |
|
8104 | for (var j = 0; (j < 4) && (i + j * 0.75 < sigBytes); j++) {
|
8105 | base64Chars.push(map.charAt((triplet >>> (6 * (3 - j))) & 0x3f));
|
8106 | }
|
8107 | }
|
8108 |
|
8109 | // Add padding
|
8110 | var paddingChar = map.charAt(64);
|
8111 | if (paddingChar) {
|
8112 | while (base64Chars.length % 4) {
|
8113 | base64Chars.push(paddingChar);
|
8114 | }
|
8115 | }
|
8116 |
|
8117 | return base64Chars.join('');
|
8118 | },
|
8119 |
|
8120 | /**
|
8121 | * Converts a Base64 string to a word array.
|
8122 | *
|
8123 | * @param {string} base64Str The Base64 string.
|
8124 | *
|
8125 | * @return {WordArray} The word array.
|
8126 | *
|
8127 | * @static
|
8128 | *
|
8129 | * @example
|
8130 | *
|
8131 | * var wordArray = CryptoJS.enc.Base64.parse(base64String);
|
8132 | */
|
8133 | parse: function (base64Str) {
|
8134 | // Shortcuts
|
8135 | var base64StrLength = base64Str.length;
|
8136 | var map = this._map;
|
8137 |
|
8138 | // Ignore padding
|
8139 | var paddingChar = map.charAt(64);
|
8140 | if (paddingChar) {
|
8141 | var paddingIndex = base64Str.indexOf(paddingChar);
|
8142 | if (paddingIndex != -1) {
|
8143 | base64StrLength = paddingIndex;
|
8144 | }
|
8145 | }
|
8146 |
|
8147 | // Convert
|
8148 | var words = [];
|
8149 | var nBytes = 0;
|
8150 | for (var i = 0; i < base64StrLength; i++) {
|
8151 | if (i % 4) {
|
8152 | var bits1 = map.indexOf(base64Str.charAt(i - 1)) << ((i % 4) * 2);
|
8153 | var bits2 = map.indexOf(base64Str.charAt(i)) >>> (6 - (i % 4) * 2);
|
8154 | words[nBytes >>> 2] |= (bits1 | bits2) << (24 - (nBytes % 4) * 8);
|
8155 | nBytes++;
|
8156 | }
|
8157 | }
|
8158 |
|
8159 | return WordArray.create(words, nBytes);
|
8160 | },
|
8161 |
|
8162 | _map: 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='
|
8163 | };
|
8164 | }());
|
8165 |
|
8166 |
|
8167 | /***/ }),
|
8168 | /* 122 */
|
8169 | /***/ (function(module, exports, __webpack_require__) {
|
8170 |
|
8171 | var CryptoJS = __webpack_require__(14).CryptoJS;
|
8172 |
|
8173 | /*
|
8174 | CryptoJS v3.1.2
|
8175 | code.google.com/p/crypto-js
|
8176 | (c) 2009-2013 by Jeff Mott. All rights reserved.
|
8177 | code.google.com/p/crypto-js/wiki/License
|
8178 | */
|
8179 | (function () {
|
8180 | // Shortcuts
|
8181 | var C = CryptoJS;
|
8182 | var C_lib = C.lib;
|
8183 | var Base = C_lib.Base;
|
8184 | var WordArray = C_lib.WordArray;
|
8185 | var C_algo = C.algo;
|
8186 | var MD5 = C_algo.MD5;
|
8187 |
|
8188 | /**
|
8189 | * This key derivation function is meant to conform with EVP_BytesToKey.
|
8190 | * www.openssl.org/docs/crypto/EVP_BytesToKey.html
|
8191 | */
|
8192 | var EvpKDF = C_algo.EvpKDF = Base.extend({
|
8193 | /**
|
8194 | * Configuration options.
|
8195 | *
|
8196 | * @property {number} keySize The key size in words to generate. Default: 4 (128 bits)
|
8197 | * @property {Hasher} hasher The hash algorithm to use. Default: MD5
|
8198 | * @property {number} iterations The number of iterations to perform. Default: 1
|
8199 | */
|
8200 | cfg: Base.extend({
|
8201 | keySize: 128/32,
|
8202 | hasher: MD5,
|
8203 | iterations: 1
|
8204 | }),
|
8205 |
|
8206 | /**
|
8207 | * Initializes a newly created key derivation function.
|
8208 | *
|
8209 | * @param {Object} cfg (Optional) The configuration options to use for the derivation.
|
8210 | *
|
8211 | * @example
|
8212 | *
|
8213 | * var kdf = CryptoJS.algo.EvpKDF.create();
|
8214 | * var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8 });
|
8215 | * var kdf = CryptoJS.algo.EvpKDF.create({ keySize: 8, iterations: 1000 });
|
8216 | */
|
8217 | init: function (cfg) {
|
8218 | this.cfg = this.cfg.extend(cfg);
|
8219 | },
|
8220 |
|
8221 | /**
|
8222 | * Derives a key from a password.
|
8223 | *
|
8224 | * @param {WordArray|string} password The password.
|
8225 | * @param {WordArray|string} salt A salt.
|
8226 | *
|
8227 | * @return {WordArray} The derived key.
|
8228 | *
|
8229 | * @example
|
8230 | *
|
8231 | * var key = kdf.compute(password, salt);
|
8232 | */
|
8233 | compute: function (password, salt) {
|
8234 | // Shortcut
|
8235 | var cfg = this.cfg;
|
8236 |
|
8237 | // Init hasher
|
8238 | var hasher = cfg.hasher.create();
|
8239 |
|
8240 | // Initial values
|
8241 | var derivedKey = WordArray.create();
|
8242 |
|
8243 | // Shortcuts
|
8244 | var derivedKeyWords = derivedKey.words;
|
8245 | var keySize = cfg.keySize;
|
8246 | var iterations = cfg.iterations;
|
8247 |
|
8248 | // Generate key
|
8249 | while (derivedKeyWords.length < keySize) {
|
8250 | if (block) {
|
8251 | hasher.update(block);
|
8252 | }
|
8253 | var block = hasher.update(password).finalize(salt);
|
8254 | hasher.reset();
|
8255 |
|
8256 | // Iterations
|
8257 | for (var i = 1; i < iterations; i++) {
|
8258 | block = hasher.finalize(block);
|
8259 | hasher.reset();
|
8260 | }
|
8261 |
|
8262 | derivedKey.concat(block);
|
8263 | }
|
8264 | derivedKey.sigBytes = keySize * 4;
|
8265 |
|
8266 | return derivedKey;
|
8267 | }
|
8268 | });
|
8269 |
|
8270 | /**
|
8271 | * Derives a key from a password.
|
8272 | *
|
8273 | * @param {WordArray|string} password The password.
|
8274 | * @param {WordArray|string} salt A salt.
|
8275 | * @param {Object} cfg (Optional) The configuration options to use for this computation.
|
8276 | *
|
8277 | * @return {WordArray} The derived key.
|
8278 | *
|
8279 | * @static
|
8280 | *
|
8281 | * @example
|
8282 | *
|
8283 | * var key = CryptoJS.EvpKDF(password, salt);
|
8284 | * var key = CryptoJS.EvpKDF(password, salt, { keySize: 8 });
|
8285 | * var key = CryptoJS.EvpKDF(password, salt, { keySize: 8, iterations: 1000 });
|
8286 | */
|
8287 | C.EvpKDF = function (password, salt, cfg) {
|
8288 | return EvpKDF.create(cfg).compute(password, salt);
|
8289 | };
|
8290 | }());
|
8291 |
|
8292 |
|
8293 | /***/ }),
|
8294 | /* 123 */
|
8295 | /***/ (function(module, exports, __webpack_require__) {
|
8296 |
|
8297 | var CryptoJS = __webpack_require__(14).CryptoJS;
|
8298 |
|
8299 | // create custom json serialization format
|
8300 | var JsonFormatter = {
|
8301 | stringify: function (cipherParams) {
|
8302 | // create json object with ciphertext
|
8303 | var jsonObj = {
|
8304 | ct: cipherParams.ciphertext.toString(CryptoJS.enc.Base64)
|
8305 | };
|
8306 |
|
8307 | // optionally add iv and salt
|
8308 | if (cipherParams.iv) {
|
8309 | jsonObj.iv = cipherParams.iv.toString();
|
8310 | }
|
8311 |
|
8312 | if (cipherParams.salt) {
|
8313 | jsonObj.s = cipherParams.salt.toString();
|
8314 | }
|
8315 |
|
8316 | // stringify json object
|
8317 | return JSON.stringify(jsonObj)
|
8318 | },
|
8319 |
|
8320 | parse: function (jsonStr) {
|
8321 | // parse json string
|
8322 | var jsonObj = JSON.parse(jsonStr);
|
8323 |
|
8324 | // extract ciphertext from json object, and create cipher params object
|
8325 | var cipherParams = CryptoJS.lib.CipherParams.create({
|
8326 | ciphertext: CryptoJS.enc.Base64.parse(jsonObj.ct)
|
8327 | });
|
8328 |
|
8329 | // optionally extract iv and salt
|
8330 | if (jsonObj.iv) {
|
8331 | cipherParams.iv = CryptoJS.enc.Hex.parse(jsonObj.iv);
|
8332 | }
|
8333 |
|
8334 | if (jsonObj.s) {
|
8335 | cipherParams.salt = CryptoJS.enc.Hex.parse(jsonObj.s);
|
8336 | }
|
8337 |
|
8338 | return cipherParams;
|
8339 | }
|
8340 | };
|
8341 |
|
8342 | exports.JsonFormatter = JsonFormatter;
|
8343 |
|
8344 | /***/ }),
|
8345 | /* 124 */
|
8346 | /***/ (function(module, exports, __webpack_require__) {
|
8347 |
|
8348 | var CryptoJS = __webpack_require__(14).CryptoJS;
|
8349 |
|
8350 | /*
|
8351 | CryptoJS v3.1.2
|
8352 | code.google.com/p/crypto-js
|
8353 | (c) 2009-2013 by Jeff Mott. All rights reserved.
|
8354 | code.google.com/p/crypto-js/wiki/License
|
8355 | */
|
8356 | (function (Math) {
|
8357 | // Shortcuts
|
8358 | var C = CryptoJS;
|
8359 | var C_lib = C.lib;
|
8360 | var WordArray = C_lib.WordArray;
|
8361 | var Hasher = C_lib.Hasher;
|
8362 | var C_algo = C.algo;
|
8363 |
|
8364 | // Constants table
|
8365 | var T = [];
|
8366 |
|
8367 | // Compute constants
|
8368 | (function () {
|
8369 | for (var i = 0; i < 64; i++) {
|
8370 | T[i] = (Math.abs(Math.sin(i + 1)) * 0x100000000) | 0;
|
8371 | }
|
8372 | }());
|
8373 |
|
8374 | /**
|
8375 | * MD5 hash algorithm.
|
8376 | */
|
8377 | var MD5 = C_algo.MD5 = Hasher.extend({
|
8378 | _doReset: function () {
|
8379 | this._hash = new WordArray.init([
|
8380 | 0x67452301, 0xefcdab89,
|
8381 | 0x98badcfe, 0x10325476
|
8382 | ]);
|
8383 | },
|
8384 |
|
8385 | _doProcessBlock: function (M, offset) {
|
8386 | // Swap endian
|
8387 | for (var i = 0; i < 16; i++) {
|
8388 | // Shortcuts
|
8389 | var offset_i = offset + i;
|
8390 | var M_offset_i = M[offset_i];
|
8391 |
|
8392 | M[offset_i] = (
|
8393 | (((M_offset_i << 8) | (M_offset_i >>> 24)) & 0x00ff00ff) |
|
8394 | (((M_offset_i << 24) | (M_offset_i >>> 8)) & 0xff00ff00)
|
8395 | );
|
8396 | }
|
8397 |
|
8398 | // Shortcuts
|
8399 | var H = this._hash.words;
|
8400 |
|
8401 | var M_offset_0 = M[offset + 0];
|
8402 | var M_offset_1 = M[offset + 1];
|
8403 | var M_offset_2 = M[offset + 2];
|
8404 | var M_offset_3 = M[offset + 3];
|
8405 | var M_offset_4 = M[offset + 4];
|
8406 | var M_offset_5 = M[offset + 5];
|
8407 | var M_offset_6 = M[offset + 6];
|
8408 | var M_offset_7 = M[offset + 7];
|
8409 | var M_offset_8 = M[offset + 8];
|
8410 | var M_offset_9 = M[offset + 9];
|
8411 | var M_offset_10 = M[offset + 10];
|
8412 | var M_offset_11 = M[offset + 11];
|
8413 | var M_offset_12 = M[offset + 12];
|
8414 | var M_offset_13 = M[offset + 13];
|
8415 | var M_offset_14 = M[offset + 14];
|
8416 | var M_offset_15 = M[offset + 15];
|
8417 |
|
8418 | // Working varialbes
|
8419 | var a = H[0];
|
8420 | var b = H[1];
|
8421 | var c = H[2];
|
8422 | var d = H[3];
|
8423 |
|
8424 | // Computation
|
8425 | a = FF(a, b, c, d, M_offset_0, 7, T[0]);
|
8426 | d = FF(d, a, b, c, M_offset_1, 12, T[1]);
|
8427 | c = FF(c, d, a, b, M_offset_2, 17, T[2]);
|
8428 | b = FF(b, c, d, a, M_offset_3, 22, T[3]);
|
8429 | a = FF(a, b, c, d, M_offset_4, 7, T[4]);
|
8430 | d = FF(d, a, b, c, M_offset_5, 12, T[5]);
|
8431 | c = FF(c, d, a, b, M_offset_6, 17, T[6]);
|
8432 | b = FF(b, c, d, a, M_offset_7, 22, T[7]);
|
8433 | a = FF(a, b, c, d, M_offset_8, 7, T[8]);
|
8434 | d = FF(d, a, b, c, M_offset_9, 12, T[9]);
|
8435 | c = FF(c, d, a, b, M_offset_10, 17, T[10]);
|
8436 | b = FF(b, c, d, a, M_offset_11, 22, T[11]);
|
8437 | a = FF(a, b, c, d, M_offset_12, 7, T[12]);
|
8438 | d = FF(d, a, b, c, M_offset_13, 12, T[13]);
|
8439 | c = FF(c, d, a, b, M_offset_14, 17, T[14]);
|
8440 | b = FF(b, c, d, a, M_offset_15, 22, T[15]);
|
8441 |
|
8442 | a = GG(a, b, c, d, M_offset_1, 5, T[16]);
|
8443 | d = GG(d, a, b, c, M_offset_6, 9, T[17]);
|
8444 | c = GG(c, d, a, b, M_offset_11, 14, T[18]);
|
8445 | b = GG(b, c, d, a, M_offset_0, 20, T[19]);
|
8446 | a = GG(a, b, c, d, M_offset_5, 5, T[20]);
|
8447 | d = GG(d, a, b, c, M_offset_10, 9, T[21]);
|
8448 | c = GG(c, d, a, b, M_offset_15, 14, T[22]);
|
8449 | b = GG(b, c, d, a, M_offset_4, 20, T[23]);
|
8450 | a = GG(a, b, c, d, M_offset_9, 5, T[24]);
|
8451 | d = GG(d, a, b, c, M_offset_14, 9, T[25]);
|
8452 | c = GG(c, d, a, b, M_offset_3, 14, T[26]);
|
8453 | b = GG(b, c, d, a, M_offset_8, 20, T[27]);
|
8454 | a = GG(a, b, c, d, M_offset_13, 5, T[28]);
|
8455 | d = GG(d, a, b, c, M_offset_2, 9, T[29]);
|
8456 | c = GG(c, d, a, b, M_offset_7, 14, T[30]);
|
8457 | b = GG(b, c, d, a, M_offset_12, 20, T[31]);
|
8458 |
|
8459 | a = HH(a, b, c, d, M_offset_5, 4, T[32]);
|
8460 | d = HH(d, a, b, c, M_offset_8, 11, T[33]);
|
8461 | c = HH(c, d, a, b, M_offset_11, 16, T[34]);
|
8462 | b = HH(b, c, d, a, M_offset_14, 23, T[35]);
|
8463 | a = HH(a, b, c, d, M_offset_1, 4, T[36]);
|
8464 | d = HH(d, a, b, c, M_offset_4, 11, T[37]);
|
8465 | c = HH(c, d, a, b, M_offset_7, 16, T[38]);
|
8466 | b = HH(b, c, d, a, M_offset_10, 23, T[39]);
|
8467 | a = HH(a, b, c, d, M_offset_13, 4, T[40]);
|
8468 | d = HH(d, a, b, c, M_offset_0, 11, T[41]);
|
8469 | c = HH(c, d, a, b, M_offset_3, 16, T[42]);
|
8470 | b = HH(b, c, d, a, M_offset_6, 23, T[43]);
|
8471 | a = HH(a, b, c, d, M_offset_9, 4, T[44]);
|
8472 | d = HH(d, a, b, c, M_offset_12, 11, T[45]);
|
8473 | c = HH(c, d, a, b, M_offset_15, 16, T[46]);
|
8474 | b = HH(b, c, d, a, M_offset_2, 23, T[47]);
|
8475 |
|
8476 | a = II(a, b, c, d, M_offset_0, 6, T[48]);
|
8477 | d = II(d, a, b, c, M_offset_7, 10, T[49]);
|
8478 | c = II(c, d, a, b, M_offset_14, 15, T[50]);
|
8479 | b = II(b, c, d, a, M_offset_5, 21, T[51]);
|
8480 | a = II(a, b, c, d, M_offset_12, 6, T[52]);
|
8481 | d = II(d, a, b, c, M_offset_3, 10, T[53]);
|
8482 | c = II(c, d, a, b, M_offset_10, 15, T[54]);
|
8483 | b = II(b, c, d, a, M_offset_1, 21, T[55]);
|
8484 | a = II(a, b, c, d, M_offset_8, 6, T[56]);
|
8485 | d = II(d, a, b, c, M_offset_15, 10, T[57]);
|
8486 | c = II(c, d, a, b, M_offset_6, 15, T[58]);
|
8487 | b = II(b, c, d, a, M_offset_13, 21, T[59]);
|
8488 | a = II(a, b, c, d, M_offset_4, 6, T[60]);
|
8489 | d = II(d, a, b, c, M_offset_11, 10, T[61]);
|
8490 | c = II(c, d, a, b, M_offset_2, 15, T[62]);
|
8491 | b = II(b, c, d, a, M_offset_9, 21, T[63]);
|
8492 |
|
8493 | // Intermediate hash value
|
8494 | H[0] = (H[0] + a) | 0;
|
8495 | H[1] = (H[1] + b) | 0;
|
8496 | H[2] = (H[2] + c) | 0;
|
8497 | H[3] = (H[3] + d) | 0;
|
8498 | },
|
8499 |
|
8500 | _doFinalize: function () {
|
8501 | // Shortcuts
|
8502 | var data = this._data;
|
8503 | var dataWords = data.words;
|
8504 |
|
8505 | var nBitsTotal = this._nDataBytes * 8;
|
8506 | var nBitsLeft = data.sigBytes * 8;
|
8507 |
|
8508 | // Add padding
|
8509 | dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
|
8510 |
|
8511 | var nBitsTotalH = Math.floor(nBitsTotal / 0x100000000);
|
8512 | var nBitsTotalL = nBitsTotal;
|
8513 | dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = (
|
8514 | (((nBitsTotalH << 8) | (nBitsTotalH >>> 24)) & 0x00ff00ff) |
|
8515 | (((nBitsTotalH << 24) | (nBitsTotalH >>> 8)) & 0xff00ff00)
|
8516 | );
|
8517 | dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = (
|
8518 | (((nBitsTotalL << 8) | (nBitsTotalL >>> 24)) & 0x00ff00ff) |
|
8519 | (((nBitsTotalL << 24) | (nBitsTotalL >>> 8)) & 0xff00ff00)
|
8520 | );
|
8521 |
|
8522 | data.sigBytes = (dataWords.length + 1) * 4;
|
8523 |
|
8524 | // Hash final blocks
|
8525 | this._process();
|
8526 |
|
8527 | // Shortcuts
|
8528 | var hash = this._hash;
|
8529 | var H = hash.words;
|
8530 |
|
8531 | // Swap endian
|
8532 | for (var i = 0; i < 4; i++) {
|
8533 | // Shortcut
|
8534 | var H_i = H[i];
|
8535 |
|
8536 | H[i] = (((H_i << 8) | (H_i >>> 24)) & 0x00ff00ff) |
|
8537 | (((H_i << 24) | (H_i >>> 8)) & 0xff00ff00);
|
8538 | }
|
8539 |
|
8540 | // Return final computed hash
|
8541 | return hash;
|
8542 | },
|
8543 |
|
8544 | clone: function () {
|
8545 | var clone = Hasher.clone.call(this);
|
8546 | clone._hash = this._hash.clone();
|
8547 |
|
8548 | return clone;
|
8549 | }
|
8550 | });
|
8551 |
|
8552 | function FF(a, b, c, d, x, s, t) {
|
8553 | var n = a + ((b & c) | (~b & d)) + x + t;
|
8554 | return ((n << s) | (n >>> (32 - s))) + b;
|
8555 | }
|
8556 |
|
8557 | function GG(a, b, c, d, x, s, t) {
|
8558 | var n = a + ((b & d) | (c & ~d)) + x + t;
|
8559 | return ((n << s) | (n >>> (32 - s))) + b;
|
8560 | }
|
8561 |
|
8562 | function HH(a, b, c, d, x, s, t) {
|
8563 | var n = a + (b ^ c ^ d) + x + t;
|
8564 | return ((n << s) | (n >>> (32 - s))) + b;
|
8565 | }
|
8566 |
|
8567 | function II(a, b, c, d, x, s, t) {
|
8568 | var n = a + (c ^ (b | ~d)) + x + t;
|
8569 | return ((n << s) | (n >>> (32 - s))) + b;
|
8570 | }
|
8571 |
|
8572 | /**
|
8573 | * Shortcut function to the hasher's object interface.
|
8574 | *
|
8575 | * @param {WordArray|string} message The message to hash.
|
8576 | *
|
8577 | * @return {WordArray} The hash.
|
8578 | *
|
8579 | * @static
|
8580 | *
|
8581 | * @example
|
8582 | *
|
8583 | * var hash = CryptoJS.MD5('message');
|
8584 | * var hash = CryptoJS.MD5(wordArray);
|
8585 | */
|
8586 | C.MD5 = Hasher._createHelper(MD5);
|
8587 |
|
8588 | /**
|
8589 | * Shortcut function to the HMAC's object interface.
|
8590 | *
|
8591 | * @param {WordArray|string} message The message to hash.
|
8592 | * @param {WordArray|string} key The secret key.
|
8593 | *
|
8594 | * @return {WordArray} The HMAC.
|
8595 | *
|
8596 | * @static
|
8597 | *
|
8598 | * @example
|
8599 | *
|
8600 | * var hmac = CryptoJS.HmacMD5(message, key);
|
8601 | */
|
8602 | C.HmacMD5 = Hasher._createHmacHelper(MD5);
|
8603 | }(Math));
|
8604 |
|
8605 |
|
8606 | /***/ }),
|
8607 | /* 125 */
|
8608 | /***/ (function(module, exports, __webpack_require__) {
|
8609 |
|
8610 | var CryptoJS = __webpack_require__(14).CryptoJS;
|
8611 |
|
8612 | (function (Math) {
|
8613 | // Shortcuts
|
8614 | var C = CryptoJS;
|
8615 | var C_lib = C.lib;
|
8616 | var WordArray = C_lib.WordArray;
|
8617 | var Hasher = C_lib.Hasher;
|
8618 | var C_algo = C.algo;
|
8619 |
|
8620 | // Initialization and round constants tables
|
8621 | var H = [];
|
8622 | var K = [];
|
8623 |
|
8624 | // Compute constants
|
8625 | (function () {
|
8626 | function isPrime(n) {
|
8627 | var sqrtN = Math.sqrt(n);
|
8628 | for (var factor = 2; factor <= sqrtN; factor++) {
|
8629 | if (!(n % factor)) {
|
8630 | return false;
|
8631 | }
|
8632 | }
|
8633 |
|
8634 | return true;
|
8635 | }
|
8636 |
|
8637 | function getFractionalBits(n) {
|
8638 | return ((n - (n | 0)) * 0x100000000) | 0;
|
8639 | }
|
8640 |
|
8641 | var n = 2;
|
8642 | var nPrime = 0;
|
8643 | while (nPrime < 64) {
|
8644 | if (isPrime(n)) {
|
8645 | if (nPrime < 8) {
|
8646 | H[nPrime] = getFractionalBits(Math.pow(n, 1 / 2));
|
8647 | }
|
8648 | K[nPrime] = getFractionalBits(Math.pow(n, 1 / 3));
|
8649 |
|
8650 | nPrime++;
|
8651 | }
|
8652 |
|
8653 | n++;
|
8654 | }
|
8655 | }());
|
8656 |
|
8657 | // Reusable object
|
8658 | var W = [];
|
8659 |
|
8660 | /**
|
8661 | * SHA-256 hash algorithm.
|
8662 | */
|
8663 | var SHA256 = C_algo.SHA256 = Hasher.extend({
|
8664 | _doReset: function () {
|
8665 | this._hash = new WordArray.init(H.slice(0));
|
8666 | },
|
8667 |
|
8668 | _doProcessBlock: function (M, offset) {
|
8669 | // Shortcut
|
8670 | var H = this._hash.words;
|
8671 |
|
8672 | // Working variables
|
8673 | var a = H[0];
|
8674 | var b = H[1];
|
8675 | var c = H[2];
|
8676 | var d = H[3];
|
8677 | var e = H[4];
|
8678 | var f = H[5];
|
8679 | var g = H[6];
|
8680 | var h = H[7];
|
8681 |
|
8682 | // Computation
|
8683 | for (var i = 0; i < 64; i++) {
|
8684 | if (i < 16) {
|
8685 | W[i] = M[offset + i] | 0;
|
8686 | } else {
|
8687 | var gamma0x = W[i - 15];
|
8688 | var gamma0 = ((gamma0x << 25) | (gamma0x >>> 7)) ^
|
8689 | ((gamma0x << 14) | (gamma0x >>> 18)) ^
|
8690 | (gamma0x >>> 3);
|
8691 |
|
8692 | var gamma1x = W[i - 2];
|
8693 | var gamma1 = ((gamma1x << 15) | (gamma1x >>> 17)) ^
|
8694 | ((gamma1x << 13) | (gamma1x >>> 19)) ^
|
8695 | (gamma1x >>> 10);
|
8696 |
|
8697 | W[i] = gamma0 + W[i - 7] + gamma1 + W[i - 16];
|
8698 | }
|
8699 |
|
8700 | var ch = (e & f) ^ (~e & g);
|
8701 | var maj = (a & b) ^ (a & c) ^ (b & c);
|
8702 |
|
8703 | var sigma0 = ((a << 30) | (a >>> 2)) ^ ((a << 19) | (a >>> 13)) ^ ((a << 10) | (a >>> 22));
|
8704 | var sigma1 = ((e << 26) | (e >>> 6)) ^ ((e << 21) | (e >>> 11)) ^ ((e << 7) | (e >>> 25));
|
8705 |
|
8706 | var t1 = h + sigma1 + ch + K[i] + W[i];
|
8707 | var t2 = sigma0 + maj;
|
8708 |
|
8709 | h = g;
|
8710 | g = f;
|
8711 | f = e;
|
8712 | e = (d + t1) | 0;
|
8713 | d = c;
|
8714 | c = b;
|
8715 | b = a;
|
8716 | a = (t1 + t2) | 0;
|
8717 | }
|
8718 |
|
8719 | // Intermediate hash value
|
8720 | H[0] = (H[0] + a) | 0;
|
8721 | H[1] = (H[1] + b) | 0;
|
8722 | H[2] = (H[2] + c) | 0;
|
8723 | H[3] = (H[3] + d) | 0;
|
8724 | H[4] = (H[4] + e) | 0;
|
8725 | H[5] = (H[5] + f) | 0;
|
8726 | H[6] = (H[6] + g) | 0;
|
8727 | H[7] = (H[7] + h) | 0;
|
8728 | },
|
8729 |
|
8730 | _doFinalize: function () {
|
8731 | // Shortcuts
|
8732 | var data = this._data;
|
8733 | var dataWords = data.words;
|
8734 |
|
8735 | var nBitsTotal = this._nDataBytes * 8;
|
8736 | var nBitsLeft = data.sigBytes * 8;
|
8737 |
|
8738 | // Add padding
|
8739 | dataWords[nBitsLeft >>> 5] |= 0x80 << (24 - nBitsLeft % 32);
|
8740 | dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 14] = Math.floor(nBitsTotal / 0x100000000);
|
8741 | dataWords[(((nBitsLeft + 64) >>> 9) << 4) + 15] = nBitsTotal;
|
8742 | data.sigBytes = dataWords.length * 4;
|
8743 |
|
8744 | // Hash final blocks
|
8745 | this._process();
|
8746 |
|
8747 | // Return final computed hash
|
8748 | return this._hash;
|
8749 | },
|
8750 |
|
8751 | clone: function () {
|
8752 | var clone = Hasher.clone.call(this);
|
8753 | clone._hash = this._hash.clone();
|
8754 |
|
8755 | return clone;
|
8756 | }
|
8757 | });
|
8758 |
|
8759 | /**
|
8760 | * Shortcut function to the hasher's object interface.
|
8761 | *
|
8762 | * @param {WordArray|string} message The message to hash.
|
8763 | *
|
8764 | * @return {WordArray} The hash.
|
8765 | *
|
8766 | * @static
|
8767 | *
|
8768 | * @example
|
8769 | *
|
8770 | * var hash = CryptoJS.SHA256('message');
|
8771 | * var hash = CryptoJS.SHA256(wordArray);
|
8772 | */
|
8773 | C.SHA256 = Hasher._createHelper(SHA256);
|
8774 |
|
8775 | /**
|
8776 | * Shortcut function to the HMAC's object interface.
|
8777 | *
|
8778 | * @param {WordArray|string} message The message to hash.
|
8779 | * @param {WordArray|string} key The secret key.
|
8780 | *
|
8781 | * @return {WordArray} The HMAC.
|
8782 | *
|
8783 | * @static
|
8784 | *
|
8785 | * @example
|
8786 | *
|
8787 | * var hmac = CryptoJS.HmacSHA256(message, key);
|
8788 | */
|
8789 | C.HmacSHA256 = Hasher._createHmacHelper(SHA256);
|
8790 | }(Math));
|
8791 |
|
8792 | /***/ }),
|
8793 | /* 126 */
|
8794 | /***/ (function(module, __webpack_exports__, __webpack_require__) {
|
8795 |
|
8796 | "use strict";
|
8797 | /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_jsbn__ = __webpack_require__(59);
|
8798 | /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0_jsbn___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_0_jsbn__);
|
8799 |
|
8800 |
|
8801 | const random = new __WEBPACK_IMPORTED_MODULE_0_jsbn__["SecureRandom"]();
|
8802 | /* unused harmony export random */
|
8803 |
|
8804 |
|
8805 | /* harmony default export */ __webpack_exports__["a"] = random;
|
8806 |
|
8807 | /***/ }),
|
8808 | /* 127 */
|
8809 | /***/ (function(module, __webpack_exports__, __webpack_require__) {
|
8810 |
|
8811 | "use strict";
|
8812 | /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "i", function() { return bpe; });
|
8813 | /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "r", function() { return one; });
|
8814 | /* harmony export (immutable) */ __webpack_exports__["h"] = powMod;
|
8815 | /* unused harmony export sub */
|
8816 | /* harmony export (immutable) */ __webpack_exports__["p"] = eGCD_;
|
8817 | /* harmony export (immutable) */ __webpack_exports__["n"] = greater;
|
8818 | /* harmony export (immutable) */ __webpack_exports__["d"] = divide_;
|
8819 | /* harmony export (immutable) */ __webpack_exports__["e"] = int2bigInt;
|
8820 | /* harmony export (immutable) */ __webpack_exports__["a"] = str2bigInt;
|
8821 | /* harmony export (immutable) */ __webpack_exports__["q"] = equalsInt;
|
8822 | /* harmony export (immutable) */ __webpack_exports__["l"] = isZero;
|
8823 | /* harmony export (immutable) */ __webpack_exports__["c"] = bigInt2str;
|
8824 | /* unused harmony export dup */
|
8825 | /* harmony export (immutable) */ __webpack_exports__["k"] = copy_;
|
8826 | /* harmony export (immutable) */ __webpack_exports__["j"] = copyInt_;
|
8827 | /* harmony export (immutable) */ __webpack_exports__["g"] = addInt_;
|
8828 | /* harmony export (immutable) */ __webpack_exports__["b"] = rightShift_;
|
8829 | /* harmony export (immutable) */ __webpack_exports__["f"] = leftShift_;
|
8830 | /* harmony export (immutable) */ __webpack_exports__["o"] = sub_;
|
8831 | /* harmony export (immutable) */ __webpack_exports__["m"] = add_;
|
8832 | ////////////////////////////////////////////////////////////////////////////////////////
|
8833 | // Big Integer Library v. 5.5
|
8834 | // Created 2000, last modified 2013
|
8835 | // Leemon Baird
|
8836 | // www.leemon.com
|
8837 | //
|
8838 | // Version history:
|
8839 | // v 5.5 17 Mar 2013
|
8840 | // - two lines of a form like "if (x<0) x+=n" had the "if" changed to "while" to
|
8841 | // handle the case when x<-n. (Thanks to James Ansell for finding that bug)
|
8842 | // v 5.4 3 Oct 2009
|
8843 | // - added "var i" to greaterShift() so i is not global. (Thanks to PŽter Szab— for finding that bug)
|
8844 | //
|
8845 | // v 5.3 21 Sep 2009
|
8846 | // - added randProbPrime(k) for probable primes
|
8847 | // - unrolled loop in mont_ (slightly faster)
|
8848 | // - millerRabin now takes a bigInt parameter rather than an int
|
8849 | //
|
8850 | // v 5.2 15 Sep 2009
|
8851 | // - fixed capitalization in call to int2bigInt in randBigInt
|
8852 | // (thanks to Emili Evripidou, Reinhold Behringer, and Samuel Macaleese for finding that bug)
|
8853 | //
|
8854 | // v 5.1 8 Oct 2007
|
8855 | // - renamed inverseModInt_ to inverseModInt since it doesn't change its parameters
|
8856 | // - added functions GCD and randBigInt, which call GCD_ and randBigInt_
|
8857 | // - fixed a bug found by Rob Visser (see comment with his name below)
|
8858 | // - improved comments
|
8859 | //
|
8860 | // This file is public domain. You can use it for any purpose without restriction.
|
8861 | // I do not guarantee that it is correct, so use it at your own risk. If you use
|
8862 | // it for something interesting, I'd appreciate hearing about it. If you find
|
8863 | // any bugs or make any improvements, I'd appreciate hearing about those too.
|
8864 | // It would also be nice if my name and URL were left in the comments. But none
|
8865 | // of that is required.
|
8866 | //
|
8867 | // This code defines a bigInt library for arbitrary-precision integers.
|
8868 | // A bigInt is an array of integers storing the value in chunks of bpe bits,
|
8869 | // little endian (buff[0] is the least significant word).
|
8870 | // Negative bigInts are stored two's complement. Almost all the functions treat
|
8871 | // bigInts as nonnegative. The few that view them as two's complement say so
|
8872 | // in their comments. Some functions assume their parameters have at least one
|
8873 | // leading zero element. Functions with an underscore at the end of the name put
|
8874 | // their answer into one of the arrays passed in, and have unpredictable behavior
|
8875 | // in case of overflow, so the caller must make sure the arrays are big enough to
|
8876 | // hold the answer. But the average user should never have to call any of the
|
8877 | // underscored functions. Each important underscored function has a wrapper function
|
8878 | // of the same name without the underscore that takes care of the details for you.
|
8879 | // For each underscored function where a parameter is modified, that same variable
|
8880 | // must not be used as another argument too. So, you cannot square x by doing
|
8881 | // multMod_(x,x,n). You must use squareMod_(x,n) instead, or do y=dup(x); multMod_(x,y,n).
|
8882 | // Or simply use the multMod(x,x,n) function without the underscore, where
|
8883 | // such issues never arise, because non-underscored functions never change
|
8884 | // their parameters; they always allocate new memory for the answer that is returned.
|
8885 | //
|
8886 | // These functions are designed to avoid frequent dynamic memory allocation in the inner loop.
|
8887 | // For most functions, if it needs a BigInt as a local variable it will actually use
|
8888 | // a global, and will only allocate to it only when it's not the right size. This ensures
|
8889 | // that when a function is called repeatedly with same-sized parameters, it only allocates
|
8890 | // memory on the first call.
|
8891 | //
|
8892 | // Note that for cryptographic purposes, the calls to Math.random() must
|
8893 | // be replaced with calls to a better pseudorandom number generator.
|
8894 | //
|
8895 | // In the following, "bigInt" means a bigInt with at least one leading zero element,
|
8896 | // and "integer" means a nonnegative integer less than radix. In some cases, integer
|
8897 | // can be negative. Negative bigInts are 2s complement.
|
8898 | //
|
8899 | // The following functions do not modify their inputs.
|
8900 | // Those returning a bigInt, string, or Array will dynamically allocate memory for that value.
|
8901 | // Those returning a boolean will return the integer 0 (false) or 1 (true).
|
8902 | // Those returning boolean or int will not allocate memory except possibly on the first
|
8903 | // time they're called with a given parameter size.
|
8904 | //
|
8905 | // bigInt add(x,y) //return (x+y) for bigInts x and y.
|
8906 | // bigInt addInt(x,n) //return (x+n) where x is a bigInt and n is an integer.
|
8907 | // string bigInt2str(x,base) //return a string form of bigInt x in a given base, with 2 <= base <= 95
|
8908 | // int bitSize(x) //return how many bits long the bigInt x is, not counting leading zeros
|
8909 | // bigInt dup(x) //return a copy of bigInt x
|
8910 | // boolean equals(x,y) //is the bigInt x equal to the bigint y?
|
8911 | // boolean equalsInt(x,y) //is bigint x equal to integer y?
|
8912 | // bigInt expand(x,n) //return a copy of x with at least n elements, adding leading zeros if needed
|
8913 | // Array findPrimes(n) //return array of all primes less than integer n
|
8914 | // bigInt GCD(x,y) //return greatest common divisor of bigInts x and y (each with same number of elements).
|
8915 | // boolean greater(x,y) //is x>y? (x and y are nonnegative bigInts)
|
8916 | // boolean greaterShift(x,y,shift)//is (x <<(shift*bpe)) > y?
|
8917 | // bigInt int2bigInt(t,n,m) //return a bigInt equal to integer t, with at least n bits and m array elements
|
8918 | // bigInt inverseMod(x,n) //return (x**(-1) mod n) for bigInts x and n. If no inverse exists, it returns null
|
8919 | // int inverseModInt(x,n) //return x**(-1) mod n, for integers x and n. Return 0 if there is no inverse
|
8920 | // boolean isZero(x) //is the bigInt x equal to zero?
|
8921 | // boolean millerRabin(x,b) //does one round of Miller-Rabin base integer b say that bigInt x is possibly prime? (b is bigInt, 1<b<x)
|
8922 | // boolean millerRabinInt(x,b) //does one round of Miller-Rabin base integer b say that bigInt x is possibly prime? (b is int, 1<b<x)
|
8923 | // bigInt mod(x,n) //return a new bigInt equal to (x mod n) for bigInts x and n.
|
8924 | // int modInt(x,n) //return x mod n for bigInt x and integer n.
|
8925 | // bigInt mult(x,y) //return x*y for bigInts x and y. This is faster when y<x.
|
8926 | // bigInt multMod(x,y,n) //return (x*y mod n) for bigInts x,y,n. For greater speed, let y<x.
|
8927 | // boolean negative(x) //is bigInt x negative?
|
8928 | // bigInt powMod(x,y,n) //return (x**y mod n) where x,y,n are bigInts and ** is exponentiation. 0**0=1. Faster for odd n.
|
8929 | // bigInt randBigInt(n,s) //return an n-bit random BigInt (n>=1). If s=1, then the most significant of those n bits is set to 1.
|
8930 | // bigInt randTruePrime(k) //return a new, random, k-bit, true prime bigInt using Maurer's algorithm.
|
8931 | // bigInt randProbPrime(k) //return a new, random, k-bit, probable prime bigInt (probability it's composite less than 2^-80).
|
8932 | // bigInt str2bigInt(s,b,n,m) //return a bigInt for number represented in string s in base b with at least n bits and m array elements
|
8933 | // bigInt sub(x,y) //return (x-y) for bigInts x and y. Negative answers will be 2s complement
|
8934 | // bigInt trim(x,k) //return a copy of x with exactly k leading zero elements
|
8935 | //
|
8936 | //
|
8937 | // The following functions each have a non-underscored version, which most users should call instead.
|
8938 | // These functions each write to a single parameter, and the caller is responsible for ensuring the array
|
8939 | // passed in is large enough to hold the result.
|
8940 | //
|
8941 | // void addInt_(x,n) //do x=x+n where x is a bigInt and n is an integer
|
8942 | // void add_(x,y) //do x=x+y for bigInts x and y
|
8943 | // void copy_(x,y) //do x=y on bigInts x and y
|
8944 | // void copyInt_(x,n) //do x=n on bigInt x and integer n
|
8945 | // void GCD_(x,y) //set x to the greatest common divisor of bigInts x and y, (y is destroyed). (This never overflows its array).
|
8946 | // boolean inverseMod_(x,n) //do x=x**(-1) mod n, for bigInts x and n. Returns 1 (0) if inverse does (doesn't) exist
|
8947 | // void mod_(x,n) //do x=x mod n for bigInts x and n. (This never overflows its array).
|
8948 | // void mult_(x,y) //do x=x*y for bigInts x and y.
|
8949 | // void multMod_(x,y,n) //do x=x*y mod n for bigInts x,y,n.
|
8950 | // void powMod_(x,y,n) //do x=x**y mod n, where x,y,n are bigInts (n is odd) and ** is exponentiation. 0**0=1.
|
8951 | // void randBigInt_(b,n,s) //do b = an n-bit random BigInt. if s=1, then nth bit (most significant bit) is set to 1. n>=1.
|
8952 | // void randTruePrime_(ans,k) //do ans = a random k-bit true random prime (not just probable prime) with 1 in the msb.
|
8953 | // void sub_(x,y) //do x=x-y for bigInts x and y. Negative answers will be 2s complement.
|
8954 | //
|
8955 | // The following functions do NOT have a non-underscored version.
|
8956 | // They each write a bigInt result to one or more parameters. The caller is responsible for
|
8957 | // ensuring the arrays passed in are large enough to hold the results.
|
8958 | //
|
8959 | // void addShift_(x,y,ys) //do x=x+(y<<(ys*bpe))
|
8960 | // void carry_(x) //do carries and borrows so each element of the bigInt x fits in bpe bits.
|
8961 | // void divide_(x,y,q,r) //divide x by y giving quotient q and remainder r
|
8962 | // int divInt_(x,n) //do x=floor(x/n) for bigInt x and integer n, and return the remainder. (This never overflows its array).
|
8963 | // int eGCD_(x,y,d,a,b) //sets a,b,d to positive bigInts such that d = GCD_(x,y) = a*x-b*y
|
8964 | // void halve_(x) //do x=floor(|x|/2)*sgn(x) for bigInt x in 2's complement. (This never overflows its array).
|
8965 | // void leftShift_(x,n) //left shift bigInt x by n bits. n<bpe.
|
8966 | // void linComb_(x,y,a,b) //do x=a*x+b*y for bigInts x and y and integers a and b
|
8967 | // void linCombShift_(x,y,b,ys) //do x=x+b*(y<<(ys*bpe)) for bigInts x and y, and integers b and ys
|
8968 | // void mont_(x,y,n,np) //Montgomery multiplication (see comments where the function is defined)
|
8969 | // void multInt_(x,n) //do x=x*n where x is a bigInt and n is an integer.
|
8970 | // void rightShift_(x,n) //right shift bigInt x by n bits. 0 <= n < bpe. (This never overflows its array).
|
8971 | // void squareMod_(x,n) //do x=x*x mod n for bigInts x,n
|
8972 | // void subShift_(x,y,ys) //do x=x-(y<<(ys*bpe)). Negative answers will be 2s complement.
|
8973 | //
|
8974 | // The following functions are based on algorithms from the _Handbook of Applied Cryptography_
|
8975 | // powMod_() = algorithm 14.94, Montgomery exponentiation
|
8976 | // eGCD_,inverseMod_() = algorithm 14.61, Binary extended GCD_
|
8977 | // GCD_() = algorothm 14.57, Lehmer's algorithm
|
8978 | // mont_() = algorithm 14.36, Montgomery multiplication
|
8979 | // divide_() = algorithm 14.20 Multiple-precision division
|
8980 | // squareMod_() = algorithm 14.16 Multiple-precision squaring
|
8981 | // randTruePrime_() = algorithm 4.62, Maurer's algorithm
|
8982 | // millerRabin() = algorithm 4.24, Miller-Rabin algorithm
|
8983 | //
|
8984 | // Profiling shows:
|
8985 | // randTruePrime_() spends:
|
8986 | // 10% of its time in calls to powMod_()
|
8987 | // 85% of its time in calls to millerRabin()
|
8988 | // millerRabin() spends:
|
8989 | // 99% of its time in calls to powMod_() (always with a base of 2)
|
8990 | // powMod_() spends:
|
8991 | // 94% of its time in calls to mont_() (almost always with x==y)
|
8992 | //
|
8993 | // This suggests there are several ways to speed up this library slightly:
|
8994 | // - convert powMod_ to use a Montgomery form of k-ary window (or maybe a Montgomery form of sliding window)
|
8995 | // -- this should especially focus on being fast when raising 2 to a power mod n
|
8996 | // - convert randTruePrime_() to use a minimum r of 1/3 instead of 1/2 with the appropriate change to the test
|
8997 | // - tune the parameters in randTruePrime_(), including c, m, and recLimit
|
8998 | // - speed up the single loop in mont_() that takes 95% of the runtime, perhaps by reducing checking
|
8999 | // within the loop when all the parameters are the same length.
|
9000 | //
|
9001 | // There are several ideas that look like they wouldn't help much at all:
|
9002 | // - replacing trial division in randTruePrime_() with a sieve (that speeds up something taking almost no time anyway)
|
9003 | // - increase bpe from 15 to 30 (that would help if we had a 32*32->64 multiplier, but not with JavaScript's 32*32->32)
|
9004 | // - speeding up mont_(x,y,n,np) when x==y by doing a non-modular, non-Montgomery square
|
9005 | // followed by a Montgomery reduction. The intermediate answer will be twice as long as x, so that
|
9006 | // method would be slower. This is unfortunate because the code currently spends almost all of its time
|
9007 | // doing mont_(x,x,...), both for randTruePrime_() and powMod_(). A faster method for Montgomery squaring
|
9008 | // would have a large impact on the speed of randTruePrime_() and powMod_(). HAC has a couple of poorly-worded
|
9009 | // sentences that seem to imply it's faster to do a non-modular square followed by a single
|
9010 | // Montgomery reduction, but that's obviously wrong.
|
9011 | ////////////////////////////////////////////////////////////////////////////////////////
|
9012 |
|
9013 | //globals
|
9014 | var bpe = 0; //bits stored per array element
|
9015 | var mask = 0; //AND this with an array element to chop it down to bpe bits
|
9016 | var radix = mask + 1; //equals 2^bpe. A single 1 bit to the left of the last bit of mask.
|
9017 |
|
9018 | //the digits for converting to different bases
|
9019 | var digitsStr = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz_=!@#$%^&*()[]{}|;:,.<>/?`~ \\\'\"+-';
|
9020 |
|
9021 | //initialize the global variables
|
9022 | for (bpe = 0; 1 << bpe + 1 > 1 << bpe; bpe++); //bpe=number of bits in the mantissa on this platform
|
9023 | bpe >>= 1; //bpe=number of bits in one element of the array representing the bigInt
|
9024 | mask = (1 << bpe) - 1; //AND the mask with an integer to get its bpe least significant bits
|
9025 | radix = mask + 1; //2^bpe. a single 1 bit to the left of the first bit of mask
|
9026 | var one = int2bigInt(1, 1, 1); //constant used in powMod_()
|
9027 |
|
9028 | //the following global variables are scratchpad memory to
|
9029 | //reduce dynamic memory allocation in the inner loop
|
9030 | var t = new Array(0);
|
9031 | var ss = t; //used in mult_()
|
9032 | var s0 = t; //used in multMod_(), squareMod_()
|
9033 | // var s1=t; //used in powMod_(), multMod_(), squareMod_()
|
9034 | // var s2=t; //used in powMod_(), multMod_()
|
9035 | var s3 = t; //used in powMod_()
|
9036 | var s4 = t,
|
9037 | s5 = t; //used in mod_()
|
9038 | var s6 = t; //used in bigInt2str()
|
9039 | var s7 = t; //used in powMod_()
|
9040 | var T = t; //used in GCD_()
|
9041 | var sa = t; //used in mont_()
|
9042 | var mr_x1 = t,
|
9043 | mr_r = t,
|
9044 | mr_a = t,
|
9045 | //used in millerRabin()
|
9046 | eg_v = t,
|
9047 | eg_u = t,
|
9048 | eg_A = t,
|
9049 | eg_B = t,
|
9050 | eg_C = t,
|
9051 | eg_D = t //used in eGCD_(), inverseMod_()
|
9052 | //, md_q1=t, md_q2=t, md_q3=t, md_r=t, md_r1=t, md_r2=t, md_tt=t, //used in mod_()
|
9053 |
|
9054 | ,
|
9055 | primes = t,
|
9056 | pows = t,
|
9057 | s_i = t,
|
9058 | s_i2 = t,
|
9059 | s_R = t,
|
9060 | s_rm = t,
|
9061 | s_q = t,
|
9062 | s_n1 = t,
|
9063 | s_a = t,
|
9064 | s_r2 = t,
|
9065 | s_n = t,
|
9066 | s_b = t,
|
9067 | s_d = t,
|
9068 | s_x1 = t,
|
9069 | s_x2 = t,
|
9070 | s_aa = t,
|
9071 | //used in randTruePrime_()
|
9072 |
|
9073 | rpprb = t; //used in randProbPrimeRounds() (which also uses "primes")
|
9074 |
|
9075 | ////////////////////////////////////////////////////////////////////////////////////////
|
9076 |
|
9077 | var k, buff;
|
9078 |
|
9079 | //return array of all primes less than integer n
|
9080 | function findPrimes(n) {
|
9081 | var i, s, p, ans;
|
9082 | s = new Array(n);
|
9083 | for (i = 0; i < n; i++) s[i] = 0;
|
9084 | s[0] = 2;
|
9085 | p = 0; //first p elements of s are primes, the rest are a sieve
|
9086 | for (; s[p] < n;) {
|
9087 | //s[p] is the pth prime
|
9088 | for (i = s[p] * s[p]; i < n; i += s[p]) //mark multiples of s[p]
|
9089 | s[i] = 1;
|
9090 | p++;
|
9091 | s[p] = s[p - 1] + 1;
|
9092 | for (; s[p] < n && s[s[p]]; s[p]++); //find next prime (where s[p]==0)
|
9093 | }
|
9094 | ans = new Array(p);
|
9095 | for (i = 0; i < p; i++) ans[i] = s[i];
|
9096 | return ans;
|
9097 | }
|
9098 |
|
9099 | //does a single round of Miller-Rabin base b consider x to be a possible prime?
|
9100 | //x is a bigInt, and b is an integer, with b<x
|
9101 | function millerRabinInt(x, b) {
|
9102 | if (mr_x1.length != x.length) {
|
9103 | mr_x1 = dup(x);
|
9104 | mr_r = dup(x);
|
9105 | mr_a = dup(x);
|
9106 | }
|
9107 |
|
9108 | copyInt_(mr_a, b);
|
9109 | return millerRabin(x, mr_a);
|
9110 | }
|
9111 |
|
9112 | //does a single round of Miller-Rabin base b consider x to be a possible prime?
|
9113 | //x and b are bigInts with b<x
|
9114 | function millerRabin(x, b) {
|
9115 | var i, j, k, s;
|
9116 |
|
9117 | if (mr_x1.length != x.length) {
|
9118 | mr_x1 = dup(x);
|
9119 | mr_r = dup(x);
|
9120 | mr_a = dup(x);
|
9121 | }
|
9122 |
|
9123 | copy_(mr_a, b);
|
9124 | copy_(mr_r, x);
|
9125 | copy_(mr_x1, x);
|
9126 |
|
9127 | addInt_(mr_r, -1);
|
9128 | addInt_(mr_x1, -1);
|
9129 |
|
9130 | //s=the highest power of two that divides mr_r
|
9131 | k = 0;
|
9132 | for (i = 0; i < mr_r.length; i++) for (j = 1; j < mask; j <<= 1) if (x[i] & j) {
|
9133 | s = k < mr_r.length + bpe ? k : 0;
|
9134 | i = mr_r.length;
|
9135 | j = mask;
|
9136 | } else k++;
|
9137 |
|
9138 | if (s) rightShift_(mr_r, s);
|
9139 |
|
9140 | powMod_(mr_a, mr_r, x);
|
9141 |
|
9142 | if (!equalsInt(mr_a, 1) && !equals(mr_a, mr_x1)) {
|
9143 | j = 1;
|
9144 | while (j <= s - 1 && !equals(mr_a, mr_x1)) {
|
9145 | squareMod_(mr_a, x);
|
9146 | if (equalsInt(mr_a, 1)) {
|
9147 | return 0;
|
9148 | }
|
9149 | j++;
|
9150 | }
|
9151 | if (!equals(mr_a, mr_x1)) {
|
9152 | return 0;
|
9153 | }
|
9154 | }
|
9155 | return 1;
|
9156 | }
|
9157 |
|
9158 | //returns how many bits long the bigInt is, not counting leading zeros.
|
9159 | function bitSize(x) {
|
9160 | var j, z, w;
|
9161 | for (j = x.length - 1; x[j] == 0 && j > 0; j--);
|
9162 | for (z = 0, w = x[j]; w; w >>= 1, z++);
|
9163 | z += bpe * j;
|
9164 | return z;
|
9165 | }
|
9166 |
|
9167 | //return a copy of x with at least n elements, adding leading zeros if needed
|
9168 | function expand(x, n) {
|
9169 | var ans = int2bigInt(0, (x.length > n ? x.length : n) * bpe, 0);
|
9170 | copy_(ans, x);
|
9171 | return ans;
|
9172 | }
|
9173 |
|
9174 | //return a k-bit true random prime using Maurer's algorithm.
|
9175 | function randTruePrime(k) {
|
9176 | var ans = int2bigInt(0, k, 0);
|
9177 | randTruePrime_(ans, k);
|
9178 | return trim(ans, 1);
|
9179 | }
|
9180 |
|
9181 | //return a k-bit random probable prime with probability of error < 2^-80
|
9182 | function randProbPrime(k) {
|
9183 | if (k >= 600) return randProbPrimeRounds(k, 2); //numbers from HAC table 4.3
|
9184 | if (k >= 550) return randProbPrimeRounds(k, 4);
|
9185 | if (k >= 500) return randProbPrimeRounds(k, 5);
|
9186 | if (k >= 400) return randProbPrimeRounds(k, 6);
|
9187 | if (k >= 350) return randProbPrimeRounds(k, 7);
|
9188 | if (k >= 300) return randProbPrimeRounds(k, 9);
|
9189 | if (k >= 250) return randProbPrimeRounds(k, 12); //numbers from HAC table 4.4
|
9190 | if (k >= 200) return randProbPrimeRounds(k, 15);
|
9191 | if (k >= 150) return randProbPrimeRounds(k, 18);
|
9192 | if (k >= 100) return randProbPrimeRounds(k, 27);
|
9193 | return randProbPrimeRounds(k, 40); //number from HAC remark 4.26 (only an estimate)
|
9194 | }
|
9195 |
|
9196 | //return a k-bit probable random prime using n rounds of Miller Rabin (after trial division with small primes)
|
9197 | function randProbPrimeRounds(k, n) {
|
9198 | var ans, i, divisible, B;
|
9199 | B = 30000; //B is largest prime to use in trial division
|
9200 | ans = int2bigInt(0, k, 0);
|
9201 |
|
9202 | //optimization: try larger and smaller B to find the best limit.
|
9203 |
|
9204 | if (primes.length == 0) primes = findPrimes(30000); //check for divisibility by primes <=30000
|
9205 |
|
9206 | if (rpprb.length != ans.length) rpprb = dup(ans);
|
9207 |
|
9208 | for (;;) {
|
9209 | //keep trying random values for ans until one appears to be prime
|
9210 | //optimization: pick a random number times L=2*3*5*...*p, plus a
|
9211 | // random element of the list of all numbers in [0,L) not divisible by any prime up to p.
|
9212 | // This can reduce the amount of random number generation.
|
9213 |
|
9214 | randBigInt_(ans, k, 0); //ans = a random odd number to check
|
9215 | ans[0] |= 1;
|
9216 | divisible = 0;
|
9217 |
|
9218 | //check ans for divisibility by small primes up to B
|
9219 | for (i = 0; i < primes.length && primes[i] <= B; i++) if (modInt(ans, primes[i]) == 0 && !equalsInt(ans, primes[i])) {
|
9220 | divisible = 1;
|
9221 | break;
|
9222 | }
|
9223 |
|
9224 | //optimization: change millerRabin so the base can be bigger than the number being checked, then eliminate the while here.
|
9225 |
|
9226 | //do n rounds of Miller Rabin, with random bases less than ans
|
9227 | for (i = 0; i < n && !divisible; i++) {
|
9228 | randBigInt_(rpprb, k, 0);
|
9229 | while (!greater(ans, rpprb)) //pick a random rpprb that's < ans
|
9230 | randBigInt_(rpprb, k, 0);
|
9231 | if (!millerRabin(ans, rpprb)) divisible = 1;
|
9232 | }
|
9233 |
|
9234 | if (!divisible) return ans;
|
9235 | }
|
9236 | }
|
9237 |
|
9238 | //return a new bigInt equal to (x mod n) for bigInts x and n.
|
9239 | function mod(x, n) {
|
9240 | var ans = dup(x);
|
9241 | mod_(ans, n);
|
9242 | return trim(ans, 1);
|
9243 | }
|
9244 |
|
9245 | //return (x+n) where x is a bigInt and n is an integer.
|
9246 | function addInt(x, n) {
|
9247 | var ans = expand(x, x.length + 1);
|
9248 | addInt_(ans, n);
|
9249 | return trim(ans, 1);
|
9250 | }
|
9251 |
|
9252 | //return x*y for bigInts x and y. This is faster when y<x.
|
9253 | function mult(x, y) {
|
9254 | var ans = expand(x, x.length + y.length);
|
9255 | mult_(ans, y);
|
9256 | return trim(ans, 1);
|
9257 | }
|
9258 |
|
9259 | //return (x**y mod n) where x,y,n are bigInts and ** is exponentiation. 0**0=1. Faster for odd n.
|
9260 | function powMod(x, y, n) {
|
9261 | var ans = expand(x, n.length);
|
9262 | powMod_(ans, trim(y, 2), trim(n, 2), 0); //this should work without the trim, but doesn't
|
9263 | return trim(ans, 1);
|
9264 | }
|
9265 |
|
9266 | //return (x-y) for bigInts x and y. Negative answers will be 2s complement
|
9267 | function sub(x, y) {
|
9268 | var ans = expand(x, x.length > y.length ? x.length + 1 : y.length + 1);
|
9269 | sub_(ans, y);
|
9270 | return trim(ans, 1);
|
9271 | }
|
9272 |
|
9273 | //return (x+y) for bigInts x and y.
|
9274 | function add(x, y) {
|
9275 | var ans = expand(x, x.length > y.length ? x.length + 1 : y.length + 1);
|
9276 | add_(ans, y);
|
9277 | return trim(ans, 1);
|
9278 | }
|
9279 |
|
9280 | //return (x**(-1) mod n) for bigInts x and n. If no inverse exists, it returns null
|
9281 | function inverseMod(x, n) {
|
9282 | var ans = expand(x, n.length);
|
9283 | var s;
|
9284 | s = inverseMod_(ans, n);
|
9285 | return s ? trim(ans, 1) : null;
|
9286 | }
|
9287 |
|
9288 | //return (x*y mod n) for bigInts x,y,n. For greater speed, let y<x.
|
9289 | function multMod(x, y, n) {
|
9290 | var ans = expand(x, n.length);
|
9291 | multMod_(ans, y, n);
|
9292 | return trim(ans, 1);
|
9293 | }
|
9294 |
|
9295 | //generate a k-bit true random prime using Maurer's algorithm,
|
9296 | //and put it into ans. The bigInt ans must be large enough to hold it.
|
9297 | function randTruePrime_(ans, k) {
|
9298 | var c, m, pm, dd, j, r, B, divisible, z, zz, recSize;
|
9299 | var w;
|
9300 | if (primes.length == 0) primes = findPrimes(30000); //check for divisibility by primes <=30000
|
9301 |
|
9302 | if (pows.length == 0) {
|
9303 | pows = new Array(512);
|
9304 | for (j = 0; j < 512; j++) {
|
9305 | pows[j] = Math.pow(2, j / 511. - 1.);
|
9306 | }
|
9307 | }
|
9308 |
|
9309 | //c and m should be tuned for a particular machine and value of k, to maximize speed
|
9310 | c = 0.1; //c=0.1 in HAC
|
9311 | m = 20; //generate this k-bit number by first recursively generating a number that has between k/2 and k-m bits
|
9312 | var recLimit = 20; //stop recursion when k <=recLimit. Must have recLimit >= 2
|
9313 |
|
9314 | if (s_i2.length != ans.length) {
|
9315 | s_i2 = dup(ans);
|
9316 | s_R = dup(ans);
|
9317 | s_n1 = dup(ans);
|
9318 | s_r2 = dup(ans);
|
9319 | s_d = dup(ans);
|
9320 | s_x1 = dup(ans); //TODO Seems like a bug in eslint, reports as unused
|
9321 | s_x2 = dup(ans);
|
9322 | s_b = dup(ans);
|
9323 | s_n = dup(ans);
|
9324 | s_i = dup(ans);
|
9325 | s_rm = dup(ans);
|
9326 | s_q = dup(ans);
|
9327 | s_a = dup(ans);
|
9328 | s_aa = dup(ans);
|
9329 | }
|
9330 |
|
9331 | if (k <= recLimit) {
|
9332 | //generate small random primes by trial division up to its square root
|
9333 | pm = (1 << (k + 2 >> 1)) - 1; //pm is binary number with all ones, just over sqrt(2^k)
|
9334 | copyInt_(ans, 0);
|
9335 | for (dd = 1; dd;) {
|
9336 | dd = 0;
|
9337 | ans[0] = 1 | 1 << k - 1 | Math.floor(Math.random() * (1 << k)); //random, k-bit, odd integer, with msb 1
|
9338 | for (j = 1; j < primes.length && (primes[j] & pm) == primes[j]; j++) {
|
9339 | //trial division by all primes 3...sqrt(2^k)
|
9340 | if (0 == ans[0] % primes[j]) {
|
9341 | dd = 1;
|
9342 | break;
|
9343 | }
|
9344 | }
|
9345 | }
|
9346 | carry_(ans);
|
9347 | return;
|
9348 | }
|
9349 |
|
9350 | B = c * k * k; //try small primes up to B (or all the primes[] array if the largest is less than B).
|
9351 | if (k > 2 * m) //generate this k-bit number by first recursively generating a number that has between k/2 and k-m bits
|
9352 | for (r = 1; k - k * r <= m;) r = pows[Math.floor(Math.random() * 512)]; //r=Math.pow(2,Math.random()-1);
|
9353 | else r = .5;
|
9354 |
|
9355 | //simulation suggests the more complex algorithm using r=.333 is only slightly faster.
|
9356 |
|
9357 | recSize = Math.floor(r * k) + 1;
|
9358 |
|
9359 | randTruePrime_(s_q, recSize);
|
9360 | copyInt_(s_i2, 0);
|
9361 | s_i2[Math.floor((k - 2) / bpe)] |= 1 << (k - 2) % bpe; //s_i2=2^(k-2)
|
9362 | divide_(s_i2, s_q, s_i, s_rm); //s_i=floor((2^(k-1))/(2q))
|
9363 |
|
9364 | z = bitSize(s_i);
|
9365 |
|
9366 | for (;;) {
|
9367 | for (;;) {
|
9368 | //generate z-bit numbers until one falls in the range [0,s_i-1]
|
9369 | randBigInt_(s_R, z, 0);
|
9370 | if (greater(s_i, s_R)) break;
|
9371 | } //now s_R is in the range [0,s_i-1]
|
9372 | addInt_(s_R, 1); //now s_R is in the range [1,s_i]
|
9373 | add_(s_R, s_i); //now s_R is in the range [s_i+1,2*s_i]
|
9374 |
|
9375 | copy_(s_n, s_q);
|
9376 | mult_(s_n, s_R);
|
9377 | multInt_(s_n, 2);
|
9378 | addInt_(s_n, 1); //s_n=2*s_R*s_q+1
|
9379 |
|
9380 | copy_(s_r2, s_R);
|
9381 | multInt_(s_r2, 2); //s_r2=2*s_R
|
9382 |
|
9383 | //check s_n for divisibility by small primes up to B
|
9384 | for (divisible = 0, j = 0; j < primes.length && primes[j] < B; j++) if (modInt(s_n, primes[j]) == 0 && !equalsInt(s_n, primes[j])) {
|
9385 | divisible = 1;
|
9386 | break;
|
9387 | }
|
9388 |
|
9389 | if (!divisible) //if it passes small primes check, then try a single Miller-Rabin base 2
|
9390 | if (!millerRabinInt(s_n, 2)) //this line represents 75% of the total runtime for randTruePrime_
|
9391 | divisible = 1;
|
9392 |
|
9393 | if (!divisible) {
|
9394 | //if it passes that test, continue checking s_n
|
9395 | addInt_(s_n, -3);
|
9396 | for (j = s_n.length - 1; s_n[j] == 0 && j > 0; j--); //strip leading zeros
|
9397 | for (zz = 0, w = s_n[j]; w; w >>= 1, zz++);
|
9398 | zz += bpe * j; //zz=number of bits in s_n, ignoring leading zeros
|
9399 | for (;;) {
|
9400 | //generate z-bit numbers until one falls in the range [0,s_n-1]
|
9401 | randBigInt_(s_a, zz, 0);
|
9402 | if (greater(s_n, s_a)) break;
|
9403 | } //now s_a is in the range [0,s_n-1]
|
9404 | addInt_(s_n, 3); //now s_a is in the range [0,s_n-4]
|
9405 | addInt_(s_a, 2); //now s_a is in the range [2,s_n-2]
|
9406 | copy_(s_b, s_a);
|
9407 | copy_(s_n1, s_n);
|
9408 | addInt_(s_n1, -1);
|
9409 | powMod_(s_b, s_n1, s_n); //s_b=s_a^(s_n-1) modulo s_n
|
9410 | addInt_(s_b, -1);
|
9411 | if (isZero(s_b)) {
|
9412 | copy_(s_b, s_a);
|
9413 | powMod_(s_b, s_r2, s_n);
|
9414 | addInt_(s_b, -1);
|
9415 | copy_(s_aa, s_n);
|
9416 | copy_(s_d, s_b);
|
9417 | GCD_(s_d, s_n); //if s_b and s_n are relatively prime, then s_n is a prime
|
9418 | if (equalsInt(s_d, 1)) {
|
9419 | copy_(ans, s_aa);
|
9420 | return; //if we've made it this far, then s_n is absolutely guaranteed to be prime
|
9421 | }
|
9422 | }
|
9423 | }
|
9424 | }
|
9425 | }
|
9426 |
|
9427 | //Return an n-bit random BigInt (n>=1). If s=1, then the most significant of those n bits is set to 1.
|
9428 | function randBigInt(n, s) {
|
9429 | var a, b;
|
9430 | a = Math.floor((n - 1) / bpe) + 2; //# array elements to hold the BigInt with a leading 0 element
|
9431 | b = int2bigInt(0, 0, a);
|
9432 | randBigInt_(b, n, s);
|
9433 | return b;
|
9434 | }
|
9435 |
|
9436 | //Set b to an n-bit random BigInt. If s=1, then the most significant of those n bits is set to 1.
|
9437 | //Array b must be big enough to hold the result. Must have n>=1
|
9438 | function randBigInt_(b, n, s) {
|
9439 | var i, a;
|
9440 | for (i = 0; i < b.length; i++) b[i] = 0;
|
9441 | a = Math.floor((n - 1) / bpe) + 1; //# array elements to hold the BigInt
|
9442 | for (i = 0; i < a; i++) {
|
9443 | b[i] = Math.floor(Math.random() * (1 << bpe - 1));
|
9444 | }
|
9445 | b[a - 1] &= (2 << (n - 1) % bpe) - 1;
|
9446 | if (s == 1) b[a - 1] |= 1 << (n - 1) % bpe;
|
9447 | }
|
9448 |
|
9449 | //Return the greatest common divisor of bigInts x and y (each with same number of elements).
|
9450 | function GCD(x, y) {
|
9451 | var xc, yc;
|
9452 | xc = dup(x);
|
9453 | yc = dup(y);
|
9454 | GCD_(xc, yc);
|
9455 | return xc;
|
9456 | }
|
9457 |
|
9458 | //set x to the greatest common divisor of bigInts x and y (each with same number of elements).
|
9459 | //y is destroyed.
|
9460 | function GCD_(x, y) {
|
9461 | var i, xp, yp, A, B, C, D, q, sing;
|
9462 | var qp;
|
9463 | if (T.length != x.length) T = dup(x);
|
9464 |
|
9465 | sing = 1;
|
9466 | while (sing) {
|
9467 | //while y has nonzero elements other than y[0]
|
9468 | sing = 0;
|
9469 | for (i = 1; i < y.length; i++) //check if y has nonzero elements other than 0
|
9470 | if (y[i]) {
|
9471 | sing = 1;
|
9472 | break;
|
9473 | }
|
9474 | if (!sing) break; //quit when y all zero elements except possibly y[0]
|
9475 |
|
9476 | for (i = x.length; !x[i] && i >= 0; i--); //find most significant element of x
|
9477 | xp = x[i];
|
9478 | yp = y[i];
|
9479 | A = 1;B = 0;C = 0;D = 1;
|
9480 | while (yp + C && yp + D) {
|
9481 | q = Math.floor((xp + A) / (yp + C));
|
9482 | qp = Math.floor((xp + B) / (yp + D));
|
9483 | if (q != qp) break;
|
9484 | t = A - q * C;A = C;C = t; // do (A,B,xp, C,D,yp) = (C,D,yp, A,B,xp) - q*(0,0,0, C,D,yp)
|
9485 | t = B - q * D;B = D;D = t;
|
9486 | t = xp - q * yp;xp = yp;yp = t;
|
9487 | }
|
9488 | if (B) {
|
9489 | copy_(T, x);
|
9490 | linComb_(x, y, A, B); //x=A*x+B*y
|
9491 | linComb_(y, T, D, C); //y=D*y+C*T
|
9492 | } else {
|
9493 | mod_(x, y);
|
9494 | copy_(T, x);
|
9495 | copy_(x, y);
|
9496 | copy_(y, T);
|
9497 | }
|
9498 | }
|
9499 | if (y[0] == 0) return;
|
9500 | t = modInt(x, y[0]);
|
9501 | copyInt_(x, y[0]);
|
9502 | y[0] = t;
|
9503 | while (y[0]) {
|
9504 | x[0] %= y[0];
|
9505 | t = x[0];x[0] = y[0];y[0] = t;
|
9506 | }
|
9507 | }
|
9508 |
|
9509 | //do x=x**(-1) mod n, for bigInts x and n.
|
9510 | //If no inverse exists, it sets x to zero and returns 0, else it returns 1.
|
9511 | //The x array must be at least as large as the n array.
|
9512 | function inverseMod_(x, n) {
|
9513 | var k = 1 + 2 * Math.max(x.length, n.length);
|
9514 |
|
9515 | if (!(x[0] & 1) && !(n[0] & 1)) {
|
9516 | //if both inputs are even, then inverse doesn't exist
|
9517 | copyInt_(x, 0);
|
9518 | return 0;
|
9519 | }
|
9520 |
|
9521 | if (eg_u.length != k) {
|
9522 | eg_u = new Array(k);
|
9523 | eg_v = new Array(k);
|
9524 | eg_A = new Array(k);
|
9525 | eg_B = new Array(k);
|
9526 | eg_C = new Array(k);
|
9527 | eg_D = new Array(k);
|
9528 | }
|
9529 |
|
9530 | copy_(eg_u, x);
|
9531 | copy_(eg_v, n);
|
9532 | copyInt_(eg_A, 1);
|
9533 | copyInt_(eg_B, 0);
|
9534 | copyInt_(eg_C, 0);
|
9535 | copyInt_(eg_D, 1);
|
9536 | for (;;) {
|
9537 | while (!(eg_u[0] & 1)) {
|
9538 | //while eg_u is even
|
9539 | halve_(eg_u);
|
9540 | if (!(eg_A[0] & 1) && !(eg_B[0] & 1)) {
|
9541 | //if eg_A==eg_B==0 mod 2
|
9542 | halve_(eg_A);
|
9543 | halve_(eg_B);
|
9544 | } else {
|
9545 | add_(eg_A, n);halve_(eg_A);
|
9546 | sub_(eg_B, x);halve_(eg_B);
|
9547 | }
|
9548 | }
|
9549 |
|
9550 | while (!(eg_v[0] & 1)) {
|
9551 | //while eg_v is even
|
9552 | halve_(eg_v);
|
9553 | if (!(eg_C[0] & 1) && !(eg_D[0] & 1)) {
|
9554 | //if eg_C==eg_D==0 mod 2
|
9555 | halve_(eg_C);
|
9556 | halve_(eg_D);
|
9557 | } else {
|
9558 | add_(eg_C, n);halve_(eg_C);
|
9559 | sub_(eg_D, x);halve_(eg_D);
|
9560 | }
|
9561 | }
|
9562 |
|
9563 | if (!greater(eg_v, eg_u)) {
|
9564 | //eg_v <= eg_u
|
9565 | sub_(eg_u, eg_v);
|
9566 | sub_(eg_A, eg_C);
|
9567 | sub_(eg_B, eg_D);
|
9568 | } else {
|
9569 | //eg_v > eg_u
|
9570 | sub_(eg_v, eg_u);
|
9571 | sub_(eg_C, eg_A);
|
9572 | sub_(eg_D, eg_B);
|
9573 | }
|
9574 |
|
9575 | if (equalsInt(eg_u, 0)) {
|
9576 | while (negative(eg_C)) //make sure answer is nonnegative
|
9577 | add_(eg_C, n);
|
9578 | copy_(x, eg_C);
|
9579 |
|
9580 | if (!equalsInt(eg_v, 1)) {
|
9581 | //if GCD_(x,n)!=1, then there is no inverse
|
9582 | copyInt_(x, 0);
|
9583 | return 0;
|
9584 | }
|
9585 | return 1;
|
9586 | }
|
9587 | }
|
9588 | }
|
9589 |
|
9590 | //return x**(-1) mod n, for integers x and n. Return 0 if there is no inverse
|
9591 | function inverseModInt(x, n) {
|
9592 | var a = 1,
|
9593 | b = 0,
|
9594 | t;
|
9595 | for (;;) {
|
9596 | if (x == 1) return a;
|
9597 | if (x == 0) return 0;
|
9598 | b -= a * Math.floor(n / x);
|
9599 | n %= x;
|
9600 |
|
9601 | if (n == 1) return b; //to avoid negatives, change this b to n-b, and each -= to +=
|
9602 | if (n == 0) return 0;
|
9603 | a -= b * Math.floor(x / n);
|
9604 | x %= n;
|
9605 | }
|
9606 | }
|
9607 |
|
9608 | //this deprecated function is for backward compatibility only.
|
9609 | function inverseModInt_(x, n) {
|
9610 | return inverseModInt(x, n);
|
9611 | }
|
9612 |
|
9613 | //Given positive bigInts x and y, change the bigints v, a, and b to positive bigInts such that:
|
9614 | // v = GCD_(x,y) = a*x-b*y
|
9615 | //The bigInts v, a, b, must have exactly as many elements as the larger of x and y.
|
9616 | function eGCD_(x, y, v, a, b) {
|
9617 | var g = 0;
|
9618 | var k = Math.max(x.length, y.length);
|
9619 | if (eg_u.length != k) {
|
9620 | eg_u = new Array(k);
|
9621 | eg_A = new Array(k);
|
9622 | eg_B = new Array(k);
|
9623 | eg_C = new Array(k);
|
9624 | eg_D = new Array(k);
|
9625 | }
|
9626 | while (!(x[0] & 1) && !(y[0] & 1)) {
|
9627 | //while x and y both even
|
9628 | halve_(x);
|
9629 | halve_(y);
|
9630 | g++;
|
9631 | }
|
9632 | copy_(eg_u, x);
|
9633 | copy_(v, y);
|
9634 | copyInt_(eg_A, 1);
|
9635 | copyInt_(eg_B, 0);
|
9636 | copyInt_(eg_C, 0);
|
9637 | copyInt_(eg_D, 1);
|
9638 | for (;;) {
|
9639 | while (!(eg_u[0] & 1)) {
|
9640 | //while u is even
|
9641 | halve_(eg_u);
|
9642 | if (!(eg_A[0] & 1) && !(eg_B[0] & 1)) {
|
9643 | //if A==B==0 mod 2
|
9644 | halve_(eg_A);
|
9645 | halve_(eg_B);
|
9646 | } else {
|
9647 | add_(eg_A, y);halve_(eg_A);
|
9648 | sub_(eg_B, x);halve_(eg_B);
|
9649 | }
|
9650 | }
|
9651 |
|
9652 | while (!(v[0] & 1)) {
|
9653 | //while v is even
|
9654 | halve_(v);
|
9655 | if (!(eg_C[0] & 1) && !(eg_D[0] & 1)) {
|
9656 | //if C==D==0 mod 2
|
9657 | halve_(eg_C);
|
9658 | halve_(eg_D);
|
9659 | } else {
|
9660 | add_(eg_C, y);halve_(eg_C);
|
9661 | sub_(eg_D, x);halve_(eg_D);
|
9662 | }
|
9663 | }
|
9664 |
|
9665 | if (!greater(v, eg_u)) {
|
9666 | //v<=u
|
9667 | sub_(eg_u, v);
|
9668 | sub_(eg_A, eg_C);
|
9669 | sub_(eg_B, eg_D);
|
9670 | } else {
|
9671 | //v>u
|
9672 | sub_(v, eg_u);
|
9673 | sub_(eg_C, eg_A);
|
9674 | sub_(eg_D, eg_B);
|
9675 | }
|
9676 | if (equalsInt(eg_u, 0)) {
|
9677 | while (negative(eg_C)) {
|
9678 | //make sure a (C) is nonnegative
|
9679 | add_(eg_C, y);
|
9680 | sub_(eg_D, x);
|
9681 | }
|
9682 | multInt_(eg_D, -1); ///make sure b (D) is nonnegative
|
9683 | copy_(a, eg_C);
|
9684 | copy_(b, eg_D);
|
9685 | leftShift_(v, g);
|
9686 | return;
|
9687 | }
|
9688 | }
|
9689 | }
|
9690 |
|
9691 | //is bigInt x negative?
|
9692 | function negative(x) {
|
9693 | return x[x.length - 1] >> bpe - 1 & 1;
|
9694 | }
|
9695 |
|
9696 | //is (x << (shift*bpe)) > y?
|
9697 | //x and y are nonnegative bigInts
|
9698 | //shift is a nonnegative integer
|
9699 | function greaterShift(x, y, shift) {
|
9700 | var i,
|
9701 | kx = x.length,
|
9702 | ky = y.length;
|
9703 | k = kx + shift < ky ? kx + shift : ky;
|
9704 | for (i = ky - 1 - shift; i < kx && i >= 0; i++) if (x[i] > 0) return 1; //if there are nonzeros in x to the left of the first column of y, then x is bigger
|
9705 | for (i = kx - 1 + shift; i < ky; i++) if (y[i] > 0) return 0; //if there are nonzeros in y to the left of the first column of x, then x is not bigger
|
9706 | for (i = k - 1; i >= shift; i--) if (x[i - shift] > y[i]) return 1;else if (x[i - shift] < y[i]) return 0;
|
9707 | return 0;
|
9708 | }
|
9709 |
|
9710 | //is x > y? (x and y both nonnegative)
|
9711 | function greater(x, y) {
|
9712 | var i;
|
9713 | var k = x.length < y.length ? x.length : y.length;
|
9714 |
|
9715 | for (i = x.length; i < y.length; i++) if (y[i]) return 0; //y has more digits
|
9716 |
|
9717 | for (i = y.length; i < x.length; i++) if (x[i]) return 1; //x has more digits
|
9718 |
|
9719 | for (i = k - 1; i >= 0; i--) if (x[i] > y[i]) return 1;else if (x[i] < y[i]) return 0;
|
9720 | return 0;
|
9721 | }
|
9722 |
|
9723 | //divide x by y giving quotient q and remainder r. (q=floor(x/y), r=x mod y). All 4 are bigints.
|
9724 | //x must have at least one leading zero element.
|
9725 | //y must be nonzero.
|
9726 | //q and r must be arrays that are exactly the same length as x. (Or q can have more).
|
9727 | //Must have x.length >= y.length >= 2.
|
9728 | function divide_(x, y, q, r) {
|
9729 | var kx, ky;
|
9730 | var i, j, y1, y2, c, a, b;
|
9731 | copy_(r, x);
|
9732 | for (ky = y.length; y[ky - 1] == 0; ky--); //ky is number of elements in y, not including leading zeros
|
9733 |
|
9734 | //normalize: ensure the most significant element of y has its highest bit set
|
9735 | b = y[ky - 1];
|
9736 | for (a = 0; b; a++) b >>= 1;
|
9737 | a = bpe - a; //a is how many bits to shift so that the high order bit of y is leftmost in its array element
|
9738 | leftShift_(y, a); //multiply both by 1<<a now, then divide both by that at the end
|
9739 | leftShift_(r, a);
|
9740 |
|
9741 | //Rob Visser discovered a bug: the following line was originally just before the normalization.
|
9742 | for (kx = r.length; r[kx - 1] == 0 && kx > ky; kx--); //kx is number of elements in normalized x, not including leading zeros
|
9743 |
|
9744 | copyInt_(q, 0); // q=0
|
9745 | while (!greaterShift(y, r, kx - ky)) {
|
9746 | // while (leftShift_(y,kx-ky) <= r) {
|
9747 | subShift_(r, y, kx - ky); // r=r-leftShift_(y,kx-ky)
|
9748 | q[kx - ky]++; // q[kx-ky]++;
|
9749 | } // }
|
9750 |
|
9751 | for (i = kx - 1; i >= ky; i--) {
|
9752 | if (r[i] == y[ky - 1]) q[i - ky] = mask;else q[i - ky] = Math.floor((r[i] * radix + r[i - 1]) / y[ky - 1]);
|
9753 |
|
9754 | //The following for(;;) loop is equivalent to the commented while loop,
|
9755 | //except that the uncommented version avoids overflow.
|
9756 | //The commented loop comes from HAC, which assumes r[-1]==y[-1]==0
|
9757 | // while (q[i-ky]*(y[ky-1]*radix+y[ky-2]) > r[i]*radix*radix+r[i-1]*radix+r[i-2])
|
9758 | // q[i-ky]--;
|
9759 | for (;;) {
|
9760 | y2 = (ky > 1 ? y[ky - 2] : 0) * q[i - ky];
|
9761 | c = y2 >> bpe;
|
9762 | y2 = y2 & mask;
|
9763 | y1 = c + q[i - ky] * y[ky - 1];
|
9764 | c = y1 >> bpe;
|
9765 | y1 = y1 & mask;
|
9766 |
|
9767 | if (c == r[i] ? y1 == r[i - 1] ? y2 > (i > 1 ? r[i - 2] : 0) : y1 > r[i - 1] : c > r[i]) q[i - ky]--;else break;
|
9768 | }
|
9769 |
|
9770 | linCombShift_(r, y, -q[i - ky], i - ky); //r=r-q[i-ky]*leftShift_(y,i-ky)
|
9771 | if (negative(r)) {
|
9772 | addShift_(r, y, i - ky); //r=r+leftShift_(y,i-ky)
|
9773 | q[i - ky]--;
|
9774 | }
|
9775 | }
|
9776 |
|
9777 | rightShift_(y, a); //undo the normalization step
|
9778 | rightShift_(r, a); //undo the normalization step
|
9779 | }
|
9780 |
|
9781 | //do carries and borrows so each element of the bigInt x fits in bpe bits.
|
9782 | function carry_(x) {
|
9783 | var i, k, c, b;
|
9784 | k = x.length;
|
9785 | c = 0;
|
9786 | for (i = 0; i < k; i++) {
|
9787 | c += x[i];
|
9788 | b = 0;
|
9789 | if (c < 0) {
|
9790 | b = -(c >> bpe);
|
9791 | c += b * radix;
|
9792 | }
|
9793 | x[i] = c & mask;
|
9794 | c = (c >> bpe) - b;
|
9795 | }
|
9796 | }
|
9797 |
|
9798 | //return x mod n for bigInt x and integer n.
|
9799 | function modInt(x, n) {
|
9800 | var i,
|
9801 | c = 0;
|
9802 | for (i = x.length - 1; i >= 0; i--) c = (c * radix + x[i]) % n;
|
9803 | return c;
|
9804 | }
|
9805 |
|
9806 | //convert the integer t into a bigInt with at least the given number of bits.
|
9807 | //the returned array stores the bigInt in bpe-bit chunks, little endian (buff[0] is least significant word)
|
9808 | //Pad the array with leading zeros so that it has at least minSize elements.
|
9809 | //There will always be at least one leading 0 element.
|
9810 | function int2bigInt(t, bits, minSize) {
|
9811 | var i, k;
|
9812 | k = Math.ceil(bits / bpe) + 1;
|
9813 | k = minSize > k ? minSize : k;
|
9814 | var buff = new Array(k);
|
9815 | copyInt_(buff, t);
|
9816 | return buff;
|
9817 | }
|
9818 |
|
9819 | //return the bigInt given a string representation in a given base.
|
9820 | //Pad the array with leading zeros so that it has at least minSize elements.
|
9821 | //If base=-1, then it reads in a space-separated list of array elements in decimal.
|
9822 | //The array will always have at least one leading zero, unless base=-1.
|
9823 | function str2bigInt(s, base, minSize) {
|
9824 | var d, i, j, x, y, kk;
|
9825 | var k = s.length;
|
9826 | if (base == -1) {
|
9827 | //comma-separated list of array elements in decimal
|
9828 | x = new Array(0);
|
9829 | for (;;) {
|
9830 | y = new Array(x.length + 1);
|
9831 | for (i = 0; i < x.length; i++) y[i + 1] = x[i];
|
9832 | y[0] = parseInt(s, 10); //TODO PERF Should we replace that with ~~ (not not)? https://jsperf.com/number-vs-parseint-vs-plus/7
|
9833 | x = y;
|
9834 | d = s.indexOf(',', 0);
|
9835 | if (d < 1) break;
|
9836 | s = s.substring(d + 1);
|
9837 | if (s.length == 0) break;
|
9838 | }
|
9839 | if (x.length < minSize) {
|
9840 | y = new Array(minSize);
|
9841 | copy_(y, x);
|
9842 | return y;
|
9843 | }
|
9844 | return x;
|
9845 | }
|
9846 |
|
9847 | x = int2bigInt(0, base * k, 0);
|
9848 | for (i = 0; i < k; i++) {
|
9849 | d = digitsStr.indexOf(s.substring(i, i + 1), 0);
|
9850 | if (base <= 36 && d >= 36) //convert lowercase to uppercase if base<=36
|
9851 | d -= 26;
|
9852 | if (d >= base || d < 0) {
|
9853 | //stop at first illegal character
|
9854 | break;
|
9855 | }
|
9856 | multInt_(x, base);
|
9857 | addInt_(x, d);
|
9858 | }
|
9859 |
|
9860 | for (k = x.length; k > 0 && !x[k - 1]; k--); //strip off leading zeros
|
9861 | k = minSize > k + 1 ? minSize : k + 1;
|
9862 | y = new Array(k);
|
9863 | kk = k < x.length ? k : x.length;
|
9864 | for (i = 0; i < kk; i++) y[i] = x[i];
|
9865 | for (; i < k; i++) y[i] = 0;
|
9866 | return y;
|
9867 | }
|
9868 |
|
9869 | //is bigint x equal to integer y?
|
9870 | //y must have less than bpe bits
|
9871 | function equalsInt(x, y) {
|
9872 | var i;
|
9873 | if (x[0] != y) return 0;
|
9874 | for (i = 1; i < x.length; i++) if (x[i]) return 0;
|
9875 | return 1;
|
9876 | }
|
9877 |
|
9878 | //are bigints x and y equal?
|
9879 | //this works even if x and y are different lengths and have arbitrarily many leading zeros
|
9880 | function equals(x, y) {
|
9881 | var i;
|
9882 | var k = x.length < y.length ? x.length : y.length;
|
9883 | for (i = 0; i < k; i++) if (x[i] != y[i]) return 0;
|
9884 | if (x.length > y.length) {
|
9885 | for (; i < x.length; i++) if (x[i]) return 0;
|
9886 | } else {
|
9887 | for (; i < y.length; i++) if (y[i]) return 0;
|
9888 | }
|
9889 | return 1;
|
9890 | }
|
9891 |
|
9892 | //is the bigInt x equal to zero?
|
9893 | function isZero(x) {
|
9894 | var i;
|
9895 | for (i = 0; i < x.length; i++) if (x[i]) return 0;
|
9896 | return 1;
|
9897 | }
|
9898 |
|
9899 | //convert a bigInt into a string in a given base, from base 2 up to base 95.
|
9900 | //Base -1 prints the contents of the array representing the number.
|
9901 | function bigInt2str(x, base) {
|
9902 | var i,
|
9903 | t,
|
9904 | s = '';
|
9905 |
|
9906 | if (s6.length != x.length) s6 = dup(x);else copy_(s6, x);
|
9907 |
|
9908 | if (base == -1) {
|
9909 | //return the list of array contents
|
9910 | for (i = x.length - 1; i > 0; i--) s += x[i] + ',';
|
9911 | s += x[0];
|
9912 | } else {
|
9913 | //return it in the given base
|
9914 | while (!isZero(s6)) {
|
9915 | t = divInt_(s6, base); //t=s6 % base; s6=floor(s6/base);
|
9916 | s = digitsStr.substring(t, t + 1) + s;
|
9917 | }
|
9918 | }
|
9919 | if (s.length == 0) s = '0';
|
9920 | return s;
|
9921 | }
|
9922 |
|
9923 | //returns a duplicate of bigInt x
|
9924 | function dup(x) {
|
9925 | var i;
|
9926 | buff = new Array(x.length);
|
9927 | copy_(buff, x);
|
9928 | return buff;
|
9929 | }
|
9930 |
|
9931 | //do x=y on bigInts x and y. x must be an array at least as big as y (not counting the leading zeros in y).
|
9932 | function copy_(x, y) {
|
9933 | var i;
|
9934 | var k = x.length < y.length ? x.length : y.length;
|
9935 | for (i = 0; i < k; i++) x[i] = y[i];
|
9936 | for (i = k; i < x.length; i++) x[i] = 0;
|
9937 | }
|
9938 |
|
9939 | //do x=y on bigInt x and integer y.
|
9940 | function copyInt_(x, n) {
|
9941 | var i, c;
|
9942 | var len = x.length; //TODO .length in for loop have perfomance costs. Bench this
|
9943 | for (c = n, i = 0; i < len; i++) {
|
9944 | x[i] = c & mask;
|
9945 | c >>= bpe;
|
9946 | }
|
9947 | }
|
9948 |
|
9949 | //do x=x+n where x is a bigInt and n is an integer.
|
9950 | //x must be large enough to hold the result.
|
9951 | function addInt_(x, n) {
|
9952 | var i, k, c, b;
|
9953 | x[0] += n;
|
9954 | k = x.length;
|
9955 | c = 0;
|
9956 | for (i = 0; i < k; i++) {
|
9957 | c += x[i];
|
9958 | b = 0;
|
9959 | if (c < 0) {
|
9960 | b = -(c >> bpe);
|
9961 | c += b * radix;
|
9962 | }
|
9963 | x[i] = c & mask;
|
9964 | c = (c >> bpe) - b;
|
9965 | if (!c) return; //stop carrying as soon as the carry is zero
|
9966 | }
|
9967 | }
|
9968 |
|
9969 | //right shift bigInt x by n bits. 0 <= n < bpe.
|
9970 | function rightShift_(x, n) {
|
9971 | var i;
|
9972 | var k = Math.floor(n / bpe);
|
9973 | if (k) {
|
9974 | for (i = 0; i < x.length - k; i++) //right shift x by k elements
|
9975 | x[i] = x[i + k];
|
9976 | for (; i < x.length; i++) x[i] = 0;
|
9977 | n %= bpe;
|
9978 | }
|
9979 | for (i = 0; i < x.length - 1; i++) {
|
9980 | x[i] = mask & (x[i + 1] << bpe - n | x[i] >> n);
|
9981 | }
|
9982 | x[i] >>= n;
|
9983 | }
|
9984 |
|
9985 | //do x=floor(|x|/2)*sgn(x) for bigInt x in 2's complement
|
9986 | function halve_(x) {
|
9987 | var i;
|
9988 | for (i = 0; i < x.length - 1; i++) {
|
9989 | x[i] = mask & (x[i + 1] << bpe - 1 | x[i] >> 1);
|
9990 | }
|
9991 | x[i] = x[i] >> 1 | x[i] & radix >> 1; //most significant bit stays the same
|
9992 | }
|
9993 |
|
9994 | //left shift bigInt x by n bits.
|
9995 | function leftShift_(x, n) {
|
9996 | var i;
|
9997 | var k = Math.floor(n / bpe);
|
9998 | if (k) {
|
9999 | for (i = x.length; i >= k; i--) //left shift x by k elements
|
10000 | x[i] = x[i - k];
|
10001 | for (; i >= 0; i--) x[i] = 0;
|
10002 | n %= bpe;
|
10003 | }
|
10004 | if (!n) return;
|
10005 | for (i = x.length - 1; i > 0; i--) {
|
10006 | x[i] = mask & (x[i] << n | x[i - 1] >> bpe - n);
|
10007 | }
|
10008 | x[i] = mask & x[i] << n;
|
10009 | }
|
10010 |
|
10011 | //do x=x*n where x is a bigInt and n is an integer.
|
10012 | //x must be large enough to hold the result.
|
10013 | function multInt_(x, n) {
|
10014 | var i, k, c, b;
|
10015 | if (!n) return;
|
10016 | k = x.length;
|
10017 | c = 0;
|
10018 | for (i = 0; i < k; i++) {
|
10019 | c += x[i] * n;
|
10020 | b = 0;
|
10021 | if (c < 0) {
|
10022 | b = -(c >> bpe);
|
10023 | c += b * radix;
|
10024 | }
|
10025 | x[i] = c & mask;
|
10026 | c = (c >> bpe) - b;
|
10027 | }
|
10028 | }
|
10029 |
|
10030 | //do x=floor(x/n) for bigInt x and integer n, and return the remainder
|
10031 | function divInt_(x, n) {
|
10032 | var i,
|
10033 | r = 0,
|
10034 | s;
|
10035 | for (i = x.length - 1; i >= 0; i--) {
|
10036 | s = r * radix + x[i];
|
10037 | x[i] = Math.floor(s / n);
|
10038 | r = s % n;
|
10039 | }
|
10040 | return r;
|
10041 | }
|
10042 |
|
10043 | //do the linear combination x=a*x+b*y for bigInts x and y, and integers a and b.
|
10044 | //x must be large enough to hold the answer.
|
10045 | function linComb_(x, y, a, b) {
|
10046 | var i, c, k, kk;
|
10047 | k = x.length < y.length ? x.length : y.length;
|
10048 | kk = x.length;
|
10049 | for (c = 0, i = 0; i < k; i++) {
|
10050 | c += a * x[i] + b * y[i];
|
10051 | x[i] = c & mask;
|
10052 | c >>= bpe;
|
10053 | }
|
10054 | for (i = k; i < kk; i++) {
|
10055 | c += a * x[i];
|
10056 | x[i] = c & mask;
|
10057 | c >>= bpe;
|
10058 | }
|
10059 | }
|
10060 |
|
10061 | //do the linear combination x=a*x+b*(y<<(ys*bpe)) for bigInts x and y, and integers a, b and ys.
|
10062 | //x must be large enough to hold the answer.
|
10063 | function linCombShift_(x, y, b, ys) {
|
10064 | var i, c, k, kk;
|
10065 | k = x.length < ys + y.length ? x.length : ys + y.length;
|
10066 | kk = x.length;
|
10067 | for (c = 0, i = ys; i < k; i++) {
|
10068 | c += x[i] + b * y[i - ys];
|
10069 | x[i] = c & mask;
|
10070 | c >>= bpe;
|
10071 | }
|
10072 | for (i = k; c && i < kk; i++) {
|
10073 | c += x[i];
|
10074 | x[i] = c & mask;
|
10075 | c >>= bpe;
|
10076 | }
|
10077 | }
|
10078 |
|
10079 | //do x=x+(y<<(ys*bpe)) for bigInts x and y, and integers a,b and ys.
|
10080 | //x must be large enough to hold the answer.
|
10081 | function addShift_(x, y, ys) {
|
10082 | var i, c, k, kk;
|
10083 | k = x.length < ys + y.length ? x.length : ys + y.length;
|
10084 | kk = x.length;
|
10085 | for (c = 0, i = ys; i < k; i++) {
|
10086 | c += x[i] + y[i - ys];
|
10087 | x[i] = c & mask;
|
10088 | c >>= bpe;
|
10089 | }
|
10090 | for (i = k; c && i < kk; i++) {
|
10091 | c += x[i];
|
10092 | x[i] = c & mask;
|
10093 | c >>= bpe;
|
10094 | }
|
10095 | }
|
10096 |
|
10097 | //do x=x-(y<<(ys*bpe)) for bigInts x and y, and integers a,b and ys.
|
10098 | //x must be large enough to hold the answer.
|
10099 | function subShift_(x, y, ys) {
|
10100 | var i, c, k, kk;
|
10101 | k = x.length < ys + y.length ? x.length : ys + y.length;
|
10102 | kk = x.length;
|
10103 | for (c = 0, i = ys; i < k; i++) {
|
10104 | c += x[i] - y[i - ys];
|
10105 | x[i] = c & mask;
|
10106 | c >>= bpe;
|
10107 | }
|
10108 | for (i = k; c && i < kk; i++) {
|
10109 | c += x[i];
|
10110 | x[i] = c & mask;
|
10111 | c >>= bpe;
|
10112 | }
|
10113 | }
|
10114 |
|
10115 | //do x=x-y for bigInts x and y.
|
10116 | //x must be large enough to hold the answer.
|
10117 | //negative answers will be 2s complement
|
10118 | function sub_(x, y) {
|
10119 | var i, c, k, kk;
|
10120 | k = x.length < y.length ? x.length : y.length;
|
10121 | for (c = 0, i = 0; i < k; i++) {
|
10122 | c += x[i] - y[i];
|
10123 | x[i] = c & mask;
|
10124 | c >>= bpe;
|
10125 | }
|
10126 | for (i = k; c && i < x.length; i++) {
|
10127 | c += x[i];
|
10128 | x[i] = c & mask;
|
10129 | c >>= bpe;
|
10130 | }
|
10131 | }
|
10132 |
|
10133 | //do x=x+y for bigInts x and y.
|
10134 | //x must be large enough to hold the answer.
|
10135 | function add_(x, y) {
|
10136 | var i, c, k, kk;
|
10137 | k = x.length < y.length ? x.length : y.length;
|
10138 | for (c = 0, i = 0; i < k; i++) {
|
10139 | c += x[i] + y[i];
|
10140 | x[i] = c & mask;
|
10141 | c >>= bpe;
|
10142 | }
|
10143 | for (i = k; c && i < x.length; i++) {
|
10144 | c += x[i];
|
10145 | x[i] = c & mask;
|
10146 | c >>= bpe;
|
10147 | }
|
10148 | }
|
10149 |
|
10150 | //do x=x*y for bigInts x and y. This is faster when y<x.
|
10151 | function mult_(x, y) {
|
10152 | var i;
|
10153 | if (ss.length != 2 * x.length) ss = new Array(2 * x.length);
|
10154 | copyInt_(ss, 0);
|
10155 | for (i = 0; i < y.length; i++) if (y[i]) linCombShift_(ss, x, y[i], i); //ss=1*ss+y[i]*(x<<(i*bpe))
|
10156 | copy_(x, ss);
|
10157 | }
|
10158 |
|
10159 | //do x=x mod n for bigInts x and n.
|
10160 | function mod_(x, n) {
|
10161 | if (s4.length != x.length) s4 = dup(x);else copy_(s4, x);
|
10162 | if (s5.length != x.length) s5 = dup(x);
|
10163 | divide_(s4, n, s5, x); //x = remainder of s4 / n
|
10164 | }
|
10165 |
|
10166 | //do x=x*y mod n for bigInts x,y,n.
|
10167 | //for greater speed, let y<x.
|
10168 | function multMod_(x, y, n) {
|
10169 | var i;
|
10170 | if (s0.length != 2 * x.length) s0 = new Array(2 * x.length);
|
10171 | copyInt_(s0, 0);
|
10172 | for (i = 0; i < y.length; i++) if (y[i]) linCombShift_(s0, x, y[i], i); //s0=1*s0+y[i]*(x<<(i*bpe))
|
10173 | mod_(s0, n);
|
10174 | copy_(x, s0);
|
10175 | }
|
10176 |
|
10177 | //do x=x*x mod n for bigInts x,n.
|
10178 | function squareMod_(x, n) {
|
10179 | var i, j, d, c, kx, kn, k;
|
10180 | for (kx = x.length; kx > 0 && !x[kx - 1]; kx--); //ignore leading zeros in x
|
10181 | k = kx > n.length ? 2 * kx : 2 * n.length; //k=# elements in the product, which is twice the elements in the larger of x and n
|
10182 | if (s0.length != k) s0 = new Array(k);
|
10183 | copyInt_(s0, 0);
|
10184 | for (i = 0; i < kx; i++) {
|
10185 | c = s0[2 * i] + x[i] * x[i];
|
10186 | s0[2 * i] = c & mask;
|
10187 | c >>= bpe;
|
10188 | for (j = i + 1; j < kx; j++) {
|
10189 | c = s0[i + j] + 2 * x[i] * x[j] + c;
|
10190 | s0[i + j] = c & mask;
|
10191 | c >>= bpe;
|
10192 | }
|
10193 | s0[i + kx] = c;
|
10194 | }
|
10195 | mod_(s0, n);
|
10196 | copy_(x, s0);
|
10197 | }
|
10198 |
|
10199 | //return x with exactly k leading zero elements
|
10200 | function trim(x, k) {
|
10201 | var i, y;
|
10202 | for (i = x.length; i > 0 && !x[i - 1]; i--);
|
10203 | y = new Array(i + k);
|
10204 | copy_(y, x);
|
10205 | return y;
|
10206 | }
|
10207 |
|
10208 | //do x=x**y mod n, where x,y,n are bigInts and ** is exponentiation. 0**0=1.
|
10209 | //this is faster when n is odd. x usually needs to have as many elements as n.
|
10210 | function powMod_(x, y, n) {
|
10211 | var k1, k2, kn, np;
|
10212 | if (s7.length != n.length) s7 = dup(n);
|
10213 |
|
10214 | //for even modulus, use a simple square-and-multiply algorithm,
|
10215 | //rather than using the more complex Montgomery algorithm.
|
10216 | if ((n[0] & 1) == 0) {
|
10217 | copy_(s7, x);
|
10218 | copyInt_(x, 1);
|
10219 | while (!equalsInt(y, 0)) {
|
10220 | if (y[0] & 1) multMod_(x, s7, n);
|
10221 | divInt_(y, 2);
|
10222 | squareMod_(s7, n);
|
10223 | }
|
10224 | return;
|
10225 | }
|
10226 |
|
10227 | //calculate np from n for the Montgomery multiplications
|
10228 | copyInt_(s7, 0);
|
10229 | for (kn = n.length; kn > 0 && !n[kn - 1]; kn--);
|
10230 | np = radix - inverseModInt(modInt(n, radix), radix);
|
10231 | s7[kn] = 1;
|
10232 | multMod_(x, s7, n); // x = x * 2**(kn*bp) mod n
|
10233 |
|
10234 | if (s3.length != x.length) s3 = dup(x);else copy_(s3, x);
|
10235 |
|
10236 | for (k1 = y.length - 1; k1 > 0 & !y[k1]; k1--); //k1=first nonzero element of y
|
10237 | if (y[k1] == 0) {
|
10238 | //anything to the 0th power is 1
|
10239 | copyInt_(x, 1);
|
10240 | return;
|
10241 | }
|
10242 | for (k2 = 1 << bpe - 1; k2 && !(y[k1] & k2); k2 >>= 1); //k2=position of first 1 bit in y[k1]
|
10243 | for (;;) {
|
10244 | if (!(k2 >>= 1)) {
|
10245 | //look at next bit of y
|
10246 | k1--;
|
10247 | if (k1 < 0) {
|
10248 | mont_(x, one, n, np);
|
10249 | return;
|
10250 | }
|
10251 | k2 = 1 << bpe - 1;
|
10252 | }
|
10253 | mont_(x, x, n, np);
|
10254 |
|
10255 | if (k2 & y[k1]) //if next bit is a 1
|
10256 | mont_(x, s3, n, np);
|
10257 | }
|
10258 | }
|
10259 |
|
10260 | //do x=x*y*Ri mod n for bigInts x,y,n,
|
10261 | // where Ri = 2**(-kn*bpe) mod n, and kn is the
|
10262 | // number of elements in the n array, not
|
10263 | // counting leading zeros.
|
10264 | //x array must have at least as many elemnts as the n array
|
10265 | //It's OK if x and y are the same variable.
|
10266 | //must have:
|
10267 | // x,y < n
|
10268 | // n is odd
|
10269 | // np = -(n^(-1)) mod radix
|
10270 | function mont_(x, y, n, np) {
|
10271 | var i, j, c, ui, t, ks;
|
10272 | var kn = n.length;
|
10273 | var ky = y.length;
|
10274 |
|
10275 | if (sa.length != kn) sa = new Array(kn);
|
10276 |
|
10277 | copyInt_(sa, 0);
|
10278 |
|
10279 | for (; kn > 0 && n[kn - 1] == 0; kn--); //ignore leading zeros of n
|
10280 | for (; ky > 0 && y[ky - 1] == 0; ky--); //ignore leading zeros of y
|
10281 | ks = sa.length - 1; //sa will never have more than this many nonzero elements.
|
10282 |
|
10283 | //the following loop consumes 95% of the runtime for randTruePrime_() and powMod_() for large numbers
|
10284 | for (i = 0; i < kn; i++) {
|
10285 | t = sa[0] + x[i] * y[0];
|
10286 | ui = (t & mask) * np & mask; //the inner "& mask" was needed on Safari (but not MSIE) at one time
|
10287 | c = t + ui * n[0] >> bpe;
|
10288 | t = x[i];
|
10289 |
|
10290 | //do sa=(sa+x[i]*y+ui*n)/b where b=2**bpe. Loop is unrolled 5-fold for speed
|
10291 | j = 1;
|
10292 | for (; j < ky - 4;) {
|
10293 | c += sa[j] + ui * n[j] + t * y[j];sa[j - 1] = c & mask;c >>= bpe;j++;
|
10294 | c += sa[j] + ui * n[j] + t * y[j];sa[j - 1] = c & mask;c >>= bpe;j++;
|
10295 | c += sa[j] + ui * n[j] + t * y[j];sa[j - 1] = c & mask;c >>= bpe;j++;
|
10296 | c += sa[j] + ui * n[j] + t * y[j];sa[j - 1] = c & mask;c >>= bpe;j++;
|
10297 | c += sa[j] + ui * n[j] + t * y[j];sa[j - 1] = c & mask;c >>= bpe;j++;
|
10298 | }
|
10299 | for (; j < ky;) {
|
10300 | c += sa[j] + ui * n[j] + t * y[j];sa[j - 1] = c & mask;c >>= bpe;j++;
|
10301 | }
|
10302 | for (; j < kn - 4;) {
|
10303 | c += sa[j] + ui * n[j];sa[j - 1] = c & mask;c >>= bpe;j++;
|
10304 | c += sa[j] + ui * n[j];sa[j - 1] = c & mask;c >>= bpe;j++;
|
10305 | c += sa[j] + ui * n[j];sa[j - 1] = c & mask;c >>= bpe;j++;
|
10306 | c += sa[j] + ui * n[j];sa[j - 1] = c & mask;c >>= bpe;j++;
|
10307 | c += sa[j] + ui * n[j];sa[j - 1] = c & mask;c >>= bpe;j++;
|
10308 | }
|
10309 | for (; j < kn;) {
|
10310 | c += sa[j] + ui * n[j];sa[j - 1] = c & mask;c >>= bpe;j++;
|
10311 | }
|
10312 | for (; j < ks;) {
|
10313 | c += sa[j];sa[j - 1] = c & mask;c >>= bpe;j++;
|
10314 | }
|
10315 | sa[j - 1] = c & mask;
|
10316 | }
|
10317 |
|
10318 | if (!greater(n, sa)) sub_(sa, n);
|
10319 | copy_(x, sa);
|
10320 | }
|
10321 |
|
10322 | /***/ }),
|
10323 | /* 128 */
|
10324 | /***/ (function(module, exports, __webpack_require__) {
|
10325 |
|
10326 | "use strict";
|
10327 |
|
10328 |
|
10329 |
|
10330 | var zlib_inflate = __webpack_require__(135);
|
10331 | var utils = __webpack_require__(28);
|
10332 | var strings = __webpack_require__(129);
|
10333 | var c = __webpack_require__(131);
|
10334 | var msg = __webpack_require__(137);
|
10335 | var ZStream = __webpack_require__(138);
|
10336 | var GZheader = __webpack_require__(133);
|
10337 |
|
10338 | var toString = Object.prototype.toString;
|
10339 |
|
10340 | /**
|
10341 | * class Inflate
|
10342 | *
|
10343 | * Generic JS-style wrapper for zlib calls. If you don't need
|
10344 | * streaming behaviour - use more simple functions: [[inflate]]
|
10345 | * and [[inflateRaw]].
|
10346 | **/
|
10347 |
|
10348 | /* internal
|
10349 | * inflate.chunks -> Array
|
10350 | *
|
10351 | * Chunks of output data, if [[Inflate#onData]] not overriden.
|
10352 | **/
|
10353 |
|
10354 | /**
|
10355 | * Inflate.result -> Uint8Array|Array|String
|
10356 | *
|
10357 | * Uncompressed result, generated by default [[Inflate#onData]]
|
10358 | * and [[Inflate#onEnd]] handlers. Filled after you push last chunk
|
10359 | * (call [[Inflate#push]] with `Z_FINISH` / `true` param) or if you
|
10360 | * push a chunk with explicit flush (call [[Inflate#push]] with
|
10361 | * `Z_SYNC_FLUSH` param).
|
10362 | **/
|
10363 |
|
10364 | /**
|
10365 | * Inflate.err -> Number
|
10366 | *
|
10367 | * Error code after inflate finished. 0 (Z_OK) on success.
|
10368 | * Should be checked if broken data possible.
|
10369 | **/
|
10370 |
|
10371 | /**
|
10372 | * Inflate.msg -> String
|
10373 | *
|
10374 | * Error message, if [[Inflate.err]] != 0
|
10375 | **/
|
10376 |
|
10377 |
|
10378 | /**
|
10379 | * new Inflate(options)
|
10380 | * - options (Object): zlib inflate options.
|
10381 | *
|
10382 | * Creates new inflator instance with specified params. Throws exception
|
10383 | * on bad params. Supported options:
|
10384 | *
|
10385 | * - `windowBits`
|
10386 | * - `dictionary`
|
10387 | *
|
10388 | * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)
|
10389 | * for more information on these.
|
10390 | *
|
10391 | * Additional options, for internal needs:
|
10392 | *
|
10393 | * - `chunkSize` - size of generated data chunks (16K by default)
|
10394 | * - `raw` (Boolean) - do raw inflate
|
10395 | * - `to` (String) - if equal to 'string', then result will be converted
|
10396 | * from utf8 to utf16 (javascript) string. When string output requested,
|
10397 | * chunk length can differ from `chunkSize`, depending on content.
|
10398 | *
|
10399 | * By default, when no options set, autodetect deflate/gzip data format via
|
10400 | * wrapper header.
|
10401 | *
|
10402 | * ##### Example:
|
10403 | *
|
10404 | * ```javascript
|
10405 | * var pako = require('pako')
|
10406 | * , chunk1 = Uint8Array([1,2,3,4,5,6,7,8,9])
|
10407 | * , chunk2 = Uint8Array([10,11,12,13,14,15,16,17,18,19]);
|
10408 | *
|
10409 | * var inflate = new pako.Inflate({ level: 3});
|
10410 | *
|
10411 | * inflate.push(chunk1, false);
|
10412 | * inflate.push(chunk2, true); // true -> last chunk
|
10413 | *
|
10414 | * if (inflate.err) { throw new Error(inflate.err); }
|
10415 | *
|
10416 | * console.log(inflate.result);
|
10417 | * ```
|
10418 | **/
|
10419 | function Inflate(options) {
|
10420 | if (!(this instanceof Inflate)) return new Inflate(options);
|
10421 |
|
10422 | this.options = utils.assign({
|
10423 | chunkSize: 16384,
|
10424 | windowBits: 0,
|
10425 | to: ''
|
10426 | }, options || {});
|
10427 |
|
10428 | var opt = this.options;
|
10429 |
|
10430 | // Force window size for `raw` data, if not set directly,
|
10431 | // because we have no header for autodetect.
|
10432 | if (opt.raw && (opt.windowBits >= 0) && (opt.windowBits < 16)) {
|
10433 | opt.windowBits = -opt.windowBits;
|
10434 | if (opt.windowBits === 0) { opt.windowBits = -15; }
|
10435 | }
|
10436 |
|
10437 | // If `windowBits` not defined (and mode not raw) - set autodetect flag for gzip/deflate
|
10438 | if ((opt.windowBits >= 0) && (opt.windowBits < 16) &&
|
10439 | !(options && options.windowBits)) {
|
10440 | opt.windowBits += 32;
|
10441 | }
|
10442 |
|
10443 | // Gzip header has no info about windows size, we can do autodetect only
|
10444 | // for deflate. So, if window size not set, force it to max when gzip possible
|
10445 | if ((opt.windowBits > 15) && (opt.windowBits < 48)) {
|
10446 | // bit 3 (16) -> gzipped data
|
10447 | // bit 4 (32) -> autodetect gzip/deflate
|
10448 | if ((opt.windowBits & 15) === 0) {
|
10449 | opt.windowBits |= 15;
|
10450 | }
|
10451 | }
|
10452 |
|
10453 | this.err = 0; // error code, if happens (0 = Z_OK)
|
10454 | this.msg = ''; // error message
|
10455 | this.ended = false; // used to avoid multiple onEnd() calls
|
10456 | this.chunks = []; // chunks of compressed data
|
10457 |
|
10458 | this.strm = new ZStream();
|
10459 | this.strm.avail_out = 0;
|
10460 |
|
10461 | var status = zlib_inflate.inflateInit2(
|
10462 | this.strm,
|
10463 | opt.windowBits
|
10464 | );
|
10465 |
|
10466 | if (status !== c.Z_OK) {
|
10467 | throw new Error(msg[status]);
|
10468 | }
|
10469 |
|
10470 | this.header = new GZheader();
|
10471 |
|
10472 | zlib_inflate.inflateGetHeader(this.strm, this.header);
|
10473 | }
|
10474 |
|
10475 | /**
|
10476 | * Inflate#push(data[, mode]) -> Boolean
|
10477 | * - data (Uint8Array|Array|ArrayBuffer|String): input data
|
10478 | * - mode (Number|Boolean): 0..6 for corresponding Z_NO_FLUSH..Z_TREE modes.
|
10479 | * See constants. Skipped or `false` means Z_NO_FLUSH, `true` meansh Z_FINISH.
|
10480 | *
|
10481 | * Sends input data to inflate pipe, generating [[Inflate#onData]] calls with
|
10482 | * new output chunks. Returns `true` on success. The last data block must have
|
10483 | * mode Z_FINISH (or `true`). That will flush internal pending buffers and call
|
10484 | * [[Inflate#onEnd]]. For interim explicit flushes (without ending the stream) you
|
10485 | * can use mode Z_SYNC_FLUSH, keeping the decompression context.
|
10486 | *
|
10487 | * On fail call [[Inflate#onEnd]] with error code and return false.
|
10488 | *
|
10489 | * We strongly recommend to use `Uint8Array` on input for best speed (output
|
10490 | * format is detected automatically). Also, don't skip last param and always
|
10491 | * use the same type in your code (boolean or number). That will improve JS speed.
|
10492 | *
|
10493 | * For regular `Array`-s make sure all elements are [0..255].
|
10494 | *
|
10495 | * ##### Example
|
10496 | *
|
10497 | * ```javascript
|
10498 | * push(chunk, false); // push one of data chunks
|
10499 | * ...
|
10500 | * push(chunk, true); // push last chunk
|
10501 | * ```
|
10502 | **/
|
10503 | Inflate.prototype.push = function (data, mode) {
|
10504 | var strm = this.strm;
|
10505 | var chunkSize = this.options.chunkSize;
|
10506 | var dictionary = this.options.dictionary;
|
10507 | var status, _mode;
|
10508 | var next_out_utf8, tail, utf8str;
|
10509 | var dict;
|
10510 |
|
10511 | // Flag to properly process Z_BUF_ERROR on testing inflate call
|
10512 | // when we check that all output data was flushed.
|
10513 | var allowBufError = false;
|
10514 |
|
10515 | if (this.ended) { return false; }
|
10516 | _mode = (mode === ~~mode) ? mode : ((mode === true) ? c.Z_FINISH : c.Z_NO_FLUSH);
|
10517 |
|
10518 | // Convert data if needed
|
10519 | if (typeof data === 'string') {
|
10520 | // Only binary strings can be decompressed on practice
|
10521 | strm.input = strings.binstring2buf(data);
|
10522 | } else if (toString.call(data) === '[object ArrayBuffer]') {
|
10523 | strm.input = new Uint8Array(data);
|
10524 | } else {
|
10525 | strm.input = data;
|
10526 | }
|
10527 |
|
10528 | strm.next_in = 0;
|
10529 | strm.avail_in = strm.input.length;
|
10530 |
|
10531 | do {
|
10532 | if (strm.avail_out === 0) {
|
10533 | strm.output = new utils.Buf8(chunkSize);
|
10534 | strm.next_out = 0;
|
10535 | strm.avail_out = chunkSize;
|
10536 | }
|
10537 |
|
10538 | status = zlib_inflate.inflate(strm, c.Z_NO_FLUSH); /* no bad return value */
|
10539 |
|
10540 | if (status === c.Z_NEED_DICT && dictionary) {
|
10541 | // Convert data if needed
|
10542 | if (typeof dictionary === 'string') {
|
10543 | dict = strings.string2buf(dictionary);
|
10544 | } else if (toString.call(dictionary) === '[object ArrayBuffer]') {
|
10545 | dict = new Uint8Array(dictionary);
|
10546 | } else {
|
10547 | dict = dictionary;
|
10548 | }
|
10549 |
|
10550 | status = zlib_inflate.inflateSetDictionary(this.strm, dict);
|
10551 |
|
10552 | }
|
10553 |
|
10554 | if (status === c.Z_BUF_ERROR && allowBufError === true) {
|
10555 | status = c.Z_OK;
|
10556 | allowBufError = false;
|
10557 | }
|
10558 |
|
10559 | if (status !== c.Z_STREAM_END && status !== c.Z_OK) {
|
10560 | this.onEnd(status);
|
10561 | this.ended = true;
|
10562 | return false;
|
10563 | }
|
10564 |
|
10565 | if (strm.next_out) {
|
10566 | if (strm.avail_out === 0 || status === c.Z_STREAM_END || (strm.avail_in === 0 && (_mode === c.Z_FINISH || _mode === c.Z_SYNC_FLUSH))) {
|
10567 |
|
10568 | if (this.options.to === 'string') {
|
10569 |
|
10570 | next_out_utf8 = strings.utf8border(strm.output, strm.next_out);
|
10571 |
|
10572 | tail = strm.next_out - next_out_utf8;
|
10573 | utf8str = strings.buf2string(strm.output, next_out_utf8);
|
10574 |
|
10575 | // move tail
|
10576 | strm.next_out = tail;
|
10577 | strm.avail_out = chunkSize - tail;
|
10578 | if (tail) { utils.arraySet(strm.output, strm.output, next_out_utf8, tail, 0); }
|
10579 |
|
10580 | this.onData(utf8str);
|
10581 |
|
10582 | } else {
|
10583 | this.onData(utils.shrinkBuf(strm.output, strm.next_out));
|
10584 | }
|
10585 | }
|
10586 | }
|
10587 |
|
10588 | // When no more input data, we should check that internal inflate buffers
|
10589 | // are flushed. The only way to do it when avail_out = 0 - run one more
|
10590 | // inflate pass. But if output data not exists, inflate return Z_BUF_ERROR.
|
10591 | // Here we set flag to process this error properly.
|
10592 | //
|
10593 | // NOTE. Deflate does not return error in this case and does not needs such
|
10594 | // logic.
|
10595 | if (strm.avail_in === 0 && strm.avail_out === 0) {
|
10596 | allowBufError = true;
|
10597 | }
|
10598 |
|
10599 | } while ((strm.avail_in > 0 || strm.avail_out === 0) && status !== c.Z_STREAM_END);
|
10600 |
|
10601 | if (status === c.Z_STREAM_END) {
|
10602 | _mode = c.Z_FINISH;
|
10603 | }
|
10604 |
|
10605 | // Finalize on the last chunk.
|
10606 | if (_mode === c.Z_FINISH) {
|
10607 | status = zlib_inflate.inflateEnd(this.strm);
|
10608 | this.onEnd(status);
|
10609 | this.ended = true;
|
10610 | return status === c.Z_OK;
|
10611 | }
|
10612 |
|
10613 | // callback interim results if Z_SYNC_FLUSH.
|
10614 | if (_mode === c.Z_SYNC_FLUSH) {
|
10615 | this.onEnd(c.Z_OK);
|
10616 | strm.avail_out = 0;
|
10617 | return true;
|
10618 | }
|
10619 |
|
10620 | return true;
|
10621 | };
|
10622 |
|
10623 |
|
10624 | /**
|
10625 | * Inflate#onData(chunk) -> Void
|
10626 | * - chunk (Uint8Array|Array|String): ouput data. Type of array depends
|
10627 | * on js engine support. When string output requested, each chunk
|
10628 | * will be string.
|
10629 | *
|
10630 | * By default, stores data blocks in `chunks[]` property and glue
|
10631 | * those in `onEnd`. Override this handler, if you need another behaviour.
|
10632 | **/
|
10633 | Inflate.prototype.onData = function (chunk) {
|
10634 | this.chunks.push(chunk);
|
10635 | };
|
10636 |
|
10637 |
|
10638 | /**
|
10639 | * Inflate#onEnd(status) -> Void
|
10640 | * - status (Number): inflate status. 0 (Z_OK) on success,
|
10641 | * other if not.
|
10642 | *
|
10643 | * Called either after you tell inflate that the input stream is
|
10644 | * complete (Z_FINISH) or should be flushed (Z_SYNC_FLUSH)
|
10645 | * or if an error happened. By default - join collected chunks,
|
10646 | * free memory and fill `results` / `err` properties.
|
10647 | **/
|
10648 | Inflate.prototype.onEnd = function (status) {
|
10649 | // On success - join
|
10650 | if (status === c.Z_OK) {
|
10651 | if (this.options.to === 'string') {
|
10652 | // Glue & convert here, until we teach pako to send
|
10653 | // utf8 alligned strings to onData
|
10654 | this.result = this.chunks.join('');
|
10655 | } else {
|
10656 | this.result = utils.flattenChunks(this.chunks);
|
10657 | }
|
10658 | }
|
10659 | this.chunks = [];
|
10660 | this.err = status;
|
10661 | this.msg = this.strm.msg;
|
10662 | };
|
10663 |
|
10664 |
|
10665 | /**
|
10666 | * inflate(data[, options]) -> Uint8Array|Array|String
|
10667 | * - data (Uint8Array|Array|String): input data to decompress.
|
10668 | * - options (Object): zlib inflate options.
|
10669 | *
|
10670 | * Decompress `data` with inflate/ungzip and `options`. Autodetect
|
10671 | * format via wrapper header by default. That's why we don't provide
|
10672 | * separate `ungzip` method.
|
10673 | *
|
10674 | * Supported options are:
|
10675 | *
|
10676 | * - windowBits
|
10677 | *
|
10678 | * [http://zlib.net/manual.html#Advanced](http://zlib.net/manual.html#Advanced)
|
10679 | * for more information.
|
10680 | *
|
10681 | * Sugar (options):
|
10682 | *
|
10683 | * - `raw` (Boolean) - say that we work with raw stream, if you don't wish to specify
|
10684 | * negative windowBits implicitly.
|
10685 | * - `to` (String) - if equal to 'string', then result will be converted
|
10686 | * from utf8 to utf16 (javascript) string. When string output requested,
|
10687 | * chunk length can differ from `chunkSize`, depending on content.
|
10688 | *
|
10689 | *
|
10690 | * ##### Example:
|
10691 | *
|
10692 | * ```javascript
|
10693 | * var pako = require('pako')
|
10694 | * , input = pako.deflate([1,2,3,4,5,6,7,8,9])
|
10695 | * , output;
|
10696 | *
|
10697 | * try {
|
10698 | * output = pako.inflate(input);
|
10699 | * } catch (err)
|
10700 | * console.log(err);
|
10701 | * }
|
10702 | * ```
|
10703 | **/
|
10704 | function inflate(input, options) {
|
10705 | var inflator = new Inflate(options);
|
10706 |
|
10707 | inflator.push(input, true);
|
10708 |
|
10709 | // That will never happens, if you don't cheat with options :)
|
10710 | if (inflator.err) { throw inflator.msg || msg[inflator.err]; }
|
10711 |
|
10712 | return inflator.result;
|
10713 | }
|
10714 |
|
10715 |
|
10716 | /**
|
10717 | * inflateRaw(data[, options]) -> Uint8Array|Array|String
|
10718 | * - data (Uint8Array|Array|String): input data to decompress.
|
10719 | * - options (Object): zlib inflate options.
|
10720 | *
|
10721 | * The same as [[inflate]], but creates raw data, without wrapper
|
10722 | * (header and adler32 crc).
|
10723 | **/
|
10724 | function inflateRaw(input, options) {
|
10725 | options = options || {};
|
10726 | options.raw = true;
|
10727 | return inflate(input, options);
|
10728 | }
|
10729 |
|
10730 |
|
10731 | /**
|
10732 | * ungzip(data[, options]) -> Uint8Array|Array|String
|
10733 | * - data (Uint8Array|Array|String): input data to decompress.
|
10734 | * - options (Object): zlib inflate options.
|
10735 | *
|
10736 | * Just shortcut to [[inflate]], because it autodetects format
|
10737 | * by header.content. Done for convenience.
|
10738 | **/
|
10739 |
|
10740 |
|
10741 | exports.Inflate = Inflate;
|
10742 | exports.inflate = inflate;
|
10743 | exports.inflateRaw = inflateRaw;
|
10744 | exports.ungzip = inflate;
|
10745 |
|
10746 |
|
10747 | /***/ }),
|
10748 | /* 129 */
|
10749 | /***/ (function(module, exports, __webpack_require__) {
|
10750 |
|
10751 | "use strict";
|
10752 | // String encode/decode helpers
|
10753 |
|
10754 |
|
10755 |
|
10756 | var utils = __webpack_require__(28);
|
10757 |
|
10758 |
|
10759 | // Quick check if we can use fast array to bin string conversion
|
10760 | //
|
10761 | // - apply(Array) can fail on Android 2.2
|
10762 | // - apply(Uint8Array) can fail on iOS 5.1 Safary
|
10763 | //
|
10764 | var STR_APPLY_OK = true;
|
10765 | var STR_APPLY_UIA_OK = true;
|
10766 |
|
10767 | try { String.fromCharCode.apply(null, [ 0 ]); } catch (__) { STR_APPLY_OK = false; }
|
10768 | try { String.fromCharCode.apply(null, new Uint8Array(1)); } catch (__) { STR_APPLY_UIA_OK = false; }
|
10769 |
|
10770 |
|
10771 | // Table with utf8 lengths (calculated by first byte of sequence)
|
10772 | // Note, that 5 & 6-byte values and some 4-byte values can not be represented in JS,
|
10773 | // because max possible codepoint is 0x10ffff
|
10774 | var _utf8len = new utils.Buf8(256);
|
10775 | for (var q = 0; q < 256; q++) {
|
10776 | _utf8len[q] = (q >= 252 ? 6 : q >= 248 ? 5 : q >= 240 ? 4 : q >= 224 ? 3 : q >= 192 ? 2 : 1);
|
10777 | }
|
10778 | _utf8len[254] = _utf8len[254] = 1; // Invalid sequence start
|
10779 |
|
10780 |
|
10781 | // convert string to array (typed, when possible)
|
10782 | exports.string2buf = function (str) {
|
10783 | var buf, c, c2, m_pos, i, str_len = str.length, buf_len = 0;
|
10784 |
|
10785 | // count binary size
|
10786 | for (m_pos = 0; m_pos < str_len; m_pos++) {
|
10787 | c = str.charCodeAt(m_pos);
|
10788 | if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {
|
10789 | c2 = str.charCodeAt(m_pos + 1);
|
10790 | if ((c2 & 0xfc00) === 0xdc00) {
|
10791 | c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);
|
10792 | m_pos++;
|
10793 | }
|
10794 | }
|
10795 | buf_len += c < 0x80 ? 1 : c < 0x800 ? 2 : c < 0x10000 ? 3 : 4;
|
10796 | }
|
10797 |
|
10798 | // allocate buffer
|
10799 | buf = new utils.Buf8(buf_len);
|
10800 |
|
10801 | // convert
|
10802 | for (i = 0, m_pos = 0; i < buf_len; m_pos++) {
|
10803 | c = str.charCodeAt(m_pos);
|
10804 | if ((c & 0xfc00) === 0xd800 && (m_pos + 1 < str_len)) {
|
10805 | c2 = str.charCodeAt(m_pos + 1);
|
10806 | if ((c2 & 0xfc00) === 0xdc00) {
|
10807 | c = 0x10000 + ((c - 0xd800) << 10) + (c2 - 0xdc00);
|
10808 | m_pos++;
|
10809 | }
|
10810 | }
|
10811 | if (c < 0x80) {
|
10812 | /* one byte */
|
10813 | buf[i++] = c;
|
10814 | } else if (c < 0x800) {
|
10815 | /* two bytes */
|
10816 | buf[i++] = 0xC0 | (c >>> 6);
|
10817 | buf[i++] = 0x80 | (c & 0x3f);
|
10818 | } else if (c < 0x10000) {
|
10819 | /* three bytes */
|
10820 | buf[i++] = 0xE0 | (c >>> 12);
|
10821 | buf[i++] = 0x80 | (c >>> 6 & 0x3f);
|
10822 | buf[i++] = 0x80 | (c & 0x3f);
|
10823 | } else {
|
10824 | /* four bytes */
|
10825 | buf[i++] = 0xf0 | (c >>> 18);
|
10826 | buf[i++] = 0x80 | (c >>> 12 & 0x3f);
|
10827 | buf[i++] = 0x80 | (c >>> 6 & 0x3f);
|
10828 | buf[i++] = 0x80 | (c & 0x3f);
|
10829 | }
|
10830 | }
|
10831 |
|
10832 | return buf;
|
10833 | };
|
10834 |
|
10835 | // Helper (used in 2 places)
|
10836 | function buf2binstring(buf, len) {
|
10837 | // use fallback for big arrays to avoid stack overflow
|
10838 | if (len < 65537) {
|
10839 | if ((buf.subarray && STR_APPLY_UIA_OK) || (!buf.subarray && STR_APPLY_OK)) {
|
10840 | return String.fromCharCode.apply(null, utils.shrinkBuf(buf, len));
|
10841 | }
|
10842 | }
|
10843 |
|
10844 | var result = '';
|
10845 | for (var i = 0; i < len; i++) {
|
10846 | result += String.fromCharCode(buf[i]);
|
10847 | }
|
10848 | return result;
|
10849 | }
|
10850 |
|
10851 |
|
10852 | // Convert byte array to binary string
|
10853 | exports.buf2binstring = function (buf) {
|
10854 | return buf2binstring(buf, buf.length);
|
10855 | };
|
10856 |
|
10857 |
|
10858 | // Convert binary string (typed, when possible)
|
10859 | exports.binstring2buf = function (str) {
|
10860 | var buf = new utils.Buf8(str.length);
|
10861 | for (var i = 0, len = buf.length; i < len; i++) {
|
10862 | buf[i] = str.charCodeAt(i);
|
10863 | }
|
10864 | return buf;
|
10865 | };
|
10866 |
|
10867 |
|
10868 | // convert array to string
|
10869 | exports.buf2string = function (buf, max) {
|
10870 | var i, out, c, c_len;
|
10871 | var len = max || buf.length;
|
10872 |
|
10873 | // Reserve max possible length (2 words per char)
|
10874 | // NB: by unknown reasons, Array is significantly faster for
|
10875 | // String.fromCharCode.apply than Uint16Array.
|
10876 | var utf16buf = new Array(len * 2);
|
10877 |
|
10878 | for (out = 0, i = 0; i < len;) {
|
10879 | c = buf[i++];
|
10880 | // quick process ascii
|
10881 | if (c < 0x80) { utf16buf[out++] = c; continue; }
|
10882 |
|
10883 | c_len = _utf8len[c];
|
10884 | // skip 5 & 6 byte codes
|
10885 | if (c_len > 4) { utf16buf[out++] = 0xfffd; i += c_len - 1; continue; }
|
10886 |
|
10887 | // apply mask on first byte
|
10888 | c &= c_len === 2 ? 0x1f : c_len === 3 ? 0x0f : 0x07;
|
10889 | // join the rest
|
10890 | while (c_len > 1 && i < len) {
|
10891 | c = (c << 6) | (buf[i++] & 0x3f);
|
10892 | c_len--;
|
10893 | }
|
10894 |
|
10895 | // terminated by end of string?
|
10896 | if (c_len > 1) { utf16buf[out++] = 0xfffd; continue; }
|
10897 |
|
10898 | if (c < 0x10000) {
|
10899 | utf16buf[out++] = c;
|
10900 | } else {
|
10901 | c -= 0x10000;
|
10902 | utf16buf[out++] = 0xd800 | ((c >> 10) & 0x3ff);
|
10903 | utf16buf[out++] = 0xdc00 | (c & 0x3ff);
|
10904 | }
|
10905 | }
|
10906 |
|
10907 | return buf2binstring(utf16buf, out);
|
10908 | };
|
10909 |
|
10910 |
|
10911 | // Calculate max possible position in utf8 buffer,
|
10912 | // that will not break sequence. If that's not possible
|
10913 | // - (very small limits) return max size as is.
|
10914 | //
|
10915 | // buf[] - utf8 bytes array
|
10916 | // max - length limit (mandatory);
|
10917 | exports.utf8border = function (buf, max) {
|
10918 | var pos;
|
10919 |
|
10920 | max = max || buf.length;
|
10921 | if (max > buf.length) { max = buf.length; }
|
10922 |
|
10923 | // go back from last position, until start of sequence found
|
10924 | pos = max - 1;
|
10925 | while (pos >= 0 && (buf[pos] & 0xC0) === 0x80) { pos--; }
|
10926 |
|
10927 | // Fuckup - very small and broken sequence,
|
10928 | // return max, because we should return something anyway.
|
10929 | if (pos < 0) { return max; }
|
10930 |
|
10931 | // If we came to start of buffer - that means vuffer is too small,
|
10932 | // return max too.
|
10933 | if (pos === 0) { return max; }
|
10934 |
|
10935 | return (pos + _utf8len[buf[pos]] > max) ? pos : max;
|
10936 | };
|
10937 |
|
10938 |
|
10939 | /***/ }),
|
10940 | /* 130 */
|
10941 | /***/ (function(module, exports, __webpack_require__) {
|
10942 |
|
10943 | "use strict";
|
10944 |
|
10945 |
|
10946 | // Note: adler32 takes 12% for level 0 and 2% for level 6.
|
10947 | // It doesn't worth to make additional optimizationa as in original.
|
10948 | // Small size is preferable.
|
10949 |
|
10950 | function adler32(adler, buf, len, pos) {
|
10951 | var s1 = (adler & 0xffff) |0,
|
10952 | s2 = ((adler >>> 16) & 0xffff) |0,
|
10953 | n = 0;
|
10954 |
|
10955 | while (len !== 0) {
|
10956 | // Set limit ~ twice less than 5552, to keep
|
10957 | // s2 in 31-bits, because we force signed ints.
|
10958 | // in other case %= will fail.
|
10959 | n = len > 2000 ? 2000 : len;
|
10960 | len -= n;
|
10961 |
|
10962 | do {
|
10963 | s1 = (s1 + buf[pos++]) |0;
|
10964 | s2 = (s2 + s1) |0;
|
10965 | } while (--n);
|
10966 |
|
10967 | s1 %= 65521;
|
10968 | s2 %= 65521;
|
10969 | }
|
10970 |
|
10971 | return (s1 | (s2 << 16)) |0;
|
10972 | }
|
10973 |
|
10974 |
|
10975 | module.exports = adler32;
|
10976 |
|
10977 |
|
10978 | /***/ }),
|
10979 | /* 131 */
|
10980 | /***/ (function(module, exports, __webpack_require__) {
|
10981 |
|
10982 | "use strict";
|
10983 |
|
10984 |
|
10985 |
|
10986 | module.exports = {
|
10987 |
|
10988 | /* Allowed flush values; see deflate() and inflate() below for details */
|
10989 | Z_NO_FLUSH: 0,
|
10990 | Z_PARTIAL_FLUSH: 1,
|
10991 | Z_SYNC_FLUSH: 2,
|
10992 | Z_FULL_FLUSH: 3,
|
10993 | Z_FINISH: 4,
|
10994 | Z_BLOCK: 5,
|
10995 | Z_TREES: 6,
|
10996 |
|
10997 | /* Return codes for the compression/decompression functions. Negative values
|
10998 | * are errors, positive values are used for special but normal events.
|
10999 | */
|
11000 | Z_OK: 0,
|
11001 | Z_STREAM_END: 1,
|
11002 | Z_NEED_DICT: 2,
|
11003 | Z_ERRNO: -1,
|
11004 | Z_STREAM_ERROR: -2,
|
11005 | Z_DATA_ERROR: -3,
|
11006 | //Z_MEM_ERROR: -4,
|
11007 | Z_BUF_ERROR: -5,
|
11008 | //Z_VERSION_ERROR: -6,
|
11009 |
|
11010 | /* compression levels */
|
11011 | Z_NO_COMPRESSION: 0,
|
11012 | Z_BEST_SPEED: 1,
|
11013 | Z_BEST_COMPRESSION: 9,
|
11014 | Z_DEFAULT_COMPRESSION: -1,
|
11015 |
|
11016 |
|
11017 | Z_FILTERED: 1,
|
11018 | Z_HUFFMAN_ONLY: 2,
|
11019 | Z_RLE: 3,
|
11020 | Z_FIXED: 4,
|
11021 | Z_DEFAULT_STRATEGY: 0,
|
11022 |
|
11023 | /* Possible values of the data_type field (though see inflate()) */
|
11024 | Z_BINARY: 0,
|
11025 | Z_TEXT: 1,
|
11026 | //Z_ASCII: 1, // = Z_TEXT (deprecated)
|
11027 | Z_UNKNOWN: 2,
|
11028 |
|
11029 | /* The deflate compression method */
|
11030 | Z_DEFLATED: 8
|
11031 | //Z_NULL: null // Use -1 or null inline, depending on var type
|
11032 | };
|
11033 |
|
11034 |
|
11035 | /***/ }),
|
11036 | /* 132 */
|
11037 | /***/ (function(module, exports, __webpack_require__) {
|
11038 |
|
11039 | "use strict";
|
11040 |
|
11041 |
|
11042 | // Note: we can't get significant speed boost here.
|
11043 | // So write code to minimize size - no pregenerated tables
|
11044 | // and array tools dependencies.
|
11045 |
|
11046 |
|
11047 | // Use ordinary array, since untyped makes no boost here
|
11048 | function makeTable() {
|
11049 | var c, table = [];
|
11050 |
|
11051 | for (var n = 0; n < 256; n++) {
|
11052 | c = n;
|
11053 | for (var k = 0; k < 8; k++) {
|
11054 | c = ((c & 1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1));
|
11055 | }
|
11056 | table[n] = c;
|
11057 | }
|
11058 |
|
11059 | return table;
|
11060 | }
|
11061 |
|
11062 | // Create table on load. Just 255 signed longs. Not a problem.
|
11063 | var crcTable = makeTable();
|
11064 |
|
11065 |
|
11066 | function crc32(crc, buf, len, pos) {
|
11067 | var t = crcTable,
|
11068 | end = pos + len;
|
11069 |
|
11070 | crc ^= -1;
|
11071 |
|
11072 | for (var i = pos; i < end; i++) {
|
11073 | crc = (crc >>> 8) ^ t[(crc ^ buf[i]) & 0xFF];
|
11074 | }
|
11075 |
|
11076 | return (crc ^ (-1)); // >>> 0;
|
11077 | }
|
11078 |
|
11079 |
|
11080 | module.exports = crc32;
|
11081 |
|
11082 |
|
11083 | /***/ }),
|
11084 | /* 133 */
|
11085 | /***/ (function(module, exports, __webpack_require__) {
|
11086 |
|
11087 | "use strict";
|
11088 |
|
11089 |
|
11090 |
|
11091 | function GZheader() {
|
11092 | /* true if compressed data believed to be text */
|
11093 | this.text = 0;
|
11094 | /* modification time */
|
11095 | this.time = 0;
|
11096 | /* extra flags (not used when writing a gzip file) */
|
11097 | this.xflags = 0;
|
11098 | /* operating system */
|
11099 | this.os = 0;
|
11100 | /* pointer to extra field or Z_NULL if none */
|
11101 | this.extra = null;
|
11102 | /* extra field length (valid if extra != Z_NULL) */
|
11103 | this.extra_len = 0; // Actually, we don't need it in JS,
|
11104 | // but leave for few code modifications
|
11105 |
|
11106 | //
|
11107 | // Setup limits is not necessary because in js we should not preallocate memory
|
11108 | // for inflate use constant limit in 65536 bytes
|
11109 | //
|
11110 |
|
11111 | /* space at extra (only when reading header) */
|
11112 | // this.extra_max = 0;
|
11113 | /* pointer to zero-terminated file name or Z_NULL */
|
11114 | this.name = '';
|
11115 | /* space at name (only when reading header) */
|
11116 | // this.name_max = 0;
|
11117 | /* pointer to zero-terminated comment or Z_NULL */
|
11118 | this.comment = '';
|
11119 | /* space at comment (only when reading header) */
|
11120 | // this.comm_max = 0;
|
11121 | /* true if there was or will be a header crc */
|
11122 | this.hcrc = 0;
|
11123 | /* true when done reading gzip header (not used when writing a gzip file) */
|
11124 | this.done = false;
|
11125 | }
|
11126 |
|
11127 | module.exports = GZheader;
|
11128 |
|
11129 |
|
11130 | /***/ }),
|
11131 | /* 134 */
|
11132 | /***/ (function(module, exports, __webpack_require__) {
|
11133 |
|
11134 | "use strict";
|
11135 |
|
11136 |
|
11137 | // See state defs from inflate.js
|
11138 | var BAD = 30; /* got a data error -- remain here until reset */
|
11139 | var TYPE = 12; /* i: waiting for type bits, including last-flag bit */
|
11140 |
|
11141 | /*
|
11142 | Decode literal, length, and distance codes and write out the resulting
|
11143 | literal and match bytes until either not enough input or output is
|
11144 | available, an end-of-block is encountered, or a data error is encountered.
|
11145 | When large enough input and output buffers are supplied to inflate(), for
|
11146 | example, a 16K input buffer and a 64K output buffer, more than 95% of the
|
11147 | inflate execution time is spent in this routine.
|
11148 |
|
11149 | Entry assumptions:
|
11150 |
|
11151 | state.mode === LEN
|
11152 | strm.avail_in >= 6
|
11153 | strm.avail_out >= 258
|
11154 | start >= strm.avail_out
|
11155 | state.bits < 8
|
11156 |
|
11157 | On return, state.mode is one of:
|
11158 |
|
11159 | LEN -- ran out of enough output space or enough available input
|
11160 | TYPE -- reached end of block code, inflate() to interpret next block
|
11161 | BAD -- error in block data
|
11162 |
|
11163 | Notes:
|
11164 |
|
11165 | - The maximum input bits used by a length/distance pair is 15 bits for the
|
11166 | length code, 5 bits for the length extra, 15 bits for the distance code,
|
11167 | and 13 bits for the distance extra. This totals 48 bits, or six bytes.
|
11168 | Therefore if strm.avail_in >= 6, then there is enough input to avoid
|
11169 | checking for available input while decoding.
|
11170 |
|
11171 | - The maximum bytes that a single length/distance pair can output is 258
|
11172 | bytes, which is the maximum length that can be coded. inflate_fast()
|
11173 | requires strm.avail_out >= 258 for each loop to avoid checking for
|
11174 | output space.
|
11175 | */
|
11176 | module.exports = function inflate_fast(strm, start) {
|
11177 | var state;
|
11178 | var _in; /* local strm.input */
|
11179 | var last; /* have enough input while in < last */
|
11180 | var _out; /* local strm.output */
|
11181 | var beg; /* inflate()'s initial strm.output */
|
11182 | var end; /* while out < end, enough space available */
|
11183 | //#ifdef INFLATE_STRICT
|
11184 | var dmax; /* maximum distance from zlib header */
|
11185 | //#endif
|
11186 | var wsize; /* window size or zero if not using window */
|
11187 | var whave; /* valid bytes in the window */
|
11188 | var wnext; /* window write index */
|
11189 | // Use `s_window` instead `window`, avoid conflict with instrumentation tools
|
11190 | var s_window; /* allocated sliding window, if wsize != 0 */
|
11191 | var hold; /* local strm.hold */
|
11192 | var bits; /* local strm.bits */
|
11193 | var lcode; /* local strm.lencode */
|
11194 | var dcode; /* local strm.distcode */
|
11195 | var lmask; /* mask for first level of length codes */
|
11196 | var dmask; /* mask for first level of distance codes */
|
11197 | var here; /* retrieved table entry */
|
11198 | var op; /* code bits, operation, extra bits, or */
|
11199 | /* window position, window bytes to copy */
|
11200 | var len; /* match length, unused bytes */
|
11201 | var dist; /* match distance */
|
11202 | var from; /* where to copy match from */
|
11203 | var from_source;
|
11204 |
|
11205 |
|
11206 | var input, output; // JS specific, because we have no pointers
|
11207 |
|
11208 | /* copy state to local variables */
|
11209 | state = strm.state;
|
11210 | //here = state.here;
|
11211 | _in = strm.next_in;
|
11212 | input = strm.input;
|
11213 | last = _in + (strm.avail_in - 5);
|
11214 | _out = strm.next_out;
|
11215 | output = strm.output;
|
11216 | beg = _out - (start - strm.avail_out);
|
11217 | end = _out + (strm.avail_out - 257);
|
11218 | //#ifdef INFLATE_STRICT
|
11219 | dmax = state.dmax;
|
11220 | //#endif
|
11221 | wsize = state.wsize;
|
11222 | whave = state.whave;
|
11223 | wnext = state.wnext;
|
11224 | s_window = state.window;
|
11225 | hold = state.hold;
|
11226 | bits = state.bits;
|
11227 | lcode = state.lencode;
|
11228 | dcode = state.distcode;
|
11229 | lmask = (1 << state.lenbits) - 1;
|
11230 | dmask = (1 << state.distbits) - 1;
|
11231 |
|
11232 |
|
11233 | /* decode literals and length/distances until end-of-block or not enough
|
11234 | input data or output space */
|
11235 |
|
11236 | top:
|
11237 | do {
|
11238 | if (bits < 15) {
|
11239 | hold += input[_in++] << bits;
|
11240 | bits += 8;
|
11241 | hold += input[_in++] << bits;
|
11242 | bits += 8;
|
11243 | }
|
11244 |
|
11245 | here = lcode[hold & lmask];
|
11246 |
|
11247 | dolen:
|
11248 | for (;;) { // Goto emulation
|
11249 | op = here >>> 24/*here.bits*/;
|
11250 | hold >>>= op;
|
11251 | bits -= op;
|
11252 | op = (here >>> 16) & 0xff/*here.op*/;
|
11253 | if (op === 0) { /* literal */
|
11254 | //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
|
11255 | // "inflate: literal '%c'\n" :
|
11256 | // "inflate: literal 0x%02x\n", here.val));
|
11257 | output[_out++] = here & 0xffff/*here.val*/;
|
11258 | }
|
11259 | else if (op & 16) { /* length base */
|
11260 | len = here & 0xffff/*here.val*/;
|
11261 | op &= 15; /* number of extra bits */
|
11262 | if (op) {
|
11263 | if (bits < op) {
|
11264 | hold += input[_in++] << bits;
|
11265 | bits += 8;
|
11266 | }
|
11267 | len += hold & ((1 << op) - 1);
|
11268 | hold >>>= op;
|
11269 | bits -= op;
|
11270 | }
|
11271 | //Tracevv((stderr, "inflate: length %u\n", len));
|
11272 | if (bits < 15) {
|
11273 | hold += input[_in++] << bits;
|
11274 | bits += 8;
|
11275 | hold += input[_in++] << bits;
|
11276 | bits += 8;
|
11277 | }
|
11278 | here = dcode[hold & dmask];
|
11279 |
|
11280 | dodist:
|
11281 | for (;;) { // goto emulation
|
11282 | op = here >>> 24/*here.bits*/;
|
11283 | hold >>>= op;
|
11284 | bits -= op;
|
11285 | op = (here >>> 16) & 0xff/*here.op*/;
|
11286 |
|
11287 | if (op & 16) { /* distance base */
|
11288 | dist = here & 0xffff/*here.val*/;
|
11289 | op &= 15; /* number of extra bits */
|
11290 | if (bits < op) {
|
11291 | hold += input[_in++] << bits;
|
11292 | bits += 8;
|
11293 | if (bits < op) {
|
11294 | hold += input[_in++] << bits;
|
11295 | bits += 8;
|
11296 | }
|
11297 | }
|
11298 | dist += hold & ((1 << op) - 1);
|
11299 | //#ifdef INFLATE_STRICT
|
11300 | if (dist > dmax) {
|
11301 | strm.msg = 'invalid distance too far back';
|
11302 | state.mode = BAD;
|
11303 | break top;
|
11304 | }
|
11305 | //#endif
|
11306 | hold >>>= op;
|
11307 | bits -= op;
|
11308 | //Tracevv((stderr, "inflate: distance %u\n", dist));
|
11309 | op = _out - beg; /* max distance in output */
|
11310 | if (dist > op) { /* see if copy from window */
|
11311 | op = dist - op; /* distance back in window */
|
11312 | if (op > whave) {
|
11313 | if (state.sane) {
|
11314 | strm.msg = 'invalid distance too far back';
|
11315 | state.mode = BAD;
|
11316 | break top;
|
11317 | }
|
11318 |
|
11319 | // (!) This block is disabled in zlib defailts,
|
11320 | // don't enable it for binary compatibility
|
11321 | //#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
|
11322 | // if (len <= op - whave) {
|
11323 | // do {
|
11324 | // output[_out++] = 0;
|
11325 | // } while (--len);
|
11326 | // continue top;
|
11327 | // }
|
11328 | // len -= op - whave;
|
11329 | // do {
|
11330 | // output[_out++] = 0;
|
11331 | // } while (--op > whave);
|
11332 | // if (op === 0) {
|
11333 | // from = _out - dist;
|
11334 | // do {
|
11335 | // output[_out++] = output[from++];
|
11336 | // } while (--len);
|
11337 | // continue top;
|
11338 | // }
|
11339 | //#endif
|
11340 | }
|
11341 | from = 0; // window index
|
11342 | from_source = s_window;
|
11343 | if (wnext === 0) { /* very common case */
|
11344 | from += wsize - op;
|
11345 | if (op < len) { /* some from window */
|
11346 | len -= op;
|
11347 | do {
|
11348 | output[_out++] = s_window[from++];
|
11349 | } while (--op);
|
11350 | from = _out - dist; /* rest from output */
|
11351 | from_source = output;
|
11352 | }
|
11353 | }
|
11354 | else if (wnext < op) { /* wrap around window */
|
11355 | from += wsize + wnext - op;
|
11356 | op -= wnext;
|
11357 | if (op < len) { /* some from end of window */
|
11358 | len -= op;
|
11359 | do {
|
11360 | output[_out++] = s_window[from++];
|
11361 | } while (--op);
|
11362 | from = 0;
|
11363 | if (wnext < len) { /* some from start of window */
|
11364 | op = wnext;
|
11365 | len -= op;
|
11366 | do {
|
11367 | output[_out++] = s_window[from++];
|
11368 | } while (--op);
|
11369 | from = _out - dist; /* rest from output */
|
11370 | from_source = output;
|
11371 | }
|
11372 | }
|
11373 | }
|
11374 | else { /* contiguous in window */
|
11375 | from += wnext - op;
|
11376 | if (op < len) { /* some from window */
|
11377 | len -= op;
|
11378 | do {
|
11379 | output[_out++] = s_window[from++];
|
11380 | } while (--op);
|
11381 | from = _out - dist; /* rest from output */
|
11382 | from_source = output;
|
11383 | }
|
11384 | }
|
11385 | while (len > 2) {
|
11386 | output[_out++] = from_source[from++];
|
11387 | output[_out++] = from_source[from++];
|
11388 | output[_out++] = from_source[from++];
|
11389 | len -= 3;
|
11390 | }
|
11391 | if (len) {
|
11392 | output[_out++] = from_source[from++];
|
11393 | if (len > 1) {
|
11394 | output[_out++] = from_source[from++];
|
11395 | }
|
11396 | }
|
11397 | }
|
11398 | else {
|
11399 | from = _out - dist; /* copy direct from output */
|
11400 | do { /* minimum length is three */
|
11401 | output[_out++] = output[from++];
|
11402 | output[_out++] = output[from++];
|
11403 | output[_out++] = output[from++];
|
11404 | len -= 3;
|
11405 | } while (len > 2);
|
11406 | if (len) {
|
11407 | output[_out++] = output[from++];
|
11408 | if (len > 1) {
|
11409 | output[_out++] = output[from++];
|
11410 | }
|
11411 | }
|
11412 | }
|
11413 | }
|
11414 | else if ((op & 64) === 0) { /* 2nd level distance code */
|
11415 | here = dcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];
|
11416 | continue dodist;
|
11417 | }
|
11418 | else {
|
11419 | strm.msg = 'invalid distance code';
|
11420 | state.mode = BAD;
|
11421 | break top;
|
11422 | }
|
11423 |
|
11424 | break; // need to emulate goto via "continue"
|
11425 | }
|
11426 | }
|
11427 | else if ((op & 64) === 0) { /* 2nd level length code */
|
11428 | here = lcode[(here & 0xffff)/*here.val*/ + (hold & ((1 << op) - 1))];
|
11429 | continue dolen;
|
11430 | }
|
11431 | else if (op & 32) { /* end-of-block */
|
11432 | //Tracevv((stderr, "inflate: end of block\n"));
|
11433 | state.mode = TYPE;
|
11434 | break top;
|
11435 | }
|
11436 | else {
|
11437 | strm.msg = 'invalid literal/length code';
|
11438 | state.mode = BAD;
|
11439 | break top;
|
11440 | }
|
11441 |
|
11442 | break; // need to emulate goto via "continue"
|
11443 | }
|
11444 | } while (_in < last && _out < end);
|
11445 |
|
11446 | /* return unused bytes (on entry, bits < 8, so in won't go too far back) */
|
11447 | len = bits >> 3;
|
11448 | _in -= len;
|
11449 | bits -= len << 3;
|
11450 | hold &= (1 << bits) - 1;
|
11451 |
|
11452 | /* update state and return */
|
11453 | strm.next_in = _in;
|
11454 | strm.next_out = _out;
|
11455 | strm.avail_in = (_in < last ? 5 + (last - _in) : 5 - (_in - last));
|
11456 | strm.avail_out = (_out < end ? 257 + (end - _out) : 257 - (_out - end));
|
11457 | state.hold = hold;
|
11458 | state.bits = bits;
|
11459 | return;
|
11460 | };
|
11461 |
|
11462 |
|
11463 | /***/ }),
|
11464 | /* 135 */
|
11465 | /***/ (function(module, exports, __webpack_require__) {
|
11466 |
|
11467 | "use strict";
|
11468 |
|
11469 |
|
11470 |
|
11471 | var utils = __webpack_require__(28);
|
11472 | var adler32 = __webpack_require__(130);
|
11473 | var crc32 = __webpack_require__(132);
|
11474 | var inflate_fast = __webpack_require__(134);
|
11475 | var inflate_table = __webpack_require__(136);
|
11476 |
|
11477 | var CODES = 0;
|
11478 | var LENS = 1;
|
11479 | var DISTS = 2;
|
11480 |
|
11481 | /* Public constants ==========================================================*/
|
11482 | /* ===========================================================================*/
|
11483 |
|
11484 |
|
11485 | /* Allowed flush values; see deflate() and inflate() below for details */
|
11486 | //var Z_NO_FLUSH = 0;
|
11487 | //var Z_PARTIAL_FLUSH = 1;
|
11488 | //var Z_SYNC_FLUSH = 2;
|
11489 | //var Z_FULL_FLUSH = 3;
|
11490 | var Z_FINISH = 4;
|
11491 | var Z_BLOCK = 5;
|
11492 | var Z_TREES = 6;
|
11493 |
|
11494 |
|
11495 | /* Return codes for the compression/decompression functions. Negative values
|
11496 | * are errors, positive values are used for special but normal events.
|
11497 | */
|
11498 | var Z_OK = 0;
|
11499 | var Z_STREAM_END = 1;
|
11500 | var Z_NEED_DICT = 2;
|
11501 | //var Z_ERRNO = -1;
|
11502 | var Z_STREAM_ERROR = -2;
|
11503 | var Z_DATA_ERROR = -3;
|
11504 | var Z_MEM_ERROR = -4;
|
11505 | var Z_BUF_ERROR = -5;
|
11506 | //var Z_VERSION_ERROR = -6;
|
11507 |
|
11508 | /* The deflate compression method */
|
11509 | var Z_DEFLATED = 8;
|
11510 |
|
11511 |
|
11512 | /* STATES ====================================================================*/
|
11513 | /* ===========================================================================*/
|
11514 |
|
11515 |
|
11516 | var HEAD = 1; /* i: waiting for magic header */
|
11517 | var FLAGS = 2; /* i: waiting for method and flags (gzip) */
|
11518 | var TIME = 3; /* i: waiting for modification time (gzip) */
|
11519 | var OS = 4; /* i: waiting for extra flags and operating system (gzip) */
|
11520 | var EXLEN = 5; /* i: waiting for extra length (gzip) */
|
11521 | var EXTRA = 6; /* i: waiting for extra bytes (gzip) */
|
11522 | var NAME = 7; /* i: waiting for end of file name (gzip) */
|
11523 | var COMMENT = 8; /* i: waiting for end of comment (gzip) */
|
11524 | var HCRC = 9; /* i: waiting for header crc (gzip) */
|
11525 | var DICTID = 10; /* i: waiting for dictionary check value */
|
11526 | var DICT = 11; /* waiting for inflateSetDictionary() call */
|
11527 | var TYPE = 12; /* i: waiting for type bits, including last-flag bit */
|
11528 | var TYPEDO = 13; /* i: same, but skip check to exit inflate on new block */
|
11529 | var STORED = 14; /* i: waiting for stored size (length and complement) */
|
11530 | var COPY_ = 15; /* i/o: same as COPY below, but only first time in */
|
11531 | var COPY = 16; /* i/o: waiting for input or output to copy stored block */
|
11532 | var TABLE = 17; /* i: waiting for dynamic block table lengths */
|
11533 | var LENLENS = 18; /* i: waiting for code length code lengths */
|
11534 | var CODELENS = 19; /* i: waiting for length/lit and distance code lengths */
|
11535 | var LEN_ = 20; /* i: same as LEN below, but only first time in */
|
11536 | var LEN = 21; /* i: waiting for length/lit/eob code */
|
11537 | var LENEXT = 22; /* i: waiting for length extra bits */
|
11538 | var DIST = 23; /* i: waiting for distance code */
|
11539 | var DISTEXT = 24; /* i: waiting for distance extra bits */
|
11540 | var MATCH = 25; /* o: waiting for output space to copy string */
|
11541 | var LIT = 26; /* o: waiting for output space to write literal */
|
11542 | var CHECK = 27; /* i: waiting for 32-bit check value */
|
11543 | var LENGTH = 28; /* i: waiting for 32-bit length (gzip) */
|
11544 | var DONE = 29; /* finished check, done -- remain here until reset */
|
11545 | var BAD = 30; /* got a data error -- remain here until reset */
|
11546 | var MEM = 31; /* got an inflate() memory error -- remain here until reset */
|
11547 | var SYNC = 32; /* looking for synchronization bytes to restart inflate() */
|
11548 |
|
11549 | /* ===========================================================================*/
|
11550 |
|
11551 |
|
11552 |
|
11553 | var ENOUGH_LENS = 852;
|
11554 | var ENOUGH_DISTS = 592;
|
11555 | //var ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);
|
11556 |
|
11557 | var MAX_WBITS = 15;
|
11558 | /* 32K LZ77 window */
|
11559 | var DEF_WBITS = MAX_WBITS;
|
11560 |
|
11561 |
|
11562 | function zswap32(q) {
|
11563 | return (((q >>> 24) & 0xff) +
|
11564 | ((q >>> 8) & 0xff00) +
|
11565 | ((q & 0xff00) << 8) +
|
11566 | ((q & 0xff) << 24));
|
11567 | }
|
11568 |
|
11569 |
|
11570 | function InflateState() {
|
11571 | this.mode = 0; /* current inflate mode */
|
11572 | this.last = false; /* true if processing last block */
|
11573 | this.wrap = 0; /* bit 0 true for zlib, bit 1 true for gzip */
|
11574 | this.havedict = false; /* true if dictionary provided */
|
11575 | this.flags = 0; /* gzip header method and flags (0 if zlib) */
|
11576 | this.dmax = 0; /* zlib header max distance (INFLATE_STRICT) */
|
11577 | this.check = 0; /* protected copy of check value */
|
11578 | this.total = 0; /* protected copy of output count */
|
11579 | // TODO: may be {}
|
11580 | this.head = null; /* where to save gzip header information */
|
11581 |
|
11582 | /* sliding window */
|
11583 | this.wbits = 0; /* log base 2 of requested window size */
|
11584 | this.wsize = 0; /* window size or zero if not using window */
|
11585 | this.whave = 0; /* valid bytes in the window */
|
11586 | this.wnext = 0; /* window write index */
|
11587 | this.window = null; /* allocated sliding window, if needed */
|
11588 |
|
11589 | /* bit accumulator */
|
11590 | this.hold = 0; /* input bit accumulator */
|
11591 | this.bits = 0; /* number of bits in "in" */
|
11592 |
|
11593 | /* for string and stored block copying */
|
11594 | this.length = 0; /* literal or length of data to copy */
|
11595 | this.offset = 0; /* distance back to copy string from */
|
11596 |
|
11597 | /* for table and code decoding */
|
11598 | this.extra = 0; /* extra bits needed */
|
11599 |
|
11600 | /* fixed and dynamic code tables */
|
11601 | this.lencode = null; /* starting table for length/literal codes */
|
11602 | this.distcode = null; /* starting table for distance codes */
|
11603 | this.lenbits = 0; /* index bits for lencode */
|
11604 | this.distbits = 0; /* index bits for distcode */
|
11605 |
|
11606 | /* dynamic table building */
|
11607 | this.ncode = 0; /* number of code length code lengths */
|
11608 | this.nlen = 0; /* number of length code lengths */
|
11609 | this.ndist = 0; /* number of distance code lengths */
|
11610 | this.have = 0; /* number of code lengths in lens[] */
|
11611 | this.next = null; /* next available space in codes[] */
|
11612 |
|
11613 | this.lens = new utils.Buf16(320); /* temporary storage for code lengths */
|
11614 | this.work = new utils.Buf16(288); /* work area for code table building */
|
11615 |
|
11616 | /*
|
11617 | because we don't have pointers in js, we use lencode and distcode directly
|
11618 | as buffers so we don't need codes
|
11619 | */
|
11620 | //this.codes = new utils.Buf32(ENOUGH); /* space for code tables */
|
11621 | this.lendyn = null; /* dynamic table for length/literal codes (JS specific) */
|
11622 | this.distdyn = null; /* dynamic table for distance codes (JS specific) */
|
11623 | this.sane = 0; /* if false, allow invalid distance too far */
|
11624 | this.back = 0; /* bits back of last unprocessed length/lit */
|
11625 | this.was = 0; /* initial length of match */
|
11626 | }
|
11627 |
|
11628 | function inflateResetKeep(strm) {
|
11629 | var state;
|
11630 |
|
11631 | if (!strm || !strm.state) { return Z_STREAM_ERROR; }
|
11632 | state = strm.state;
|
11633 | strm.total_in = strm.total_out = state.total = 0;
|
11634 | strm.msg = ''; /*Z_NULL*/
|
11635 | if (state.wrap) { /* to support ill-conceived Java test suite */
|
11636 | strm.adler = state.wrap & 1;
|
11637 | }
|
11638 | state.mode = HEAD;
|
11639 | state.last = 0;
|
11640 | state.havedict = 0;
|
11641 | state.dmax = 32768;
|
11642 | state.head = null/*Z_NULL*/;
|
11643 | state.hold = 0;
|
11644 | state.bits = 0;
|
11645 | //state.lencode = state.distcode = state.next = state.codes;
|
11646 | state.lencode = state.lendyn = new utils.Buf32(ENOUGH_LENS);
|
11647 | state.distcode = state.distdyn = new utils.Buf32(ENOUGH_DISTS);
|
11648 |
|
11649 | state.sane = 1;
|
11650 | state.back = -1;
|
11651 | //Tracev((stderr, "inflate: reset\n"));
|
11652 | return Z_OK;
|
11653 | }
|
11654 |
|
11655 | function inflateReset(strm) {
|
11656 | var state;
|
11657 |
|
11658 | if (!strm || !strm.state) { return Z_STREAM_ERROR; }
|
11659 | state = strm.state;
|
11660 | state.wsize = 0;
|
11661 | state.whave = 0;
|
11662 | state.wnext = 0;
|
11663 | return inflateResetKeep(strm);
|
11664 |
|
11665 | }
|
11666 |
|
11667 | function inflateReset2(strm, windowBits) {
|
11668 | var wrap;
|
11669 | var state;
|
11670 |
|
11671 | /* get the state */
|
11672 | if (!strm || !strm.state) { return Z_STREAM_ERROR; }
|
11673 | state = strm.state;
|
11674 |
|
11675 | /* extract wrap request from windowBits parameter */
|
11676 | if (windowBits < 0) {
|
11677 | wrap = 0;
|
11678 | windowBits = -windowBits;
|
11679 | }
|
11680 | else {
|
11681 | wrap = (windowBits >> 4) + 1;
|
11682 | if (windowBits < 48) {
|
11683 | windowBits &= 15;
|
11684 | }
|
11685 | }
|
11686 |
|
11687 | /* set number of window bits, free window if different */
|
11688 | if (windowBits && (windowBits < 8 || windowBits > 15)) {
|
11689 | return Z_STREAM_ERROR;
|
11690 | }
|
11691 | if (state.window !== null && state.wbits !== windowBits) {
|
11692 | state.window = null;
|
11693 | }
|
11694 |
|
11695 | /* update state and reset the rest of it */
|
11696 | state.wrap = wrap;
|
11697 | state.wbits = windowBits;
|
11698 | return inflateReset(strm);
|
11699 | }
|
11700 |
|
11701 | function inflateInit2(strm, windowBits) {
|
11702 | var ret;
|
11703 | var state;
|
11704 |
|
11705 | if (!strm) { return Z_STREAM_ERROR; }
|
11706 | //strm.msg = Z_NULL; /* in case we return an error */
|
11707 |
|
11708 | state = new InflateState();
|
11709 |
|
11710 | //if (state === Z_NULL) return Z_MEM_ERROR;
|
11711 | //Tracev((stderr, "inflate: allocated\n"));
|
11712 | strm.state = state;
|
11713 | state.window = null/*Z_NULL*/;
|
11714 | ret = inflateReset2(strm, windowBits);
|
11715 | if (ret !== Z_OK) {
|
11716 | strm.state = null/*Z_NULL*/;
|
11717 | }
|
11718 | return ret;
|
11719 | }
|
11720 |
|
11721 | function inflateInit(strm) {
|
11722 | return inflateInit2(strm, DEF_WBITS);
|
11723 | }
|
11724 |
|
11725 |
|
11726 | /*
|
11727 | Return state with length and distance decoding tables and index sizes set to
|
11728 | fixed code decoding. Normally this returns fixed tables from inffixed.h.
|
11729 | If BUILDFIXED is defined, then instead this routine builds the tables the
|
11730 | first time it's called, and returns those tables the first time and
|
11731 | thereafter. This reduces the size of the code by about 2K bytes, in
|
11732 | exchange for a little execution time. However, BUILDFIXED should not be
|
11733 | used for threaded applications, since the rewriting of the tables and virgin
|
11734 | may not be thread-safe.
|
11735 | */
|
11736 | var virgin = true;
|
11737 |
|
11738 | var lenfix, distfix; // We have no pointers in JS, so keep tables separate
|
11739 |
|
11740 | function fixedtables(state) {
|
11741 | /* build fixed huffman tables if first call (may not be thread safe) */
|
11742 | if (virgin) {
|
11743 | var sym;
|
11744 |
|
11745 | lenfix = new utils.Buf32(512);
|
11746 | distfix = new utils.Buf32(32);
|
11747 |
|
11748 | /* literal/length table */
|
11749 | sym = 0;
|
11750 | while (sym < 144) { state.lens[sym++] = 8; }
|
11751 | while (sym < 256) { state.lens[sym++] = 9; }
|
11752 | while (sym < 280) { state.lens[sym++] = 7; }
|
11753 | while (sym < 288) { state.lens[sym++] = 8; }
|
11754 |
|
11755 | inflate_table(LENS, state.lens, 0, 288, lenfix, 0, state.work, { bits: 9 });
|
11756 |
|
11757 | /* distance table */
|
11758 | sym = 0;
|
11759 | while (sym < 32) { state.lens[sym++] = 5; }
|
11760 |
|
11761 | inflate_table(DISTS, state.lens, 0, 32, distfix, 0, state.work, { bits: 5 });
|
11762 |
|
11763 | /* do this just once */
|
11764 | virgin = false;
|
11765 | }
|
11766 |
|
11767 | state.lencode = lenfix;
|
11768 | state.lenbits = 9;
|
11769 | state.distcode = distfix;
|
11770 | state.distbits = 5;
|
11771 | }
|
11772 |
|
11773 |
|
11774 | /*
|
11775 | Update the window with the last wsize (normally 32K) bytes written before
|
11776 | returning. If window does not exist yet, create it. This is only called
|
11777 | when a window is already in use, or when output has been written during this
|
11778 | inflate call, but the end of the deflate stream has not been reached yet.
|
11779 | It is also called to create a window for dictionary data when a dictionary
|
11780 | is loaded.
|
11781 |
|
11782 | Providing output buffers larger than 32K to inflate() should provide a speed
|
11783 | advantage, since only the last 32K of output is copied to the sliding window
|
11784 | upon return from inflate(), and since all distances after the first 32K of
|
11785 | output will fall in the output data, making match copies simpler and faster.
|
11786 | The advantage may be dependent on the size of the processor's data caches.
|
11787 | */
|
11788 | function updatewindow(strm, src, end, copy) {
|
11789 | var dist;
|
11790 | var state = strm.state;
|
11791 |
|
11792 | /* if it hasn't been done already, allocate space for the window */
|
11793 | if (state.window === null) {
|
11794 | state.wsize = 1 << state.wbits;
|
11795 | state.wnext = 0;
|
11796 | state.whave = 0;
|
11797 |
|
11798 | state.window = new utils.Buf8(state.wsize);
|
11799 | }
|
11800 |
|
11801 | /* copy state->wsize or less output bytes into the circular window */
|
11802 | if (copy >= state.wsize) {
|
11803 | utils.arraySet(state.window, src, end - state.wsize, state.wsize, 0);
|
11804 | state.wnext = 0;
|
11805 | state.whave = state.wsize;
|
11806 | }
|
11807 | else {
|
11808 | dist = state.wsize - state.wnext;
|
11809 | if (dist > copy) {
|
11810 | dist = copy;
|
11811 | }
|
11812 | //zmemcpy(state->window + state->wnext, end - copy, dist);
|
11813 | utils.arraySet(state.window, src, end - copy, dist, state.wnext);
|
11814 | copy -= dist;
|
11815 | if (copy) {
|
11816 | //zmemcpy(state->window, end - copy, copy);
|
11817 | utils.arraySet(state.window, src, end - copy, copy, 0);
|
11818 | state.wnext = copy;
|
11819 | state.whave = state.wsize;
|
11820 | }
|
11821 | else {
|
11822 | state.wnext += dist;
|
11823 | if (state.wnext === state.wsize) { state.wnext = 0; }
|
11824 | if (state.whave < state.wsize) { state.whave += dist; }
|
11825 | }
|
11826 | }
|
11827 | return 0;
|
11828 | }
|
11829 |
|
11830 | function inflate(strm, flush) {
|
11831 | var state;
|
11832 | var input, output; // input/output buffers
|
11833 | var next; /* next input INDEX */
|
11834 | var put; /* next output INDEX */
|
11835 | var have, left; /* available input and output */
|
11836 | var hold; /* bit buffer */
|
11837 | var bits; /* bits in bit buffer */
|
11838 | var _in, _out; /* save starting available input and output */
|
11839 | var copy; /* number of stored or match bytes to copy */
|
11840 | var from; /* where to copy match bytes from */
|
11841 | var from_source;
|
11842 | var here = 0; /* current decoding table entry */
|
11843 | var here_bits, here_op, here_val; // paked "here" denormalized (JS specific)
|
11844 | //var last; /* parent table entry */
|
11845 | var last_bits, last_op, last_val; // paked "last" denormalized (JS specific)
|
11846 | var len; /* length to copy for repeats, bits to drop */
|
11847 | var ret; /* return code */
|
11848 | var hbuf = new utils.Buf8(4); /* buffer for gzip header crc calculation */
|
11849 | var opts;
|
11850 |
|
11851 | var n; // temporary var for NEED_BITS
|
11852 |
|
11853 | var order = /* permutation of code lengths */
|
11854 | [ 16, 17, 18, 0, 8, 7, 9, 6, 10, 5, 11, 4, 12, 3, 13, 2, 14, 1, 15 ];
|
11855 |
|
11856 |
|
11857 | if (!strm || !strm.state || !strm.output ||
|
11858 | (!strm.input && strm.avail_in !== 0)) {
|
11859 | return Z_STREAM_ERROR;
|
11860 | }
|
11861 |
|
11862 | state = strm.state;
|
11863 | if (state.mode === TYPE) { state.mode = TYPEDO; } /* skip check */
|
11864 |
|
11865 |
|
11866 | //--- LOAD() ---
|
11867 | put = strm.next_out;
|
11868 | output = strm.output;
|
11869 | left = strm.avail_out;
|
11870 | next = strm.next_in;
|
11871 | input = strm.input;
|
11872 | have = strm.avail_in;
|
11873 | hold = state.hold;
|
11874 | bits = state.bits;
|
11875 | //---
|
11876 |
|
11877 | _in = have;
|
11878 | _out = left;
|
11879 | ret = Z_OK;
|
11880 |
|
11881 | inf_leave: // goto emulation
|
11882 | for (;;) {
|
11883 | switch (state.mode) {
|
11884 | case HEAD:
|
11885 | if (state.wrap === 0) {
|
11886 | state.mode = TYPEDO;
|
11887 | break;
|
11888 | }
|
11889 | //=== NEEDBITS(16);
|
11890 | while (bits < 16) {
|
11891 | if (have === 0) { break inf_leave; }
|
11892 | have--;
|
11893 | hold += input[next++] << bits;
|
11894 | bits += 8;
|
11895 | }
|
11896 | //===//
|
11897 | if ((state.wrap & 2) && hold === 0x8b1f) { /* gzip header */
|
11898 | state.check = 0/*crc32(0L, Z_NULL, 0)*/;
|
11899 | //=== CRC2(state.check, hold);
|
11900 | hbuf[0] = hold & 0xff;
|
11901 | hbuf[1] = (hold >>> 8) & 0xff;
|
11902 | state.check = crc32(state.check, hbuf, 2, 0);
|
11903 | //===//
|
11904 |
|
11905 | //=== INITBITS();
|
11906 | hold = 0;
|
11907 | bits = 0;
|
11908 | //===//
|
11909 | state.mode = FLAGS;
|
11910 | break;
|
11911 | }
|
11912 | state.flags = 0; /* expect zlib header */
|
11913 | if (state.head) {
|
11914 | state.head.done = false;
|
11915 | }
|
11916 | if (!(state.wrap & 1) || /* check if zlib header allowed */
|
11917 | (((hold & 0xff)/*BITS(8)*/ << 8) + (hold >> 8)) % 31) {
|
11918 | strm.msg = 'incorrect header check';
|
11919 | state.mode = BAD;
|
11920 | break;
|
11921 | }
|
11922 | if ((hold & 0x0f)/*BITS(4)*/ !== Z_DEFLATED) {
|
11923 | strm.msg = 'unknown compression method';
|
11924 | state.mode = BAD;
|
11925 | break;
|
11926 | }
|
11927 | //--- DROPBITS(4) ---//
|
11928 | hold >>>= 4;
|
11929 | bits -= 4;
|
11930 | //---//
|
11931 | len = (hold & 0x0f)/*BITS(4)*/ + 8;
|
11932 | if (state.wbits === 0) {
|
11933 | state.wbits = len;
|
11934 | }
|
11935 | else if (len > state.wbits) {
|
11936 | strm.msg = 'invalid window size';
|
11937 | state.mode = BAD;
|
11938 | break;
|
11939 | }
|
11940 | state.dmax = 1 << len;
|
11941 | //Tracev((stderr, "inflate: zlib header ok\n"));
|
11942 | strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;
|
11943 | state.mode = hold & 0x200 ? DICTID : TYPE;
|
11944 | //=== INITBITS();
|
11945 | hold = 0;
|
11946 | bits = 0;
|
11947 | //===//
|
11948 | break;
|
11949 | case FLAGS:
|
11950 | //=== NEEDBITS(16); */
|
11951 | while (bits < 16) {
|
11952 | if (have === 0) { break inf_leave; }
|
11953 | have--;
|
11954 | hold += input[next++] << bits;
|
11955 | bits += 8;
|
11956 | }
|
11957 | //===//
|
11958 | state.flags = hold;
|
11959 | if ((state.flags & 0xff) !== Z_DEFLATED) {
|
11960 | strm.msg = 'unknown compression method';
|
11961 | state.mode = BAD;
|
11962 | break;
|
11963 | }
|
11964 | if (state.flags & 0xe000) {
|
11965 | strm.msg = 'unknown header flags set';
|
11966 | state.mode = BAD;
|
11967 | break;
|
11968 | }
|
11969 | if (state.head) {
|
11970 | state.head.text = ((hold >> 8) & 1);
|
11971 | }
|
11972 | if (state.flags & 0x0200) {
|
11973 | //=== CRC2(state.check, hold);
|
11974 | hbuf[0] = hold & 0xff;
|
11975 | hbuf[1] = (hold >>> 8) & 0xff;
|
11976 | state.check = crc32(state.check, hbuf, 2, 0);
|
11977 | //===//
|
11978 | }
|
11979 | //=== INITBITS();
|
11980 | hold = 0;
|
11981 | bits = 0;
|
11982 | //===//
|
11983 | state.mode = TIME;
|
11984 | /* falls through */
|
11985 | case TIME:
|
11986 | //=== NEEDBITS(32); */
|
11987 | while (bits < 32) {
|
11988 | if (have === 0) { break inf_leave; }
|
11989 | have--;
|
11990 | hold += input[next++] << bits;
|
11991 | bits += 8;
|
11992 | }
|
11993 | //===//
|
11994 | if (state.head) {
|
11995 | state.head.time = hold;
|
11996 | }
|
11997 | if (state.flags & 0x0200) {
|
11998 | //=== CRC4(state.check, hold)
|
11999 | hbuf[0] = hold & 0xff;
|
12000 | hbuf[1] = (hold >>> 8) & 0xff;
|
12001 | hbuf[2] = (hold >>> 16) & 0xff;
|
12002 | hbuf[3] = (hold >>> 24) & 0xff;
|
12003 | state.check = crc32(state.check, hbuf, 4, 0);
|
12004 | //===
|
12005 | }
|
12006 | //=== INITBITS();
|
12007 | hold = 0;
|
12008 | bits = 0;
|
12009 | //===//
|
12010 | state.mode = OS;
|
12011 | /* falls through */
|
12012 | case OS:
|
12013 | //=== NEEDBITS(16); */
|
12014 | while (bits < 16) {
|
12015 | if (have === 0) { break inf_leave; }
|
12016 | have--;
|
12017 | hold += input[next++] << bits;
|
12018 | bits += 8;
|
12019 | }
|
12020 | //===//
|
12021 | if (state.head) {
|
12022 | state.head.xflags = (hold & 0xff);
|
12023 | state.head.os = (hold >> 8);
|
12024 | }
|
12025 | if (state.flags & 0x0200) {
|
12026 | //=== CRC2(state.check, hold);
|
12027 | hbuf[0] = hold & 0xff;
|
12028 | hbuf[1] = (hold >>> 8) & 0xff;
|
12029 | state.check = crc32(state.check, hbuf, 2, 0);
|
12030 | //===//
|
12031 | }
|
12032 | //=== INITBITS();
|
12033 | hold = 0;
|
12034 | bits = 0;
|
12035 | //===//
|
12036 | state.mode = EXLEN;
|
12037 | /* falls through */
|
12038 | case EXLEN:
|
12039 | if (state.flags & 0x0400) {
|
12040 | //=== NEEDBITS(16); */
|
12041 | while (bits < 16) {
|
12042 | if (have === 0) { break inf_leave; }
|
12043 | have--;
|
12044 | hold += input[next++] << bits;
|
12045 | bits += 8;
|
12046 | }
|
12047 | //===//
|
12048 | state.length = hold;
|
12049 | if (state.head) {
|
12050 | state.head.extra_len = hold;
|
12051 | }
|
12052 | if (state.flags & 0x0200) {
|
12053 | //=== CRC2(state.check, hold);
|
12054 | hbuf[0] = hold & 0xff;
|
12055 | hbuf[1] = (hold >>> 8) & 0xff;
|
12056 | state.check = crc32(state.check, hbuf, 2, 0);
|
12057 | //===//
|
12058 | }
|
12059 | //=== INITBITS();
|
12060 | hold = 0;
|
12061 | bits = 0;
|
12062 | //===//
|
12063 | }
|
12064 | else if (state.head) {
|
12065 | state.head.extra = null/*Z_NULL*/;
|
12066 | }
|
12067 | state.mode = EXTRA;
|
12068 | /* falls through */
|
12069 | case EXTRA:
|
12070 | if (state.flags & 0x0400) {
|
12071 | copy = state.length;
|
12072 | if (copy > have) { copy = have; }
|
12073 | if (copy) {
|
12074 | if (state.head) {
|
12075 | len = state.head.extra_len - state.length;
|
12076 | if (!state.head.extra) {
|
12077 | // Use untyped array for more conveniend processing later
|
12078 | state.head.extra = new Array(state.head.extra_len);
|
12079 | }
|
12080 | utils.arraySet(
|
12081 | state.head.extra,
|
12082 | input,
|
12083 | next,
|
12084 | // extra field is limited to 65536 bytes
|
12085 | // - no need for additional size check
|
12086 | copy,
|
12087 | /*len + copy > state.head.extra_max - len ? state.head.extra_max : copy,*/
|
12088 | len
|
12089 | );
|
12090 | //zmemcpy(state.head.extra + len, next,
|
12091 | // len + copy > state.head.extra_max ?
|
12092 | // state.head.extra_max - len : copy);
|
12093 | }
|
12094 | if (state.flags & 0x0200) {
|
12095 | state.check = crc32(state.check, input, copy, next);
|
12096 | }
|
12097 | have -= copy;
|
12098 | next += copy;
|
12099 | state.length -= copy;
|
12100 | }
|
12101 | if (state.length) { break inf_leave; }
|
12102 | }
|
12103 | state.length = 0;
|
12104 | state.mode = NAME;
|
12105 | /* falls through */
|
12106 | case NAME:
|
12107 | if (state.flags & 0x0800) {
|
12108 | if (have === 0) { break inf_leave; }
|
12109 | copy = 0;
|
12110 | do {
|
12111 | // TODO: 2 or 1 bytes?
|
12112 | len = input[next + copy++];
|
12113 | /* use constant limit because in js we should not preallocate memory */
|
12114 | if (state.head && len &&
|
12115 | (state.length < 65536 /*state.head.name_max*/)) {
|
12116 | state.head.name += String.fromCharCode(len);
|
12117 | }
|
12118 | } while (len && copy < have);
|
12119 |
|
12120 | if (state.flags & 0x0200) {
|
12121 | state.check = crc32(state.check, input, copy, next);
|
12122 | }
|
12123 | have -= copy;
|
12124 | next += copy;
|
12125 | if (len) { break inf_leave; }
|
12126 | }
|
12127 | else if (state.head) {
|
12128 | state.head.name = null;
|
12129 | }
|
12130 | state.length = 0;
|
12131 | state.mode = COMMENT;
|
12132 | /* falls through */
|
12133 | case COMMENT:
|
12134 | if (state.flags & 0x1000) {
|
12135 | if (have === 0) { break inf_leave; }
|
12136 | copy = 0;
|
12137 | do {
|
12138 | len = input[next + copy++];
|
12139 | /* use constant limit because in js we should not preallocate memory */
|
12140 | if (state.head && len &&
|
12141 | (state.length < 65536 /*state.head.comm_max*/)) {
|
12142 | state.head.comment += String.fromCharCode(len);
|
12143 | }
|
12144 | } while (len && copy < have);
|
12145 | if (state.flags & 0x0200) {
|
12146 | state.check = crc32(state.check, input, copy, next);
|
12147 | }
|
12148 | have -= copy;
|
12149 | next += copy;
|
12150 | if (len) { break inf_leave; }
|
12151 | }
|
12152 | else if (state.head) {
|
12153 | state.head.comment = null;
|
12154 | }
|
12155 | state.mode = HCRC;
|
12156 | /* falls through */
|
12157 | case HCRC:
|
12158 | if (state.flags & 0x0200) {
|
12159 | //=== NEEDBITS(16); */
|
12160 | while (bits < 16) {
|
12161 | if (have === 0) { break inf_leave; }
|
12162 | have--;
|
12163 | hold += input[next++] << bits;
|
12164 | bits += 8;
|
12165 | }
|
12166 | //===//
|
12167 | if (hold !== (state.check & 0xffff)) {
|
12168 | strm.msg = 'header crc mismatch';
|
12169 | state.mode = BAD;
|
12170 | break;
|
12171 | }
|
12172 | //=== INITBITS();
|
12173 | hold = 0;
|
12174 | bits = 0;
|
12175 | //===//
|
12176 | }
|
12177 | if (state.head) {
|
12178 | state.head.hcrc = ((state.flags >> 9) & 1);
|
12179 | state.head.done = true;
|
12180 | }
|
12181 | strm.adler = state.check = 0;
|
12182 | state.mode = TYPE;
|
12183 | break;
|
12184 | case DICTID:
|
12185 | //=== NEEDBITS(32); */
|
12186 | while (bits < 32) {
|
12187 | if (have === 0) { break inf_leave; }
|
12188 | have--;
|
12189 | hold += input[next++] << bits;
|
12190 | bits += 8;
|
12191 | }
|
12192 | //===//
|
12193 | strm.adler = state.check = zswap32(hold);
|
12194 | //=== INITBITS();
|
12195 | hold = 0;
|
12196 | bits = 0;
|
12197 | //===//
|
12198 | state.mode = DICT;
|
12199 | /* falls through */
|
12200 | case DICT:
|
12201 | if (state.havedict === 0) {
|
12202 | //--- RESTORE() ---
|
12203 | strm.next_out = put;
|
12204 | strm.avail_out = left;
|
12205 | strm.next_in = next;
|
12206 | strm.avail_in = have;
|
12207 | state.hold = hold;
|
12208 | state.bits = bits;
|
12209 | //---
|
12210 | return Z_NEED_DICT;
|
12211 | }
|
12212 | strm.adler = state.check = 1/*adler32(0L, Z_NULL, 0)*/;
|
12213 | state.mode = TYPE;
|
12214 | /* falls through */
|
12215 | case TYPE:
|
12216 | if (flush === Z_BLOCK || flush === Z_TREES) { break inf_leave; }
|
12217 | /* falls through */
|
12218 | case TYPEDO:
|
12219 | if (state.last) {
|
12220 | //--- BYTEBITS() ---//
|
12221 | hold >>>= bits & 7;
|
12222 | bits -= bits & 7;
|
12223 | //---//
|
12224 | state.mode = CHECK;
|
12225 | break;
|
12226 | }
|
12227 | //=== NEEDBITS(3); */
|
12228 | while (bits < 3) {
|
12229 | if (have === 0) { break inf_leave; }
|
12230 | have--;
|
12231 | hold += input[next++] << bits;
|
12232 | bits += 8;
|
12233 | }
|
12234 | //===//
|
12235 | state.last = (hold & 0x01)/*BITS(1)*/;
|
12236 | //--- DROPBITS(1) ---//
|
12237 | hold >>>= 1;
|
12238 | bits -= 1;
|
12239 | //---//
|
12240 |
|
12241 | switch ((hold & 0x03)/*BITS(2)*/) {
|
12242 | case 0: /* stored block */
|
12243 | //Tracev((stderr, "inflate: stored block%s\n",
|
12244 | // state.last ? " (last)" : ""));
|
12245 | state.mode = STORED;
|
12246 | break;
|
12247 | case 1: /* fixed block */
|
12248 | fixedtables(state);
|
12249 | //Tracev((stderr, "inflate: fixed codes block%s\n",
|
12250 | // state.last ? " (last)" : ""));
|
12251 | state.mode = LEN_; /* decode codes */
|
12252 | if (flush === Z_TREES) {
|
12253 | //--- DROPBITS(2) ---//
|
12254 | hold >>>= 2;
|
12255 | bits -= 2;
|
12256 | //---//
|
12257 | break inf_leave;
|
12258 | }
|
12259 | break;
|
12260 | case 2: /* dynamic block */
|
12261 | //Tracev((stderr, "inflate: dynamic codes block%s\n",
|
12262 | // state.last ? " (last)" : ""));
|
12263 | state.mode = TABLE;
|
12264 | break;
|
12265 | case 3:
|
12266 | strm.msg = 'invalid block type';
|
12267 | state.mode = BAD;
|
12268 | }
|
12269 | //--- DROPBITS(2) ---//
|
12270 | hold >>>= 2;
|
12271 | bits -= 2;
|
12272 | //---//
|
12273 | break;
|
12274 | case STORED:
|
12275 | //--- BYTEBITS() ---// /* go to byte boundary */
|
12276 | hold >>>= bits & 7;
|
12277 | bits -= bits & 7;
|
12278 | //---//
|
12279 | //=== NEEDBITS(32); */
|
12280 | while (bits < 32) {
|
12281 | if (have === 0) { break inf_leave; }
|
12282 | have--;
|
12283 | hold += input[next++] << bits;
|
12284 | bits += 8;
|
12285 | }
|
12286 | //===//
|
12287 | if ((hold & 0xffff) !== ((hold >>> 16) ^ 0xffff)) {
|
12288 | strm.msg = 'invalid stored block lengths';
|
12289 | state.mode = BAD;
|
12290 | break;
|
12291 | }
|
12292 | state.length = hold & 0xffff;
|
12293 | //Tracev((stderr, "inflate: stored length %u\n",
|
12294 | // state.length));
|
12295 | //=== INITBITS();
|
12296 | hold = 0;
|
12297 | bits = 0;
|
12298 | //===//
|
12299 | state.mode = COPY_;
|
12300 | if (flush === Z_TREES) { break inf_leave; }
|
12301 | /* falls through */
|
12302 | case COPY_:
|
12303 | state.mode = COPY;
|
12304 | /* falls through */
|
12305 | case COPY:
|
12306 | copy = state.length;
|
12307 | if (copy) {
|
12308 | if (copy > have) { copy = have; }
|
12309 | if (copy > left) { copy = left; }
|
12310 | if (copy === 0) { break inf_leave; }
|
12311 | //--- zmemcpy(put, next, copy); ---
|
12312 | utils.arraySet(output, input, next, copy, put);
|
12313 | //---//
|
12314 | have -= copy;
|
12315 | next += copy;
|
12316 | left -= copy;
|
12317 | put += copy;
|
12318 | state.length -= copy;
|
12319 | break;
|
12320 | }
|
12321 | //Tracev((stderr, "inflate: stored end\n"));
|
12322 | state.mode = TYPE;
|
12323 | break;
|
12324 | case TABLE:
|
12325 | //=== NEEDBITS(14); */
|
12326 | while (bits < 14) {
|
12327 | if (have === 0) { break inf_leave; }
|
12328 | have--;
|
12329 | hold += input[next++] << bits;
|
12330 | bits += 8;
|
12331 | }
|
12332 | //===//
|
12333 | state.nlen = (hold & 0x1f)/*BITS(5)*/ + 257;
|
12334 | //--- DROPBITS(5) ---//
|
12335 | hold >>>= 5;
|
12336 | bits -= 5;
|
12337 | //---//
|
12338 | state.ndist = (hold & 0x1f)/*BITS(5)*/ + 1;
|
12339 | //--- DROPBITS(5) ---//
|
12340 | hold >>>= 5;
|
12341 | bits -= 5;
|
12342 | //---//
|
12343 | state.ncode = (hold & 0x0f)/*BITS(4)*/ + 4;
|
12344 | //--- DROPBITS(4) ---//
|
12345 | hold >>>= 4;
|
12346 | bits -= 4;
|
12347 | //---//
|
12348 | //#ifndef PKZIP_BUG_WORKAROUND
|
12349 | if (state.nlen > 286 || state.ndist > 30) {
|
12350 | strm.msg = 'too many length or distance symbols';
|
12351 | state.mode = BAD;
|
12352 | break;
|
12353 | }
|
12354 | //#endif
|
12355 | //Tracev((stderr, "inflate: table sizes ok\n"));
|
12356 | state.have = 0;
|
12357 | state.mode = LENLENS;
|
12358 | /* falls through */
|
12359 | case LENLENS:
|
12360 | while (state.have < state.ncode) {
|
12361 | //=== NEEDBITS(3);
|
12362 | while (bits < 3) {
|
12363 | if (have === 0) { break inf_leave; }
|
12364 | have--;
|
12365 | hold += input[next++] << bits;
|
12366 | bits += 8;
|
12367 | }
|
12368 | //===//
|
12369 | state.lens[order[state.have++]] = (hold & 0x07);//BITS(3);
|
12370 | //--- DROPBITS(3) ---//
|
12371 | hold >>>= 3;
|
12372 | bits -= 3;
|
12373 | //---//
|
12374 | }
|
12375 | while (state.have < 19) {
|
12376 | state.lens[order[state.have++]] = 0;
|
12377 | }
|
12378 | // We have separate tables & no pointers. 2 commented lines below not needed.
|
12379 | //state.next = state.codes;
|
12380 | //state.lencode = state.next;
|
12381 | // Switch to use dynamic table
|
12382 | state.lencode = state.lendyn;
|
12383 | state.lenbits = 7;
|
12384 |
|
12385 | opts = { bits: state.lenbits };
|
12386 | ret = inflate_table(CODES, state.lens, 0, 19, state.lencode, 0, state.work, opts);
|
12387 | state.lenbits = opts.bits;
|
12388 |
|
12389 | if (ret) {
|
12390 | strm.msg = 'invalid code lengths set';
|
12391 | state.mode = BAD;
|
12392 | break;
|
12393 | }
|
12394 | //Tracev((stderr, "inflate: code lengths ok\n"));
|
12395 | state.have = 0;
|
12396 | state.mode = CODELENS;
|
12397 | /* falls through */
|
12398 | case CODELENS:
|
12399 | while (state.have < state.nlen + state.ndist) {
|
12400 | for (;;) {
|
12401 | here = state.lencode[hold & ((1 << state.lenbits) - 1)];/*BITS(state.lenbits)*/
|
12402 | here_bits = here >>> 24;
|
12403 | here_op = (here >>> 16) & 0xff;
|
12404 | here_val = here & 0xffff;
|
12405 |
|
12406 | if ((here_bits) <= bits) { break; }
|
12407 | //--- PULLBYTE() ---//
|
12408 | if (have === 0) { break inf_leave; }
|
12409 | have--;
|
12410 | hold += input[next++] << bits;
|
12411 | bits += 8;
|
12412 | //---//
|
12413 | }
|
12414 | if (here_val < 16) {
|
12415 | //--- DROPBITS(here.bits) ---//
|
12416 | hold >>>= here_bits;
|
12417 | bits -= here_bits;
|
12418 | //---//
|
12419 | state.lens[state.have++] = here_val;
|
12420 | }
|
12421 | else {
|
12422 | if (here_val === 16) {
|
12423 | //=== NEEDBITS(here.bits + 2);
|
12424 | n = here_bits + 2;
|
12425 | while (bits < n) {
|
12426 | if (have === 0) { break inf_leave; }
|
12427 | have--;
|
12428 | hold += input[next++] << bits;
|
12429 | bits += 8;
|
12430 | }
|
12431 | //===//
|
12432 | //--- DROPBITS(here.bits) ---//
|
12433 | hold >>>= here_bits;
|
12434 | bits -= here_bits;
|
12435 | //---//
|
12436 | if (state.have === 0) {
|
12437 | strm.msg = 'invalid bit length repeat';
|
12438 | state.mode = BAD;
|
12439 | break;
|
12440 | }
|
12441 | len = state.lens[state.have - 1];
|
12442 | copy = 3 + (hold & 0x03);//BITS(2);
|
12443 | //--- DROPBITS(2) ---//
|
12444 | hold >>>= 2;
|
12445 | bits -= 2;
|
12446 | //---//
|
12447 | }
|
12448 | else if (here_val === 17) {
|
12449 | //=== NEEDBITS(here.bits + 3);
|
12450 | n = here_bits + 3;
|
12451 | while (bits < n) {
|
12452 | if (have === 0) { break inf_leave; }
|
12453 | have--;
|
12454 | hold += input[next++] << bits;
|
12455 | bits += 8;
|
12456 | }
|
12457 | //===//
|
12458 | //--- DROPBITS(here.bits) ---//
|
12459 | hold >>>= here_bits;
|
12460 | bits -= here_bits;
|
12461 | //---//
|
12462 | len = 0;
|
12463 | copy = 3 + (hold & 0x07);//BITS(3);
|
12464 | //--- DROPBITS(3) ---//
|
12465 | hold >>>= 3;
|
12466 | bits -= 3;
|
12467 | //---//
|
12468 | }
|
12469 | else {
|
12470 | //=== NEEDBITS(here.bits + 7);
|
12471 | n = here_bits + 7;
|
12472 | while (bits < n) {
|
12473 | if (have === 0) { break inf_leave; }
|
12474 | have--;
|
12475 | hold += input[next++] << bits;
|
12476 | bits += 8;
|
12477 | }
|
12478 | //===//
|
12479 | //--- DROPBITS(here.bits) ---//
|
12480 | hold >>>= here_bits;
|
12481 | bits -= here_bits;
|
12482 | //---//
|
12483 | len = 0;
|
12484 | copy = 11 + (hold & 0x7f);//BITS(7);
|
12485 | //--- DROPBITS(7) ---//
|
12486 | hold >>>= 7;
|
12487 | bits -= 7;
|
12488 | //---//
|
12489 | }
|
12490 | if (state.have + copy > state.nlen + state.ndist) {
|
12491 | strm.msg = 'invalid bit length repeat';
|
12492 | state.mode = BAD;
|
12493 | break;
|
12494 | }
|
12495 | while (copy--) {
|
12496 | state.lens[state.have++] = len;
|
12497 | }
|
12498 | }
|
12499 | }
|
12500 |
|
12501 | /* handle error breaks in while */
|
12502 | if (state.mode === BAD) { break; }
|
12503 |
|
12504 | /* check for end-of-block code (better have one) */
|
12505 | if (state.lens[256] === 0) {
|
12506 | strm.msg = 'invalid code -- missing end-of-block';
|
12507 | state.mode = BAD;
|
12508 | break;
|
12509 | }
|
12510 |
|
12511 | /* build code tables -- note: do not change the lenbits or distbits
|
12512 | values here (9 and 6) without reading the comments in inftrees.h
|
12513 | concerning the ENOUGH constants, which depend on those values */
|
12514 | state.lenbits = 9;
|
12515 |
|
12516 | opts = { bits: state.lenbits };
|
12517 | ret = inflate_table(LENS, state.lens, 0, state.nlen, state.lencode, 0, state.work, opts);
|
12518 | // We have separate tables & no pointers. 2 commented lines below not needed.
|
12519 | // state.next_index = opts.table_index;
|
12520 | state.lenbits = opts.bits;
|
12521 | // state.lencode = state.next;
|
12522 |
|
12523 | if (ret) {
|
12524 | strm.msg = 'invalid literal/lengths set';
|
12525 | state.mode = BAD;
|
12526 | break;
|
12527 | }
|
12528 |
|
12529 | state.distbits = 6;
|
12530 | //state.distcode.copy(state.codes);
|
12531 | // Switch to use dynamic table
|
12532 | state.distcode = state.distdyn;
|
12533 | opts = { bits: state.distbits };
|
12534 | ret = inflate_table(DISTS, state.lens, state.nlen, state.ndist, state.distcode, 0, state.work, opts);
|
12535 | // We have separate tables & no pointers. 2 commented lines below not needed.
|
12536 | // state.next_index = opts.table_index;
|
12537 | state.distbits = opts.bits;
|
12538 | // state.distcode = state.next;
|
12539 |
|
12540 | if (ret) {
|
12541 | strm.msg = 'invalid distances set';
|
12542 | state.mode = BAD;
|
12543 | break;
|
12544 | }
|
12545 | //Tracev((stderr, 'inflate: codes ok\n'));
|
12546 | state.mode = LEN_;
|
12547 | if (flush === Z_TREES) { break inf_leave; }
|
12548 | /* falls through */
|
12549 | case LEN_:
|
12550 | state.mode = LEN;
|
12551 | /* falls through */
|
12552 | case LEN:
|
12553 | if (have >= 6 && left >= 258) {
|
12554 | //--- RESTORE() ---
|
12555 | strm.next_out = put;
|
12556 | strm.avail_out = left;
|
12557 | strm.next_in = next;
|
12558 | strm.avail_in = have;
|
12559 | state.hold = hold;
|
12560 | state.bits = bits;
|
12561 | //---
|
12562 | inflate_fast(strm, _out);
|
12563 | //--- LOAD() ---
|
12564 | put = strm.next_out;
|
12565 | output = strm.output;
|
12566 | left = strm.avail_out;
|
12567 | next = strm.next_in;
|
12568 | input = strm.input;
|
12569 | have = strm.avail_in;
|
12570 | hold = state.hold;
|
12571 | bits = state.bits;
|
12572 | //---
|
12573 |
|
12574 | if (state.mode === TYPE) {
|
12575 | state.back = -1;
|
12576 | }
|
12577 | break;
|
12578 | }
|
12579 | state.back = 0;
|
12580 | for (;;) {
|
12581 | here = state.lencode[hold & ((1 << state.lenbits) - 1)]; /*BITS(state.lenbits)*/
|
12582 | here_bits = here >>> 24;
|
12583 | here_op = (here >>> 16) & 0xff;
|
12584 | here_val = here & 0xffff;
|
12585 |
|
12586 | if (here_bits <= bits) { break; }
|
12587 | //--- PULLBYTE() ---//
|
12588 | if (have === 0) { break inf_leave; }
|
12589 | have--;
|
12590 | hold += input[next++] << bits;
|
12591 | bits += 8;
|
12592 | //---//
|
12593 | }
|
12594 | if (here_op && (here_op & 0xf0) === 0) {
|
12595 | last_bits = here_bits;
|
12596 | last_op = here_op;
|
12597 | last_val = here_val;
|
12598 | for (;;) {
|
12599 | here = state.lencode[last_val +
|
12600 | ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];
|
12601 | here_bits = here >>> 24;
|
12602 | here_op = (here >>> 16) & 0xff;
|
12603 | here_val = here & 0xffff;
|
12604 |
|
12605 | if ((last_bits + here_bits) <= bits) { break; }
|
12606 | //--- PULLBYTE() ---//
|
12607 | if (have === 0) { break inf_leave; }
|
12608 | have--;
|
12609 | hold += input[next++] << bits;
|
12610 | bits += 8;
|
12611 | //---//
|
12612 | }
|
12613 | //--- DROPBITS(last.bits) ---//
|
12614 | hold >>>= last_bits;
|
12615 | bits -= last_bits;
|
12616 | //---//
|
12617 | state.back += last_bits;
|
12618 | }
|
12619 | //--- DROPBITS(here.bits) ---//
|
12620 | hold >>>= here_bits;
|
12621 | bits -= here_bits;
|
12622 | //---//
|
12623 | state.back += here_bits;
|
12624 | state.length = here_val;
|
12625 | if (here_op === 0) {
|
12626 | //Tracevv((stderr, here.val >= 0x20 && here.val < 0x7f ?
|
12627 | // "inflate: literal '%c'\n" :
|
12628 | // "inflate: literal 0x%02x\n", here.val));
|
12629 | state.mode = LIT;
|
12630 | break;
|
12631 | }
|
12632 | if (here_op & 32) {
|
12633 | //Tracevv((stderr, "inflate: end of block\n"));
|
12634 | state.back = -1;
|
12635 | state.mode = TYPE;
|
12636 | break;
|
12637 | }
|
12638 | if (here_op & 64) {
|
12639 | strm.msg = 'invalid literal/length code';
|
12640 | state.mode = BAD;
|
12641 | break;
|
12642 | }
|
12643 | state.extra = here_op & 15;
|
12644 | state.mode = LENEXT;
|
12645 | /* falls through */
|
12646 | case LENEXT:
|
12647 | if (state.extra) {
|
12648 | //=== NEEDBITS(state.extra);
|
12649 | n = state.extra;
|
12650 | while (bits < n) {
|
12651 | if (have === 0) { break inf_leave; }
|
12652 | have--;
|
12653 | hold += input[next++] << bits;
|
12654 | bits += 8;
|
12655 | }
|
12656 | //===//
|
12657 | state.length += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;
|
12658 | //--- DROPBITS(state.extra) ---//
|
12659 | hold >>>= state.extra;
|
12660 | bits -= state.extra;
|
12661 | //---//
|
12662 | state.back += state.extra;
|
12663 | }
|
12664 | //Tracevv((stderr, "inflate: length %u\n", state.length));
|
12665 | state.was = state.length;
|
12666 | state.mode = DIST;
|
12667 | /* falls through */
|
12668 | case DIST:
|
12669 | for (;;) {
|
12670 | here = state.distcode[hold & ((1 << state.distbits) - 1)];/*BITS(state.distbits)*/
|
12671 | here_bits = here >>> 24;
|
12672 | here_op = (here >>> 16) & 0xff;
|
12673 | here_val = here & 0xffff;
|
12674 |
|
12675 | if ((here_bits) <= bits) { break; }
|
12676 | //--- PULLBYTE() ---//
|
12677 | if (have === 0) { break inf_leave; }
|
12678 | have--;
|
12679 | hold += input[next++] << bits;
|
12680 | bits += 8;
|
12681 | //---//
|
12682 | }
|
12683 | if ((here_op & 0xf0) === 0) {
|
12684 | last_bits = here_bits;
|
12685 | last_op = here_op;
|
12686 | last_val = here_val;
|
12687 | for (;;) {
|
12688 | here = state.distcode[last_val +
|
12689 | ((hold & ((1 << (last_bits + last_op)) - 1))/*BITS(last.bits + last.op)*/ >> last_bits)];
|
12690 | here_bits = here >>> 24;
|
12691 | here_op = (here >>> 16) & 0xff;
|
12692 | here_val = here & 0xffff;
|
12693 |
|
12694 | if ((last_bits + here_bits) <= bits) { break; }
|
12695 | //--- PULLBYTE() ---//
|
12696 | if (have === 0) { break inf_leave; }
|
12697 | have--;
|
12698 | hold += input[next++] << bits;
|
12699 | bits += 8;
|
12700 | //---//
|
12701 | }
|
12702 | //--- DROPBITS(last.bits) ---//
|
12703 | hold >>>= last_bits;
|
12704 | bits -= last_bits;
|
12705 | //---//
|
12706 | state.back += last_bits;
|
12707 | }
|
12708 | //--- DROPBITS(here.bits) ---//
|
12709 | hold >>>= here_bits;
|
12710 | bits -= here_bits;
|
12711 | //---//
|
12712 | state.back += here_bits;
|
12713 | if (here_op & 64) {
|
12714 | strm.msg = 'invalid distance code';
|
12715 | state.mode = BAD;
|
12716 | break;
|
12717 | }
|
12718 | state.offset = here_val;
|
12719 | state.extra = (here_op) & 15;
|
12720 | state.mode = DISTEXT;
|
12721 | /* falls through */
|
12722 | case DISTEXT:
|
12723 | if (state.extra) {
|
12724 | //=== NEEDBITS(state.extra);
|
12725 | n = state.extra;
|
12726 | while (bits < n) {
|
12727 | if (have === 0) { break inf_leave; }
|
12728 | have--;
|
12729 | hold += input[next++] << bits;
|
12730 | bits += 8;
|
12731 | }
|
12732 | //===//
|
12733 | state.offset += hold & ((1 << state.extra) - 1)/*BITS(state.extra)*/;
|
12734 | //--- DROPBITS(state.extra) ---//
|
12735 | hold >>>= state.extra;
|
12736 | bits -= state.extra;
|
12737 | //---//
|
12738 | state.back += state.extra;
|
12739 | }
|
12740 | //#ifdef INFLATE_STRICT
|
12741 | if (state.offset > state.dmax) {
|
12742 | strm.msg = 'invalid distance too far back';
|
12743 | state.mode = BAD;
|
12744 | break;
|
12745 | }
|
12746 | //#endif
|
12747 | //Tracevv((stderr, "inflate: distance %u\n", state.offset));
|
12748 | state.mode = MATCH;
|
12749 | /* falls through */
|
12750 | case MATCH:
|
12751 | if (left === 0) { break inf_leave; }
|
12752 | copy = _out - left;
|
12753 | if (state.offset > copy) { /* copy from window */
|
12754 | copy = state.offset - copy;
|
12755 | if (copy > state.whave) {
|
12756 | if (state.sane) {
|
12757 | strm.msg = 'invalid distance too far back';
|
12758 | state.mode = BAD;
|
12759 | break;
|
12760 | }
|
12761 | // (!) This block is disabled in zlib defailts,
|
12762 | // don't enable it for binary compatibility
|
12763 | //#ifdef INFLATE_ALLOW_INVALID_DISTANCE_TOOFAR_ARRR
|
12764 | // Trace((stderr, "inflate.c too far\n"));
|
12765 | // copy -= state.whave;
|
12766 | // if (copy > state.length) { copy = state.length; }
|
12767 | // if (copy > left) { copy = left; }
|
12768 | // left -= copy;
|
12769 | // state.length -= copy;
|
12770 | // do {
|
12771 | // output[put++] = 0;
|
12772 | // } while (--copy);
|
12773 | // if (state.length === 0) { state.mode = LEN; }
|
12774 | // break;
|
12775 | //#endif
|
12776 | }
|
12777 | if (copy > state.wnext) {
|
12778 | copy -= state.wnext;
|
12779 | from = state.wsize - copy;
|
12780 | }
|
12781 | else {
|
12782 | from = state.wnext - copy;
|
12783 | }
|
12784 | if (copy > state.length) { copy = state.length; }
|
12785 | from_source = state.window;
|
12786 | }
|
12787 | else { /* copy from output */
|
12788 | from_source = output;
|
12789 | from = put - state.offset;
|
12790 | copy = state.length;
|
12791 | }
|
12792 | if (copy > left) { copy = left; }
|
12793 | left -= copy;
|
12794 | state.length -= copy;
|
12795 | do {
|
12796 | output[put++] = from_source[from++];
|
12797 | } while (--copy);
|
12798 | if (state.length === 0) { state.mode = LEN; }
|
12799 | break;
|
12800 | case LIT:
|
12801 | if (left === 0) { break inf_leave; }
|
12802 | output[put++] = state.length;
|
12803 | left--;
|
12804 | state.mode = LEN;
|
12805 | break;
|
12806 | case CHECK:
|
12807 | if (state.wrap) {
|
12808 | //=== NEEDBITS(32);
|
12809 | while (bits < 32) {
|
12810 | if (have === 0) { break inf_leave; }
|
12811 | have--;
|
12812 | // Use '|' insdead of '+' to make sure that result is signed
|
12813 | hold |= input[next++] << bits;
|
12814 | bits += 8;
|
12815 | }
|
12816 | //===//
|
12817 | _out -= left;
|
12818 | strm.total_out += _out;
|
12819 | state.total += _out;
|
12820 | if (_out) {
|
12821 | strm.adler = state.check =
|
12822 | /*UPDATE(state.check, put - _out, _out);*/
|
12823 | (state.flags ? crc32(state.check, output, _out, put - _out) : adler32(state.check, output, _out, put - _out));
|
12824 |
|
12825 | }
|
12826 | _out = left;
|
12827 | // NB: crc32 stored as signed 32-bit int, zswap32 returns signed too
|
12828 | if ((state.flags ? hold : zswap32(hold)) !== state.check) {
|
12829 | strm.msg = 'incorrect data check';
|
12830 | state.mode = BAD;
|
12831 | break;
|
12832 | }
|
12833 | //=== INITBITS();
|
12834 | hold = 0;
|
12835 | bits = 0;
|
12836 | //===//
|
12837 | //Tracev((stderr, "inflate: check matches trailer\n"));
|
12838 | }
|
12839 | state.mode = LENGTH;
|
12840 | /* falls through */
|
12841 | case LENGTH:
|
12842 | if (state.wrap && state.flags) {
|
12843 | //=== NEEDBITS(32);
|
12844 | while (bits < 32) {
|
12845 | if (have === 0) { break inf_leave; }
|
12846 | have--;
|
12847 | hold += input[next++] << bits;
|
12848 | bits += 8;
|
12849 | }
|
12850 | //===//
|
12851 | if (hold !== (state.total & 0xffffffff)) {
|
12852 | strm.msg = 'incorrect length check';
|
12853 | state.mode = BAD;
|
12854 | break;
|
12855 | }
|
12856 | //=== INITBITS();
|
12857 | hold = 0;
|
12858 | bits = 0;
|
12859 | //===//
|
12860 | //Tracev((stderr, "inflate: length matches trailer\n"));
|
12861 | }
|
12862 | state.mode = DONE;
|
12863 | /* falls through */
|
12864 | case DONE:
|
12865 | ret = Z_STREAM_END;
|
12866 | break inf_leave;
|
12867 | case BAD:
|
12868 | ret = Z_DATA_ERROR;
|
12869 | break inf_leave;
|
12870 | case MEM:
|
12871 | return Z_MEM_ERROR;
|
12872 | case SYNC:
|
12873 | /* falls through */
|
12874 | default:
|
12875 | return Z_STREAM_ERROR;
|
12876 | }
|
12877 | }
|
12878 |
|
12879 | // inf_leave <- here is real place for "goto inf_leave", emulated via "break inf_leave"
|
12880 |
|
12881 | /*
|
12882 | Return from inflate(), updating the total counts and the check value.
|
12883 | If there was no progress during the inflate() call, return a buffer
|
12884 | error. Call updatewindow() to create and/or update the window state.
|
12885 | Note: a memory error from inflate() is non-recoverable.
|
12886 | */
|
12887 |
|
12888 | //--- RESTORE() ---
|
12889 | strm.next_out = put;
|
12890 | strm.avail_out = left;
|
12891 | strm.next_in = next;
|
12892 | strm.avail_in = have;
|
12893 | state.hold = hold;
|
12894 | state.bits = bits;
|
12895 | //---
|
12896 |
|
12897 | if (state.wsize || (_out !== strm.avail_out && state.mode < BAD &&
|
12898 | (state.mode < CHECK || flush !== Z_FINISH))) {
|
12899 | if (updatewindow(strm, strm.output, strm.next_out, _out - strm.avail_out)) {
|
12900 | state.mode = MEM;
|
12901 | return Z_MEM_ERROR;
|
12902 | }
|
12903 | }
|
12904 | _in -= strm.avail_in;
|
12905 | _out -= strm.avail_out;
|
12906 | strm.total_in += _in;
|
12907 | strm.total_out += _out;
|
12908 | state.total += _out;
|
12909 | if (state.wrap && _out) {
|
12910 | strm.adler = state.check = /*UPDATE(state.check, strm.next_out - _out, _out);*/
|
12911 | (state.flags ? crc32(state.check, output, _out, strm.next_out - _out) : adler32(state.check, output, _out, strm.next_out - _out));
|
12912 | }
|
12913 | strm.data_type = state.bits + (state.last ? 64 : 0) +
|
12914 | (state.mode === TYPE ? 128 : 0) +
|
12915 | (state.mode === LEN_ || state.mode === COPY_ ? 256 : 0);
|
12916 | if (((_in === 0 && _out === 0) || flush === Z_FINISH) && ret === Z_OK) {
|
12917 | ret = Z_BUF_ERROR;
|
12918 | }
|
12919 | return ret;
|
12920 | }
|
12921 |
|
12922 | function inflateEnd(strm) {
|
12923 |
|
12924 | if (!strm || !strm.state /*|| strm->zfree == (free_func)0*/) {
|
12925 | return Z_STREAM_ERROR;
|
12926 | }
|
12927 |
|
12928 | var state = strm.state;
|
12929 | if (state.window) {
|
12930 | state.window = null;
|
12931 | }
|
12932 | strm.state = null;
|
12933 | return Z_OK;
|
12934 | }
|
12935 |
|
12936 | function inflateGetHeader(strm, head) {
|
12937 | var state;
|
12938 |
|
12939 | /* check state */
|
12940 | if (!strm || !strm.state) { return Z_STREAM_ERROR; }
|
12941 | state = strm.state;
|
12942 | if ((state.wrap & 2) === 0) { return Z_STREAM_ERROR; }
|
12943 |
|
12944 | /* save header structure */
|
12945 | state.head = head;
|
12946 | head.done = false;
|
12947 | return Z_OK;
|
12948 | }
|
12949 |
|
12950 | function inflateSetDictionary(strm, dictionary) {
|
12951 | var dictLength = dictionary.length;
|
12952 |
|
12953 | var state;
|
12954 | var dictid;
|
12955 | var ret;
|
12956 |
|
12957 | /* check state */
|
12958 | if (!strm /* == Z_NULL */ || !strm.state /* == Z_NULL */) { return Z_STREAM_ERROR; }
|
12959 | state = strm.state;
|
12960 |
|
12961 | if (state.wrap !== 0 && state.mode !== DICT) {
|
12962 | return Z_STREAM_ERROR;
|
12963 | }
|
12964 |
|
12965 | /* check for correct dictionary identifier */
|
12966 | if (state.mode === DICT) {
|
12967 | dictid = 1; /* adler32(0, null, 0)*/
|
12968 | /* dictid = adler32(dictid, dictionary, dictLength); */
|
12969 | dictid = adler32(dictid, dictionary, dictLength, 0);
|
12970 | if (dictid !== state.check) {
|
12971 | return Z_DATA_ERROR;
|
12972 | }
|
12973 | }
|
12974 | /* copy dictionary to window using updatewindow(), which will amend the
|
12975 | existing dictionary if appropriate */
|
12976 | ret = updatewindow(strm, dictionary, dictLength, dictLength);
|
12977 | if (ret) {
|
12978 | state.mode = MEM;
|
12979 | return Z_MEM_ERROR;
|
12980 | }
|
12981 | state.havedict = 1;
|
12982 | // Tracev((stderr, "inflate: dictionary set\n"));
|
12983 | return Z_OK;
|
12984 | }
|
12985 |
|
12986 | exports.inflateReset = inflateReset;
|
12987 | exports.inflateReset2 = inflateReset2;
|
12988 | exports.inflateResetKeep = inflateResetKeep;
|
12989 | exports.inflateInit = inflateInit;
|
12990 | exports.inflateInit2 = inflateInit2;
|
12991 | exports.inflate = inflate;
|
12992 | exports.inflateEnd = inflateEnd;
|
12993 | exports.inflateGetHeader = inflateGetHeader;
|
12994 | exports.inflateSetDictionary = inflateSetDictionary;
|
12995 | exports.inflateInfo = 'pako inflate (from Nodeca project)';
|
12996 |
|
12997 | /* Not implemented
|
12998 | exports.inflateCopy = inflateCopy;
|
12999 | exports.inflateGetDictionary = inflateGetDictionary;
|
13000 | exports.inflateMark = inflateMark;
|
13001 | exports.inflatePrime = inflatePrime;
|
13002 | exports.inflateSync = inflateSync;
|
13003 | exports.inflateSyncPoint = inflateSyncPoint;
|
13004 | exports.inflateUndermine = inflateUndermine;
|
13005 | */
|
13006 |
|
13007 |
|
13008 | /***/ }),
|
13009 | /* 136 */
|
13010 | /***/ (function(module, exports, __webpack_require__) {
|
13011 |
|
13012 | "use strict";
|
13013 |
|
13014 |
|
13015 |
|
13016 | var utils = __webpack_require__(28);
|
13017 |
|
13018 | var MAXBITS = 15;
|
13019 | var ENOUGH_LENS = 852;
|
13020 | var ENOUGH_DISTS = 592;
|
13021 | //var ENOUGH = (ENOUGH_LENS+ENOUGH_DISTS);
|
13022 |
|
13023 | var CODES = 0;
|
13024 | var LENS = 1;
|
13025 | var DISTS = 2;
|
13026 |
|
13027 | var lbase = [ /* Length codes 257..285 base */
|
13028 | 3, 4, 5, 6, 7, 8, 9, 10, 11, 13, 15, 17, 19, 23, 27, 31,
|
13029 | 35, 43, 51, 59, 67, 83, 99, 115, 131, 163, 195, 227, 258, 0, 0
|
13030 | ];
|
13031 |
|
13032 | var lext = [ /* Length codes 257..285 extra */
|
13033 | 16, 16, 16, 16, 16, 16, 16, 16, 17, 17, 17, 17, 18, 18, 18, 18,
|
13034 | 19, 19, 19, 19, 20, 20, 20, 20, 21, 21, 21, 21, 16, 72, 78
|
13035 | ];
|
13036 |
|
13037 | var dbase = [ /* Distance codes 0..29 base */
|
13038 | 1, 2, 3, 4, 5, 7, 9, 13, 17, 25, 33, 49, 65, 97, 129, 193,
|
13039 | 257, 385, 513, 769, 1025, 1537, 2049, 3073, 4097, 6145,
|
13040 | 8193, 12289, 16385, 24577, 0, 0
|
13041 | ];
|
13042 |
|
13043 | var dext = [ /* Distance codes 0..29 extra */
|
13044 | 16, 16, 16, 16, 17, 17, 18, 18, 19, 19, 20, 20, 21, 21, 22, 22,
|
13045 | 23, 23, 24, 24, 25, 25, 26, 26, 27, 27,
|
13046 | 28, 28, 29, 29, 64, 64
|
13047 | ];
|
13048 |
|
13049 | module.exports = function inflate_table(type, lens, lens_index, codes, table, table_index, work, opts)
|
13050 | {
|
13051 | var bits = opts.bits;
|
13052 | //here = opts.here; /* table entry for duplication */
|
13053 |
|
13054 | var len = 0; /* a code's length in bits */
|
13055 | var sym = 0; /* index of code symbols */
|
13056 | var min = 0, max = 0; /* minimum and maximum code lengths */
|
13057 | var root = 0; /* number of index bits for root table */
|
13058 | var curr = 0; /* number of index bits for current table */
|
13059 | var drop = 0; /* code bits to drop for sub-table */
|
13060 | var left = 0; /* number of prefix codes available */
|
13061 | var used = 0; /* code entries in table used */
|
13062 | var huff = 0; /* Huffman code */
|
13063 | var incr; /* for incrementing code, index */
|
13064 | var fill; /* index for replicating entries */
|
13065 | var low; /* low bits for current root entry */
|
13066 | var mask; /* mask for low root bits */
|
13067 | var next; /* next available space in table */
|
13068 | var base = null; /* base value table to use */
|
13069 | var base_index = 0;
|
13070 | // var shoextra; /* extra bits table to use */
|
13071 | var end; /* use base and extra for symbol > end */
|
13072 | var count = new utils.Buf16(MAXBITS + 1); //[MAXBITS+1]; /* number of codes of each length */
|
13073 | var offs = new utils.Buf16(MAXBITS + 1); //[MAXBITS+1]; /* offsets in table for each length */
|
13074 | var extra = null;
|
13075 | var extra_index = 0;
|
13076 |
|
13077 | var here_bits, here_op, here_val;
|
13078 |
|
13079 | /*
|
13080 | Process a set of code lengths to create a canonical Huffman code. The
|
13081 | code lengths are lens[0..codes-1]. Each length corresponds to the
|
13082 | symbols 0..codes-1. The Huffman code is generated by first sorting the
|
13083 | symbols by length from short to long, and retaining the symbol order
|
13084 | for codes with equal lengths. Then the code starts with all zero bits
|
13085 | for the first code of the shortest length, and the codes are integer
|
13086 | increments for the same length, and zeros are appended as the length
|
13087 | increases. For the deflate format, these bits are stored backwards
|
13088 | from their more natural integer increment ordering, and so when the
|
13089 | decoding tables are built in the large loop below, the integer codes
|
13090 | are incremented backwards.
|
13091 |
|
13092 | This routine assumes, but does not check, that all of the entries in
|
13093 | lens[] are in the range 0..MAXBITS. The caller must assure this.
|
13094 | 1..MAXBITS is interpreted as that code length. zero means that that
|
13095 | symbol does not occur in this code.
|
13096 |
|
13097 | The codes are sorted by computing a count of codes for each length,
|
13098 | creating from that a table of starting indices for each length in the
|
13099 | sorted table, and then entering the symbols in order in the sorted
|
13100 | table. The sorted table is work[], with that space being provided by
|
13101 | the caller.
|
13102 |
|
13103 | The length counts are used for other purposes as well, i.e. finding
|
13104 | the minimum and maximum length codes, determining if there are any
|
13105 | codes at all, checking for a valid set of lengths, and looking ahead
|
13106 | at length counts to determine sub-table sizes when building the
|
13107 | decoding tables.
|
13108 | */
|
13109 |
|
13110 | /* accumulate lengths for codes (assumes lens[] all in 0..MAXBITS) */
|
13111 | for (len = 0; len <= MAXBITS; len++) {
|
13112 | count[len] = 0;
|
13113 | }
|
13114 | for (sym = 0; sym < codes; sym++) {
|
13115 | count[lens[lens_index + sym]]++;
|
13116 | }
|
13117 |
|
13118 | /* bound code lengths, force root to be within code lengths */
|
13119 | root = bits;
|
13120 | for (max = MAXBITS; max >= 1; max--) {
|
13121 | if (count[max] !== 0) { break; }
|
13122 | }
|
13123 | if (root > max) {
|
13124 | root = max;
|
13125 | }
|
13126 | if (max === 0) { /* no symbols to code at all */
|
13127 | //table.op[opts.table_index] = 64; //here.op = (var char)64; /* invalid code marker */
|
13128 | //table.bits[opts.table_index] = 1; //here.bits = (var char)1;
|
13129 | //table.val[opts.table_index++] = 0; //here.val = (var short)0;
|
13130 | table[table_index++] = (1 << 24) | (64 << 16) | 0;
|
13131 |
|
13132 |
|
13133 | //table.op[opts.table_index] = 64;
|
13134 | //table.bits[opts.table_index] = 1;
|
13135 | //table.val[opts.table_index++] = 0;
|
13136 | table[table_index++] = (1 << 24) | (64 << 16) | 0;
|
13137 |
|
13138 | opts.bits = 1;
|
13139 | return 0; /* no symbols, but wait for decoding to report error */
|
13140 | }
|
13141 | for (min = 1; min < max; min++) {
|
13142 | if (count[min] !== 0) { break; }
|
13143 | }
|
13144 | if (root < min) {
|
13145 | root = min;
|
13146 | }
|
13147 |
|
13148 | /* check for an over-subscribed or incomplete set of lengths */
|
13149 | left = 1;
|
13150 | for (len = 1; len <= MAXBITS; len++) {
|
13151 | left <<= 1;
|
13152 | left -= count[len];
|
13153 | if (left < 0) {
|
13154 | return -1;
|
13155 | } /* over-subscribed */
|
13156 | }
|
13157 | if (left > 0 && (type === CODES || max !== 1)) {
|
13158 | return -1; /* incomplete set */
|
13159 | }
|
13160 |
|
13161 | /* generate offsets into symbol table for each length for sorting */
|
13162 | offs[1] = 0;
|
13163 | for (len = 1; len < MAXBITS; len++) {
|
13164 | offs[len + 1] = offs[len] + count[len];
|
13165 | }
|
13166 |
|
13167 | /* sort symbols by length, by symbol order within each length */
|
13168 | for (sym = 0; sym < codes; sym++) {
|
13169 | if (lens[lens_index + sym] !== 0) {
|
13170 | work[offs[lens[lens_index + sym]]++] = sym;
|
13171 | }
|
13172 | }
|
13173 |
|
13174 | /*
|
13175 | Create and fill in decoding tables. In this loop, the table being
|
13176 | filled is at next and has curr index bits. The code being used is huff
|
13177 | with length len. That code is converted to an index by dropping drop
|
13178 | bits off of the bottom. For codes where len is less than drop + curr,
|
13179 | those top drop + curr - len bits are incremented through all values to
|
13180 | fill the table with replicated entries.
|
13181 |
|
13182 | root is the number of index bits for the root table. When len exceeds
|
13183 | root, sub-tables are created pointed to by the root entry with an index
|
13184 | of the low root bits of huff. This is saved in low to check for when a
|
13185 | new sub-table should be started. drop is zero when the root table is
|
13186 | being filled, and drop is root when sub-tables are being filled.
|
13187 |
|
13188 | When a new sub-table is needed, it is necessary to look ahead in the
|
13189 | code lengths to determine what size sub-table is needed. The length
|
13190 | counts are used for this, and so count[] is decremented as codes are
|
13191 | entered in the tables.
|
13192 |
|
13193 | used keeps track of how many table entries have been allocated from the
|
13194 | provided *table space. It is checked for LENS and DIST tables against
|
13195 | the constants ENOUGH_LENS and ENOUGH_DISTS to guard against changes in
|
13196 | the initial root table size constants. See the comments in inftrees.h
|
13197 | for more information.
|
13198 |
|
13199 | sym increments through all symbols, and the loop terminates when
|
13200 | all codes of length max, i.e. all codes, have been processed. This
|
13201 | routine permits incomplete codes, so another loop after this one fills
|
13202 | in the rest of the decoding tables with invalid code markers.
|
13203 | */
|
13204 |
|
13205 | /* set up for code type */
|
13206 | // poor man optimization - use if-else instead of switch,
|
13207 | // to avoid deopts in old v8
|
13208 | if (type === CODES) {
|
13209 | base = extra = work; /* dummy value--not used */
|
13210 | end = 19;
|
13211 |
|
13212 | } else if (type === LENS) {
|
13213 | base = lbase;
|
13214 | base_index -= 257;
|
13215 | extra = lext;
|
13216 | extra_index -= 257;
|
13217 | end = 256;
|
13218 |
|
13219 | } else { /* DISTS */
|
13220 | base = dbase;
|
13221 | extra = dext;
|
13222 | end = -1;
|
13223 | }
|
13224 |
|
13225 | /* initialize opts for loop */
|
13226 | huff = 0; /* starting code */
|
13227 | sym = 0; /* starting code symbol */
|
13228 | len = min; /* starting code length */
|
13229 | next = table_index; /* current table to fill in */
|
13230 | curr = root; /* current table index bits */
|
13231 | drop = 0; /* current bits to drop from code for index */
|
13232 | low = -1; /* trigger new sub-table when len > root */
|
13233 | used = 1 << root; /* use root table entries */
|
13234 | mask = used - 1; /* mask for comparing low */
|
13235 |
|
13236 | /* check available table space */
|
13237 | if ((type === LENS && used > ENOUGH_LENS) ||
|
13238 | (type === DISTS && used > ENOUGH_DISTS)) {
|
13239 | return 1;
|
13240 | }
|
13241 |
|
13242 | /* process all codes and make table entries */
|
13243 | for (;;) {
|
13244 | /* create table entry */
|
13245 | here_bits = len - drop;
|
13246 | if (work[sym] < end) {
|
13247 | here_op = 0;
|
13248 | here_val = work[sym];
|
13249 | }
|
13250 | else if (work[sym] > end) {
|
13251 | here_op = extra[extra_index + work[sym]];
|
13252 | here_val = base[base_index + work[sym]];
|
13253 | }
|
13254 | else {
|
13255 | here_op = 32 + 64; /* end of block */
|
13256 | here_val = 0;
|
13257 | }
|
13258 |
|
13259 | /* replicate for those indices with low len bits equal to huff */
|
13260 | incr = 1 << (len - drop);
|
13261 | fill = 1 << curr;
|
13262 | min = fill; /* save offset to next table */
|
13263 | do {
|
13264 | fill -= incr;
|
13265 | table[next + (huff >> drop) + fill] = (here_bits << 24) | (here_op << 16) | here_val |0;
|
13266 | } while (fill !== 0);
|
13267 |
|
13268 | /* backwards increment the len-bit code huff */
|
13269 | incr = 1 << (len - 1);
|
13270 | while (huff & incr) {
|
13271 | incr >>= 1;
|
13272 | }
|
13273 | if (incr !== 0) {
|
13274 | huff &= incr - 1;
|
13275 | huff += incr;
|
13276 | } else {
|
13277 | huff = 0;
|
13278 | }
|
13279 |
|
13280 | /* go to next symbol, update count, len */
|
13281 | sym++;
|
13282 | if (--count[len] === 0) {
|
13283 | if (len === max) { break; }
|
13284 | len = lens[lens_index + work[sym]];
|
13285 | }
|
13286 |
|
13287 | /* create new sub-table if needed */
|
13288 | if (len > root && (huff & mask) !== low) {
|
13289 | /* if first time, transition to sub-tables */
|
13290 | if (drop === 0) {
|
13291 | drop = root;
|
13292 | }
|
13293 |
|
13294 | /* increment past last table */
|
13295 | next += min; /* here min is 1 << curr */
|
13296 |
|
13297 | /* determine length of next table */
|
13298 | curr = len - drop;
|
13299 | left = 1 << curr;
|
13300 | while (curr + drop < max) {
|
13301 | left -= count[curr + drop];
|
13302 | if (left <= 0) { break; }
|
13303 | curr++;
|
13304 | left <<= 1;
|
13305 | }
|
13306 |
|
13307 | /* check for enough space */
|
13308 | used += 1 << curr;
|
13309 | if ((type === LENS && used > ENOUGH_LENS) ||
|
13310 | (type === DISTS && used > ENOUGH_DISTS)) {
|
13311 | return 1;
|
13312 | }
|
13313 |
|
13314 | /* point entry in root table to sub-table */
|
13315 | low = huff & mask;
|
13316 | /*table.op[low] = curr;
|
13317 | table.bits[low] = root;
|
13318 | table.val[low] = next - opts.table_index;*/
|
13319 | table[low] = (root << 24) | (curr << 16) | (next - table_index) |0;
|
13320 | }
|
13321 | }
|
13322 |
|
13323 | /* fill in remaining table entry if code is incomplete (guaranteed to have
|
13324 | at most one remaining entry, since if the code is incomplete, the
|
13325 | maximum code length that was allowed to get this far is one bit) */
|
13326 | if (huff !== 0) {
|
13327 | //table.op[next + huff] = 64; /* invalid code marker */
|
13328 | //table.bits[next + huff] = len - drop;
|
13329 | //table.val[next + huff] = 0;
|
13330 | table[next + huff] = ((len - drop) << 24) | (64 << 16) |0;
|
13331 | }
|
13332 |
|
13333 | /* set return parameters */
|
13334 | //opts.table_index += used;
|
13335 | opts.bits = root;
|
13336 | return 0;
|
13337 | };
|
13338 |
|
13339 |
|
13340 | /***/ }),
|
13341 | /* 137 */
|
13342 | /***/ (function(module, exports, __webpack_require__) {
|
13343 |
|
13344 | "use strict";
|
13345 |
|
13346 |
|
13347 | module.exports = {
|
13348 | 2: 'need dictionary', /* Z_NEED_DICT 2 */
|
13349 | 1: 'stream end', /* Z_STREAM_END 1 */
|
13350 | 0: '', /* Z_OK 0 */
|
13351 | '-1': 'file error', /* Z_ERRNO (-1) */
|
13352 | '-2': 'stream error', /* Z_STREAM_ERROR (-2) */
|
13353 | '-3': 'data error', /* Z_DATA_ERROR (-3) */
|
13354 | '-4': 'insufficient memory', /* Z_MEM_ERROR (-4) */
|
13355 | '-5': 'buffer error', /* Z_BUF_ERROR (-5) */
|
13356 | '-6': 'incompatible version' /* Z_VERSION_ERROR (-6) */
|
13357 | };
|
13358 |
|
13359 |
|
13360 | /***/ }),
|
13361 | /* 138 */
|
13362 | /***/ (function(module, exports, __webpack_require__) {
|
13363 |
|
13364 | "use strict";
|
13365 |
|
13366 |
|
13367 |
|
13368 | function ZStream() {
|
13369 | /* next input byte */
|
13370 | this.input = null; // JS specific, because we have no pointers
|
13371 | this.next_in = 0;
|
13372 | /* number of bytes available at input */
|
13373 | this.avail_in = 0;
|
13374 | /* total number of input bytes read so far */
|
13375 | this.total_in = 0;
|
13376 | /* next output byte should be put there */
|
13377 | this.output = null; // JS specific, because we have no pointers
|
13378 | this.next_out = 0;
|
13379 | /* remaining free space at output */
|
13380 | this.avail_out = 0;
|
13381 | /* total number of bytes output so far */
|
13382 | this.total_out = 0;
|
13383 | /* last error message, NULL if no error */
|
13384 | this.msg = ''/*Z_NULL*/;
|
13385 | /* not visible by applications */
|
13386 | this.state = null;
|
13387 | /* best guess about the data type: binary or text */
|
13388 | this.data_type = 2/*Z_UNKNOWN*/;
|
13389 | /* adler32 value of the uncompressed data */
|
13390 | this.adler = 0;
|
13391 | }
|
13392 |
|
13393 | module.exports = ZStream;
|
13394 |
|
13395 |
|
13396 | /***/ }),
|
13397 | /* 139 */
|
13398 | /***/ (function(module, exports, __webpack_require__) {
|
13399 |
|
13400 | module.exports = {
|
13401 | F: __webpack_require__(140),
|
13402 | T: __webpack_require__(141),
|
13403 | __: __webpack_require__(142),
|
13404 | add: __webpack_require__(29),
|
13405 | addIndex: __webpack_require__(143),
|
13406 | adjust: __webpack_require__(60),
|
13407 | all: __webpack_require__(144),
|
13408 | allPass: __webpack_require__(145),
|
13409 | always: __webpack_require__(19),
|
13410 | and: __webpack_require__(61),
|
13411 | any: __webpack_require__(62),
|
13412 | anyPass: __webpack_require__(146),
|
13413 | ap: __webpack_require__(44),
|
13414 | aperture: __webpack_require__(147),
|
13415 | append: __webpack_require__(148),
|
13416 | apply: __webpack_require__(63),
|
13417 | applySpec: __webpack_require__(149),
|
13418 | ascend: __webpack_require__(150),
|
13419 | assoc: __webpack_require__(30),
|
13420 | assocPath: __webpack_require__(64),
|
13421 | binary: __webpack_require__(151),
|
13422 | bind: __webpack_require__(65),
|
13423 | both: __webpack_require__(152),
|
13424 | call: __webpack_require__(153),
|
13425 | chain: __webpack_require__(45),
|
13426 | clamp: __webpack_require__(154),
|
13427 | clone: __webpack_require__(155),
|
13428 | comparator: __webpack_require__(156),
|
13429 | complement: __webpack_require__(157),
|
13430 | compose: __webpack_require__(46),
|
13431 | composeK: __webpack_require__(66),
|
13432 | composeP: __webpack_require__(158),
|
13433 | concat: __webpack_require__(47),
|
13434 | cond: __webpack_require__(159),
|
13435 | construct: __webpack_require__(160),
|
13436 | constructN: __webpack_require__(67),
|
13437 | contains: __webpack_require__(161),
|
13438 | converge: __webpack_require__(68),
|
13439 | countBy: __webpack_require__(162),
|
13440 | curry: __webpack_require__(31),
|
13441 | curryN: __webpack_require__(5),
|
13442 | dec: __webpack_require__(163),
|
13443 | descend: __webpack_require__(164),
|
13444 | defaultTo: __webpack_require__(69),
|
13445 | difference: __webpack_require__(70),
|
13446 | differenceWith: __webpack_require__(71),
|
13447 | dissoc: __webpack_require__(72),
|
13448 | dissocPath: __webpack_require__(165),
|
13449 | divide: __webpack_require__(166),
|
13450 | drop: __webpack_require__(73),
|
13451 | dropLast: __webpack_require__(167),
|
13452 | dropLastWhile: __webpack_require__(168),
|
13453 | dropRepeats: __webpack_require__(169),
|
13454 | dropRepeatsWith: __webpack_require__(74),
|
13455 | dropWhile: __webpack_require__(170),
|
13456 | either: __webpack_require__(171),
|
13457 | empty: __webpack_require__(75),
|
13458 | eqBy: __webpack_require__(172),
|
13459 | eqProps: __webpack_require__(173),
|
13460 | equals: __webpack_require__(10),
|
13461 | evolve: __webpack_require__(174),
|
13462 | filter: __webpack_require__(48),
|
13463 | find: __webpack_require__(175),
|
13464 | findIndex: __webpack_require__(176),
|
13465 | findLast: __webpack_require__(177),
|
13466 | findLastIndex: __webpack_require__(178),
|
13467 | flatten: __webpack_require__(179),
|
13468 | flip: __webpack_require__(32),
|
13469 | forEach: __webpack_require__(180),
|
13470 | forEachObjIndexed: __webpack_require__(181),
|
13471 | fromPairs: __webpack_require__(182),
|
13472 | groupBy: __webpack_require__(183),
|
13473 | groupWith: __webpack_require__(184),
|
13474 | gt: __webpack_require__(185),
|
13475 | gte: __webpack_require__(186),
|
13476 | has: __webpack_require__(187),
|
13477 | hasIn: __webpack_require__(188),
|
13478 | head: __webpack_require__(189),
|
13479 | identical: __webpack_require__(76),
|
13480 | identity: __webpack_require__(49),
|
13481 | ifElse: __webpack_require__(190),
|
13482 | inc: __webpack_require__(191),
|
13483 | indexBy: __webpack_require__(192),
|
13484 | indexOf: __webpack_require__(193),
|
13485 | init: __webpack_require__(194),
|
13486 | insert: __webpack_require__(195),
|
13487 | insertAll: __webpack_require__(196),
|
13488 | intersection: __webpack_require__(231),
|
13489 | intersectionWith: __webpack_require__(232),
|
13490 | intersperse: __webpack_require__(233),
|
13491 | into: __webpack_require__(234),
|
13492 | invert: __webpack_require__(235),
|
13493 | invertObj: __webpack_require__(236),
|
13494 | invoker: __webpack_require__(22),
|
13495 | is: __webpack_require__(91),
|
13496 | isArrayLike: __webpack_require__(23),
|
13497 | isEmpty: __webpack_require__(237),
|
13498 | isNil: __webpack_require__(238),
|
13499 | join: __webpack_require__(239),
|
13500 | juxt: __webpack_require__(92),
|
13501 | keys: __webpack_require__(12),
|
13502 | keysIn: __webpack_require__(240),
|
13503 | last: __webpack_require__(93),
|
13504 | lastIndexOf: __webpack_require__(241),
|
13505 | length: __webpack_require__(94),
|
13506 | lens: __webpack_require__(38),
|
13507 | lensIndex: __webpack_require__(242),
|
13508 | lensPath: __webpack_require__(243),
|
13509 | lensProp: __webpack_require__(244),
|
13510 | lift: __webpack_require__(39),
|
13511 | liftN: __webpack_require__(95),
|
13512 | lt: __webpack_require__(245),
|
13513 | lte: __webpack_require__(246),
|
13514 | map: __webpack_require__(7),
|
13515 | mapAccum: __webpack_require__(247),
|
13516 | mapAccumRight: __webpack_require__(248),
|
13517 | mapObjIndexed: __webpack_require__(249),
|
13518 | match: __webpack_require__(250),
|
13519 | mathMod: __webpack_require__(251),
|
13520 | max: __webpack_require__(20),
|
13521 | maxBy: __webpack_require__(252),
|
13522 | mean: __webpack_require__(96),
|
13523 | median: __webpack_require__(253),
|
13524 | memoize: __webpack_require__(254),
|
13525 | merge: __webpack_require__(255),
|
13526 | mergeAll: __webpack_require__(256),
|
13527 | mergeWith: __webpack_require__(257),
|
13528 | mergeWithKey: __webpack_require__(97),
|
13529 | min: __webpack_require__(258),
|
13530 | minBy: __webpack_require__(259),
|
13531 | modulo: __webpack_require__(260),
|
13532 | multiply: __webpack_require__(98),
|
13533 | nAry: __webpack_require__(40),
|
13534 | negate: __webpack_require__(261),
|
13535 | none: __webpack_require__(262),
|
13536 | not: __webpack_require__(99),
|
13537 | nth: __webpack_require__(24),
|
13538 | nthArg: __webpack_require__(263),
|
13539 | objOf: __webpack_require__(100),
|
13540 | of: __webpack_require__(264),
|
13541 | omit: __webpack_require__(265),
|
13542 | once: __webpack_require__(266),
|
13543 | or: __webpack_require__(101),
|
13544 | over: __webpack_require__(102),
|
13545 | pair: __webpack_require__(267),
|
13546 | partial: __webpack_require__(268),
|
13547 | partialRight: __webpack_require__(269),
|
13548 | partition: __webpack_require__(270),
|
13549 | path: __webpack_require__(25),
|
13550 | pathEq: __webpack_require__(271),
|
13551 | pathOr: __webpack_require__(272),
|
13552 | pathSatisfies: __webpack_require__(273),
|
13553 | pick: __webpack_require__(274),
|
13554 | pickAll: __webpack_require__(103),
|
13555 | pickBy: __webpack_require__(275),
|
13556 | pipe: __webpack_require__(104),
|
13557 | pipeK: __webpack_require__(276),
|
13558 | pipeP: __webpack_require__(105),
|
13559 | pluck: __webpack_require__(26),
|
13560 | prepend: __webpack_require__(106),
|
13561 | product: __webpack_require__(277),
|
13562 | project: __webpack_require__(278),
|
13563 | prop: __webpack_require__(54),
|
13564 | propEq: __webpack_require__(279),
|
13565 | propIs: __webpack_require__(280),
|
13566 | propOr: __webpack_require__(281),
|
13567 | propSatisfies: __webpack_require__(282),
|
13568 | props: __webpack_require__(283),
|
13569 | range: __webpack_require__(284),
|
13570 | reduce: __webpack_require__(13),
|
13571 | reduceBy: __webpack_require__(41),
|
13572 | reduceRight: __webpack_require__(107),
|
13573 | reduceWhile: __webpack_require__(285),
|
13574 | reduced: __webpack_require__(286),
|
13575 | reject: __webpack_require__(42),
|
13576 | remove: __webpack_require__(287),
|
13577 | repeat: __webpack_require__(288),
|
13578 | replace: __webpack_require__(289),
|
13579 | reverse: __webpack_require__(43),
|
13580 | scan: __webpack_require__(290),
|
13581 | sequence: __webpack_require__(108),
|
13582 | set: __webpack_require__(291),
|
13583 | slice: __webpack_require__(18),
|
13584 | sort: __webpack_require__(292),
|
13585 | sortBy: __webpack_require__(293),
|
13586 | sortWith: __webpack_require__(294),
|
13587 | split: __webpack_require__(295),
|
13588 | splitAt: __webpack_require__(296),
|
13589 | splitEvery: __webpack_require__(297),
|
13590 | splitWhen: __webpack_require__(298),
|
13591 | subtract: __webpack_require__(299),
|
13592 | sum: __webpack_require__(109),
|
13593 | symmetricDifference: __webpack_require__(300),
|
13594 | symmetricDifferenceWith: __webpack_require__(301),
|
13595 | tail: __webpack_require__(55),
|
13596 | take: __webpack_require__(110),
|
13597 | takeLast: __webpack_require__(302),
|
13598 | takeLastWhile: __webpack_require__(303),
|
13599 | takeWhile: __webpack_require__(304),
|
13600 | tap: __webpack_require__(305),
|
13601 | test: __webpack_require__(306),
|
13602 | times: __webpack_require__(111),
|
13603 | toLower: __webpack_require__(307),
|
13604 | toPairs: __webpack_require__(308),
|
13605 | toPairsIn: __webpack_require__(309),
|
13606 | toString: __webpack_require__(27),
|
13607 | toUpper: __webpack_require__(310),
|
13608 | transduce: __webpack_require__(311),
|
13609 | transpose: __webpack_require__(312),
|
13610 | traverse: __webpack_require__(313),
|
13611 | trim: __webpack_require__(314),
|
13612 | tryCatch: __webpack_require__(315),
|
13613 | type: __webpack_require__(56),
|
13614 | unapply: __webpack_require__(316),
|
13615 | unary: __webpack_require__(317),
|
13616 | uncurryN: __webpack_require__(318),
|
13617 | unfold: __webpack_require__(319),
|
13618 | union: __webpack_require__(320),
|
13619 | unionWith: __webpack_require__(321),
|
13620 | uniq: __webpack_require__(57),
|
13621 | uniqBy: __webpack_require__(112),
|
13622 | uniqWith: __webpack_require__(58),
|
13623 | unless: __webpack_require__(322),
|
13624 | unnest: __webpack_require__(323),
|
13625 | until: __webpack_require__(324),
|
13626 | update: __webpack_require__(113),
|
13627 | useWith: __webpack_require__(114),
|
13628 | values: __webpack_require__(115),
|
13629 | valuesIn: __webpack_require__(325),
|
13630 | view: __webpack_require__(326),
|
13631 | when: __webpack_require__(327),
|
13632 | where: __webpack_require__(116),
|
13633 | whereEq: __webpack_require__(328),
|
13634 | without: __webpack_require__(329),
|
13635 | xprod: __webpack_require__(330),
|
13636 | zip: __webpack_require__(331),
|
13637 | zipObj: __webpack_require__(332),
|
13638 | zipWith: __webpack_require__(333)
|
13639 | };
|
13640 |
|
13641 |
|
13642 | /***/ }),
|
13643 | /* 140 */
|
13644 | /***/ (function(module, exports, __webpack_require__) {
|
13645 |
|
13646 | var always = __webpack_require__(19);
|
13647 |
|
13648 |
|
13649 | /**
|
13650 | * A function that always returns `false`. Any passed in parameters are ignored.
|
13651 | *
|
13652 | * @func
|
13653 | * @memberOf R
|
13654 | * @since v0.9.0
|
13655 | * @category Function
|
13656 | * @sig * -> Boolean
|
13657 | * @param {*}
|
13658 | * @return {Boolean}
|
13659 | * @see R.always, R.T
|
13660 | * @example
|
13661 | *
|
13662 | * R.F(); //=> false
|
13663 | */
|
13664 | module.exports = always(false);
|
13665 |
|
13666 |
|
13667 | /***/ }),
|
13668 | /* 141 */
|
13669 | /***/ (function(module, exports, __webpack_require__) {
|
13670 |
|
13671 | var always = __webpack_require__(19);
|
13672 |
|
13673 |
|
13674 | /**
|
13675 | * A function that always returns `true`. Any passed in parameters are ignored.
|
13676 | *
|
13677 | * @func
|
13678 | * @memberOf R
|
13679 | * @since v0.9.0
|
13680 | * @category Function
|
13681 | * @sig * -> Boolean
|
13682 | * @param {*}
|
13683 | * @return {Boolean}
|
13684 | * @see R.always, R.F
|
13685 | * @example
|
13686 | *
|
13687 | * R.T(); //=> true
|
13688 | */
|
13689 | module.exports = always(true);
|
13690 |
|
13691 |
|
13692 | /***/ }),
|
13693 | /* 142 */
|
13694 | /***/ (function(module, exports) {
|
13695 |
|
13696 | /**
|
13697 | * A special placeholder value used to specify "gaps" within curried functions,
|
13698 | * allowing partial application of any combination of arguments, regardless of
|
13699 | * their positions.
|
13700 | *
|
13701 | * If `g` is a curried ternary function and `_` is `R.__`, the following are
|
13702 | * equivalent:
|
13703 | *
|
13704 | * - `g(1, 2, 3)`
|
13705 | * - `g(_, 2, 3)(1)`
|
13706 | * - `g(_, _, 3)(1)(2)`
|
13707 | * - `g(_, _, 3)(1, 2)`
|
13708 | * - `g(_, 2, _)(1, 3)`
|
13709 | * - `g(_, 2)(1)(3)`
|
13710 | * - `g(_, 2)(1, 3)`
|
13711 | * - `g(_, 2)(_, 3)(1)`
|
13712 | *
|
13713 | * @constant
|
13714 | * @memberOf R
|
13715 | * @since v0.6.0
|
13716 | * @category Function
|
13717 | * @example
|
13718 | *
|
13719 | * var greet = R.replace('{name}', R.__, 'Hello, {name}!');
|
13720 | * greet('Alice'); //=> 'Hello, Alice!'
|
13721 | */
|
13722 | module.exports = {'@@functional/placeholder': true};
|
13723 |
|
13724 |
|
13725 | /***/ }),
|
13726 | /* 143 */
|
13727 | /***/ (function(module, exports, __webpack_require__) {
|
13728 |
|
13729 | var _concat = __webpack_require__(9);
|
13730 | var _curry1 = __webpack_require__(1);
|
13731 | var curryN = __webpack_require__(5);
|
13732 |
|
13733 |
|
13734 | /**
|
13735 | * Creates a new list iteration function from an existing one by adding two new
|
13736 | * parameters to its callback function: the current index, and the entire list.
|
13737 | *
|
13738 | * This would turn, for instance, Ramda's simple `map` function into one that
|
13739 | * more closely resembles `Array.prototype.map`. Note that this will only work
|
13740 | * for functions in which the iteration callback function is the first
|
13741 | * parameter, and where the list is the last parameter. (This latter might be
|
13742 | * unimportant if the list parameter is not used.)
|
13743 | *
|
13744 | * @func
|
13745 | * @memberOf R
|
13746 | * @since v0.15.0
|
13747 | * @category Function
|
13748 | * @category List
|
13749 | * @sig ((a ... -> b) ... -> [a] -> *) -> (a ..., Int, [a] -> b) ... -> [a] -> *)
|
13750 | * @param {Function} fn A list iteration function that does not pass index or list to its callback
|
13751 | * @return {Function} An altered list iteration function that passes (item, index, list) to its callback
|
13752 | * @example
|
13753 | *
|
13754 | * var mapIndexed = R.addIndex(R.map);
|
13755 | * mapIndexed((val, idx) => idx + '-' + val, ['f', 'o', 'o', 'b', 'a', 'r']);
|
13756 | * //=> ['0-f', '1-o', '2-o', '3-b', '4-a', '5-r']
|
13757 | */
|
13758 | module.exports = _curry1(function addIndex(fn) {
|
13759 | return curryN(fn.length, function() {
|
13760 | var idx = 0;
|
13761 | var origFn = arguments[0];
|
13762 | var list = arguments[arguments.length - 1];
|
13763 | var args = Array.prototype.slice.call(arguments, 0);
|
13764 | args[0] = function() {
|
13765 | var result = origFn.apply(this, _concat(arguments, [idx, list]));
|
13766 | idx += 1;
|
13767 | return result;
|
13768 | };
|
13769 | return fn.apply(this, args);
|
13770 | });
|
13771 | });
|
13772 |
|
13773 |
|
13774 | /***/ }),
|
13775 | /* 144 */
|
13776 | /***/ (function(module, exports, __webpack_require__) {
|
13777 |
|
13778 | var _curry2 = __webpack_require__(0);
|
13779 | var _dispatchable = __webpack_require__(3);
|
13780 | var _xall = __webpack_require__(215);
|
13781 |
|
13782 |
|
13783 | /**
|
13784 | * Returns `true` if all elements of the list match the predicate, `false` if
|
13785 | * there are any that don't.
|
13786 | *
|
13787 | * Dispatches to the `all` method of the second argument, if present.
|
13788 | *
|
13789 | * Acts as a transducer if a transformer is given in list position.
|
13790 | *
|
13791 | * @func
|
13792 | * @memberOf R
|
13793 | * @since v0.1.0
|
13794 | * @category List
|
13795 | * @sig (a -> Boolean) -> [a] -> Boolean
|
13796 | * @param {Function} fn The predicate function.
|
13797 | * @param {Array} list The array to consider.
|
13798 | * @return {Boolean} `true` if the predicate is satisfied by every element, `false`
|
13799 | * otherwise.
|
13800 | * @see R.any, R.none, R.transduce
|
13801 | * @example
|
13802 | *
|
13803 | * var equals3 = R.equals(3);
|
13804 | * R.all(equals3)([3, 3, 3, 3]); //=> true
|
13805 | * R.all(equals3)([3, 3, 1, 3]); //=> false
|
13806 | */
|
13807 | module.exports = _curry2(_dispatchable(['all'], _xall, function all(fn, list) {
|
13808 | var idx = 0;
|
13809 | while (idx < list.length) {
|
13810 | if (!fn(list[idx])) {
|
13811 | return false;
|
13812 | }
|
13813 | idx += 1;
|
13814 | }
|
13815 | return true;
|
13816 | }));
|
13817 |
|
13818 |
|
13819 | /***/ }),
|
13820 | /* 145 */
|
13821 | /***/ (function(module, exports, __webpack_require__) {
|
13822 |
|
13823 | var _curry1 = __webpack_require__(1);
|
13824 | var curryN = __webpack_require__(5);
|
13825 | var max = __webpack_require__(20);
|
13826 | var pluck = __webpack_require__(26);
|
13827 | var reduce = __webpack_require__(13);
|
13828 |
|
13829 |
|
13830 | /**
|
13831 | * Takes a list of predicates and returns a predicate that returns true for a
|
13832 | * given list of arguments if every one of the provided predicates is satisfied
|
13833 | * by those arguments.
|
13834 | *
|
13835 | * The function returned is a curried function whose arity matches that of the
|
13836 | * highest-arity predicate.
|
13837 | *
|
13838 | * @func
|
13839 | * @memberOf R
|
13840 | * @since v0.9.0
|
13841 | * @category Logic
|
13842 | * @sig [(*... -> Boolean)] -> (*... -> Boolean)
|
13843 | * @param {Array} predicates An array of predicates to check
|
13844 | * @return {Function} The combined predicate
|
13845 | * @see R.anyPass
|
13846 | * @example
|
13847 | *
|
13848 | * var isQueen = R.propEq('rank', 'Q');
|
13849 | * var isSpade = R.propEq('suit', '♠︎');
|
13850 | * var isQueenOfSpades = R.allPass([isQueen, isSpade]);
|
13851 | *
|
13852 | * isQueenOfSpades({rank: 'Q', suit: '♣︎'}); //=> false
|
13853 | * isQueenOfSpades({rank: 'Q', suit: '♠︎'}); //=> true
|
13854 | */
|
13855 | module.exports = _curry1(function allPass(preds) {
|
13856 | return curryN(reduce(max, 0, pluck('length', preds)), function() {
|
13857 | var idx = 0;
|
13858 | var len = preds.length;
|
13859 | while (idx < len) {
|
13860 | if (!preds[idx].apply(this, arguments)) {
|
13861 | return false;
|
13862 | }
|
13863 | idx += 1;
|
13864 | }
|
13865 | return true;
|
13866 | });
|
13867 | });
|
13868 |
|
13869 |
|
13870 | /***/ }),
|
13871 | /* 146 */
|
13872 | /***/ (function(module, exports, __webpack_require__) {
|
13873 |
|
13874 | var _curry1 = __webpack_require__(1);
|
13875 | var curryN = __webpack_require__(5);
|
13876 | var max = __webpack_require__(20);
|
13877 | var pluck = __webpack_require__(26);
|
13878 | var reduce = __webpack_require__(13);
|
13879 |
|
13880 |
|
13881 | /**
|
13882 | * Takes a list of predicates and returns a predicate that returns true for a
|
13883 | * given list of arguments if at least one of the provided predicates is
|
13884 | * satisfied by those arguments.
|
13885 | *
|
13886 | * The function returned is a curried function whose arity matches that of the
|
13887 | * highest-arity predicate.
|
13888 | *
|
13889 | * @func
|
13890 | * @memberOf R
|
13891 | * @since v0.9.0
|
13892 | * @category Logic
|
13893 | * @sig [(*... -> Boolean)] -> (*... -> Boolean)
|
13894 | * @param {Array} predicates An array of predicates to check
|
13895 | * @return {Function} The combined predicate
|
13896 | * @see R.allPass
|
13897 | * @example
|
13898 | *
|
13899 | * var isClub = R.propEq('suit', '♣');
|
13900 | * var isSpade = R.propEq('suit', '♠');
|
13901 | * var isBlackCard = R.anyPass([isClub, isSpade]);
|
13902 | *
|
13903 | * isBlackCard({rank: '10', suit: '♣'}); //=> true
|
13904 | * isBlackCard({rank: 'Q', suit: '♠'}); //=> true
|
13905 | * isBlackCard({rank: 'Q', suit: '♦'}); //=> false
|
13906 | */
|
13907 | module.exports = _curry1(function anyPass(preds) {
|
13908 | return curryN(reduce(max, 0, pluck('length', preds)), function() {
|
13909 | var idx = 0;
|
13910 | var len = preds.length;
|
13911 | while (idx < len) {
|
13912 | if (preds[idx].apply(this, arguments)) {
|
13913 | return true;
|
13914 | }
|
13915 | idx += 1;
|
13916 | }
|
13917 | return false;
|
13918 | });
|
13919 | });
|
13920 |
|
13921 |
|
13922 | /***/ }),
|
13923 | /* 147 */
|
13924 | /***/ (function(module, exports, __webpack_require__) {
|
13925 |
|
13926 | var _aperture = __webpack_require__(198);
|
13927 | var _curry2 = __webpack_require__(0);
|
13928 | var _dispatchable = __webpack_require__(3);
|
13929 | var _xaperture = __webpack_require__(216);
|
13930 |
|
13931 |
|
13932 | /**
|
13933 | * Returns a new list, composed of n-tuples of consecutive elements If `n` is
|
13934 | * greater than the length of the list, an empty list is returned.
|
13935 | *
|
13936 | * Acts as a transducer if a transformer is given in list position.
|
13937 | *
|
13938 | * @func
|
13939 | * @memberOf R
|
13940 | * @since v0.12.0
|
13941 | * @category List
|
13942 | * @sig Number -> [a] -> [[a]]
|
13943 | * @param {Number} n The size of the tuples to create
|
13944 | * @param {Array} list The list to split into `n`-length tuples
|
13945 | * @return {Array} The resulting list of `n`-length tuples
|
13946 | * @see R.transduce
|
13947 | * @example
|
13948 | *
|
13949 | * R.aperture(2, [1, 2, 3, 4, 5]); //=> [[1, 2], [2, 3], [3, 4], [4, 5]]
|
13950 | * R.aperture(3, [1, 2, 3, 4, 5]); //=> [[1, 2, 3], [2, 3, 4], [3, 4, 5]]
|
13951 | * R.aperture(7, [1, 2, 3, 4, 5]); //=> []
|
13952 | */
|
13953 | module.exports = _curry2(_dispatchable([], _xaperture, _aperture));
|
13954 |
|
13955 |
|
13956 | /***/ }),
|
13957 | /* 148 */
|
13958 | /***/ (function(module, exports, __webpack_require__) {
|
13959 |
|
13960 | var _concat = __webpack_require__(9);
|
13961 | var _curry2 = __webpack_require__(0);
|
13962 |
|
13963 |
|
13964 | /**
|
13965 | * Returns a new list containing the contents of the given list, followed by
|
13966 | * the given element.
|
13967 | *
|
13968 | * @func
|
13969 | * @memberOf R
|
13970 | * @since v0.1.0
|
13971 | * @category List
|
13972 | * @sig a -> [a] -> [a]
|
13973 | * @param {*} el The element to add to the end of the new list.
|
13974 | * @param {Array} list The list of elements to add a new item to.
|
13975 | * list.
|
13976 | * @return {Array} A new list containing the elements of the old list followed by `el`.
|
13977 | * @see R.prepend
|
13978 | * @example
|
13979 | *
|
13980 | * R.append('tests', ['write', 'more']); //=> ['write', 'more', 'tests']
|
13981 | * R.append('tests', []); //=> ['tests']
|
13982 | * R.append(['tests'], ['write', 'more']); //=> ['write', 'more', ['tests']]
|
13983 | */
|
13984 | module.exports = _curry2(function append(el, list) {
|
13985 | return _concat(list, [el]);
|
13986 | });
|
13987 |
|
13988 |
|
13989 | /***/ }),
|
13990 | /* 149 */
|
13991 | /***/ (function(module, exports, __webpack_require__) {
|
13992 |
|
13993 | var _curry1 = __webpack_require__(1);
|
13994 | var apply = __webpack_require__(63);
|
13995 | var curryN = __webpack_require__(5);
|
13996 | var map = __webpack_require__(7);
|
13997 | var max = __webpack_require__(20);
|
13998 | var pluck = __webpack_require__(26);
|
13999 | var reduce = __webpack_require__(13);
|
14000 | var values = __webpack_require__(115);
|
14001 |
|
14002 |
|
14003 | /**
|
14004 | * Given a spec object recursively mapping properties to functions, creates a
|
14005 | * function producing an object of the same structure, by mapping each property
|
14006 | * to the result of calling its associated function with the supplied arguments.
|
14007 | *
|
14008 | * @func
|
14009 | * @memberOf R
|
14010 | * @since v0.20.0
|
14011 | * @category Function
|
14012 | * @sig {k: ((a, b, ..., m) -> v)} -> ((a, b, ..., m) -> {k: v})
|
14013 | * @param {Object} spec an object recursively mapping properties to functions for
|
14014 | * producing the values for these properties.
|
14015 | * @return {Function} A function that returns an object of the same structure
|
14016 | * as `spec', with each property set to the value returned by calling its
|
14017 | * associated function with the supplied arguments.
|
14018 | * @see R.converge, R.juxt
|
14019 | * @example
|
14020 | *
|
14021 | * var getMetrics = R.applySpec({
|
14022 | * sum: R.add,
|
14023 | * nested: { mul: R.multiply }
|
14024 | * });
|
14025 | * getMetrics(2, 4); // => { sum: 6, nested: { mul: 8 } }
|
14026 | * @symb R.applySpec({ x: f, y: { z: g } })(a, b) = { x: f(a, b), y: { z: g(a, b) } }
|
14027 | */
|
14028 | module.exports = _curry1(function applySpec(spec) {
|
14029 | spec = map(function(v) { return typeof v == 'function' ? v : applySpec(v); },
|
14030 | spec);
|
14031 | return curryN(reduce(max, 0, pluck('length', values(spec))),
|
14032 | function() {
|
14033 | var args = arguments;
|
14034 | return map(function(f) { return apply(f, args); }, spec);
|
14035 | });
|
14036 | });
|
14037 |
|
14038 |
|
14039 | /***/ }),
|
14040 | /* 150 */
|
14041 | /***/ (function(module, exports, __webpack_require__) {
|
14042 |
|
14043 | var _curry3 = __webpack_require__(2);
|
14044 |
|
14045 |
|
14046 | /**
|
14047 | * Makes an ascending comparator function out of a function that returns a value
|
14048 | * that can be compared with `<` and `>`.
|
14049 | *
|
14050 | * @func
|
14051 | * @memberOf R
|
14052 | * @since v0.23.0
|
14053 | * @category Function
|
14054 | * @sig Ord b => (a -> b) -> a -> a -> Number
|
14055 | * @param {Function} fn A function of arity one that returns a value that can be compared
|
14056 | * @param {*} a The first item to be compared.
|
14057 | * @param {*} b The second item to be compared.
|
14058 | * @return {Number} `-1` if fn(a) < fn(b), `1` if fn(b) < fn(a), otherwise `0`
|
14059 | * @example
|
14060 | *
|
14061 | * var byAge = R.ascend(R.prop('age'));
|
14062 | * var people = [
|
14063 | * // ...
|
14064 | * ];
|
14065 | * var peopleByYoungestFirst = R.sort(byAge, people);
|
14066 | */
|
14067 | module.exports = _curry3(function ascend(fn, a, b) {
|
14068 | var aa = fn(a);
|
14069 | var bb = fn(b);
|
14070 | return aa < bb ? -1 : aa > bb ? 1 : 0;
|
14071 | });
|
14072 |
|
14073 |
|
14074 | /***/ }),
|
14075 | /* 151 */
|
14076 | /***/ (function(module, exports, __webpack_require__) {
|
14077 |
|
14078 | var _curry1 = __webpack_require__(1);
|
14079 | var nAry = __webpack_require__(40);
|
14080 |
|
14081 |
|
14082 | /**
|
14083 | * Wraps a function of any arity (including nullary) in a function that accepts
|
14084 | * exactly 2 parameters. Any extraneous parameters will not be passed to the
|
14085 | * supplied function.
|
14086 | *
|
14087 | * @func
|
14088 | * @memberOf R
|
14089 | * @since v0.2.0
|
14090 | * @category Function
|
14091 | * @sig (* -> c) -> (a, b -> c)
|
14092 | * @param {Function} fn The function to wrap.
|
14093 | * @return {Function} A new function wrapping `fn`. The new function is guaranteed to be of
|
14094 | * arity 2.
|
14095 | * @example
|
14096 | *
|
14097 | * var takesThreeArgs = function(a, b, c) {
|
14098 | * return [a, b, c];
|
14099 | * };
|
14100 | * takesThreeArgs.length; //=> 3
|
14101 | * takesThreeArgs(1, 2, 3); //=> [1, 2, 3]
|
14102 | *
|
14103 | * var takesTwoArgs = R.binary(takesThreeArgs);
|
14104 | * takesTwoArgs.length; //=> 2
|
14105 | * // Only 2 arguments are passed to the wrapped function
|
14106 | * takesTwoArgs(1, 2, 3); //=> [1, 2, undefined]
|
14107 | * @symb R.binary(f)(a, b, c) = f(a, b)
|
14108 | */
|
14109 | module.exports = _curry1(function binary(fn) {
|
14110 | return nAry(2, fn);
|
14111 | });
|
14112 |
|
14113 |
|
14114 | /***/ }),
|
14115 | /* 152 */
|
14116 | /***/ (function(module, exports, __webpack_require__) {
|
14117 |
|
14118 | var _curry2 = __webpack_require__(0);
|
14119 | var _isFunction = __webpack_require__(34);
|
14120 | var and = __webpack_require__(61);
|
14121 | var lift = __webpack_require__(39);
|
14122 |
|
14123 |
|
14124 | /**
|
14125 | * A function which calls the two provided functions and returns the `&&`
|
14126 | * of the results.
|
14127 | * It returns the result of the first function if it is false-y and the result
|
14128 | * of the second function otherwise. Note that this is short-circuited,
|
14129 | * meaning that the second function will not be invoked if the first returns a
|
14130 | * false-y value.
|
14131 | *
|
14132 | * In addition to functions, `R.both` also accepts any fantasy-land compatible
|
14133 | * applicative functor.
|
14134 | *
|
14135 | * @func
|
14136 | * @memberOf R
|
14137 | * @since v0.12.0
|
14138 | * @category Logic
|
14139 | * @sig (*... -> Boolean) -> (*... -> Boolean) -> (*... -> Boolean)
|
14140 | * @param {Function} f A predicate
|
14141 | * @param {Function} g Another predicate
|
14142 | * @return {Function} a function that applies its arguments to `f` and `g` and `&&`s their outputs together.
|
14143 | * @see R.and
|
14144 | * @example
|
14145 | *
|
14146 | * var gt10 = R.gt(R.__, 10)
|
14147 | * var lt20 = R.lt(R.__, 20)
|
14148 | * var f = R.both(gt10, lt20);
|
14149 | * f(15); //=> true
|
14150 | * f(30); //=> false
|
14151 | */
|
14152 | module.exports = _curry2(function both(f, g) {
|
14153 | return _isFunction(f) ?
|
14154 | function _both() {
|
14155 | return f.apply(this, arguments) && g.apply(this, arguments);
|
14156 | } :
|
14157 | lift(and)(f, g);
|
14158 | });
|
14159 |
|
14160 |
|
14161 | /***/ }),
|
14162 | /* 153 */
|
14163 | /***/ (function(module, exports, __webpack_require__) {
|
14164 |
|
14165 | var curry = __webpack_require__(31);
|
14166 |
|
14167 |
|
14168 | /**
|
14169 | * Returns the result of calling its first argument with the remaining
|
14170 | * arguments. This is occasionally useful as a converging function for
|
14171 | * `R.converge`: the left branch can produce a function while the right branch
|
14172 | * produces a value to be passed to that function as an argument.
|
14173 | *
|
14174 | * @func
|
14175 | * @memberOf R
|
14176 | * @since v0.9.0
|
14177 | * @category Function
|
14178 | * @sig (*... -> a),*... -> a
|
14179 | * @param {Function} fn The function to apply to the remaining arguments.
|
14180 | * @param {...*} args Any number of positional arguments.
|
14181 | * @return {*}
|
14182 | * @see R.apply
|
14183 | * @example
|
14184 | *
|
14185 | * R.call(R.add, 1, 2); //=> 3
|
14186 | *
|
14187 | * var indentN = R.pipe(R.times(R.always(' ')),
|
14188 | * R.join(''),
|
14189 | * R.replace(/^(?!$)/gm));
|
14190 | *
|
14191 | * var format = R.converge(R.call, [
|
14192 | * R.pipe(R.prop('indent'), indentN),
|
14193 | * R.prop('value')
|
14194 | * ]);
|
14195 | *
|
14196 | * format({indent: 2, value: 'foo\nbar\nbaz\n'}); //=> ' foo\n bar\n baz\n'
|
14197 | * @symb R.call(f, a, b) = f(a, b)
|
14198 | */
|
14199 | module.exports = curry(function call(fn) {
|
14200 | return fn.apply(this, Array.prototype.slice.call(arguments, 1));
|
14201 | });
|
14202 |
|
14203 |
|
14204 | /***/ }),
|
14205 | /* 154 */
|
14206 | /***/ (function(module, exports, __webpack_require__) {
|
14207 |
|
14208 | var _curry3 = __webpack_require__(2);
|
14209 |
|
14210 | /**
|
14211 | * Restricts a number to be within a range.
|
14212 | *
|
14213 | * Also works for other ordered types such as Strings and Dates.
|
14214 | *
|
14215 | * @func
|
14216 | * @memberOf R
|
14217 | * @since v0.20.0
|
14218 | * @category Relation
|
14219 | * @sig Ord a => a -> a -> a -> a
|
14220 | * @param {Number} minimum The lower limit of the clamp (inclusive)
|
14221 | * @param {Number} maximum The upper limit of the clamp (inclusive)
|
14222 | * @param {Number} value Value to be clamped
|
14223 | * @return {Number} Returns `minimum` when `val < minimum`, `maximum` when `val > maximum`, returns `val` otherwise
|
14224 | * @example
|
14225 | *
|
14226 | * R.clamp(1, 10, -5) // => 1
|
14227 | * R.clamp(1, 10, 15) // => 10
|
14228 | * R.clamp(1, 10, 4) // => 4
|
14229 | */
|
14230 | module.exports = _curry3(function clamp(min, max, value) {
|
14231 | if (min > max) {
|
14232 | throw new Error('min must not be greater than max in clamp(min, max, value)');
|
14233 | }
|
14234 | return value < min ? min :
|
14235 | value > max ? max :
|
14236 | value;
|
14237 | });
|
14238 |
|
14239 |
|
14240 | /***/ }),
|
14241 | /* 155 */
|
14242 | /***/ (function(module, exports, __webpack_require__) {
|
14243 |
|
14244 | var _clone = __webpack_require__(77);
|
14245 | var _curry1 = __webpack_require__(1);
|
14246 |
|
14247 |
|
14248 | /**
|
14249 | * Creates a deep copy of the value which may contain (nested) `Array`s and
|
14250 | * `Object`s, `Number`s, `String`s, `Boolean`s and `Date`s. `Function`s are
|
14251 | * assigned by reference rather than copied
|
14252 | *
|
14253 | * Dispatches to a `clone` method if present.
|
14254 | *
|
14255 | * @func
|
14256 | * @memberOf R
|
14257 | * @since v0.1.0
|
14258 | * @category Object
|
14259 | * @sig {*} -> {*}
|
14260 | * @param {*} value The object or array to clone
|
14261 | * @return {*} A deeply cloned copy of `val`
|
14262 | * @example
|
14263 | *
|
14264 | * var objects = [{}, {}, {}];
|
14265 | * var objectsClone = R.clone(objects);
|
14266 | * objects === objectsClone; //=> false
|
14267 | * objects[0] === objectsClone[0]; //=> false
|
14268 | */
|
14269 | module.exports = _curry1(function clone(value) {
|
14270 | return value != null && typeof value.clone === 'function' ?
|
14271 | value.clone() :
|
14272 | _clone(value, [], [], true);
|
14273 | });
|
14274 |
|
14275 |
|
14276 | /***/ }),
|
14277 | /* 156 */
|
14278 | /***/ (function(module, exports, __webpack_require__) {
|
14279 |
|
14280 | var _curry1 = __webpack_require__(1);
|
14281 |
|
14282 |
|
14283 | /**
|
14284 | * Makes a comparator function out of a function that reports whether the first
|
14285 | * element is less than the second.
|
14286 | *
|
14287 | * @func
|
14288 | * @memberOf R
|
14289 | * @since v0.1.0
|
14290 | * @category Function
|
14291 | * @sig (a, b -> Boolean) -> (a, b -> Number)
|
14292 | * @param {Function} pred A predicate function of arity two which will return `true` if the first argument
|
14293 | * is less than the second, `false` otherwise
|
14294 | * @return {Function} A Function :: a -> b -> Int that returns `-1` if a < b, `1` if b < a, otherwise `0`
|
14295 | * @example
|
14296 | *
|
14297 | * var byAge = R.comparator((a, b) => a.age < b.age);
|
14298 | * var people = [
|
14299 | * // ...
|
14300 | * ];
|
14301 | * var peopleByIncreasingAge = R.sort(byAge, people);
|
14302 | */
|
14303 | module.exports = _curry1(function comparator(pred) {
|
14304 | return function(a, b) {
|
14305 | return pred(a, b) ? -1 : pred(b, a) ? 1 : 0;
|
14306 | };
|
14307 | });
|
14308 |
|
14309 |
|
14310 | /***/ }),
|
14311 | /* 157 */
|
14312 | /***/ (function(module, exports, __webpack_require__) {
|
14313 |
|
14314 | var lift = __webpack_require__(39);
|
14315 | var not = __webpack_require__(99);
|
14316 |
|
14317 |
|
14318 | /**
|
14319 | * Takes a function `f` and returns a function `g` such that if called with the same arguments
|
14320 | * when `f` returns a "truthy" value, `g` returns `false` and when `f` returns a "falsy" value `g` returns `true`.
|
14321 | *
|
14322 | * `R.complement` may be applied to any functor
|
14323 | *
|
14324 | * @func
|
14325 | * @memberOf R
|
14326 | * @since v0.12.0
|
14327 | * @category Logic
|
14328 | * @sig (*... -> *) -> (*... -> Boolean)
|
14329 | * @param {Function} f
|
14330 | * @return {Function}
|
14331 | * @see R.not
|
14332 | * @example
|
14333 | *
|
14334 | * var isNotNil = R.complement(R.isNil);
|
14335 | * isNil(null); //=> true
|
14336 | * isNotNil(null); //=> false
|
14337 | * isNil(7); //=> false
|
14338 | * isNotNil(7); //=> true
|
14339 | */
|
14340 | module.exports = lift(not);
|
14341 |
|
14342 |
|
14343 | /***/ }),
|
14344 | /* 158 */
|
14345 | /***/ (function(module, exports, __webpack_require__) {
|
14346 |
|
14347 | var pipeP = __webpack_require__(105);
|
14348 | var reverse = __webpack_require__(43);
|
14349 |
|
14350 |
|
14351 | /**
|
14352 | * Performs right-to-left composition of one or more Promise-returning
|
14353 | * functions. The rightmost function may have any arity; the remaining
|
14354 | * functions must be unary.
|
14355 | *
|
14356 | * @func
|
14357 | * @memberOf R
|
14358 | * @since v0.10.0
|
14359 | * @category Function
|
14360 | * @sig ((y -> Promise z), (x -> Promise y), ..., (a -> Promise b)) -> (a -> Promise z)
|
14361 | * @param {...Function} functions The functions to compose
|
14362 | * @return {Function}
|
14363 | * @see R.pipeP
|
14364 | * @example
|
14365 | *
|
14366 | * var db = {
|
14367 | * users: {
|
14368 | * JOE: {
|
14369 | * name: 'Joe',
|
14370 | * followers: ['STEVE', 'SUZY']
|
14371 | * }
|
14372 | * }
|
14373 | * }
|
14374 | *
|
14375 | * // We'll pretend to do a db lookup which returns a promise
|
14376 | * var lookupUser = (userId) => Promise.resolve(db.users[userId])
|
14377 | * var lookupFollowers = (user) => Promise.resolve(user.followers)
|
14378 | * lookupUser('JOE').then(lookupFollowers)
|
14379 | *
|
14380 | * // followersForUser :: String -> Promise [UserId]
|
14381 | * var followersForUser = R.composeP(lookupFollowers, lookupUser);
|
14382 | * followersForUser('JOE').then(followers => console.log('Followers:', followers))
|
14383 | * // Followers: ["STEVE","SUZY"]
|
14384 | */
|
14385 | module.exports = function composeP() {
|
14386 | if (arguments.length === 0) {
|
14387 | throw new Error('composeP requires at least one argument');
|
14388 | }
|
14389 | return pipeP.apply(this, reverse(arguments));
|
14390 | };
|
14391 |
|
14392 |
|
14393 | /***/ }),
|
14394 | /* 159 */
|
14395 | /***/ (function(module, exports, __webpack_require__) {
|
14396 |
|
14397 | var _arity = __webpack_require__(11);
|
14398 | var _curry1 = __webpack_require__(1);
|
14399 | var map = __webpack_require__(7);
|
14400 | var max = __webpack_require__(20);
|
14401 | var reduce = __webpack_require__(13);
|
14402 |
|
14403 |
|
14404 | /**
|
14405 | * Returns a function, `fn`, which encapsulates `if/else, if/else, ...` logic.
|
14406 | * `R.cond` takes a list of [predicate, transformer] pairs. All of the arguments
|
14407 | * to `fn` are applied to each of the predicates in turn until one returns a
|
14408 | * "truthy" value, at which point `fn` returns the result of applying its
|
14409 | * arguments to the corresponding transformer. If none of the predicates
|
14410 | * matches, `fn` returns undefined.
|
14411 | *
|
14412 | * @func
|
14413 | * @memberOf R
|
14414 | * @since v0.6.0
|
14415 | * @category Logic
|
14416 | * @sig [[(*... -> Boolean),(*... -> *)]] -> (*... -> *)
|
14417 | * @param {Array} pairs A list of [predicate, transformer]
|
14418 | * @return {Function}
|
14419 | * @example
|
14420 | *
|
14421 | * var fn = R.cond([
|
14422 | * [R.equals(0), R.always('water freezes at 0°C')],
|
14423 | * [R.equals(100), R.always('water boils at 100°C')],
|
14424 | * [R.T, temp => 'nothing special happens at ' + temp + '°C']
|
14425 | * ]);
|
14426 | * fn(0); //=> 'water freezes at 0°C'
|
14427 | * fn(50); //=> 'nothing special happens at 50°C'
|
14428 | * fn(100); //=> 'water boils at 100°C'
|
14429 | */
|
14430 | module.exports = _curry1(function cond(pairs) {
|
14431 | var arity = reduce(max,
|
14432 | 0,
|
14433 | map(function(pair) { return pair[0].length; }, pairs));
|
14434 | return _arity(arity, function() {
|
14435 | var idx = 0;
|
14436 | while (idx < pairs.length) {
|
14437 | if (pairs[idx][0].apply(this, arguments)) {
|
14438 | return pairs[idx][1].apply(this, arguments);
|
14439 | }
|
14440 | idx += 1;
|
14441 | }
|
14442 | });
|
14443 | });
|
14444 |
|
14445 |
|
14446 | /***/ }),
|
14447 | /* 160 */
|
14448 | /***/ (function(module, exports, __webpack_require__) {
|
14449 |
|
14450 | var _curry1 = __webpack_require__(1);
|
14451 | var constructN = __webpack_require__(67);
|
14452 |
|
14453 |
|
14454 | /**
|
14455 | * Wraps a constructor function inside a curried function that can be called
|
14456 | * with the same arguments and returns the same type.
|
14457 | *
|
14458 | * @func
|
14459 | * @memberOf R
|
14460 | * @since v0.1.0
|
14461 | * @category Function
|
14462 | * @sig (* -> {*}) -> (* -> {*})
|
14463 | * @param {Function} fn The constructor function to wrap.
|
14464 | * @return {Function} A wrapped, curried constructor function.
|
14465 | * @example
|
14466 | *
|
14467 | * // Constructor function
|
14468 | * function Animal(kind) {
|
14469 | * this.kind = kind;
|
14470 | * };
|
14471 | * Animal.prototype.sighting = function() {
|
14472 | * return "It's a " + this.kind + "!";
|
14473 | * }
|
14474 | *
|
14475 | * var AnimalConstructor = R.construct(Animal)
|
14476 | *
|
14477 | * // Notice we no longer need the 'new' keyword:
|
14478 | * AnimalConstructor('Pig'); //=> {"kind": "Pig", "sighting": function (){...}};
|
14479 | *
|
14480 | * var animalTypes = ["Lion", "Tiger", "Bear"];
|
14481 | * var animalSighting = R.invoker(0, 'sighting');
|
14482 | * var sightNewAnimal = R.compose(animalSighting, AnimalConstructor);
|
14483 | * R.map(sightNewAnimal, animalTypes); //=> ["It's a Lion!", "It's a Tiger!", "It's a Bear!"]
|
14484 | */
|
14485 | module.exports = _curry1(function construct(Fn) {
|
14486 | return constructN(Fn.length, Fn);
|
14487 | });
|
14488 |
|
14489 |
|
14490 | /***/ }),
|
14491 | /* 161 */
|
14492 | /***/ (function(module, exports, __webpack_require__) {
|
14493 |
|
14494 | var _contains = __webpack_require__(17);
|
14495 | var _curry2 = __webpack_require__(0);
|
14496 |
|
14497 |
|
14498 | /**
|
14499 | * Returns `true` if the specified value is equal, in `R.equals` terms, to at
|
14500 | * least one element of the given list; `false` otherwise.
|
14501 | *
|
14502 | * @func
|
14503 | * @memberOf R
|
14504 | * @since v0.1.0
|
14505 | * @category List
|
14506 | * @sig a -> [a] -> Boolean
|
14507 | * @param {Object} a The item to compare against.
|
14508 | * @param {Array} list The array to consider.
|
14509 | * @return {Boolean} `true` if an equivalent item is in the list, `false` otherwise.
|
14510 | * @see R.any
|
14511 | * @example
|
14512 | *
|
14513 | * R.contains(3, [1, 2, 3]); //=> true
|
14514 | * R.contains(4, [1, 2, 3]); //=> false
|
14515 | * R.contains({ name: 'Fred' }, [{ name: 'Fred' }]); //=> true
|
14516 | * R.contains([42], [[42]]); //=> true
|
14517 | */
|
14518 | module.exports = _curry2(_contains);
|
14519 |
|
14520 |
|
14521 | /***/ }),
|
14522 | /* 162 */
|
14523 | /***/ (function(module, exports, __webpack_require__) {
|
14524 |
|
14525 | var reduceBy = __webpack_require__(41);
|
14526 |
|
14527 |
|
14528 | /**
|
14529 | * Counts the elements of a list according to how many match each value of a
|
14530 | * key generated by the supplied function. Returns an object mapping the keys
|
14531 | * produced by `fn` to the number of occurrences in the list. Note that all
|
14532 | * keys are coerced to strings because of how JavaScript objects work.
|
14533 | *
|
14534 | * Acts as a transducer if a transformer is given in list position.
|
14535 | *
|
14536 | * @func
|
14537 | * @memberOf R
|
14538 | * @since v0.1.0
|
14539 | * @category Relation
|
14540 | * @sig (a -> String) -> [a] -> {*}
|
14541 | * @param {Function} fn The function used to map values to keys.
|
14542 | * @param {Array} list The list to count elements from.
|
14543 | * @return {Object} An object mapping keys to number of occurrences in the list.
|
14544 | * @example
|
14545 | *
|
14546 | * var numbers = [1.0, 1.1, 1.2, 2.0, 3.0, 2.2];
|
14547 | * R.countBy(Math.floor)(numbers); //=> {'1': 3, '2': 2, '3': 1}
|
14548 | *
|
14549 | * var letters = ['a', 'b', 'A', 'a', 'B', 'c'];
|
14550 | * R.countBy(R.toLower)(letters); //=> {'a': 3, 'b': 2, 'c': 1}
|
14551 | */
|
14552 | module.exports = reduceBy(function(acc, elem) { return acc + 1; }, 0);
|
14553 |
|
14554 |
|
14555 | /***/ }),
|
14556 | /* 163 */
|
14557 | /***/ (function(module, exports, __webpack_require__) {
|
14558 |
|
14559 | var add = __webpack_require__(29);
|
14560 |
|
14561 |
|
14562 | /**
|
14563 | * Decrements its argument.
|
14564 | *
|
14565 | * @func
|
14566 | * @memberOf R
|
14567 | * @since v0.9.0
|
14568 | * @category Math
|
14569 | * @sig Number -> Number
|
14570 | * @param {Number} n
|
14571 | * @return {Number} n - 1
|
14572 | * @see R.inc
|
14573 | * @example
|
14574 | *
|
14575 | * R.dec(42); //=> 41
|
14576 | */
|
14577 | module.exports = add(-1);
|
14578 |
|
14579 |
|
14580 | /***/ }),
|
14581 | /* 164 */
|
14582 | /***/ (function(module, exports, __webpack_require__) {
|
14583 |
|
14584 | var _curry3 = __webpack_require__(2);
|
14585 |
|
14586 |
|
14587 | /**
|
14588 | * Makes a descending comparator function out of a function that returns a value
|
14589 | * that can be compared with `<` and `>`.
|
14590 | *
|
14591 | * @func
|
14592 | * @memberOf R
|
14593 | * @since v0.23.0
|
14594 | * @category Function
|
14595 | * @sig Ord b => (a -> b) -> a -> a -> Number
|
14596 | * @param {Function} fn A function of arity one that returns a value that can be compared
|
14597 | * @param {*} a The first item to be compared.
|
14598 | * @param {*} b The second item to be compared.
|
14599 | * @return {Number} `-1` if fn(a) > fn(b), `1` if fn(b) > fn(a), otherwise `0`
|
14600 | * @example
|
14601 | *
|
14602 | * var byAge = R.descend(R.prop('age'));
|
14603 | * var people = [
|
14604 | * // ...
|
14605 | * ];
|
14606 | * var peopleByOldestFirst = R.sort(byAge, people);
|
14607 | */
|
14608 | module.exports = _curry3(function descend(fn, a, b) {
|
14609 | var aa = fn(a);
|
14610 | var bb = fn(b);
|
14611 | return aa > bb ? -1 : aa < bb ? 1 : 0;
|
14612 | });
|
14613 |
|
14614 |
|
14615 | /***/ }),
|
14616 | /* 165 */
|
14617 | /***/ (function(module, exports, __webpack_require__) {
|
14618 |
|
14619 | var _curry2 = __webpack_require__(0);
|
14620 | var assoc = __webpack_require__(30);
|
14621 | var dissoc = __webpack_require__(72);
|
14622 |
|
14623 |
|
14624 | /**
|
14625 | * Makes a shallow clone of an object, omitting the property at the given path.
|
14626 | * Note that this copies and flattens prototype properties onto the new object
|
14627 | * as well. All non-primitive properties are copied by reference.
|
14628 | *
|
14629 | * @func
|
14630 | * @memberOf R
|
14631 | * @since v0.11.0
|
14632 | * @category Object
|
14633 | * @sig [String] -> {k: v} -> {k: v}
|
14634 | * @param {Array} path The path to the value to omit
|
14635 | * @param {Object} obj The object to clone
|
14636 | * @return {Object} A new object without the property at path
|
14637 | * @see R.assocPath
|
14638 | * @example
|
14639 | *
|
14640 | * R.dissocPath(['a', 'b', 'c'], {a: {b: {c: 42}}}); //=> {a: {b: {}}}
|
14641 | */
|
14642 | module.exports = _curry2(function dissocPath(path, obj) {
|
14643 | switch (path.length) {
|
14644 | case 0:
|
14645 | return obj;
|
14646 | case 1:
|
14647 | return dissoc(path[0], obj);
|
14648 | default:
|
14649 | var head = path[0];
|
14650 | var tail = Array.prototype.slice.call(path, 1);
|
14651 | return obj[head] == null ? obj : assoc(head, dissocPath(tail, obj[head]), obj);
|
14652 | }
|
14653 | });
|
14654 |
|
14655 |
|
14656 | /***/ }),
|
14657 | /* 166 */
|
14658 | /***/ (function(module, exports, __webpack_require__) {
|
14659 |
|
14660 | var _curry2 = __webpack_require__(0);
|
14661 |
|
14662 |
|
14663 | /**
|
14664 | * Divides two numbers. Equivalent to `a / b`.
|
14665 | *
|
14666 | * @func
|
14667 | * @memberOf R
|
14668 | * @since v0.1.0
|
14669 | * @category Math
|
14670 | * @sig Number -> Number -> Number
|
14671 | * @param {Number} a The first value.
|
14672 | * @param {Number} b The second value.
|
14673 | * @return {Number} The result of `a / b`.
|
14674 | * @see R.multiply
|
14675 | * @example
|
14676 | *
|
14677 | * R.divide(71, 100); //=> 0.71
|
14678 | *
|
14679 | * var half = R.divide(R.__, 2);
|
14680 | * half(42); //=> 21
|
14681 | *
|
14682 | * var reciprocal = R.divide(1);
|
14683 | * reciprocal(4); //=> 0.25
|
14684 | */
|
14685 | module.exports = _curry2(function divide(a, b) { return a / b; });
|
14686 |
|
14687 |
|
14688 | /***/ }),
|
14689 | /* 167 */
|
14690 | /***/ (function(module, exports, __webpack_require__) {
|
14691 |
|
14692 | var _curry2 = __webpack_require__(0);
|
14693 | var _dispatchable = __webpack_require__(3);
|
14694 | var _dropLast = __webpack_require__(200);
|
14695 | var _xdropLast = __webpack_require__(219);
|
14696 |
|
14697 |
|
14698 | /**
|
14699 | * Returns a list containing all but the last `n` elements of the given `list`.
|
14700 | *
|
14701 | * @func
|
14702 | * @memberOf R
|
14703 | * @since v0.16.0
|
14704 | * @category List
|
14705 | * @sig Number -> [a] -> [a]
|
14706 | * @sig Number -> String -> String
|
14707 | * @param {Number} n The number of elements of `list` to skip.
|
14708 | * @param {Array} list The list of elements to consider.
|
14709 | * @return {Array} A copy of the list with only the first `list.length - n` elements
|
14710 | * @see R.takeLast, R.drop, R.dropWhile, R.dropLastWhile
|
14711 | * @example
|
14712 | *
|
14713 | * R.dropLast(1, ['foo', 'bar', 'baz']); //=> ['foo', 'bar']
|
14714 | * R.dropLast(2, ['foo', 'bar', 'baz']); //=> ['foo']
|
14715 | * R.dropLast(3, ['foo', 'bar', 'baz']); //=> []
|
14716 | * R.dropLast(4, ['foo', 'bar', 'baz']); //=> []
|
14717 | * R.dropLast(3, 'ramda'); //=> 'ra'
|
14718 | */
|
14719 | module.exports = _curry2(_dispatchable([], _xdropLast, _dropLast));
|
14720 |
|
14721 |
|
14722 | /***/ }),
|
14723 | /* 168 */
|
14724 | /***/ (function(module, exports, __webpack_require__) {
|
14725 |
|
14726 | var _curry2 = __webpack_require__(0);
|
14727 | var _dispatchable = __webpack_require__(3);
|
14728 | var _dropLastWhile = __webpack_require__(201);
|
14729 | var _xdropLastWhile = __webpack_require__(220);
|
14730 |
|
14731 |
|
14732 | /**
|
14733 | * Returns a new list excluding all the tailing elements of a given list which
|
14734 | * satisfy the supplied predicate function. It passes each value from the right
|
14735 | * to the supplied predicate function, skipping elements until the predicate
|
14736 | * function returns a `falsy` value. The predicate function is applied to one argument:
|
14737 | * *(value)*.
|
14738 | *
|
14739 | * @func
|
14740 | * @memberOf R
|
14741 | * @since v0.16.0
|
14742 | * @category List
|
14743 | * @sig (a -> Boolean) -> [a] -> [a]
|
14744 | * @param {Function} predicate The function to be called on each element
|
14745 | * @param {Array} list The collection to iterate over.
|
14746 | * @return {Array} A new array without any trailing elements that return `falsy` values from the `predicate`.
|
14747 | * @see R.takeLastWhile, R.addIndex, R.drop, R.dropWhile
|
14748 | * @example
|
14749 | *
|
14750 | * var lteThree = x => x <= 3;
|
14751 | *
|
14752 | * R.dropLastWhile(lteThree, [1, 2, 3, 4, 3, 2, 1]); //=> [1, 2, 3, 4]
|
14753 | */
|
14754 | module.exports = _curry2(_dispatchable([], _xdropLastWhile, _dropLastWhile));
|
14755 |
|
14756 |
|
14757 | /***/ }),
|
14758 | /* 169 */
|
14759 | /***/ (function(module, exports, __webpack_require__) {
|
14760 |
|
14761 | var _curry1 = __webpack_require__(1);
|
14762 | var _dispatchable = __webpack_require__(3);
|
14763 | var _xdropRepeatsWith = __webpack_require__(89);
|
14764 | var dropRepeatsWith = __webpack_require__(74);
|
14765 | var equals = __webpack_require__(10);
|
14766 |
|
14767 |
|
14768 | /**
|
14769 | * Returns a new list without any consecutively repeating elements. `R.equals`
|
14770 | * is used to determine equality.
|
14771 | *
|
14772 | * Acts as a transducer if a transformer is given in list position.
|
14773 | *
|
14774 | * @func
|
14775 | * @memberOf R
|
14776 | * @since v0.14.0
|
14777 | * @category List
|
14778 | * @sig [a] -> [a]
|
14779 | * @param {Array} list The array to consider.
|
14780 | * @return {Array} `list` without repeating elements.
|
14781 | * @see R.transduce
|
14782 | * @example
|
14783 | *
|
14784 | * R.dropRepeats([1, 1, 1, 2, 3, 4, 4, 2, 2]); //=> [1, 2, 3, 4, 2]
|
14785 | */
|
14786 | module.exports = _curry1(_dispatchable([], _xdropRepeatsWith(equals), dropRepeatsWith(equals)));
|
14787 |
|
14788 |
|
14789 | /***/ }),
|
14790 | /* 170 */
|
14791 | /***/ (function(module, exports, __webpack_require__) {
|
14792 |
|
14793 | var _curry2 = __webpack_require__(0);
|
14794 | var _dispatchable = __webpack_require__(3);
|
14795 | var _xdropWhile = __webpack_require__(221);
|
14796 |
|
14797 |
|
14798 | /**
|
14799 | * Returns a new list excluding the leading elements of a given list which
|
14800 | * satisfy the supplied predicate function. It passes each value to the supplied
|
14801 | * predicate function, skipping elements while the predicate function returns
|
14802 | * `true`. The predicate function is applied to one argument: *(value)*.
|
14803 | *
|
14804 | * Dispatches to the `dropWhile` method of the second argument, if present.
|
14805 | *
|
14806 | * Acts as a transducer if a transformer is given in list position.
|
14807 | *
|
14808 | * @func
|
14809 | * @memberOf R
|
14810 | * @since v0.9.0
|
14811 | * @category List
|
14812 | * @sig (a -> Boolean) -> [a] -> [a]
|
14813 | * @param {Function} fn The function called per iteration.
|
14814 | * @param {Array} list The collection to iterate over.
|
14815 | * @return {Array} A new array.
|
14816 | * @see R.takeWhile, R.transduce, R.addIndex
|
14817 | * @example
|
14818 | *
|
14819 | * var lteTwo = x => x <= 2;
|
14820 | *
|
14821 | * R.dropWhile(lteTwo, [1, 2, 3, 4, 3, 2, 1]); //=> [3, 4, 3, 2, 1]
|
14822 | */
|
14823 | module.exports = _curry2(_dispatchable(['dropWhile'], _xdropWhile, function dropWhile(pred, list) {
|
14824 | var idx = 0;
|
14825 | var len = list.length;
|
14826 | while (idx < len && pred(list[idx])) {
|
14827 | idx += 1;
|
14828 | }
|
14829 | return Array.prototype.slice.call(list, idx);
|
14830 | }));
|
14831 |
|
14832 |
|
14833 | /***/ }),
|
14834 | /* 171 */
|
14835 | /***/ (function(module, exports, __webpack_require__) {
|
14836 |
|
14837 | var _curry2 = __webpack_require__(0);
|
14838 | var _isFunction = __webpack_require__(34);
|
14839 | var lift = __webpack_require__(39);
|
14840 | var or = __webpack_require__(101);
|
14841 |
|
14842 |
|
14843 | /**
|
14844 | * A function wrapping calls to the two functions in an `||` operation,
|
14845 | * returning the result of the first function if it is truth-y and the result
|
14846 | * of the second function otherwise. Note that this is short-circuited,
|
14847 | * meaning that the second function will not be invoked if the first returns a
|
14848 | * truth-y value.
|
14849 | *
|
14850 | * In addition to functions, `R.either` also accepts any fantasy-land compatible
|
14851 | * applicative functor.
|
14852 | *
|
14853 | * @func
|
14854 | * @memberOf R
|
14855 | * @since v0.12.0
|
14856 | * @category Logic
|
14857 | * @sig (*... -> Boolean) -> (*... -> Boolean) -> (*... -> Boolean)
|
14858 | * @param {Function} f a predicate
|
14859 | * @param {Function} g another predicate
|
14860 | * @return {Function} a function that applies its arguments to `f` and `g` and `||`s their outputs together.
|
14861 | * @see R.or
|
14862 | * @example
|
14863 | *
|
14864 | * var gt10 = x => x > 10;
|
14865 | * var even = x => x % 2 === 0;
|
14866 | * var f = R.either(gt10, even);
|
14867 | * f(101); //=> true
|
14868 | * f(8); //=> true
|
14869 | */
|
14870 | module.exports = _curry2(function either(f, g) {
|
14871 | return _isFunction(f) ?
|
14872 | function _either() {
|
14873 | return f.apply(this, arguments) || g.apply(this, arguments);
|
14874 | } :
|
14875 | lift(or)(f, g);
|
14876 | });
|
14877 |
|
14878 |
|
14879 | /***/ }),
|
14880 | /* 172 */
|
14881 | /***/ (function(module, exports, __webpack_require__) {
|
14882 |
|
14883 | var _curry3 = __webpack_require__(2);
|
14884 | var equals = __webpack_require__(10);
|
14885 |
|
14886 |
|
14887 | /**
|
14888 | * Takes a function and two values in its domain and returns `true` if the
|
14889 | * values map to the same value in the codomain; `false` otherwise.
|
14890 | *
|
14891 | * @func
|
14892 | * @memberOf R
|
14893 | * @since v0.18.0
|
14894 | * @category Relation
|
14895 | * @sig (a -> b) -> a -> a -> Boolean
|
14896 | * @param {Function} f
|
14897 | * @param {*} x
|
14898 | * @param {*} y
|
14899 | * @return {Boolean}
|
14900 | * @example
|
14901 | *
|
14902 | * R.eqBy(Math.abs, 5, -5); //=> true
|
14903 | */
|
14904 | module.exports = _curry3(function eqBy(f, x, y) {
|
14905 | return equals(f(x), f(y));
|
14906 | });
|
14907 |
|
14908 |
|
14909 | /***/ }),
|
14910 | /* 173 */
|
14911 | /***/ (function(module, exports, __webpack_require__) {
|
14912 |
|
14913 | var _curry3 = __webpack_require__(2);
|
14914 | var equals = __webpack_require__(10);
|
14915 |
|
14916 |
|
14917 | /**
|
14918 | * Reports whether two objects have the same value, in `R.equals` terms, for
|
14919 | * the specified property. Useful as a curried predicate.
|
14920 | *
|
14921 | * @func
|
14922 | * @memberOf R
|
14923 | * @since v0.1.0
|
14924 | * @category Object
|
14925 | * @sig k -> {k: v} -> {k: v} -> Boolean
|
14926 | * @param {String} prop The name of the property to compare
|
14927 | * @param {Object} obj1
|
14928 | * @param {Object} obj2
|
14929 | * @return {Boolean}
|
14930 | *
|
14931 | * @example
|
14932 | *
|
14933 | * var o1 = { a: 1, b: 2, c: 3, d: 4 };
|
14934 | * var o2 = { a: 10, b: 20, c: 3, d: 40 };
|
14935 | * R.eqProps('a', o1, o2); //=> false
|
14936 | * R.eqProps('c', o1, o2); //=> true
|
14937 | */
|
14938 | module.exports = _curry3(function eqProps(prop, obj1, obj2) {
|
14939 | return equals(obj1[prop], obj2[prop]);
|
14940 | });
|
14941 |
|
14942 |
|
14943 | /***/ }),
|
14944 | /* 174 */
|
14945 | /***/ (function(module, exports, __webpack_require__) {
|
14946 |
|
14947 | var _curry2 = __webpack_require__(0);
|
14948 |
|
14949 |
|
14950 | /**
|
14951 | * Creates a new object by recursively evolving a shallow copy of `object`,
|
14952 | * according to the `transformation` functions. All non-primitive properties
|
14953 | * are copied by reference.
|
14954 | *
|
14955 | * A `transformation` function will not be invoked if its corresponding key
|
14956 | * does not exist in the evolved object.
|
14957 | *
|
14958 | * @func
|
14959 | * @memberOf R
|
14960 | * @since v0.9.0
|
14961 | * @category Object
|
14962 | * @sig {k: (v -> v)} -> {k: v} -> {k: v}
|
14963 | * @param {Object} transformations The object specifying transformation functions to apply
|
14964 | * to the object.
|
14965 | * @param {Object} object The object to be transformed.
|
14966 | * @return {Object} The transformed object.
|
14967 | * @example
|
14968 | *
|
14969 | * var tomato = {firstName: ' Tomato ', data: {elapsed: 100, remaining: 1400}, id:123};
|
14970 | * var transformations = {
|
14971 | * firstName: R.trim,
|
14972 | * lastName: R.trim, // Will not get invoked.
|
14973 | * data: {elapsed: R.add(1), remaining: R.add(-1)}
|
14974 | * };
|
14975 | * R.evolve(transformations, tomato); //=> {firstName: 'Tomato', data: {elapsed: 101, remaining: 1399}, id:123}
|
14976 | */
|
14977 | module.exports = _curry2(function evolve(transformations, object) {
|
14978 | var result = {};
|
14979 | var transformation, key, type;
|
14980 | for (key in object) {
|
14981 | transformation = transformations[key];
|
14982 | type = typeof transformation;
|
14983 | result[key] = type === 'function' ? transformation(object[key])
|
14984 | : transformation && type === 'object' ? evolve(transformation, object[key])
|
14985 | : object[key];
|
14986 | }
|
14987 | return result;
|
14988 | });
|
14989 |
|
14990 |
|
14991 | /***/ }),
|
14992 | /* 175 */
|
14993 | /***/ (function(module, exports, __webpack_require__) {
|
14994 |
|
14995 | var _curry2 = __webpack_require__(0);
|
14996 | var _dispatchable = __webpack_require__(3);
|
14997 | var _xfind = __webpack_require__(223);
|
14998 |
|
14999 |
|
15000 | /**
|
15001 | * Returns the first element of the list which matches the predicate, or
|
15002 | * `undefined` if no element matches.
|
15003 | *
|
15004 | * Dispatches to the `find` method of the second argument, if present.
|
15005 | *
|
15006 | * Acts as a transducer if a transformer is given in list position.
|
15007 | *
|
15008 | * @func
|
15009 | * @memberOf R
|
15010 | * @since v0.1.0
|
15011 | * @category List
|
15012 | * @sig (a -> Boolean) -> [a] -> a | undefined
|
15013 | * @param {Function} fn The predicate function used to determine if the element is the
|
15014 | * desired one.
|
15015 | * @param {Array} list The array to consider.
|
15016 | * @return {Object} The element found, or `undefined`.
|
15017 | * @see R.transduce
|
15018 | * @example
|
15019 | *
|
15020 | * var xs = [{a: 1}, {a: 2}, {a: 3}];
|
15021 | * R.find(R.propEq('a', 2))(xs); //=> {a: 2}
|
15022 | * R.find(R.propEq('a', 4))(xs); //=> undefined
|
15023 | */
|
15024 | module.exports = _curry2(_dispatchable(['find'], _xfind, function find(fn, list) {
|
15025 | var idx = 0;
|
15026 | var len = list.length;
|
15027 | while (idx < len) {
|
15028 | if (fn(list[idx])) {
|
15029 | return list[idx];
|
15030 | }
|
15031 | idx += 1;
|
15032 | }
|
15033 | }));
|
15034 |
|
15035 |
|
15036 | /***/ }),
|
15037 | /* 176 */
|
15038 | /***/ (function(module, exports, __webpack_require__) {
|
15039 |
|
15040 | var _curry2 = __webpack_require__(0);
|
15041 | var _dispatchable = __webpack_require__(3);
|
15042 | var _xfindIndex = __webpack_require__(224);
|
15043 |
|
15044 |
|
15045 | /**
|
15046 | * Returns the index of the first element of the list which matches the
|
15047 | * predicate, or `-1` if no element matches.
|
15048 | *
|
15049 | * Acts as a transducer if a transformer is given in list position.
|
15050 | *
|
15051 | * @func
|
15052 | * @memberOf R
|
15053 | * @since v0.1.1
|
15054 | * @category List
|
15055 | * @sig (a -> Boolean) -> [a] -> Number
|
15056 | * @param {Function} fn The predicate function used to determine if the element is the
|
15057 | * desired one.
|
15058 | * @param {Array} list The array to consider.
|
15059 | * @return {Number} The index of the element found, or `-1`.
|
15060 | * @see R.transduce
|
15061 | * @example
|
15062 | *
|
15063 | * var xs = [{a: 1}, {a: 2}, {a: 3}];
|
15064 | * R.findIndex(R.propEq('a', 2))(xs); //=> 1
|
15065 | * R.findIndex(R.propEq('a', 4))(xs); //=> -1
|
15066 | */
|
15067 | module.exports = _curry2(_dispatchable([], _xfindIndex, function findIndex(fn, list) {
|
15068 | var idx = 0;
|
15069 | var len = list.length;
|
15070 | while (idx < len) {
|
15071 | if (fn(list[idx])) {
|
15072 | return idx;
|
15073 | }
|
15074 | idx += 1;
|
15075 | }
|
15076 | return -1;
|
15077 | }));
|
15078 |
|
15079 |
|
15080 | /***/ }),
|
15081 | /* 177 */
|
15082 | /***/ (function(module, exports, __webpack_require__) {
|
15083 |
|
15084 | var _curry2 = __webpack_require__(0);
|
15085 | var _dispatchable = __webpack_require__(3);
|
15086 | var _xfindLast = __webpack_require__(225);
|
15087 |
|
15088 |
|
15089 | /**
|
15090 | * Returns the last element of the list which matches the predicate, or
|
15091 | * `undefined` if no element matches.
|
15092 | *
|
15093 | * Acts as a transducer if a transformer is given in list position.
|
15094 | *
|
15095 | * @func
|
15096 | * @memberOf R
|
15097 | * @since v0.1.1
|
15098 | * @category List
|
15099 | * @sig (a -> Boolean) -> [a] -> a | undefined
|
15100 | * @param {Function} fn The predicate function used to determine if the element is the
|
15101 | * desired one.
|
15102 | * @param {Array} list The array to consider.
|
15103 | * @return {Object} The element found, or `undefined`.
|
15104 | * @see R.transduce
|
15105 | * @example
|
15106 | *
|
15107 | * var xs = [{a: 1, b: 0}, {a:1, b: 1}];
|
15108 | * R.findLast(R.propEq('a', 1))(xs); //=> {a: 1, b: 1}
|
15109 | * R.findLast(R.propEq('a', 4))(xs); //=> undefined
|
15110 | */
|
15111 | module.exports = _curry2(_dispatchable([], _xfindLast, function findLast(fn, list) {
|
15112 | var idx = list.length - 1;
|
15113 | while (idx >= 0) {
|
15114 | if (fn(list[idx])) {
|
15115 | return list[idx];
|
15116 | }
|
15117 | idx -= 1;
|
15118 | }
|
15119 | }));
|
15120 |
|
15121 |
|
15122 | /***/ }),
|
15123 | /* 178 */
|
15124 | /***/ (function(module, exports, __webpack_require__) {
|
15125 |
|
15126 | var _curry2 = __webpack_require__(0);
|
15127 | var _dispatchable = __webpack_require__(3);
|
15128 | var _xfindLastIndex = __webpack_require__(226);
|
15129 |
|
15130 |
|
15131 | /**
|
15132 | * Returns the index of the last element of the list which matches the
|
15133 | * predicate, or `-1` if no element matches.
|
15134 | *
|
15135 | * Acts as a transducer if a transformer is given in list position.
|
15136 | *
|
15137 | * @func
|
15138 | * @memberOf R
|
15139 | * @since v0.1.1
|
15140 | * @category List
|
15141 | * @sig (a -> Boolean) -> [a] -> Number
|
15142 | * @param {Function} fn The predicate function used to determine if the element is the
|
15143 | * desired one.
|
15144 | * @param {Array} list The array to consider.
|
15145 | * @return {Number} The index of the element found, or `-1`.
|
15146 | * @see R.transduce
|
15147 | * @example
|
15148 | *
|
15149 | * var xs = [{a: 1, b: 0}, {a:1, b: 1}];
|
15150 | * R.findLastIndex(R.propEq('a', 1))(xs); //=> 1
|
15151 | * R.findLastIndex(R.propEq('a', 4))(xs); //=> -1
|
15152 | */
|
15153 | module.exports = _curry2(_dispatchable([], _xfindLastIndex, function findLastIndex(fn, list) {
|
15154 | var idx = list.length - 1;
|
15155 | while (idx >= 0) {
|
15156 | if (fn(list[idx])) {
|
15157 | return idx;
|
15158 | }
|
15159 | idx -= 1;
|
15160 | }
|
15161 | return -1;
|
15162 | }));
|
15163 |
|
15164 |
|
15165 | /***/ }),
|
15166 | /* 179 */
|
15167 | /***/ (function(module, exports, __webpack_require__) {
|
15168 |
|
15169 | var _curry1 = __webpack_require__(1);
|
15170 | var _makeFlat = __webpack_require__(87);
|
15171 |
|
15172 |
|
15173 | /**
|
15174 | * Returns a new list by pulling every item out of it (and all its sub-arrays)
|
15175 | * and putting them in a new array, depth-first.
|
15176 | *
|
15177 | * @func
|
15178 | * @memberOf R
|
15179 | * @since v0.1.0
|
15180 | * @category List
|
15181 | * @sig [a] -> [b]
|
15182 | * @param {Array} list The array to consider.
|
15183 | * @return {Array} The flattened list.
|
15184 | * @see R.unnest
|
15185 | * @example
|
15186 | *
|
15187 | * R.flatten([1, 2, [3, 4], 5, [6, [7, 8, [9, [10, 11], 12]]]]);
|
15188 | * //=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12]
|
15189 | */
|
15190 | module.exports = _curry1(_makeFlat(true));
|
15191 |
|
15192 |
|
15193 | /***/ }),
|
15194 | /* 180 */
|
15195 | /***/ (function(module, exports, __webpack_require__) {
|
15196 |
|
15197 | var _checkForMethod = __webpack_require__(21);
|
15198 | var _curry2 = __webpack_require__(0);
|
15199 |
|
15200 |
|
15201 | /**
|
15202 | * Iterate over an input `list`, calling a provided function `fn` for each
|
15203 | * element in the list.
|
15204 | *
|
15205 | * `fn` receives one argument: *(value)*.
|
15206 | *
|
15207 | * Note: `R.forEach` does not skip deleted or unassigned indices (sparse
|
15208 | * arrays), unlike the native `Array.prototype.forEach` method. For more
|
15209 | * details on this behavior, see:
|
15210 | * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach#Description
|
15211 | *
|
15212 | * Also note that, unlike `Array.prototype.forEach`, Ramda's `forEach` returns
|
15213 | * the original array. In some libraries this function is named `each`.
|
15214 | *
|
15215 | * Dispatches to the `forEach` method of the second argument, if present.
|
15216 | *
|
15217 | * @func
|
15218 | * @memberOf R
|
15219 | * @since v0.1.1
|
15220 | * @category List
|
15221 | * @sig (a -> *) -> [a] -> [a]
|
15222 | * @param {Function} fn The function to invoke. Receives one argument, `value`.
|
15223 | * @param {Array} list The list to iterate over.
|
15224 | * @return {Array} The original list.
|
15225 | * @see R.addIndex
|
15226 | * @example
|
15227 | *
|
15228 | * var printXPlusFive = x => console.log(x + 5);
|
15229 | * R.forEach(printXPlusFive, [1, 2, 3]); //=> [1, 2, 3]
|
15230 | * // logs 6
|
15231 | * // logs 7
|
15232 | * // logs 8
|
15233 | * @symb R.forEach(f, [a, b, c]) = [a, b, c]
|
15234 | */
|
15235 | module.exports = _curry2(_checkForMethod('forEach', function forEach(fn, list) {
|
15236 | var len = list.length;
|
15237 | var idx = 0;
|
15238 | while (idx < len) {
|
15239 | fn(list[idx]);
|
15240 | idx += 1;
|
15241 | }
|
15242 | return list;
|
15243 | }));
|
15244 |
|
15245 |
|
15246 | /***/ }),
|
15247 | /* 181 */
|
15248 | /***/ (function(module, exports, __webpack_require__) {
|
15249 |
|
15250 | var _curry2 = __webpack_require__(0);
|
15251 | var keys = __webpack_require__(12);
|
15252 |
|
15253 |
|
15254 | /**
|
15255 | * Iterate over an input `object`, calling a provided function `fn` for each
|
15256 | * key and value in the object.
|
15257 | *
|
15258 | * `fn` receives three argument: *(value, key, obj)*.
|
15259 | *
|
15260 | * @func
|
15261 | * @memberOf R
|
15262 | * @since v0.23.0
|
15263 | * @category Object
|
15264 | * @sig ((a, String, StrMap a) -> Any) -> StrMap a -> StrMap a
|
15265 | * @param {Function} fn The function to invoke. Receives three argument, `value`, `key`, `obj`.
|
15266 | * @param {Object} obj The object to iterate over.
|
15267 | * @return {Object} The original object.
|
15268 | * @example
|
15269 | *
|
15270 | * var printKeyConcatValue = (value, key) => console.log(key + ':' + value);
|
15271 | * R.forEachObjIndexed(printKeyConcatValue, {x: 1, y: 2}); //=> {x: 1, y: 2}
|
15272 | * // logs x:1
|
15273 | * // logs y:2
|
15274 | * @symb R.forEachObjIndexed(f, {x: a, y: b}) = {x: a, y: b}
|
15275 | */
|
15276 | module.exports = _curry2(function forEachObjIndexed(fn, obj) {
|
15277 | var keyList = keys(obj);
|
15278 | var idx = 0;
|
15279 | while (idx < keyList.length) {
|
15280 | var key = keyList[idx];
|
15281 | fn(obj[key], key, obj);
|
15282 | idx += 1;
|
15283 | }
|
15284 | return obj;
|
15285 | });
|
15286 |
|
15287 |
|
15288 | /***/ }),
|
15289 | /* 182 */
|
15290 | /***/ (function(module, exports, __webpack_require__) {
|
15291 |
|
15292 | var _curry1 = __webpack_require__(1);
|
15293 |
|
15294 |
|
15295 | /**
|
15296 | * Creates a new object from a list key-value pairs. If a key appears in
|
15297 | * multiple pairs, the rightmost pair is included in the object.
|
15298 | *
|
15299 | * @func
|
15300 | * @memberOf R
|
15301 | * @since v0.3.0
|
15302 | * @category List
|
15303 | * @sig [[k,v]] -> {k: v}
|
15304 | * @param {Array} pairs An array of two-element arrays that will be the keys and values of the output object.
|
15305 | * @return {Object} The object made by pairing up `keys` and `values`.
|
15306 | * @see R.toPairs, R.pair
|
15307 | * @example
|
15308 | *
|
15309 | * R.fromPairs([['a', 1], ['b', 2], ['c', 3]]); //=> {a: 1, b: 2, c: 3}
|
15310 | */
|
15311 | module.exports = _curry1(function fromPairs(pairs) {
|
15312 | var result = {};
|
15313 | var idx = 0;
|
15314 | while (idx < pairs.length) {
|
15315 | result[pairs[idx][0]] = pairs[idx][1];
|
15316 | idx += 1;
|
15317 | }
|
15318 | return result;
|
15319 | });
|
15320 |
|
15321 |
|
15322 | /***/ }),
|
15323 | /* 183 */
|
15324 | /***/ (function(module, exports, __webpack_require__) {
|
15325 |
|
15326 | var _checkForMethod = __webpack_require__(21);
|
15327 | var _curry2 = __webpack_require__(0);
|
15328 | var reduceBy = __webpack_require__(41);
|
15329 |
|
15330 | /**
|
15331 | * Splits a list into sub-lists stored in an object, based on the result of
|
15332 | * calling a String-returning function on each element, and grouping the
|
15333 | * results according to values returned.
|
15334 | *
|
15335 | * Dispatches to the `groupBy` method of the second argument, if present.
|
15336 | *
|
15337 | * Acts as a transducer if a transformer is given in list position.
|
15338 | *
|
15339 | * @func
|
15340 | * @memberOf R
|
15341 | * @since v0.1.0
|
15342 | * @category List
|
15343 | * @sig (a -> String) -> [a] -> {String: [a]}
|
15344 | * @param {Function} fn Function :: a -> String
|
15345 | * @param {Array} list The array to group
|
15346 | * @return {Object} An object with the output of `fn` for keys, mapped to arrays of elements
|
15347 | * that produced that key when passed to `fn`.
|
15348 | * @see R.transduce
|
15349 | * @example
|
15350 | *
|
15351 | * var byGrade = R.groupBy(function(student) {
|
15352 | * var score = student.score;
|
15353 | * return score < 65 ? 'F' :
|
15354 | * score < 70 ? 'D' :
|
15355 | * score < 80 ? 'C' :
|
15356 | * score < 90 ? 'B' : 'A';
|
15357 | * });
|
15358 | * var students = [{name: 'Abby', score: 84},
|
15359 | * {name: 'Eddy', score: 58},
|
15360 | * // ...
|
15361 | * {name: 'Jack', score: 69}];
|
15362 | * byGrade(students);
|
15363 | * // {
|
15364 | * // 'A': [{name: 'Dianne', score: 99}],
|
15365 | * // 'B': [{name: 'Abby', score: 84}]
|
15366 | * // // ...,
|
15367 | * // 'F': [{name: 'Eddy', score: 58}]
|
15368 | * // }
|
15369 | */
|
15370 | module.exports = _curry2(_checkForMethod('groupBy', reduceBy(function(acc, item) {
|
15371 | if (acc == null) {
|
15372 | acc = [];
|
15373 | }
|
15374 | acc.push(item);
|
15375 | return acc;
|
15376 | }, null)));
|
15377 |
|
15378 |
|
15379 | /***/ }),
|
15380 | /* 184 */
|
15381 | /***/ (function(module, exports, __webpack_require__) {
|
15382 |
|
15383 | var _curry2 = __webpack_require__(0);
|
15384 |
|
15385 | /**
|
15386 | * Takes a list and returns a list of lists where each sublist's elements are
|
15387 | * all "equal" according to the provided equality function.
|
15388 | *
|
15389 | * @func
|
15390 | * @memberOf R
|
15391 | * @since v0.21.0
|
15392 | * @category List
|
15393 | * @sig ((a, a) → Boolean) → [a] → [[a]]
|
15394 | * @param {Function} fn Function for determining whether two given (adjacent)
|
15395 | * elements should be in the same group
|
15396 | * @param {Array} list The array to group. Also accepts a string, which will be
|
15397 | * treated as a list of characters.
|
15398 | * @return {List} A list that contains sublists of equal elements,
|
15399 | * whose concatenations are equal to the original list.
|
15400 | * @example
|
15401 | *
|
15402 | * R.groupWith(R.equals, [0, 1, 1, 2, 3, 5, 8, 13, 21])
|
15403 | * //=> [[0], [1, 1], [2], [3], [5], [8], [13], [21]]
|
15404 | *
|
15405 | * R.groupWith((a, b) => a % 2 === b % 2, [0, 1, 1, 2, 3, 5, 8, 13, 21])
|
15406 | * //=> [[0], [1, 1], [2], [3, 5], [8], [13, 21]]
|
15407 | *
|
15408 | * R.groupWith(R.eqBy(isVowel), 'aestiou')
|
15409 | * //=> ['ae', 'st', 'iou']
|
15410 | */
|
15411 | module.exports = _curry2(function(fn, list) {
|
15412 | var res = [];
|
15413 | var idx = 0;
|
15414 | var len = list.length;
|
15415 | while (idx < len) {
|
15416 | var nextidx = idx + 1;
|
15417 | while (nextidx < len && fn(list[idx], list[nextidx])) {
|
15418 | nextidx += 1;
|
15419 | }
|
15420 | res.push(list.slice(idx, nextidx));
|
15421 | idx = nextidx;
|
15422 | }
|
15423 | return res;
|
15424 | });
|
15425 |
|
15426 |
|
15427 | /***/ }),
|
15428 | /* 185 */
|
15429 | /***/ (function(module, exports, __webpack_require__) {
|
15430 |
|
15431 | var _curry2 = __webpack_require__(0);
|
15432 |
|
15433 |
|
15434 | /**
|
15435 | * Returns `true` if the first argument is greater than the second; `false`
|
15436 | * otherwise.
|
15437 | *
|
15438 | * @func
|
15439 | * @memberOf R
|
15440 | * @since v0.1.0
|
15441 | * @category Relation
|
15442 | * @sig Ord a => a -> a -> Boolean
|
15443 | * @param {*} a
|
15444 | * @param {*} b
|
15445 | * @return {Boolean}
|
15446 | * @see R.lt
|
15447 | * @example
|
15448 | *
|
15449 | * R.gt(2, 1); //=> true
|
15450 | * R.gt(2, 2); //=> false
|
15451 | * R.gt(2, 3); //=> false
|
15452 | * R.gt('a', 'z'); //=> false
|
15453 | * R.gt('z', 'a'); //=> true
|
15454 | */
|
15455 | module.exports = _curry2(function gt(a, b) { return a > b; });
|
15456 |
|
15457 |
|
15458 | /***/ }),
|
15459 | /* 186 */
|
15460 | /***/ (function(module, exports, __webpack_require__) {
|
15461 |
|
15462 | var _curry2 = __webpack_require__(0);
|
15463 |
|
15464 |
|
15465 | /**
|
15466 | * Returns `true` if the first argument is greater than or equal to the second;
|
15467 | * `false` otherwise.
|
15468 | *
|
15469 | * @func
|
15470 | * @memberOf R
|
15471 | * @since v0.1.0
|
15472 | * @category Relation
|
15473 | * @sig Ord a => a -> a -> Boolean
|
15474 | * @param {Number} a
|
15475 | * @param {Number} b
|
15476 | * @return {Boolean}
|
15477 | * @see R.lte
|
15478 | * @example
|
15479 | *
|
15480 | * R.gte(2, 1); //=> true
|
15481 | * R.gte(2, 2); //=> true
|
15482 | * R.gte(2, 3); //=> false
|
15483 | * R.gte('a', 'z'); //=> false
|
15484 | * R.gte('z', 'a'); //=> true
|
15485 | */
|
15486 | module.exports = _curry2(function gte(a, b) { return a >= b; });
|
15487 |
|
15488 |
|
15489 | /***/ }),
|
15490 | /* 187 */
|
15491 | /***/ (function(module, exports, __webpack_require__) {
|
15492 |
|
15493 | var _curry2 = __webpack_require__(0);
|
15494 | var _has = __webpack_require__(6);
|
15495 |
|
15496 |
|
15497 | /**
|
15498 | * Returns whether or not an object has an own property with the specified name
|
15499 | *
|
15500 | * @func
|
15501 | * @memberOf R
|
15502 | * @since v0.7.0
|
15503 | * @category Object
|
15504 | * @sig s -> {s: x} -> Boolean
|
15505 | * @param {String} prop The name of the property to check for.
|
15506 | * @param {Object} obj The object to query.
|
15507 | * @return {Boolean} Whether the property exists.
|
15508 | * @example
|
15509 | *
|
15510 | * var hasName = R.has('name');
|
15511 | * hasName({name: 'alice'}); //=> true
|
15512 | * hasName({name: 'bob'}); //=> true
|
15513 | * hasName({}); //=> false
|
15514 | *
|
15515 | * var point = {x: 0, y: 0};
|
15516 | * var pointHas = R.has(R.__, point);
|
15517 | * pointHas('x'); //=> true
|
15518 | * pointHas('y'); //=> true
|
15519 | * pointHas('z'); //=> false
|
15520 | */
|
15521 | module.exports = _curry2(_has);
|
15522 |
|
15523 |
|
15524 | /***/ }),
|
15525 | /* 188 */
|
15526 | /***/ (function(module, exports, __webpack_require__) {
|
15527 |
|
15528 | var _curry2 = __webpack_require__(0);
|
15529 |
|
15530 |
|
15531 | /**
|
15532 | * Returns whether or not an object or its prototype chain has a property with
|
15533 | * the specified name
|
15534 | *
|
15535 | * @func
|
15536 | * @memberOf R
|
15537 | * @since v0.7.0
|
15538 | * @category Object
|
15539 | * @sig s -> {s: x} -> Boolean
|
15540 | * @param {String} prop The name of the property to check for.
|
15541 | * @param {Object} obj The object to query.
|
15542 | * @return {Boolean} Whether the property exists.
|
15543 | * @example
|
15544 | *
|
15545 | * function Rectangle(width, height) {
|
15546 | * this.width = width;
|
15547 | * this.height = height;
|
15548 | * }
|
15549 | * Rectangle.prototype.area = function() {
|
15550 | * return this.width * this.height;
|
15551 | * };
|
15552 | *
|
15553 | * var square = new Rectangle(2, 2);
|
15554 | * R.hasIn('width', square); //=> true
|
15555 | * R.hasIn('area', square); //=> true
|
15556 | */
|
15557 | module.exports = _curry2(function hasIn(prop, obj) {
|
15558 | return prop in obj;
|
15559 | });
|
15560 |
|
15561 |
|
15562 | /***/ }),
|
15563 | /* 189 */
|
15564 | /***/ (function(module, exports, __webpack_require__) {
|
15565 |
|
15566 | var nth = __webpack_require__(24);
|
15567 |
|
15568 |
|
15569 | /**
|
15570 | * Returns the first element of the given list or string. In some libraries
|
15571 | * this function is named `first`.
|
15572 | *
|
15573 | * @func
|
15574 | * @memberOf R
|
15575 | * @since v0.1.0
|
15576 | * @category List
|
15577 | * @sig [a] -> a | Undefined
|
15578 | * @sig String -> String
|
15579 | * @param {Array|String} list
|
15580 | * @return {*}
|
15581 | * @see R.tail, R.init, R.last
|
15582 | * @example
|
15583 | *
|
15584 | * R.head(['fi', 'fo', 'fum']); //=> 'fi'
|
15585 | * R.head([]); //=> undefined
|
15586 | *
|
15587 | * R.head('abc'); //=> 'a'
|
15588 | * R.head(''); //=> ''
|
15589 | */
|
15590 | module.exports = nth(0);
|
15591 |
|
15592 |
|
15593 | /***/ }),
|
15594 | /* 190 */
|
15595 | /***/ (function(module, exports, __webpack_require__) {
|
15596 |
|
15597 | var _curry3 = __webpack_require__(2);
|
15598 | var curryN = __webpack_require__(5);
|
15599 |
|
15600 |
|
15601 | /**
|
15602 | * Creates a function that will process either the `onTrue` or the `onFalse`
|
15603 | * function depending upon the result of the `condition` predicate.
|
15604 | *
|
15605 | * @func
|
15606 | * @memberOf R
|
15607 | * @since v0.8.0
|
15608 | * @category Logic
|
15609 | * @sig (*... -> Boolean) -> (*... -> *) -> (*... -> *) -> (*... -> *)
|
15610 | * @param {Function} condition A predicate function
|
15611 | * @param {Function} onTrue A function to invoke when the `condition` evaluates to a truthy value.
|
15612 | * @param {Function} onFalse A function to invoke when the `condition` evaluates to a falsy value.
|
15613 | * @return {Function} A new unary function that will process either the `onTrue` or the `onFalse`
|
15614 | * function depending upon the result of the `condition` predicate.
|
15615 | * @see R.unless, R.when
|
15616 | * @example
|
15617 | *
|
15618 | * var incCount = R.ifElse(
|
15619 | * R.has('count'),
|
15620 | * R.over(R.lensProp('count'), R.inc),
|
15621 | * R.assoc('count', 1)
|
15622 | * );
|
15623 | * incCount({}); //=> { count: 1 }
|
15624 | * incCount({ count: 1 }); //=> { count: 2 }
|
15625 | */
|
15626 | module.exports = _curry3(function ifElse(condition, onTrue, onFalse) {
|
15627 | return curryN(Math.max(condition.length, onTrue.length, onFalse.length),
|
15628 | function _ifElse() {
|
15629 | return condition.apply(this, arguments) ? onTrue.apply(this, arguments) : onFalse.apply(this, arguments);
|
15630 | }
|
15631 | );
|
15632 | });
|
15633 |
|
15634 |
|
15635 | /***/ }),
|
15636 | /* 191 */
|
15637 | /***/ (function(module, exports, __webpack_require__) {
|
15638 |
|
15639 | var add = __webpack_require__(29);
|
15640 |
|
15641 |
|
15642 | /**
|
15643 | * Increments its argument.
|
15644 | *
|
15645 | * @func
|
15646 | * @memberOf R
|
15647 | * @since v0.9.0
|
15648 | * @category Math
|
15649 | * @sig Number -> Number
|
15650 | * @param {Number} n
|
15651 | * @return {Number} n + 1
|
15652 | * @see R.dec
|
15653 | * @example
|
15654 | *
|
15655 | * R.inc(42); //=> 43
|
15656 | */
|
15657 | module.exports = add(1);
|
15658 |
|
15659 |
|
15660 | /***/ }),
|
15661 | /* 192 */
|
15662 | /***/ (function(module, exports, __webpack_require__) {
|
15663 |
|
15664 | var reduceBy = __webpack_require__(41);
|
15665 |
|
15666 |
|
15667 | /**
|
15668 | * Given a function that generates a key, turns a list of objects into an
|
15669 | * object indexing the objects by the given key. Note that if multiple
|
15670 | * objects generate the same value for the indexing key only the last value
|
15671 | * will be included in the generated object.
|
15672 | *
|
15673 | * Acts as a transducer if a transformer is given in list position.
|
15674 | *
|
15675 | * @func
|
15676 | * @memberOf R
|
15677 | * @since v0.19.0
|
15678 | * @category List
|
15679 | * @sig (a -> String) -> [{k: v}] -> {k: {k: v}}
|
15680 | * @param {Function} fn Function :: a -> String
|
15681 | * @param {Array} array The array of objects to index
|
15682 | * @return {Object} An object indexing each array element by the given property.
|
15683 | * @example
|
15684 | *
|
15685 | * var list = [{id: 'xyz', title: 'A'}, {id: 'abc', title: 'B'}];
|
15686 | * R.indexBy(R.prop('id'), list);
|
15687 | * //=> {abc: {id: 'abc', title: 'B'}, xyz: {id: 'xyz', title: 'A'}}
|
15688 | */
|
15689 | module.exports = reduceBy(function(acc, elem) { return elem; }, null);
|
15690 |
|
15691 |
|
15692 | /***/ }),
|
15693 | /* 193 */
|
15694 | /***/ (function(module, exports, __webpack_require__) {
|
15695 |
|
15696 | var _curry2 = __webpack_require__(0);
|
15697 | var _indexOf = __webpack_require__(82);
|
15698 | var _isArray = __webpack_require__(15);
|
15699 |
|
15700 |
|
15701 | /**
|
15702 | * Returns the position of the first occurrence of an item in an array, or -1
|
15703 | * if the item is not included in the array. `R.equals` is used to determine
|
15704 | * equality.
|
15705 | *
|
15706 | * @func
|
15707 | * @memberOf R
|
15708 | * @since v0.1.0
|
15709 | * @category List
|
15710 | * @sig a -> [a] -> Number
|
15711 | * @param {*} target The item to find.
|
15712 | * @param {Array} xs The array to search in.
|
15713 | * @return {Number} the index of the target, or -1 if the target is not found.
|
15714 | * @see R.lastIndexOf
|
15715 | * @example
|
15716 | *
|
15717 | * R.indexOf(3, [1,2,3,4]); //=> 2
|
15718 | * R.indexOf(10, [1,2,3,4]); //=> -1
|
15719 | */
|
15720 | module.exports = _curry2(function indexOf(target, xs) {
|
15721 | return typeof xs.indexOf === 'function' && !_isArray(xs) ?
|
15722 | xs.indexOf(target) :
|
15723 | _indexOf(xs, target, 0);
|
15724 | });
|
15725 |
|
15726 |
|
15727 | /***/ }),
|
15728 | /* 194 */
|
15729 | /***/ (function(module, exports, __webpack_require__) {
|
15730 |
|
15731 | var slice = __webpack_require__(18);
|
15732 |
|
15733 |
|
15734 | /**
|
15735 | * Returns all but the last element of the given list or string.
|
15736 | *
|
15737 | * @func
|
15738 | * @memberOf R
|
15739 | * @since v0.9.0
|
15740 | * @category List
|
15741 | * @sig [a] -> [a]
|
15742 | * @sig String -> String
|
15743 | * @param {*} list
|
15744 | * @return {*}
|
15745 | * @see R.last, R.head, R.tail
|
15746 | * @example
|
15747 | *
|
15748 | * R.init([1, 2, 3]); //=> [1, 2]
|
15749 | * R.init([1, 2]); //=> [1]
|
15750 | * R.init([1]); //=> []
|
15751 | * R.init([]); //=> []
|
15752 | *
|
15753 | * R.init('abc'); //=> 'ab'
|
15754 | * R.init('ab'); //=> 'a'
|
15755 | * R.init('a'); //=> ''
|
15756 | * R.init(''); //=> ''
|
15757 | */
|
15758 | module.exports = slice(0, -1);
|
15759 |
|
15760 |
|
15761 | /***/ }),
|
15762 | /* 195 */
|
15763 | /***/ (function(module, exports, __webpack_require__) {
|
15764 |
|
15765 | var _curry3 = __webpack_require__(2);
|
15766 |
|
15767 |
|
15768 | /**
|
15769 | * Inserts the supplied element into the list, at index `index`. _Note that
|
15770 | * this is not destructive_: it returns a copy of the list with the changes.
|
15771 | * <small>No lists have been harmed in the application of this function.</small>
|
15772 | *
|
15773 | * @func
|
15774 | * @memberOf R
|
15775 | * @since v0.2.2
|
15776 | * @category List
|
15777 | * @sig Number -> a -> [a] -> [a]
|
15778 | * @param {Number} index The position to insert the element
|
15779 | * @param {*} elt The element to insert into the Array
|
15780 | * @param {Array} list The list to insert into
|
15781 | * @return {Array} A new Array with `elt` inserted at `index`.
|
15782 | * @example
|
15783 | *
|
15784 | * R.insert(2, 'x', [1,2,3,4]); //=> [1,2,'x',3,4]
|
15785 | */
|
15786 | module.exports = _curry3(function insert(idx, elt, list) {
|
15787 | idx = idx < list.length && idx >= 0 ? idx : list.length;
|
15788 | var result = Array.prototype.slice.call(list, 0);
|
15789 | result.splice(idx, 0, elt);
|
15790 | return result;
|
15791 | });
|
15792 |
|
15793 |
|
15794 | /***/ }),
|
15795 | /* 196 */
|
15796 | /***/ (function(module, exports, __webpack_require__) {
|
15797 |
|
15798 | var _curry3 = __webpack_require__(2);
|
15799 |
|
15800 |
|
15801 | /**
|
15802 | * Inserts the sub-list into the list, at index `index`. _Note that this is not
|
15803 | * destructive_: it returns a copy of the list with the changes.
|
15804 | * <small>No lists have been harmed in the application of this function.</small>
|
15805 | *
|
15806 | * @func
|
15807 | * @memberOf R
|
15808 | * @since v0.9.0
|
15809 | * @category List
|
15810 | * @sig Number -> [a] -> [a] -> [a]
|
15811 | * @param {Number} index The position to insert the sub-list
|
15812 | * @param {Array} elts The sub-list to insert into the Array
|
15813 | * @param {Array} list The list to insert the sub-list into
|
15814 | * @return {Array} A new Array with `elts` inserted starting at `index`.
|
15815 | * @example
|
15816 | *
|
15817 | * R.insertAll(2, ['x','y','z'], [1,2,3,4]); //=> [1,2,'x','y','z',3,4]
|
15818 | */
|
15819 | module.exports = _curry3(function insertAll(idx, elts, list) {
|
15820 | idx = idx < list.length && idx >= 0 ? idx : list.length;
|
15821 | return [].concat(Array.prototype.slice.call(list, 0, idx),
|
15822 | elts,
|
15823 | Array.prototype.slice.call(list, idx));
|
15824 | });
|
15825 |
|
15826 |
|
15827 | /***/ }),
|
15828 | /* 197 */
|
15829 | /***/ (function(module, exports, __webpack_require__) {
|
15830 |
|
15831 | var _contains = __webpack_require__(17);
|
15832 |
|
15833 |
|
15834 | // A simple Set type that honours R.equals semantics
|
15835 | module.exports = (function() {
|
15836 | function _Set() {
|
15837 | /* globals Set */
|
15838 | this._nativeSet = typeof Set === 'function' ? new Set() : null;
|
15839 | this._items = {};
|
15840 | }
|
15841 |
|
15842 | // until we figure out why jsdoc chokes on this
|
15843 | // @param item The item to add to the Set
|
15844 | // @returns {boolean} true if the item did not exist prior, otherwise false
|
15845 | //
|
15846 | _Set.prototype.add = function(item) {
|
15847 | return !hasOrAdd(item, true, this);
|
15848 | };
|
15849 |
|
15850 | //
|
15851 | // @param item The item to check for existence in the Set
|
15852 | // @returns {boolean} true if the item exists in the Set, otherwise false
|
15853 | //
|
15854 | _Set.prototype.has = function(item) {
|
15855 | return hasOrAdd(item, false, this);
|
15856 | };
|
15857 |
|
15858 | //
|
15859 | // Combines the logic for checking whether an item is a member of the set and
|
15860 | // for adding a new item to the set.
|
15861 | //
|
15862 | // @param item The item to check or add to the Set instance.
|
15863 | // @param shouldAdd If true, the item will be added to the set if it doesn't
|
15864 | // already exist.
|
15865 | // @param set The set instance to check or add to.
|
15866 | // @return {boolean} true if the item already existed, otherwise false.
|
15867 | //
|
15868 | function hasOrAdd(item, shouldAdd, set) {
|
15869 | var type = typeof item;
|
15870 | var prevSize, newSize;
|
15871 | switch (type) {
|
15872 | case 'string':
|
15873 | case 'number':
|
15874 | // distinguish between +0 and -0
|
15875 | if (item === 0 && 1 / item === -Infinity) {
|
15876 | if (set._items['-0']) {
|
15877 | return true;
|
15878 | } else {
|
15879 | if (shouldAdd) {
|
15880 | set._items['-0'] = true;
|
15881 | }
|
15882 | return false;
|
15883 | }
|
15884 | }
|
15885 | // these types can all utilise the native Set
|
15886 | if (set._nativeSet !== null) {
|
15887 | if (shouldAdd) {
|
15888 | prevSize = set._nativeSet.size;
|
15889 | set._nativeSet.add(item);
|
15890 | newSize = set._nativeSet.size;
|
15891 | return newSize === prevSize;
|
15892 | } else {
|
15893 | return set._nativeSet.has(item);
|
15894 | }
|
15895 | } else {
|
15896 | if (!(type in set._items)) {
|
15897 | if (shouldAdd) {
|
15898 | set._items[type] = {};
|
15899 | set._items[type][item] = true;
|
15900 | }
|
15901 | return false;
|
15902 | } else if (item in set._items[type]) {
|
15903 | return true;
|
15904 | } else {
|
15905 | if (shouldAdd) {
|
15906 | set._items[type][item] = true;
|
15907 | }
|
15908 | return false;
|
15909 | }
|
15910 | }
|
15911 |
|
15912 | case 'boolean':
|
15913 | // set._items['boolean'] holds a two element array
|
15914 | // representing [ falseExists, trueExists ]
|
15915 | if (type in set._items) {
|
15916 | var bIdx = item ? 1 : 0;
|
15917 | if (set._items[type][bIdx]) {
|
15918 | return true;
|
15919 | } else {
|
15920 | if (shouldAdd) {
|
15921 | set._items[type][bIdx] = true;
|
15922 | }
|
15923 | return false;
|
15924 | }
|
15925 | } else {
|
15926 | if (shouldAdd) {
|
15927 | set._items[type] = item ? [false, true] : [true, false];
|
15928 | }
|
15929 | return false;
|
15930 | }
|
15931 |
|
15932 | case 'function':
|
15933 | // compare functions for reference equality
|
15934 | if (set._nativeSet !== null) {
|
15935 | if (shouldAdd) {
|
15936 | prevSize = set._nativeSet.size;
|
15937 | set._nativeSet.add(item);
|
15938 | newSize = set._nativeSet.size;
|
15939 | return newSize === prevSize;
|
15940 | } else {
|
15941 | return set._nativeSet.has(item);
|
15942 | }
|
15943 | } else {
|
15944 | if (!(type in set._items)) {
|
15945 | if (shouldAdd) {
|
15946 | set._items[type] = [item];
|
15947 | }
|
15948 | return false;
|
15949 | }
|
15950 | if (!_contains(item, set._items[type])) {
|
15951 | if (shouldAdd) {
|
15952 | set._items[type].push(item);
|
15953 | }
|
15954 | return false;
|
15955 | }
|
15956 | return true;
|
15957 | }
|
15958 |
|
15959 | case 'undefined':
|
15960 | if (set._items[type]) {
|
15961 | return true;
|
15962 | } else {
|
15963 | if (shouldAdd) {
|
15964 | set._items[type] = true;
|
15965 | }
|
15966 | return false;
|
15967 | }
|
15968 |
|
15969 | case 'object':
|
15970 | if (item === null) {
|
15971 | if (!set._items['null']) {
|
15972 | if (shouldAdd) {
|
15973 | set._items['null'] = true;
|
15974 | }
|
15975 | return false;
|
15976 | }
|
15977 | return true;
|
15978 | }
|
15979 | /* falls through */
|
15980 | default:
|
15981 | // reduce the search size of heterogeneous sets by creating buckets
|
15982 | // for each type.
|
15983 | type = Object.prototype.toString.call(item);
|
15984 | if (!(type in set._items)) {
|
15985 | if (shouldAdd) {
|
15986 | set._items[type] = [item];
|
15987 | }
|
15988 | return false;
|
15989 | }
|
15990 | // scan through all previously applied items
|
15991 | if (!_contains(item, set._items[type])) {
|
15992 | if (shouldAdd) {
|
15993 | set._items[type].push(item);
|
15994 | }
|
15995 | return false;
|
15996 | }
|
15997 | return true;
|
15998 | }
|
15999 | }
|
16000 | return _Set;
|
16001 | }());
|
16002 |
|
16003 |
|
16004 | /***/ }),
|
16005 | /* 198 */
|
16006 | /***/ (function(module, exports) {
|
16007 |
|
16008 | module.exports = function _aperture(n, list) {
|
16009 | var idx = 0;
|
16010 | var limit = list.length - (n - 1);
|
16011 | var acc = new Array(limit >= 0 ? limit : 0);
|
16012 | while (idx < limit) {
|
16013 | acc[idx] = Array.prototype.slice.call(list, idx, idx + n);
|
16014 | idx += 1;
|
16015 | }
|
16016 | return acc;
|
16017 | };
|
16018 |
|
16019 |
|
16020 | /***/ }),
|
16021 | /* 199 */
|
16022 | /***/ (function(module, exports) {
|
16023 |
|
16024 | module.exports = function _arrayFromIterator(iter) {
|
16025 | var list = [];
|
16026 | var next;
|
16027 | while (!(next = iter.next()).done) {
|
16028 | list.push(next.value);
|
16029 | }
|
16030 | return list;
|
16031 | };
|
16032 |
|
16033 |
|
16034 | /***/ }),
|
16035 | /* 200 */
|
16036 | /***/ (function(module, exports, __webpack_require__) {
|
16037 |
|
16038 | var take = __webpack_require__(110);
|
16039 |
|
16040 | module.exports = function dropLast(n, xs) {
|
16041 | return take(n < xs.length ? xs.length - n : 0, xs);
|
16042 | };
|
16043 |
|
16044 |
|
16045 | /***/ }),
|
16046 | /* 201 */
|
16047 | /***/ (function(module, exports) {
|
16048 |
|
16049 | module.exports = function dropLastWhile(pred, list) {
|
16050 | var idx = list.length - 1;
|
16051 | while (idx >= 0 && pred(list[idx])) {
|
16052 | idx -= 1;
|
16053 | }
|
16054 | return Array.prototype.slice.call(list, 0, idx + 1);
|
16055 | };
|
16056 |
|
16057 |
|
16058 | /***/ }),
|
16059 | /* 202 */
|
16060 | /***/ (function(module, exports, __webpack_require__) {
|
16061 |
|
16062 | var _arrayFromIterator = __webpack_require__(199);
|
16063 | var _functionName = __webpack_require__(205);
|
16064 | var _has = __webpack_require__(6);
|
16065 | var identical = __webpack_require__(76);
|
16066 | var keys = __webpack_require__(12);
|
16067 | var type = __webpack_require__(56);
|
16068 |
|
16069 |
|
16070 | module.exports = function _equals(a, b, stackA, stackB) {
|
16071 | if (identical(a, b)) {
|
16072 | return true;
|
16073 | }
|
16074 |
|
16075 | if (type(a) !== type(b)) {
|
16076 | return false;
|
16077 | }
|
16078 |
|
16079 | if (a == null || b == null) {
|
16080 | return false;
|
16081 | }
|
16082 |
|
16083 | if (typeof a.equals === 'function' || typeof b.equals === 'function') {
|
16084 | return typeof a.equals === 'function' && a.equals(b) &&
|
16085 | typeof b.equals === 'function' && b.equals(a);
|
16086 | }
|
16087 |
|
16088 | switch (type(a)) {
|
16089 | case 'Arguments':
|
16090 | case 'Array':
|
16091 | case 'Object':
|
16092 | if (typeof a.constructor === 'function' &&
|
16093 | _functionName(a.constructor) === 'Promise') {
|
16094 | return a === b;
|
16095 | }
|
16096 | break;
|
16097 | case 'Boolean':
|
16098 | case 'Number':
|
16099 | case 'String':
|
16100 | if (!(typeof a === typeof b && identical(a.valueOf(), b.valueOf()))) {
|
16101 | return false;
|
16102 | }
|
16103 | break;
|
16104 | case 'Date':
|
16105 | if (!identical(a.valueOf(), b.valueOf())) {
|
16106 | return false;
|
16107 | }
|
16108 | break;
|
16109 | case 'Error':
|
16110 | return a.name === b.name && a.message === b.message;
|
16111 | case 'RegExp':
|
16112 | if (!(a.source === b.source &&
|
16113 | a.global === b.global &&
|
16114 | a.ignoreCase === b.ignoreCase &&
|
16115 | a.multiline === b.multiline &&
|
16116 | a.sticky === b.sticky &&
|
16117 | a.unicode === b.unicode)) {
|
16118 | return false;
|
16119 | }
|
16120 | break;
|
16121 | case 'Map':
|
16122 | case 'Set':
|
16123 | if (!_equals(_arrayFromIterator(a.entries()), _arrayFromIterator(b.entries()), stackA, stackB)) {
|
16124 | return false;
|
16125 | }
|
16126 | break;
|
16127 | case 'Int8Array':
|
16128 | case 'Uint8Array':
|
16129 | case 'Uint8ClampedArray':
|
16130 | case 'Int16Array':
|
16131 | case 'Uint16Array':
|
16132 | case 'Int32Array':
|
16133 | case 'Uint32Array':
|
16134 | case 'Float32Array':
|
16135 | case 'Float64Array':
|
16136 | break;
|
16137 | case 'ArrayBuffer':
|
16138 | break;
|
16139 | default:
|
16140 | // Values of other types are only equal if identical.
|
16141 | return false;
|
16142 | }
|
16143 |
|
16144 | var keysA = keys(a);
|
16145 | if (keysA.length !== keys(b).length) {
|
16146 | return false;
|
16147 | }
|
16148 |
|
16149 | var idx = stackA.length - 1;
|
16150 | while (idx >= 0) {
|
16151 | if (stackA[idx] === a) {
|
16152 | return stackB[idx] === b;
|
16153 | }
|
16154 | idx -= 1;
|
16155 | }
|
16156 |
|
16157 | stackA.push(a);
|
16158 | stackB.push(b);
|
16159 | idx = keysA.length - 1;
|
16160 | while (idx >= 0) {
|
16161 | var key = keysA[idx];
|
16162 | if (!(_has(key, b) && _equals(b[key], a[key], stackA, stackB))) {
|
16163 | return false;
|
16164 | }
|
16165 | idx -= 1;
|
16166 | }
|
16167 | stackA.pop();
|
16168 | stackB.pop();
|
16169 | return true;
|
16170 | };
|
16171 |
|
16172 |
|
16173 | /***/ }),
|
16174 | /* 203 */
|
16175 | /***/ (function(module, exports, __webpack_require__) {
|
16176 |
|
16177 | var _forceReduced = __webpack_require__(204);
|
16178 | var _reduce = __webpack_require__(8);
|
16179 | var _xfBase = __webpack_require__(4);
|
16180 | var isArrayLike = __webpack_require__(23);
|
16181 |
|
16182 | module.exports = (function() {
|
16183 | var preservingReduced = function(xf) {
|
16184 | return {
|
16185 | '@@transducer/init': _xfBase.init,
|
16186 | '@@transducer/result': function(result) {
|
16187 | return xf['@@transducer/result'](result);
|
16188 | },
|
16189 | '@@transducer/step': function(result, input) {
|
16190 | var ret = xf['@@transducer/step'](result, input);
|
16191 | return ret['@@transducer/reduced'] ? _forceReduced(ret) : ret;
|
16192 | }
|
16193 | };
|
16194 | };
|
16195 |
|
16196 | return function _xcat(xf) {
|
16197 | var rxf = preservingReduced(xf);
|
16198 | return {
|
16199 | '@@transducer/init': _xfBase.init,
|
16200 | '@@transducer/result': function(result) {
|
16201 | return rxf['@@transducer/result'](result);
|
16202 | },
|
16203 | '@@transducer/step': function(result, input) {
|
16204 | return !isArrayLike(input) ? _reduce(rxf, result, [input]) : _reduce(rxf, result, input);
|
16205 | }
|
16206 | };
|
16207 | };
|
16208 | }());
|
16209 |
|
16210 |
|
16211 | /***/ }),
|
16212 | /* 204 */
|
16213 | /***/ (function(module, exports) {
|
16214 |
|
16215 | module.exports = function _forceReduced(x) {
|
16216 | return {
|
16217 | '@@transducer/value': x,
|
16218 | '@@transducer/reduced': true
|
16219 | };
|
16220 | };
|
16221 |
|
16222 |
|
16223 | /***/ }),
|
16224 | /* 205 */
|
16225 | /***/ (function(module, exports) {
|
16226 |
|
16227 | module.exports = function _functionName(f) {
|
16228 | // String(x => x) evaluates to "x => x", so the pattern may not match.
|
16229 | var match = String(f).match(/^function (\w*)/);
|
16230 | return match == null ? '' : match[1];
|
16231 | };
|
16232 |
|
16233 |
|
16234 | /***/ }),
|
16235 | /* 206 */
|
16236 | /***/ (function(module, exports) {
|
16237 |
|
16238 | module.exports = function _isRegExp(x) {
|
16239 | return Object.prototype.toString.call(x) === '[object RegExp]';
|
16240 | };
|
16241 |
|
16242 |
|
16243 | /***/ }),
|
16244 | /* 207 */
|
16245 | /***/ (function(module, exports, __webpack_require__) {
|
16246 |
|
16247 | var _has = __webpack_require__(6);
|
16248 |
|
16249 | // Based on https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
|
16250 | module.exports = function _objectAssign(target) {
|
16251 | if (target == null) {
|
16252 | throw new TypeError('Cannot convert undefined or null to object');
|
16253 | }
|
16254 |
|
16255 | var output = Object(target);
|
16256 | var idx = 1;
|
16257 | var length = arguments.length;
|
16258 | while (idx < length) {
|
16259 | var source = arguments[idx];
|
16260 | if (source != null) {
|
16261 | for (var nextKey in source) {
|
16262 | if (_has(nextKey, source)) {
|
16263 | output[nextKey] = source[nextKey];
|
16264 | }
|
16265 | }
|
16266 | }
|
16267 | idx += 1;
|
16268 | }
|
16269 | return output;
|
16270 | };
|
16271 |
|
16272 |
|
16273 | /***/ }),
|
16274 | /* 208 */
|
16275 | /***/ (function(module, exports) {
|
16276 |
|
16277 | module.exports = function _of(x) { return [x]; };
|
16278 |
|
16279 |
|
16280 | /***/ }),
|
16281 | /* 209 */
|
16282 | /***/ (function(module, exports) {
|
16283 |
|
16284 | module.exports = function _pipe(f, g) {
|
16285 | return function() {
|
16286 | return g.call(this, f.apply(this, arguments));
|
16287 | };
|
16288 | };
|
16289 |
|
16290 |
|
16291 | /***/ }),
|
16292 | /* 210 */
|
16293 | /***/ (function(module, exports) {
|
16294 |
|
16295 | module.exports = function _pipeP(f, g) {
|
16296 | return function() {
|
16297 | var ctx = this;
|
16298 | return f.apply(ctx, arguments).then(function(x) {
|
16299 | return g.call(ctx, x);
|
16300 | });
|
16301 | };
|
16302 | };
|
16303 |
|
16304 |
|
16305 | /***/ }),
|
16306 | /* 211 */
|
16307 | /***/ (function(module, exports) {
|
16308 |
|
16309 | module.exports = function _quote(s) {
|
16310 | var escaped = s
|
16311 | .replace(/\\/g, '\\\\')
|
16312 | .replace(/[\b]/g, '\\b') // \b matches word boundary; [\b] matches backspace
|
16313 | .replace(/\f/g, '\\f')
|
16314 | .replace(/\n/g, '\\n')
|
16315 | .replace(/\r/g, '\\r')
|
16316 | .replace(/\t/g, '\\t')
|
16317 | .replace(/\v/g, '\\v')
|
16318 | .replace(/\0/g, '\\0');
|
16319 |
|
16320 | return '"' + escaped.replace(/"/g, '\\"') + '"';
|
16321 | };
|
16322 |
|
16323 |
|
16324 | /***/ }),
|
16325 | /* 212 */
|
16326 | /***/ (function(module, exports, __webpack_require__) {
|
16327 |
|
16328 | var _assign = __webpack_require__(50);
|
16329 | var _identity = __webpack_require__(52);
|
16330 | var _isTransformer = __webpack_require__(53);
|
16331 | var isArrayLike = __webpack_require__(23);
|
16332 | var objOf = __webpack_require__(100);
|
16333 |
|
16334 |
|
16335 | module.exports = (function() {
|
16336 | var _stepCatArray = {
|
16337 | '@@transducer/init': Array,
|
16338 | '@@transducer/step': function(xs, x) {
|
16339 | xs.push(x);
|
16340 | return xs;
|
16341 | },
|
16342 | '@@transducer/result': _identity
|
16343 | };
|
16344 | var _stepCatString = {
|
16345 | '@@transducer/init': String,
|
16346 | '@@transducer/step': function(a, b) { return a + b; },
|
16347 | '@@transducer/result': _identity
|
16348 | };
|
16349 | var _stepCatObject = {
|
16350 | '@@transducer/init': Object,
|
16351 | '@@transducer/step': function(result, input) {
|
16352 | return _assign(
|
16353 | result,
|
16354 | isArrayLike(input) ? objOf(input[0], input[1]) : input
|
16355 | );
|
16356 | },
|
16357 | '@@transducer/result': _identity
|
16358 | };
|
16359 |
|
16360 | return function _stepCat(obj) {
|
16361 | if (_isTransformer(obj)) {
|
16362 | return obj;
|
16363 | }
|
16364 | if (isArrayLike(obj)) {
|
16365 | return _stepCatArray;
|
16366 | }
|
16367 | if (typeof obj === 'string') {
|
16368 | return _stepCatString;
|
16369 | }
|
16370 | if (typeof obj === 'object') {
|
16371 | return _stepCatObject;
|
16372 | }
|
16373 | throw new Error('Cannot create transformer for ' + obj);
|
16374 | };
|
16375 | }());
|
16376 |
|
16377 |
|
16378 | /***/ }),
|
16379 | /* 213 */
|
16380 | /***/ (function(module, exports) {
|
16381 |
|
16382 | /**
|
16383 | * Polyfill from <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString>.
|
16384 | */
|
16385 | module.exports = (function() {
|
16386 | var pad = function pad(n) { return (n < 10 ? '0' : '') + n; };
|
16387 |
|
16388 | return typeof Date.prototype.toISOString === 'function' ?
|
16389 | function _toISOString(d) {
|
16390 | return d.toISOString();
|
16391 | } :
|
16392 | function _toISOString(d) {
|
16393 | return (
|
16394 | d.getUTCFullYear() + '-' +
|
16395 | pad(d.getUTCMonth() + 1) + '-' +
|
16396 | pad(d.getUTCDate()) + 'T' +
|
16397 | pad(d.getUTCHours()) + ':' +
|
16398 | pad(d.getUTCMinutes()) + ':' +
|
16399 | pad(d.getUTCSeconds()) + '.' +
|
16400 | (d.getUTCMilliseconds() / 1000).toFixed(3).slice(2, 5) + 'Z'
|
16401 | );
|
16402 | };
|
16403 | }());
|
16404 |
|
16405 |
|
16406 | /***/ }),
|
16407 | /* 214 */
|
16408 | /***/ (function(module, exports, __webpack_require__) {
|
16409 |
|
16410 | var _contains = __webpack_require__(17);
|
16411 | var _map = __webpack_require__(37);
|
16412 | var _quote = __webpack_require__(211);
|
16413 | var _toISOString = __webpack_require__(213);
|
16414 | var keys = __webpack_require__(12);
|
16415 | var reject = __webpack_require__(42);
|
16416 |
|
16417 |
|
16418 | module.exports = function _toString(x, seen) {
|
16419 | var recur = function recur(y) {
|
16420 | var xs = seen.concat([x]);
|
16421 | return _contains(y, xs) ? '<Circular>' : _toString(y, xs);
|
16422 | };
|
16423 |
|
16424 | // mapPairs :: (Object, [String]) -> [String]
|
16425 | var mapPairs = function(obj, keys) {
|
16426 | return _map(function(k) { return _quote(k) + ': ' + recur(obj[k]); }, keys.slice().sort());
|
16427 | };
|
16428 |
|
16429 | switch (Object.prototype.toString.call(x)) {
|
16430 | case '[object Arguments]':
|
16431 | return '(function() { return arguments; }(' + _map(recur, x).join(', ') + '))';
|
16432 | case '[object Array]':
|
16433 | return '[' + _map(recur, x).concat(mapPairs(x, reject(function(k) { return /^\d+$/.test(k); }, keys(x)))).join(', ') + ']';
|
16434 | case '[object Boolean]':
|
16435 | return typeof x === 'object' ? 'new Boolean(' + recur(x.valueOf()) + ')' : x.toString();
|
16436 | case '[object Date]':
|
16437 | return 'new Date(' + (isNaN(x.valueOf()) ? recur(NaN) : _quote(_toISOString(x))) + ')';
|
16438 | case '[object Null]':
|
16439 | return 'null';
|
16440 | case '[object Number]':
|
16441 | return typeof x === 'object' ? 'new Number(' + recur(x.valueOf()) + ')' : 1 / x === -Infinity ? '-0' : x.toString(10);
|
16442 | case '[object String]':
|
16443 | return typeof x === 'object' ? 'new String(' + recur(x.valueOf()) + ')' : _quote(x);
|
16444 | case '[object Undefined]':
|
16445 | return 'undefined';
|
16446 | default:
|
16447 | if (typeof x.toString === 'function') {
|
16448 | var repr = x.toString();
|
16449 | if (repr !== '[object Object]') {
|
16450 | return repr;
|
16451 | }
|
16452 | }
|
16453 | return '{' + mapPairs(x, keys(x)).join(', ') + '}';
|
16454 | }
|
16455 | };
|
16456 |
|
16457 |
|
16458 | /***/ }),
|
16459 | /* 215 */
|
16460 | /***/ (function(module, exports, __webpack_require__) {
|
16461 |
|
16462 | var _curry2 = __webpack_require__(0);
|
16463 | var _reduced = __webpack_require__(16);
|
16464 | var _xfBase = __webpack_require__(4);
|
16465 |
|
16466 |
|
16467 | module.exports = (function() {
|
16468 | function XAll(f, xf) {
|
16469 | this.xf = xf;
|
16470 | this.f = f;
|
16471 | this.all = true;
|
16472 | }
|
16473 | XAll.prototype['@@transducer/init'] = _xfBase.init;
|
16474 | XAll.prototype['@@transducer/result'] = function(result) {
|
16475 | if (this.all) {
|
16476 | result = this.xf['@@transducer/step'](result, true);
|
16477 | }
|
16478 | return this.xf['@@transducer/result'](result);
|
16479 | };
|
16480 | XAll.prototype['@@transducer/step'] = function(result, input) {
|
16481 | if (!this.f(input)) {
|
16482 | this.all = false;
|
16483 | result = _reduced(this.xf['@@transducer/step'](result, false));
|
16484 | }
|
16485 | return result;
|
16486 | };
|
16487 |
|
16488 | return _curry2(function _xall(f, xf) { return new XAll(f, xf); });
|
16489 | }());
|
16490 |
|
16491 |
|
16492 | /***/ }),
|
16493 | /* 216 */
|
16494 | /***/ (function(module, exports, __webpack_require__) {
|
16495 |
|
16496 | var _concat = __webpack_require__(9);
|
16497 | var _curry2 = __webpack_require__(0);
|
16498 | var _xfBase = __webpack_require__(4);
|
16499 |
|
16500 |
|
16501 | module.exports = (function() {
|
16502 | function XAperture(n, xf) {
|
16503 | this.xf = xf;
|
16504 | this.pos = 0;
|
16505 | this.full = false;
|
16506 | this.acc = new Array(n);
|
16507 | }
|
16508 | XAperture.prototype['@@transducer/init'] = _xfBase.init;
|
16509 | XAperture.prototype['@@transducer/result'] = function(result) {
|
16510 | this.acc = null;
|
16511 | return this.xf['@@transducer/result'](result);
|
16512 | };
|
16513 | XAperture.prototype['@@transducer/step'] = function(result, input) {
|
16514 | this.store(input);
|
16515 | return this.full ? this.xf['@@transducer/step'](result, this.getCopy()) : result;
|
16516 | };
|
16517 | XAperture.prototype.store = function(input) {
|
16518 | this.acc[this.pos] = input;
|
16519 | this.pos += 1;
|
16520 | if (this.pos === this.acc.length) {
|
16521 | this.pos = 0;
|
16522 | this.full = true;
|
16523 | }
|
16524 | };
|
16525 | XAperture.prototype.getCopy = function() {
|
16526 | return _concat(Array.prototype.slice.call(this.acc, this.pos),
|
16527 | Array.prototype.slice.call(this.acc, 0, this.pos));
|
16528 | };
|
16529 |
|
16530 | return _curry2(function _xaperture(n, xf) { return new XAperture(n, xf); });
|
16531 | }());
|
16532 |
|
16533 |
|
16534 | /***/ }),
|
16535 | /* 217 */
|
16536 | /***/ (function(module, exports, __webpack_require__) {
|
16537 |
|
16538 | var _curry2 = __webpack_require__(0);
|
16539 | var _flatCat = __webpack_require__(203);
|
16540 | var map = __webpack_require__(7);
|
16541 |
|
16542 |
|
16543 | module.exports = _curry2(function _xchain(f, xf) {
|
16544 | return map(f, _flatCat(xf));
|
16545 | });
|
16546 |
|
16547 |
|
16548 | /***/ }),
|
16549 | /* 218 */
|
16550 | /***/ (function(module, exports, __webpack_require__) {
|
16551 |
|
16552 | var _curry2 = __webpack_require__(0);
|
16553 | var _xfBase = __webpack_require__(4);
|
16554 |
|
16555 |
|
16556 | module.exports = (function() {
|
16557 | function XDrop(n, xf) {
|
16558 | this.xf = xf;
|
16559 | this.n = n;
|
16560 | }
|
16561 | XDrop.prototype['@@transducer/init'] = _xfBase.init;
|
16562 | XDrop.prototype['@@transducer/result'] = _xfBase.result;
|
16563 | XDrop.prototype['@@transducer/step'] = function(result, input) {
|
16564 | if (this.n > 0) {
|
16565 | this.n -= 1;
|
16566 | return result;
|
16567 | }
|
16568 | return this.xf['@@transducer/step'](result, input);
|
16569 | };
|
16570 |
|
16571 | return _curry2(function _xdrop(n, xf) { return new XDrop(n, xf); });
|
16572 | }());
|
16573 |
|
16574 |
|
16575 | /***/ }),
|
16576 | /* 219 */
|
16577 | /***/ (function(module, exports, __webpack_require__) {
|
16578 |
|
16579 | var _curry2 = __webpack_require__(0);
|
16580 | var _xfBase = __webpack_require__(4);
|
16581 |
|
16582 |
|
16583 | module.exports = (function() {
|
16584 | function XDropLast(n, xf) {
|
16585 | this.xf = xf;
|
16586 | this.pos = 0;
|
16587 | this.full = false;
|
16588 | this.acc = new Array(n);
|
16589 | }
|
16590 | XDropLast.prototype['@@transducer/init'] = _xfBase.init;
|
16591 | XDropLast.prototype['@@transducer/result'] = function(result) {
|
16592 | this.acc = null;
|
16593 | return this.xf['@@transducer/result'](result);
|
16594 | };
|
16595 | XDropLast.prototype['@@transducer/step'] = function(result, input) {
|
16596 | if (this.full) {
|
16597 | result = this.xf['@@transducer/step'](result, this.acc[this.pos]);
|
16598 | }
|
16599 | this.store(input);
|
16600 | return result;
|
16601 | };
|
16602 | XDropLast.prototype.store = function(input) {
|
16603 | this.acc[this.pos] = input;
|
16604 | this.pos += 1;
|
16605 | if (this.pos === this.acc.length) {
|
16606 | this.pos = 0;
|
16607 | this.full = true;
|
16608 | }
|
16609 | };
|
16610 |
|
16611 | return _curry2(function _xdropLast(n, xf) { return new XDropLast(n, xf); });
|
16612 | }());
|
16613 |
|
16614 |
|
16615 | /***/ }),
|
16616 | /* 220 */
|
16617 | /***/ (function(module, exports, __webpack_require__) {
|
16618 |
|
16619 | var _curry2 = __webpack_require__(0);
|
16620 | var _reduce = __webpack_require__(8);
|
16621 | var _xfBase = __webpack_require__(4);
|
16622 |
|
16623 | module.exports = (function() {
|
16624 | function XDropLastWhile(fn, xf) {
|
16625 | this.f = fn;
|
16626 | this.retained = [];
|
16627 | this.xf = xf;
|
16628 | }
|
16629 | XDropLastWhile.prototype['@@transducer/init'] = _xfBase.init;
|
16630 | XDropLastWhile.prototype['@@transducer/result'] = function(result) {
|
16631 | this.retained = null;
|
16632 | return this.xf['@@transducer/result'](result);
|
16633 | };
|
16634 | XDropLastWhile.prototype['@@transducer/step'] = function(result, input) {
|
16635 | return this.f(input) ? this.retain(result, input)
|
16636 | : this.flush(result, input);
|
16637 | };
|
16638 | XDropLastWhile.prototype.flush = function(result, input) {
|
16639 | result = _reduce(
|
16640 | this.xf['@@transducer/step'],
|
16641 | result,
|
16642 | this.retained
|
16643 | );
|
16644 | this.retained = [];
|
16645 | return this.xf['@@transducer/step'](result, input);
|
16646 | };
|
16647 | XDropLastWhile.prototype.retain = function(result, input) {
|
16648 | this.retained.push(input);
|
16649 | return result;
|
16650 | };
|
16651 |
|
16652 | return _curry2(function _xdropLastWhile(fn, xf) { return new XDropLastWhile(fn, xf); });
|
16653 | }());
|
16654 |
|
16655 |
|
16656 | /***/ }),
|
16657 | /* 221 */
|
16658 | /***/ (function(module, exports, __webpack_require__) {
|
16659 |
|
16660 | var _curry2 = __webpack_require__(0);
|
16661 | var _xfBase = __webpack_require__(4);
|
16662 |
|
16663 |
|
16664 | module.exports = (function() {
|
16665 | function XDropWhile(f, xf) {
|
16666 | this.xf = xf;
|
16667 | this.f = f;
|
16668 | }
|
16669 | XDropWhile.prototype['@@transducer/init'] = _xfBase.init;
|
16670 | XDropWhile.prototype['@@transducer/result'] = _xfBase.result;
|
16671 | XDropWhile.prototype['@@transducer/step'] = function(result, input) {
|
16672 | if (this.f) {
|
16673 | if (this.f(input)) {
|
16674 | return result;
|
16675 | }
|
16676 | this.f = null;
|
16677 | }
|
16678 | return this.xf['@@transducer/step'](result, input);
|
16679 | };
|
16680 |
|
16681 | return _curry2(function _xdropWhile(f, xf) { return new XDropWhile(f, xf); });
|
16682 | }());
|
16683 |
|
16684 |
|
16685 | /***/ }),
|
16686 | /* 222 */
|
16687 | /***/ (function(module, exports, __webpack_require__) {
|
16688 |
|
16689 | var _curry2 = __webpack_require__(0);
|
16690 | var _xfBase = __webpack_require__(4);
|
16691 |
|
16692 |
|
16693 | module.exports = (function() {
|
16694 | function XFilter(f, xf) {
|
16695 | this.xf = xf;
|
16696 | this.f = f;
|
16697 | }
|
16698 | XFilter.prototype['@@transducer/init'] = _xfBase.init;
|
16699 | XFilter.prototype['@@transducer/result'] = _xfBase.result;
|
16700 | XFilter.prototype['@@transducer/step'] = function(result, input) {
|
16701 | return this.f(input) ? this.xf['@@transducer/step'](result, input) : result;
|
16702 | };
|
16703 |
|
16704 | return _curry2(function _xfilter(f, xf) { return new XFilter(f, xf); });
|
16705 | }());
|
16706 |
|
16707 |
|
16708 | /***/ }),
|
16709 | /* 223 */
|
16710 | /***/ (function(module, exports, __webpack_require__) {
|
16711 |
|
16712 | var _curry2 = __webpack_require__(0);
|
16713 | var _reduced = __webpack_require__(16);
|
16714 | var _xfBase = __webpack_require__(4);
|
16715 |
|
16716 |
|
16717 | module.exports = (function() {
|
16718 | function XFind(f, xf) {
|
16719 | this.xf = xf;
|
16720 | this.f = f;
|
16721 | this.found = false;
|
16722 | }
|
16723 | XFind.prototype['@@transducer/init'] = _xfBase.init;
|
16724 | XFind.prototype['@@transducer/result'] = function(result) {
|
16725 | if (!this.found) {
|
16726 | result = this.xf['@@transducer/step'](result, void 0);
|
16727 | }
|
16728 | return this.xf['@@transducer/result'](result);
|
16729 | };
|
16730 | XFind.prototype['@@transducer/step'] = function(result, input) {
|
16731 | if (this.f(input)) {
|
16732 | this.found = true;
|
16733 | result = _reduced(this.xf['@@transducer/step'](result, input));
|
16734 | }
|
16735 | return result;
|
16736 | };
|
16737 |
|
16738 | return _curry2(function _xfind(f, xf) { return new XFind(f, xf); });
|
16739 | }());
|
16740 |
|
16741 |
|
16742 | /***/ }),
|
16743 | /* 224 */
|
16744 | /***/ (function(module, exports, __webpack_require__) {
|
16745 |
|
16746 | var _curry2 = __webpack_require__(0);
|
16747 | var _reduced = __webpack_require__(16);
|
16748 | var _xfBase = __webpack_require__(4);
|
16749 |
|
16750 |
|
16751 | module.exports = (function() {
|
16752 | function XFindIndex(f, xf) {
|
16753 | this.xf = xf;
|
16754 | this.f = f;
|
16755 | this.idx = -1;
|
16756 | this.found = false;
|
16757 | }
|
16758 | XFindIndex.prototype['@@transducer/init'] = _xfBase.init;
|
16759 | XFindIndex.prototype['@@transducer/result'] = function(result) {
|
16760 | if (!this.found) {
|
16761 | result = this.xf['@@transducer/step'](result, -1);
|
16762 | }
|
16763 | return this.xf['@@transducer/result'](result);
|
16764 | };
|
16765 | XFindIndex.prototype['@@transducer/step'] = function(result, input) {
|
16766 | this.idx += 1;
|
16767 | if (this.f(input)) {
|
16768 | this.found = true;
|
16769 | result = _reduced(this.xf['@@transducer/step'](result, this.idx));
|
16770 | }
|
16771 | return result;
|
16772 | };
|
16773 |
|
16774 | return _curry2(function _xfindIndex(f, xf) { return new XFindIndex(f, xf); });
|
16775 | }());
|
16776 |
|
16777 |
|
16778 | /***/ }),
|
16779 | /* 225 */
|
16780 | /***/ (function(module, exports, __webpack_require__) {
|
16781 |
|
16782 | var _curry2 = __webpack_require__(0);
|
16783 | var _xfBase = __webpack_require__(4);
|
16784 |
|
16785 |
|
16786 | module.exports = (function() {
|
16787 | function XFindLast(f, xf) {
|
16788 | this.xf = xf;
|
16789 | this.f = f;
|
16790 | }
|
16791 | XFindLast.prototype['@@transducer/init'] = _xfBase.init;
|
16792 | XFindLast.prototype['@@transducer/result'] = function(result) {
|
16793 | return this.xf['@@transducer/result'](this.xf['@@transducer/step'](result, this.last));
|
16794 | };
|
16795 | XFindLast.prototype['@@transducer/step'] = function(result, input) {
|
16796 | if (this.f(input)) {
|
16797 | this.last = input;
|
16798 | }
|
16799 | return result;
|
16800 | };
|
16801 |
|
16802 | return _curry2(function _xfindLast(f, xf) { return new XFindLast(f, xf); });
|
16803 | }());
|
16804 |
|
16805 |
|
16806 | /***/ }),
|
16807 | /* 226 */
|
16808 | /***/ (function(module, exports, __webpack_require__) {
|
16809 |
|
16810 | var _curry2 = __webpack_require__(0);
|
16811 | var _xfBase = __webpack_require__(4);
|
16812 |
|
16813 |
|
16814 | module.exports = (function() {
|
16815 | function XFindLastIndex(f, xf) {
|
16816 | this.xf = xf;
|
16817 | this.f = f;
|
16818 | this.idx = -1;
|
16819 | this.lastIdx = -1;
|
16820 | }
|
16821 | XFindLastIndex.prototype['@@transducer/init'] = _xfBase.init;
|
16822 | XFindLastIndex.prototype['@@transducer/result'] = function(result) {
|
16823 | return this.xf['@@transducer/result'](this.xf['@@transducer/step'](result, this.lastIdx));
|
16824 | };
|
16825 | XFindLastIndex.prototype['@@transducer/step'] = function(result, input) {
|
16826 | this.idx += 1;
|
16827 | if (this.f(input)) {
|
16828 | this.lastIdx = this.idx;
|
16829 | }
|
16830 | return result;
|
16831 | };
|
16832 |
|
16833 | return _curry2(function _xfindLastIndex(f, xf) { return new XFindLastIndex(f, xf); });
|
16834 | }());
|
16835 |
|
16836 |
|
16837 | /***/ }),
|
16838 | /* 227 */
|
16839 | /***/ (function(module, exports, __webpack_require__) {
|
16840 |
|
16841 | var _curry2 = __webpack_require__(0);
|
16842 | var _xfBase = __webpack_require__(4);
|
16843 |
|
16844 |
|
16845 | module.exports = (function() {
|
16846 | function XMap(f, xf) {
|
16847 | this.xf = xf;
|
16848 | this.f = f;
|
16849 | }
|
16850 | XMap.prototype['@@transducer/init'] = _xfBase.init;
|
16851 | XMap.prototype['@@transducer/result'] = _xfBase.result;
|
16852 | XMap.prototype['@@transducer/step'] = function(result, input) {
|
16853 | return this.xf['@@transducer/step'](result, this.f(input));
|
16854 | };
|
16855 |
|
16856 | return _curry2(function _xmap(f, xf) { return new XMap(f, xf); });
|
16857 | }());
|
16858 |
|
16859 |
|
16860 | /***/ }),
|
16861 | /* 228 */
|
16862 | /***/ (function(module, exports, __webpack_require__) {
|
16863 |
|
16864 | var _curryN = __webpack_require__(33);
|
16865 | var _has = __webpack_require__(6);
|
16866 | var _xfBase = __webpack_require__(4);
|
16867 |
|
16868 |
|
16869 | module.exports = (function() {
|
16870 | function XReduceBy(valueFn, valueAcc, keyFn, xf) {
|
16871 | this.valueFn = valueFn;
|
16872 | this.valueAcc = valueAcc;
|
16873 | this.keyFn = keyFn;
|
16874 | this.xf = xf;
|
16875 | this.inputs = {};
|
16876 | }
|
16877 | XReduceBy.prototype['@@transducer/init'] = _xfBase.init;
|
16878 | XReduceBy.prototype['@@transducer/result'] = function(result) {
|
16879 | var key;
|
16880 | for (key in this.inputs) {
|
16881 | if (_has(key, this.inputs)) {
|
16882 | result = this.xf['@@transducer/step'](result, this.inputs[key]);
|
16883 | if (result['@@transducer/reduced']) {
|
16884 | result = result['@@transducer/value'];
|
16885 | break;
|
16886 | }
|
16887 | }
|
16888 | }
|
16889 | this.inputs = null;
|
16890 | return this.xf['@@transducer/result'](result);
|
16891 | };
|
16892 | XReduceBy.prototype['@@transducer/step'] = function(result, input) {
|
16893 | var key = this.keyFn(input);
|
16894 | this.inputs[key] = this.inputs[key] || [key, this.valueAcc];
|
16895 | this.inputs[key][1] = this.valueFn(this.inputs[key][1], input);
|
16896 | return result;
|
16897 | };
|
16898 |
|
16899 | return _curryN(4, [],
|
16900 | function _xreduceBy(valueFn, valueAcc, keyFn, xf) {
|
16901 | return new XReduceBy(valueFn, valueAcc, keyFn, xf);
|
16902 | });
|
16903 | }());
|
16904 |
|
16905 |
|
16906 | /***/ }),
|
16907 | /* 229 */
|
16908 | /***/ (function(module, exports, __webpack_require__) {
|
16909 |
|
16910 | var _curry2 = __webpack_require__(0);
|
16911 | var _reduced = __webpack_require__(16);
|
16912 | var _xfBase = __webpack_require__(4);
|
16913 |
|
16914 | module.exports = (function() {
|
16915 | function XTake(n, xf) {
|
16916 | this.xf = xf;
|
16917 | this.n = n;
|
16918 | this.i = 0;
|
16919 | }
|
16920 | XTake.prototype['@@transducer/init'] = _xfBase.init;
|
16921 | XTake.prototype['@@transducer/result'] = _xfBase.result;
|
16922 | XTake.prototype['@@transducer/step'] = function(result, input) {
|
16923 | this.i += 1;
|
16924 | var ret = this.n === 0 ? result : this.xf['@@transducer/step'](result, input);
|
16925 | return this.i >= this.n ? _reduced(ret) : ret;
|
16926 | };
|
16927 |
|
16928 | return _curry2(function _xtake(n, xf) { return new XTake(n, xf); });
|
16929 | }());
|
16930 |
|
16931 |
|
16932 | /***/ }),
|
16933 | /* 230 */
|
16934 | /***/ (function(module, exports, __webpack_require__) {
|
16935 |
|
16936 | var _curry2 = __webpack_require__(0);
|
16937 | var _reduced = __webpack_require__(16);
|
16938 | var _xfBase = __webpack_require__(4);
|
16939 |
|
16940 |
|
16941 | module.exports = (function() {
|
16942 | function XTakeWhile(f, xf) {
|
16943 | this.xf = xf;
|
16944 | this.f = f;
|
16945 | }
|
16946 | XTakeWhile.prototype['@@transducer/init'] = _xfBase.init;
|
16947 | XTakeWhile.prototype['@@transducer/result'] = _xfBase.result;
|
16948 | XTakeWhile.prototype['@@transducer/step'] = function(result, input) {
|
16949 | return this.f(input) ? this.xf['@@transducer/step'](result, input) : _reduced(result);
|
16950 | };
|
16951 |
|
16952 | return _curry2(function _xtakeWhile(f, xf) { return new XTakeWhile(f, xf); });
|
16953 | }());
|
16954 |
|
16955 |
|
16956 | /***/ }),
|
16957 | /* 231 */
|
16958 | /***/ (function(module, exports, __webpack_require__) {
|
16959 |
|
16960 | var _contains = __webpack_require__(17);
|
16961 | var _curry2 = __webpack_require__(0);
|
16962 | var _filter = __webpack_require__(81);
|
16963 | var flip = __webpack_require__(32);
|
16964 | var uniq = __webpack_require__(57);
|
16965 |
|
16966 |
|
16967 | /**
|
16968 | * Combines two lists into a set (i.e. no duplicates) composed of those
|
16969 | * elements common to both lists.
|
16970 | *
|
16971 | * @func
|
16972 | * @memberOf R
|
16973 | * @since v0.1.0
|
16974 | * @category Relation
|
16975 | * @sig [*] -> [*] -> [*]
|
16976 | * @param {Array} list1 The first list.
|
16977 | * @param {Array} list2 The second list.
|
16978 | * @return {Array} The list of elements found in both `list1` and `list2`.
|
16979 | * @see R.intersectionWith
|
16980 | * @example
|
16981 | *
|
16982 | * R.intersection([1,2,3,4], [7,6,5,4,3]); //=> [4, 3]
|
16983 | */
|
16984 | module.exports = _curry2(function intersection(list1, list2) {
|
16985 | var lookupList, filteredList;
|
16986 | if (list1.length > list2.length) {
|
16987 | lookupList = list1;
|
16988 | filteredList = list2;
|
16989 | } else {
|
16990 | lookupList = list2;
|
16991 | filteredList = list1;
|
16992 | }
|
16993 | return uniq(_filter(flip(_contains)(lookupList), filteredList));
|
16994 | });
|
16995 |
|
16996 |
|
16997 | /***/ }),
|
16998 | /* 232 */
|
16999 | /***/ (function(module, exports, __webpack_require__) {
|
17000 |
|
17001 | var _containsWith = __webpack_require__(51);
|
17002 | var _curry3 = __webpack_require__(2);
|
17003 | var uniqWith = __webpack_require__(58);
|
17004 |
|
17005 |
|
17006 | /**
|
17007 | * Combines two lists into a set (i.e. no duplicates) composed of those
|
17008 | * elements common to both lists. Duplication is determined according to the
|
17009 | * value returned by applying the supplied predicate to two list elements.
|
17010 | *
|
17011 | * @func
|
17012 | * @memberOf R
|
17013 | * @since v0.1.0
|
17014 | * @category Relation
|
17015 | * @sig ((a, a) -> Boolean) -> [a] -> [a] -> [a]
|
17016 | * @param {Function} pred A predicate function that determines whether
|
17017 | * the two supplied elements are equal.
|
17018 | * @param {Array} list1 One list of items to compare
|
17019 | * @param {Array} list2 A second list of items to compare
|
17020 | * @return {Array} A new list containing those elements common to both lists.
|
17021 | * @see R.intersection
|
17022 | * @example
|
17023 | *
|
17024 | * var buffaloSpringfield = [
|
17025 | * {id: 824, name: 'Richie Furay'},
|
17026 | * {id: 956, name: 'Dewey Martin'},
|
17027 | * {id: 313, name: 'Bruce Palmer'},
|
17028 | * {id: 456, name: 'Stephen Stills'},
|
17029 | * {id: 177, name: 'Neil Young'}
|
17030 | * ];
|
17031 | * var csny = [
|
17032 | * {id: 204, name: 'David Crosby'},
|
17033 | * {id: 456, name: 'Stephen Stills'},
|
17034 | * {id: 539, name: 'Graham Nash'},
|
17035 | * {id: 177, name: 'Neil Young'}
|
17036 | * ];
|
17037 | *
|
17038 | * R.intersectionWith(R.eqBy(R.prop('id')), buffaloSpringfield, csny);
|
17039 | * //=> [{id: 456, name: 'Stephen Stills'}, {id: 177, name: 'Neil Young'}]
|
17040 | */
|
17041 | module.exports = _curry3(function intersectionWith(pred, list1, list2) {
|
17042 | var lookupList, filteredList;
|
17043 | if (list1.length > list2.length) {
|
17044 | lookupList = list1;
|
17045 | filteredList = list2;
|
17046 | } else {
|
17047 | lookupList = list2;
|
17048 | filteredList = list1;
|
17049 | }
|
17050 | var results = [];
|
17051 | var idx = 0;
|
17052 | while (idx < filteredList.length) {
|
17053 | if (_containsWith(pred, filteredList[idx], lookupList)) {
|
17054 | results[results.length] = filteredList[idx];
|
17055 | }
|
17056 | idx += 1;
|
17057 | }
|
17058 | return uniqWith(pred, results);
|
17059 | });
|
17060 |
|
17061 |
|
17062 | /***/ }),
|
17063 | /* 233 */
|
17064 | /***/ (function(module, exports, __webpack_require__) {
|
17065 |
|
17066 | var _checkForMethod = __webpack_require__(21);
|
17067 | var _curry2 = __webpack_require__(0);
|
17068 |
|
17069 |
|
17070 | /**
|
17071 | * Creates a new list with the separator interposed between elements.
|
17072 | *
|
17073 | * Dispatches to the `intersperse` method of the second argument, if present.
|
17074 | *
|
17075 | * @func
|
17076 | * @memberOf R
|
17077 | * @since v0.14.0
|
17078 | * @category List
|
17079 | * @sig a -> [a] -> [a]
|
17080 | * @param {*} separator The element to add to the list.
|
17081 | * @param {Array} list The list to be interposed.
|
17082 | * @return {Array} The new list.
|
17083 | * @example
|
17084 | *
|
17085 | * R.intersperse('n', ['ba', 'a', 'a']); //=> ['ba', 'n', 'a', 'n', 'a']
|
17086 | */
|
17087 | module.exports = _curry2(_checkForMethod('intersperse', function intersperse(separator, list) {
|
17088 | var out = [];
|
17089 | var idx = 0;
|
17090 | var length = list.length;
|
17091 | while (idx < length) {
|
17092 | if (idx === length - 1) {
|
17093 | out.push(list[idx]);
|
17094 | } else {
|
17095 | out.push(list[idx], separator);
|
17096 | }
|
17097 | idx += 1;
|
17098 | }
|
17099 | return out;
|
17100 | }));
|
17101 |
|
17102 |
|
17103 | /***/ }),
|
17104 | /* 234 */
|
17105 | /***/ (function(module, exports, __webpack_require__) {
|
17106 |
|
17107 | var _clone = __webpack_require__(77);
|
17108 | var _curry3 = __webpack_require__(2);
|
17109 | var _isTransformer = __webpack_require__(53);
|
17110 | var _reduce = __webpack_require__(8);
|
17111 | var _stepCat = __webpack_require__(212);
|
17112 |
|
17113 |
|
17114 | /**
|
17115 | * Transforms the items of the list with the transducer and appends the
|
17116 | * transformed items to the accumulator using an appropriate iterator function
|
17117 | * based on the accumulator type.
|
17118 | *
|
17119 | * The accumulator can be an array, string, object or a transformer. Iterated
|
17120 | * items will be appended to arrays and concatenated to strings. Objects will
|
17121 | * be merged directly or 2-item arrays will be merged as key, value pairs.
|
17122 | *
|
17123 | * The accumulator can also be a transformer object that provides a 2-arity
|
17124 | * reducing iterator function, step, 0-arity initial value function, init, and
|
17125 | * 1-arity result extraction function result. The step function is used as the
|
17126 | * iterator function in reduce. The result function is used to convert the
|
17127 | * final accumulator into the return type and in most cases is R.identity. The
|
17128 | * init function is used to provide the initial accumulator.
|
17129 | *
|
17130 | * The iteration is performed with R.reduce after initializing the transducer.
|
17131 | *
|
17132 | * @func
|
17133 | * @memberOf R
|
17134 | * @since v0.12.0
|
17135 | * @category List
|
17136 | * @sig a -> (b -> b) -> [c] -> a
|
17137 | * @param {*} acc The initial accumulator value.
|
17138 | * @param {Function} xf The transducer function. Receives a transformer and returns a transformer.
|
17139 | * @param {Array} list The list to iterate over.
|
17140 | * @return {*} The final, accumulated value.
|
17141 | * @example
|
17142 | *
|
17143 | * var numbers = [1, 2, 3, 4];
|
17144 | * var transducer = R.compose(R.map(R.add(1)), R.take(2));
|
17145 | *
|
17146 | * R.into([], transducer, numbers); //=> [2, 3]
|
17147 | *
|
17148 | * var intoArray = R.into([]);
|
17149 | * intoArray(transducer, numbers); //=> [2, 3]
|
17150 | */
|
17151 | module.exports = _curry3(function into(acc, xf, list) {
|
17152 | return _isTransformer(acc) ?
|
17153 | _reduce(xf(acc), acc['@@transducer/init'](), list) :
|
17154 | _reduce(xf(_stepCat(acc)), _clone(acc, [], [], false), list);
|
17155 | });
|
17156 |
|
17157 |
|
17158 | /***/ }),
|
17159 | /* 235 */
|
17160 | /***/ (function(module, exports, __webpack_require__) {
|
17161 |
|
17162 | var _curry1 = __webpack_require__(1);
|
17163 | var _has = __webpack_require__(6);
|
17164 | var keys = __webpack_require__(12);
|
17165 |
|
17166 |
|
17167 | /**
|
17168 | * Same as R.invertObj, however this accounts for objects with duplicate values
|
17169 | * by putting the values into an array.
|
17170 | *
|
17171 | * @func
|
17172 | * @memberOf R
|
17173 | * @since v0.9.0
|
17174 | * @category Object
|
17175 | * @sig {s: x} -> {x: [ s, ... ]}
|
17176 | * @param {Object} obj The object or array to invert
|
17177 | * @return {Object} out A new object with keys
|
17178 | * in an array.
|
17179 | * @example
|
17180 | *
|
17181 | * var raceResultsByFirstName = {
|
17182 | * first: 'alice',
|
17183 | * second: 'jake',
|
17184 | * third: 'alice',
|
17185 | * };
|
17186 | * R.invert(raceResultsByFirstName);
|
17187 | * //=> { 'alice': ['first', 'third'], 'jake':['second'] }
|
17188 | */
|
17189 | module.exports = _curry1(function invert(obj) {
|
17190 | var props = keys(obj);
|
17191 | var len = props.length;
|
17192 | var idx = 0;
|
17193 | var out = {};
|
17194 |
|
17195 | while (idx < len) {
|
17196 | var key = props[idx];
|
17197 | var val = obj[key];
|
17198 | var list = _has(val, out) ? out[val] : (out[val] = []);
|
17199 | list[list.length] = key;
|
17200 | idx += 1;
|
17201 | }
|
17202 | return out;
|
17203 | });
|
17204 |
|
17205 |
|
17206 | /***/ }),
|
17207 | /* 236 */
|
17208 | /***/ (function(module, exports, __webpack_require__) {
|
17209 |
|
17210 | var _curry1 = __webpack_require__(1);
|
17211 | var keys = __webpack_require__(12);
|
17212 |
|
17213 |
|
17214 | /**
|
17215 | * Returns a new object with the keys of the given object as values, and the
|
17216 | * values of the given object, which are coerced to strings, as keys. Note
|
17217 | * that the last key found is preferred when handling the same value.
|
17218 | *
|
17219 | * @func
|
17220 | * @memberOf R
|
17221 | * @since v0.9.0
|
17222 | * @category Object
|
17223 | * @sig {s: x} -> {x: s}
|
17224 | * @param {Object} obj The object or array to invert
|
17225 | * @return {Object} out A new object
|
17226 | * @example
|
17227 | *
|
17228 | * var raceResults = {
|
17229 | * first: 'alice',
|
17230 | * second: 'jake'
|
17231 | * };
|
17232 | * R.invertObj(raceResults);
|
17233 | * //=> { 'alice': 'first', 'jake':'second' }
|
17234 | *
|
17235 | * // Alternatively:
|
17236 | * var raceResults = ['alice', 'jake'];
|
17237 | * R.invertObj(raceResults);
|
17238 | * //=> { 'alice': '0', 'jake':'1' }
|
17239 | */
|
17240 | module.exports = _curry1(function invertObj(obj) {
|
17241 | var props = keys(obj);
|
17242 | var len = props.length;
|
17243 | var idx = 0;
|
17244 | var out = {};
|
17245 |
|
17246 | while (idx < len) {
|
17247 | var key = props[idx];
|
17248 | out[obj[key]] = key;
|
17249 | idx += 1;
|
17250 | }
|
17251 | return out;
|
17252 | });
|
17253 |
|
17254 |
|
17255 | /***/ }),
|
17256 | /* 237 */
|
17257 | /***/ (function(module, exports, __webpack_require__) {
|
17258 |
|
17259 | var _curry1 = __webpack_require__(1);
|
17260 | var empty = __webpack_require__(75);
|
17261 | var equals = __webpack_require__(10);
|
17262 |
|
17263 |
|
17264 | /**
|
17265 | * Returns `true` if the given value is its type's empty value; `false`
|
17266 | * otherwise.
|
17267 | *
|
17268 | * @func
|
17269 | * @memberOf R
|
17270 | * @since v0.1.0
|
17271 | * @category Logic
|
17272 | * @sig a -> Boolean
|
17273 | * @param {*} x
|
17274 | * @return {Boolean}
|
17275 | * @see R.empty
|
17276 | * @example
|
17277 | *
|
17278 | * R.isEmpty([1, 2, 3]); //=> false
|
17279 | * R.isEmpty([]); //=> true
|
17280 | * R.isEmpty(''); //=> true
|
17281 | * R.isEmpty(null); //=> false
|
17282 | * R.isEmpty({}); //=> true
|
17283 | * R.isEmpty({length: 0}); //=> false
|
17284 | */
|
17285 | module.exports = _curry1(function isEmpty(x) {
|
17286 | return x != null && equals(x, empty(x));
|
17287 | });
|
17288 |
|
17289 |
|
17290 | /***/ }),
|
17291 | /* 238 */
|
17292 | /***/ (function(module, exports, __webpack_require__) {
|
17293 |
|
17294 | var _curry1 = __webpack_require__(1);
|
17295 |
|
17296 |
|
17297 | /**
|
17298 | * Checks if the input value is `null` or `undefined`.
|
17299 | *
|
17300 | * @func
|
17301 | * @memberOf R
|
17302 | * @since v0.9.0
|
17303 | * @category Type
|
17304 | * @sig * -> Boolean
|
17305 | * @param {*} x The value to test.
|
17306 | * @return {Boolean} `true` if `x` is `undefined` or `null`, otherwise `false`.
|
17307 | * @example
|
17308 | *
|
17309 | * R.isNil(null); //=> true
|
17310 | * R.isNil(undefined); //=> true
|
17311 | * R.isNil(0); //=> false
|
17312 | * R.isNil([]); //=> false
|
17313 | */
|
17314 | module.exports = _curry1(function isNil(x) { return x == null; });
|
17315 |
|
17316 |
|
17317 | /***/ }),
|
17318 | /* 239 */
|
17319 | /***/ (function(module, exports, __webpack_require__) {
|
17320 |
|
17321 | var invoker = __webpack_require__(22);
|
17322 |
|
17323 |
|
17324 | /**
|
17325 | * Returns a string made by inserting the `separator` between each element and
|
17326 | * concatenating all the elements into a single string.
|
17327 | *
|
17328 | * @func
|
17329 | * @memberOf R
|
17330 | * @since v0.1.0
|
17331 | * @category List
|
17332 | * @sig String -> [a] -> String
|
17333 | * @param {Number|String} separator The string used to separate the elements.
|
17334 | * @param {Array} xs The elements to join into a string.
|
17335 | * @return {String} str The string made by concatenating `xs` with `separator`.
|
17336 | * @see R.split
|
17337 | * @example
|
17338 | *
|
17339 | * var spacer = R.join(' ');
|
17340 | * spacer(['a', 2, 3.4]); //=> 'a 2 3.4'
|
17341 | * R.join('|', [1, 2, 3]); //=> '1|2|3'
|
17342 | */
|
17343 | module.exports = invoker(1, 'join');
|
17344 |
|
17345 |
|
17346 | /***/ }),
|
17347 | /* 240 */
|
17348 | /***/ (function(module, exports, __webpack_require__) {
|
17349 |
|
17350 | var _curry1 = __webpack_require__(1);
|
17351 |
|
17352 |
|
17353 | /**
|
17354 | * Returns a list containing the names of all the properties of the supplied
|
17355 | * object, including prototype properties.
|
17356 | * Note that the order of the output array is not guaranteed to be consistent
|
17357 | * across different JS platforms.
|
17358 | *
|
17359 | * @func
|
17360 | * @memberOf R
|
17361 | * @since v0.2.0
|
17362 | * @category Object
|
17363 | * @sig {k: v} -> [k]
|
17364 | * @param {Object} obj The object to extract properties from
|
17365 | * @return {Array} An array of the object's own and prototype properties.
|
17366 | * @example
|
17367 | *
|
17368 | * var F = function() { this.x = 'X'; };
|
17369 | * F.prototype.y = 'Y';
|
17370 | * var f = new F();
|
17371 | * R.keysIn(f); //=> ['x', 'y']
|
17372 | */
|
17373 | module.exports = _curry1(function keysIn(obj) {
|
17374 | var prop;
|
17375 | var ks = [];
|
17376 | for (prop in obj) {
|
17377 | ks[ks.length] = prop;
|
17378 | }
|
17379 | return ks;
|
17380 | });
|
17381 |
|
17382 |
|
17383 | /***/ }),
|
17384 | /* 241 */
|
17385 | /***/ (function(module, exports, __webpack_require__) {
|
17386 |
|
17387 | var _curry2 = __webpack_require__(0);
|
17388 | var _isArray = __webpack_require__(15);
|
17389 | var equals = __webpack_require__(10);
|
17390 |
|
17391 |
|
17392 | /**
|
17393 | * Returns the position of the last occurrence of an item in an array, or -1 if
|
17394 | * the item is not included in the array. `R.equals` is used to determine
|
17395 | * equality.
|
17396 | *
|
17397 | * @func
|
17398 | * @memberOf R
|
17399 | * @since v0.1.0
|
17400 | * @category List
|
17401 | * @sig a -> [a] -> Number
|
17402 | * @param {*} target The item to find.
|
17403 | * @param {Array} xs The array to search in.
|
17404 | * @return {Number} the index of the target, or -1 if the target is not found.
|
17405 | * @see R.indexOf
|
17406 | * @example
|
17407 | *
|
17408 | * R.lastIndexOf(3, [-1,3,3,0,1,2,3,4]); //=> 6
|
17409 | * R.lastIndexOf(10, [1,2,3,4]); //=> -1
|
17410 | */
|
17411 | module.exports = _curry2(function lastIndexOf(target, xs) {
|
17412 | if (typeof xs.lastIndexOf === 'function' && !_isArray(xs)) {
|
17413 | return xs.lastIndexOf(target);
|
17414 | } else {
|
17415 | var idx = xs.length - 1;
|
17416 | while (idx >= 0) {
|
17417 | if (equals(xs[idx], target)) {
|
17418 | return idx;
|
17419 | }
|
17420 | idx -= 1;
|
17421 | }
|
17422 | return -1;
|
17423 | }
|
17424 | });
|
17425 |
|
17426 |
|
17427 | /***/ }),
|
17428 | /* 242 */
|
17429 | /***/ (function(module, exports, __webpack_require__) {
|
17430 |
|
17431 | var _curry1 = __webpack_require__(1);
|
17432 | var lens = __webpack_require__(38);
|
17433 | var nth = __webpack_require__(24);
|
17434 | var update = __webpack_require__(113);
|
17435 |
|
17436 |
|
17437 | /**
|
17438 | * Returns a lens whose focus is the specified index.
|
17439 | *
|
17440 | * @func
|
17441 | * @memberOf R
|
17442 | * @since v0.14.0
|
17443 | * @category Object
|
17444 | * @typedefn Lens s a = Functor f => (a -> f a) -> s -> f s
|
17445 | * @sig Number -> Lens s a
|
17446 | * @param {Number} n
|
17447 | * @return {Lens}
|
17448 | * @see R.view, R.set, R.over
|
17449 | * @example
|
17450 | *
|
17451 | * var headLens = R.lensIndex(0);
|
17452 | *
|
17453 | * R.view(headLens, ['a', 'b', 'c']); //=> 'a'
|
17454 | * R.set(headLens, 'x', ['a', 'b', 'c']); //=> ['x', 'b', 'c']
|
17455 | * R.over(headLens, R.toUpper, ['a', 'b', 'c']); //=> ['A', 'b', 'c']
|
17456 | */
|
17457 | module.exports = _curry1(function lensIndex(n) {
|
17458 | return lens(nth(n), update(n));
|
17459 | });
|
17460 |
|
17461 |
|
17462 | /***/ }),
|
17463 | /* 243 */
|
17464 | /***/ (function(module, exports, __webpack_require__) {
|
17465 |
|
17466 | var _curry1 = __webpack_require__(1);
|
17467 | var assocPath = __webpack_require__(64);
|
17468 | var lens = __webpack_require__(38);
|
17469 | var path = __webpack_require__(25);
|
17470 |
|
17471 |
|
17472 | /**
|
17473 | * Returns a lens whose focus is the specified path.
|
17474 | *
|
17475 | * @func
|
17476 | * @memberOf R
|
17477 | * @since v0.19.0
|
17478 | * @category Object
|
17479 | * @typedefn Idx = String | Int
|
17480 | * @typedefn Lens s a = Functor f => (a -> f a) -> s -> f s
|
17481 | * @sig [Idx] -> Lens s a
|
17482 | * @param {Array} path The path to use.
|
17483 | * @return {Lens}
|
17484 | * @see R.view, R.set, R.over
|
17485 | * @example
|
17486 | *
|
17487 | * var xHeadYLens = R.lensPath(['x', 0, 'y']);
|
17488 | *
|
17489 | * R.view(xHeadYLens, {x: [{y: 2, z: 3}, {y: 4, z: 5}]});
|
17490 | * //=> 2
|
17491 | * R.set(xHeadYLens, 1, {x: [{y: 2, z: 3}, {y: 4, z: 5}]});
|
17492 | * //=> {x: [{y: 1, z: 3}, {y: 4, z: 5}]}
|
17493 | * R.over(xHeadYLens, R.negate, {x: [{y: 2, z: 3}, {y: 4, z: 5}]});
|
17494 | * //=> {x: [{y: -2, z: 3}, {y: 4, z: 5}]}
|
17495 | */
|
17496 | module.exports = _curry1(function lensPath(p) {
|
17497 | return lens(path(p), assocPath(p));
|
17498 | });
|
17499 |
|
17500 |
|
17501 | /***/ }),
|
17502 | /* 244 */
|
17503 | /***/ (function(module, exports, __webpack_require__) {
|
17504 |
|
17505 | var _curry1 = __webpack_require__(1);
|
17506 | var assoc = __webpack_require__(30);
|
17507 | var lens = __webpack_require__(38);
|
17508 | var prop = __webpack_require__(54);
|
17509 |
|
17510 |
|
17511 | /**
|
17512 | * Returns a lens whose focus is the specified property.
|
17513 | *
|
17514 | * @func
|
17515 | * @memberOf R
|
17516 | * @since v0.14.0
|
17517 | * @category Object
|
17518 | * @typedefn Lens s a = Functor f => (a -> f a) -> s -> f s
|
17519 | * @sig String -> Lens s a
|
17520 | * @param {String} k
|
17521 | * @return {Lens}
|
17522 | * @see R.view, R.set, R.over
|
17523 | * @example
|
17524 | *
|
17525 | * var xLens = R.lensProp('x');
|
17526 | *
|
17527 | * R.view(xLens, {x: 1, y: 2}); //=> 1
|
17528 | * R.set(xLens, 4, {x: 1, y: 2}); //=> {x: 4, y: 2}
|
17529 | * R.over(xLens, R.negate, {x: 1, y: 2}); //=> {x: -1, y: 2}
|
17530 | */
|
17531 | module.exports = _curry1(function lensProp(k) {
|
17532 | return lens(prop(k), assoc(k));
|
17533 | });
|
17534 |
|
17535 |
|
17536 | /***/ }),
|
17537 | /* 245 */
|
17538 | /***/ (function(module, exports, __webpack_require__) {
|
17539 |
|
17540 | var _curry2 = __webpack_require__(0);
|
17541 |
|
17542 |
|
17543 | /**
|
17544 | * Returns `true` if the first argument is less than the second; `false`
|
17545 | * otherwise.
|
17546 | *
|
17547 | * @func
|
17548 | * @memberOf R
|
17549 | * @since v0.1.0
|
17550 | * @category Relation
|
17551 | * @sig Ord a => a -> a -> Boolean
|
17552 | * @param {*} a
|
17553 | * @param {*} b
|
17554 | * @return {Boolean}
|
17555 | * @see R.gt
|
17556 | * @example
|
17557 | *
|
17558 | * R.lt(2, 1); //=> false
|
17559 | * R.lt(2, 2); //=> false
|
17560 | * R.lt(2, 3); //=> true
|
17561 | * R.lt('a', 'z'); //=> true
|
17562 | * R.lt('z', 'a'); //=> false
|
17563 | */
|
17564 | module.exports = _curry2(function lt(a, b) { return a < b; });
|
17565 |
|
17566 |
|
17567 | /***/ }),
|
17568 | /* 246 */
|
17569 | /***/ (function(module, exports, __webpack_require__) {
|
17570 |
|
17571 | var _curry2 = __webpack_require__(0);
|
17572 |
|
17573 |
|
17574 | /**
|
17575 | * Returns `true` if the first argument is less than or equal to the second;
|
17576 | * `false` otherwise.
|
17577 | *
|
17578 | * @func
|
17579 | * @memberOf R
|
17580 | * @since v0.1.0
|
17581 | * @category Relation
|
17582 | * @sig Ord a => a -> a -> Boolean
|
17583 | * @param {Number} a
|
17584 | * @param {Number} b
|
17585 | * @return {Boolean}
|
17586 | * @see R.gte
|
17587 | * @example
|
17588 | *
|
17589 | * R.lte(2, 1); //=> false
|
17590 | * R.lte(2, 2); //=> true
|
17591 | * R.lte(2, 3); //=> true
|
17592 | * R.lte('a', 'z'); //=> true
|
17593 | * R.lte('z', 'a'); //=> false
|
17594 | */
|
17595 | module.exports = _curry2(function lte(a, b) { return a <= b; });
|
17596 |
|
17597 |
|
17598 | /***/ }),
|
17599 | /* 247 */
|
17600 | /***/ (function(module, exports, __webpack_require__) {
|
17601 |
|
17602 | var _curry3 = __webpack_require__(2);
|
17603 |
|
17604 |
|
17605 | /**
|
17606 | * The mapAccum function behaves like a combination of map and reduce; it
|
17607 | * applies a function to each element of a list, passing an accumulating
|
17608 | * parameter from left to right, and returning a final value of this
|
17609 | * accumulator together with the new list.
|
17610 | *
|
17611 | * The iterator function receives two arguments, *acc* and *value*, and should
|
17612 | * return a tuple *[acc, value]*.
|
17613 | *
|
17614 | * @func
|
17615 | * @memberOf R
|
17616 | * @since v0.10.0
|
17617 | * @category List
|
17618 | * @sig (acc -> x -> (acc, y)) -> acc -> [x] -> (acc, [y])
|
17619 | * @param {Function} fn The function to be called on every element of the input `list`.
|
17620 | * @param {*} acc The accumulator value.
|
17621 | * @param {Array} list The list to iterate over.
|
17622 | * @return {*} The final, accumulated value.
|
17623 | * @see R.addIndex, R.mapAccumRight
|
17624 | * @example
|
17625 | *
|
17626 | * var digits = ['1', '2', '3', '4'];
|
17627 | * var appender = (a, b) => [a + b, a + b];
|
17628 | *
|
17629 | * R.mapAccum(appender, 0, digits); //=> ['01234', ['01', '012', '0123', '01234']]
|
17630 | * @symb R.mapAccum(f, a, [b, c, d]) = [
|
17631 | * f(f(f(a, b)[0], c)[0], d)[0],
|
17632 | * [
|
17633 | * f(a, b)[1],
|
17634 | * f(f(a, b)[0], c)[1],
|
17635 | * f(f(f(a, b)[0], c)[0], d)[1]
|
17636 | * ]
|
17637 | * ]
|
17638 | */
|
17639 | module.exports = _curry3(function mapAccum(fn, acc, list) {
|
17640 | var idx = 0;
|
17641 | var len = list.length;
|
17642 | var result = [];
|
17643 | var tuple = [acc];
|
17644 | while (idx < len) {
|
17645 | tuple = fn(tuple[0], list[idx]);
|
17646 | result[idx] = tuple[1];
|
17647 | idx += 1;
|
17648 | }
|
17649 | return [tuple[0], result];
|
17650 | });
|
17651 |
|
17652 |
|
17653 | /***/ }),
|
17654 | /* 248 */
|
17655 | /***/ (function(module, exports, __webpack_require__) {
|
17656 |
|
17657 | var _curry3 = __webpack_require__(2);
|
17658 |
|
17659 |
|
17660 | /**
|
17661 | * The mapAccumRight function behaves like a combination of map and reduce; it
|
17662 | * applies a function to each element of a list, passing an accumulating
|
17663 | * parameter from right to left, and returning a final value of this
|
17664 | * accumulator together with the new list.
|
17665 | *
|
17666 | * Similar to `mapAccum`, except moves through the input list from the right to
|
17667 | * the left.
|
17668 | *
|
17669 | * The iterator function receives two arguments, *value* and *acc*, and should
|
17670 | * return a tuple *[value, acc]*.
|
17671 | *
|
17672 | * @func
|
17673 | * @memberOf R
|
17674 | * @since v0.10.0
|
17675 | * @category List
|
17676 | * @sig (x-> acc -> (y, acc)) -> acc -> [x] -> ([y], acc)
|
17677 | * @param {Function} fn The function to be called on every element of the input `list`.
|
17678 | * @param {*} acc The accumulator value.
|
17679 | * @param {Array} list The list to iterate over.
|
17680 | * @return {*} The final, accumulated value.
|
17681 | * @see R.addIndex, R.mapAccum
|
17682 | * @example
|
17683 | *
|
17684 | * var digits = ['1', '2', '3', '4'];
|
17685 | * var append = (a, b) => [a + b, a + b];
|
17686 | *
|
17687 | * R.mapAccumRight(append, 5, digits); //=> [['12345', '2345', '345', '45'], '12345']
|
17688 | * @symb R.mapAccumRight(f, a, [b, c, d]) = [
|
17689 | * [
|
17690 | * f(b, f(c, f(d, a)[0])[0])[1],
|
17691 | * f(c, f(d, a)[0])[1],
|
17692 | * f(d, a)[1],
|
17693 | * ]
|
17694 | * f(b, f(c, f(d, a)[0])[0])[0],
|
17695 | * ]
|
17696 | */
|
17697 | module.exports = _curry3(function mapAccumRight(fn, acc, list) {
|
17698 | var idx = list.length - 1;
|
17699 | var result = [];
|
17700 | var tuple = [acc];
|
17701 | while (idx >= 0) {
|
17702 | tuple = fn(list[idx], tuple[0]);
|
17703 | result[idx] = tuple[1];
|
17704 | idx -= 1;
|
17705 | }
|
17706 | return [result, tuple[0]];
|
17707 | });
|
17708 |
|
17709 |
|
17710 | /***/ }),
|
17711 | /* 249 */
|
17712 | /***/ (function(module, exports, __webpack_require__) {
|
17713 |
|
17714 | var _curry2 = __webpack_require__(0);
|
17715 | var _reduce = __webpack_require__(8);
|
17716 | var keys = __webpack_require__(12);
|
17717 |
|
17718 |
|
17719 | /**
|
17720 | * An Object-specific version of `map`. The function is applied to three
|
17721 | * arguments: *(value, key, obj)*. If only the value is significant, use
|
17722 | * `map` instead.
|
17723 | *
|
17724 | * @func
|
17725 | * @memberOf R
|
17726 | * @since v0.9.0
|
17727 | * @category Object
|
17728 | * @sig ((*, String, Object) -> *) -> Object -> Object
|
17729 | * @param {Function} fn
|
17730 | * @param {Object} obj
|
17731 | * @return {Object}
|
17732 | * @see R.map
|
17733 | * @example
|
17734 | *
|
17735 | * var values = { x: 1, y: 2, z: 3 };
|
17736 | * var prependKeyAndDouble = (num, key, obj) => key + (num * 2);
|
17737 | *
|
17738 | * R.mapObjIndexed(prependKeyAndDouble, values); //=> { x: 'x2', y: 'y4', z: 'z6' }
|
17739 | */
|
17740 | module.exports = _curry2(function mapObjIndexed(fn, obj) {
|
17741 | return _reduce(function(acc, key) {
|
17742 | acc[key] = fn(obj[key], key, obj);
|
17743 | return acc;
|
17744 | }, {}, keys(obj));
|
17745 | });
|
17746 |
|
17747 |
|
17748 | /***/ }),
|
17749 | /* 250 */
|
17750 | /***/ (function(module, exports, __webpack_require__) {
|
17751 |
|
17752 | var _curry2 = __webpack_require__(0);
|
17753 |
|
17754 |
|
17755 | /**
|
17756 | * Tests a regular expression against a String. Note that this function will
|
17757 | * return an empty array when there are no matches. This differs from
|
17758 | * [`String.prototype.match`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match)
|
17759 | * which returns `null` when there are no matches.
|
17760 | *
|
17761 | * @func
|
17762 | * @memberOf R
|
17763 | * @since v0.1.0
|
17764 | * @category String
|
17765 | * @sig RegExp -> String -> [String | Undefined]
|
17766 | * @param {RegExp} rx A regular expression.
|
17767 | * @param {String} str The string to match against
|
17768 | * @return {Array} The list of matches or empty array.
|
17769 | * @see R.test
|
17770 | * @example
|
17771 | *
|
17772 | * R.match(/([a-z]a)/g, 'bananas'); //=> ['ba', 'na', 'na']
|
17773 | * R.match(/a/, 'b'); //=> []
|
17774 | * R.match(/a/, null); //=> TypeError: null does not have a method named "match"
|
17775 | */
|
17776 | module.exports = _curry2(function match(rx, str) {
|
17777 | return str.match(rx) || [];
|
17778 | });
|
17779 |
|
17780 |
|
17781 | /***/ }),
|
17782 | /* 251 */
|
17783 | /***/ (function(module, exports, __webpack_require__) {
|
17784 |
|
17785 | var _curry2 = __webpack_require__(0);
|
17786 | var _isInteger = __webpack_require__(84);
|
17787 |
|
17788 |
|
17789 | /**
|
17790 | * mathMod behaves like the modulo operator should mathematically, unlike the
|
17791 | * `%` operator (and by extension, R.modulo). So while "-17 % 5" is -2,
|
17792 | * mathMod(-17, 5) is 3. mathMod requires Integer arguments, and returns NaN
|
17793 | * when the modulus is zero or negative.
|
17794 | *
|
17795 | * @func
|
17796 | * @memberOf R
|
17797 | * @since v0.3.0
|
17798 | * @category Math
|
17799 | * @sig Number -> Number -> Number
|
17800 | * @param {Number} m The dividend.
|
17801 | * @param {Number} p the modulus.
|
17802 | * @return {Number} The result of `b mod a`.
|
17803 | * @example
|
17804 | *
|
17805 | * R.mathMod(-17, 5); //=> 3
|
17806 | * R.mathMod(17, 5); //=> 2
|
17807 | * R.mathMod(17, -5); //=> NaN
|
17808 | * R.mathMod(17, 0); //=> NaN
|
17809 | * R.mathMod(17.2, 5); //=> NaN
|
17810 | * R.mathMod(17, 5.3); //=> NaN
|
17811 | *
|
17812 | * var clock = R.mathMod(R.__, 12);
|
17813 | * clock(15); //=> 3
|
17814 | * clock(24); //=> 0
|
17815 | *
|
17816 | * var seventeenMod = R.mathMod(17);
|
17817 | * seventeenMod(3); //=> 2
|
17818 | * seventeenMod(4); //=> 1
|
17819 | * seventeenMod(10); //=> 7
|
17820 | */
|
17821 | module.exports = _curry2(function mathMod(m, p) {
|
17822 | if (!_isInteger(m)) { return NaN; }
|
17823 | if (!_isInteger(p) || p < 1) { return NaN; }
|
17824 | return ((m % p) + p) % p;
|
17825 | });
|
17826 |
|
17827 |
|
17828 | /***/ }),
|
17829 | /* 252 */
|
17830 | /***/ (function(module, exports, __webpack_require__) {
|
17831 |
|
17832 | var _curry3 = __webpack_require__(2);
|
17833 |
|
17834 |
|
17835 | /**
|
17836 | * Takes a function and two values, and returns whichever value produces the
|
17837 | * larger result when passed to the provided function.
|
17838 | *
|
17839 | * @func
|
17840 | * @memberOf R
|
17841 | * @since v0.8.0
|
17842 | * @category Relation
|
17843 | * @sig Ord b => (a -> b) -> a -> a -> a
|
17844 | * @param {Function} f
|
17845 | * @param {*} a
|
17846 | * @param {*} b
|
17847 | * @return {*}
|
17848 | * @see R.max, R.minBy
|
17849 | * @example
|
17850 | *
|
17851 | * // square :: Number -> Number
|
17852 | * var square = n => n * n;
|
17853 | *
|
17854 | * R.maxBy(square, -3, 2); //=> -3
|
17855 | *
|
17856 | * R.reduce(R.maxBy(square), 0, [3, -5, 4, 1, -2]); //=> -5
|
17857 | * R.reduce(R.maxBy(square), 0, []); //=> 0
|
17858 | */
|
17859 | module.exports = _curry3(function maxBy(f, a, b) {
|
17860 | return f(b) > f(a) ? b : a;
|
17861 | });
|
17862 |
|
17863 |
|
17864 | /***/ }),
|
17865 | /* 253 */
|
17866 | /***/ (function(module, exports, __webpack_require__) {
|
17867 |
|
17868 | var _curry1 = __webpack_require__(1);
|
17869 | var mean = __webpack_require__(96);
|
17870 |
|
17871 |
|
17872 | /**
|
17873 | * Returns the median of the given list of numbers.
|
17874 | *
|
17875 | * @func
|
17876 | * @memberOf R
|
17877 | * @since v0.14.0
|
17878 | * @category Math
|
17879 | * @sig [Number] -> Number
|
17880 | * @param {Array} list
|
17881 | * @return {Number}
|
17882 | * @example
|
17883 | *
|
17884 | * R.median([2, 9, 7]); //=> 7
|
17885 | * R.median([7, 2, 10, 9]); //=> 8
|
17886 | * R.median([]); //=> NaN
|
17887 | */
|
17888 | module.exports = _curry1(function median(list) {
|
17889 | var len = list.length;
|
17890 | if (len === 0) {
|
17891 | return NaN;
|
17892 | }
|
17893 | var width = 2 - len % 2;
|
17894 | var idx = (len - width) / 2;
|
17895 | return mean(Array.prototype.slice.call(list, 0).sort(function(a, b) {
|
17896 | return a < b ? -1 : a > b ? 1 : 0;
|
17897 | }).slice(idx, idx + width));
|
17898 | });
|
17899 |
|
17900 |
|
17901 | /***/ }),
|
17902 | /* 254 */
|
17903 | /***/ (function(module, exports, __webpack_require__) {
|
17904 |
|
17905 | var _arity = __webpack_require__(11);
|
17906 | var _curry1 = __webpack_require__(1);
|
17907 | var _has = __webpack_require__(6);
|
17908 | var toString = __webpack_require__(27);
|
17909 |
|
17910 |
|
17911 | /**
|
17912 | * Creates a new function that, when invoked, caches the result of calling `fn`
|
17913 | * for a given argument set and returns the result. Subsequent calls to the
|
17914 | * memoized `fn` with the same argument set will not result in an additional
|
17915 | * call to `fn`; instead, the cached result for that set of arguments will be
|
17916 | * returned.
|
17917 | *
|
17918 | * @func
|
17919 | * @memberOf R
|
17920 | * @since v0.1.0
|
17921 | * @category Function
|
17922 | * @sig (*... -> a) -> (*... -> a)
|
17923 | * @param {Function} fn The function to memoize.
|
17924 | * @return {Function} Memoized version of `fn`.
|
17925 | * @example
|
17926 | *
|
17927 | * var count = 0;
|
17928 | * var factorial = R.memoize(n => {
|
17929 | * count += 1;
|
17930 | * return R.product(R.range(1, n + 1));
|
17931 | * });
|
17932 | * factorial(5); //=> 120
|
17933 | * factorial(5); //=> 120
|
17934 | * factorial(5); //=> 120
|
17935 | * count; //=> 1
|
17936 | */
|
17937 | module.exports = _curry1(function memoize(fn) {
|
17938 | var cache = {};
|
17939 | return _arity(fn.length, function() {
|
17940 | var key = toString(arguments);
|
17941 | if (!_has(key, cache)) {
|
17942 | cache[key] = fn.apply(this, arguments);
|
17943 | }
|
17944 | return cache[key];
|
17945 | });
|
17946 | });
|
17947 |
|
17948 |
|
17949 | /***/ }),
|
17950 | /* 255 */
|
17951 | /***/ (function(module, exports, __webpack_require__) {
|
17952 |
|
17953 | var _assign = __webpack_require__(50);
|
17954 | var _curry2 = __webpack_require__(0);
|
17955 |
|
17956 |
|
17957 | /**
|
17958 | * Create a new object with the own properties of the first object merged with
|
17959 | * the own properties of the second object. If a key exists in both objects,
|
17960 | * the value from the second object will be used.
|
17961 | *
|
17962 | * @func
|
17963 | * @memberOf R
|
17964 | * @since v0.1.0
|
17965 | * @category Object
|
17966 | * @sig {k: v} -> {k: v} -> {k: v}
|
17967 | * @param {Object} l
|
17968 | * @param {Object} r
|
17969 | * @return {Object}
|
17970 | * @see R.mergeWith, R.mergeWithKey
|
17971 | * @example
|
17972 | *
|
17973 | * R.merge({ 'name': 'fred', 'age': 10 }, { 'age': 40 });
|
17974 | * //=> { 'name': 'fred', 'age': 40 }
|
17975 | *
|
17976 | * var resetToDefault = R.merge(R.__, {x: 0});
|
17977 | * resetToDefault({x: 5, y: 2}); //=> {x: 0, y: 2}
|
17978 | * @symb R.merge({ x: 1, y: 2 }, { y: 5, z: 3 }) = { x: 1, y: 5, z: 3 }
|
17979 | */
|
17980 | module.exports = _curry2(function merge(l, r) {
|
17981 | return _assign({}, l, r);
|
17982 | });
|
17983 |
|
17984 |
|
17985 | /***/ }),
|
17986 | /* 256 */
|
17987 | /***/ (function(module, exports, __webpack_require__) {
|
17988 |
|
17989 | var _assign = __webpack_require__(50);
|
17990 | var _curry1 = __webpack_require__(1);
|
17991 |
|
17992 |
|
17993 | /**
|
17994 | * Merges a list of objects together into one object.
|
17995 | *
|
17996 | * @func
|
17997 | * @memberOf R
|
17998 | * @since v0.10.0
|
17999 | * @category List
|
18000 | * @sig [{k: v}] -> {k: v}
|
18001 | * @param {Array} list An array of objects
|
18002 | * @return {Object} A merged object.
|
18003 | * @see R.reduce
|
18004 | * @example
|
18005 | *
|
18006 | * R.mergeAll([{foo:1},{bar:2},{baz:3}]); //=> {foo:1,bar:2,baz:3}
|
18007 | * R.mergeAll([{foo:1},{foo:2},{bar:2}]); //=> {foo:2,bar:2}
|
18008 | * @symb R.mergeAll([{ x: 1 }, { y: 2 }, { z: 3 }]) = { x: 1, y: 2, z: 3 }
|
18009 | */
|
18010 | module.exports = _curry1(function mergeAll(list) {
|
18011 | return _assign.apply(null, [{}].concat(list));
|
18012 | });
|
18013 |
|
18014 |
|
18015 | /***/ }),
|
18016 | /* 257 */
|
18017 | /***/ (function(module, exports, __webpack_require__) {
|
18018 |
|
18019 | var _curry3 = __webpack_require__(2);
|
18020 | var mergeWithKey = __webpack_require__(97);
|
18021 |
|
18022 |
|
18023 | /**
|
18024 | * Creates a new object with the own properties of the two provided objects. If
|
18025 | * a key exists in both objects, the provided function is applied to the values
|
18026 | * associated with the key in each object, with the result being used as the
|
18027 | * value associated with the key in the returned object. The key will be
|
18028 | * excluded from the returned object if the resulting value is `undefined`.
|
18029 | *
|
18030 | * @func
|
18031 | * @memberOf R
|
18032 | * @since v0.19.0
|
18033 | * @category Object
|
18034 | * @sig (a -> a -> a) -> {a} -> {a} -> {a}
|
18035 | * @param {Function} fn
|
18036 | * @param {Object} l
|
18037 | * @param {Object} r
|
18038 | * @return {Object}
|
18039 | * @see R.merge, R.mergeWithKey
|
18040 | * @example
|
18041 | *
|
18042 | * R.mergeWith(R.concat,
|
18043 | * { a: true, values: [10, 20] },
|
18044 | * { b: true, values: [15, 35] });
|
18045 | * //=> { a: true, b: true, values: [10, 20, 15, 35] }
|
18046 | */
|
18047 | module.exports = _curry3(function mergeWith(fn, l, r) {
|
18048 | return mergeWithKey(function(_, _l, _r) {
|
18049 | return fn(_l, _r);
|
18050 | }, l, r);
|
18051 | });
|
18052 |
|
18053 |
|
18054 | /***/ }),
|
18055 | /* 258 */
|
18056 | /***/ (function(module, exports, __webpack_require__) {
|
18057 |
|
18058 | var _curry2 = __webpack_require__(0);
|
18059 |
|
18060 |
|
18061 | /**
|
18062 | * Returns the smaller of its two arguments.
|
18063 | *
|
18064 | * @func
|
18065 | * @memberOf R
|
18066 | * @since v0.1.0
|
18067 | * @category Relation
|
18068 | * @sig Ord a => a -> a -> a
|
18069 | * @param {*} a
|
18070 | * @param {*} b
|
18071 | * @return {*}
|
18072 | * @see R.minBy, R.max
|
18073 | * @example
|
18074 | *
|
18075 | * R.min(789, 123); //=> 123
|
18076 | * R.min('a', 'b'); //=> 'a'
|
18077 | */
|
18078 | module.exports = _curry2(function min(a, b) { return b < a ? b : a; });
|
18079 |
|
18080 |
|
18081 | /***/ }),
|
18082 | /* 259 */
|
18083 | /***/ (function(module, exports, __webpack_require__) {
|
18084 |
|
18085 | var _curry3 = __webpack_require__(2);
|
18086 |
|
18087 |
|
18088 | /**
|
18089 | * Takes a function and two values, and returns whichever value produces the
|
18090 | * smaller result when passed to the provided function.
|
18091 | *
|
18092 | * @func
|
18093 | * @memberOf R
|
18094 | * @since v0.8.0
|
18095 | * @category Relation
|
18096 | * @sig Ord b => (a -> b) -> a -> a -> a
|
18097 | * @param {Function} f
|
18098 | * @param {*} a
|
18099 | * @param {*} b
|
18100 | * @return {*}
|
18101 | * @see R.min, R.maxBy
|
18102 | * @example
|
18103 | *
|
18104 | * // square :: Number -> Number
|
18105 | * var square = n => n * n;
|
18106 | *
|
18107 | * R.minBy(square, -3, 2); //=> 2
|
18108 | *
|
18109 | * R.reduce(R.minBy(square), Infinity, [3, -5, 4, 1, -2]); //=> 1
|
18110 | * R.reduce(R.minBy(square), Infinity, []); //=> Infinity
|
18111 | */
|
18112 | module.exports = _curry3(function minBy(f, a, b) {
|
18113 | return f(b) < f(a) ? b : a;
|
18114 | });
|
18115 |
|
18116 |
|
18117 | /***/ }),
|
18118 | /* 260 */
|
18119 | /***/ (function(module, exports, __webpack_require__) {
|
18120 |
|
18121 | var _curry2 = __webpack_require__(0);
|
18122 |
|
18123 |
|
18124 | /**
|
18125 | * Divides the first parameter by the second and returns the remainder. Note
|
18126 | * that this function preserves the JavaScript-style behavior for modulo. For
|
18127 | * mathematical modulo see `mathMod`.
|
18128 | *
|
18129 | * @func
|
18130 | * @memberOf R
|
18131 | * @since v0.1.1
|
18132 | * @category Math
|
18133 | * @sig Number -> Number -> Number
|
18134 | * @param {Number} a The value to the divide.
|
18135 | * @param {Number} b The pseudo-modulus
|
18136 | * @return {Number} The result of `b % a`.
|
18137 | * @see R.mathMod
|
18138 | * @example
|
18139 | *
|
18140 | * R.modulo(17, 3); //=> 2
|
18141 | * // JS behavior:
|
18142 | * R.modulo(-17, 3); //=> -2
|
18143 | * R.modulo(17, -3); //=> 2
|
18144 | *
|
18145 | * var isOdd = R.modulo(R.__, 2);
|
18146 | * isOdd(42); //=> 0
|
18147 | * isOdd(21); //=> 1
|
18148 | */
|
18149 | module.exports = _curry2(function modulo(a, b) { return a % b; });
|
18150 |
|
18151 |
|
18152 | /***/ }),
|
18153 | /* 261 */
|
18154 | /***/ (function(module, exports, __webpack_require__) {
|
18155 |
|
18156 | var _curry1 = __webpack_require__(1);
|
18157 |
|
18158 |
|
18159 | /**
|
18160 | * Negates its argument.
|
18161 | *
|
18162 | * @func
|
18163 | * @memberOf R
|
18164 | * @since v0.9.0
|
18165 | * @category Math
|
18166 | * @sig Number -> Number
|
18167 | * @param {Number} n
|
18168 | * @return {Number}
|
18169 | * @example
|
18170 | *
|
18171 | * R.negate(42); //=> -42
|
18172 | */
|
18173 | module.exports = _curry1(function negate(n) { return -n; });
|
18174 |
|
18175 |
|
18176 | /***/ }),
|
18177 | /* 262 */
|
18178 | /***/ (function(module, exports, __webpack_require__) {
|
18179 |
|
18180 | var _complement = __webpack_require__(79);
|
18181 | var _curry2 = __webpack_require__(0);
|
18182 | var _dispatchable = __webpack_require__(3);
|
18183 | var _xany = __webpack_require__(88);
|
18184 | var any = __webpack_require__(62);
|
18185 |
|
18186 |
|
18187 | /**
|
18188 | * Returns `true` if no elements of the list match the predicate, `false`
|
18189 | * otherwise.
|
18190 | *
|
18191 | * Dispatches to the `any` method of the second argument, if present.
|
18192 | *
|
18193 | * @func
|
18194 | * @memberOf R
|
18195 | * @since v0.12.0
|
18196 | * @category List
|
18197 | * @sig (a -> Boolean) -> [a] -> Boolean
|
18198 | * @param {Function} fn The predicate function.
|
18199 | * @param {Array} list The array to consider.
|
18200 | * @return {Boolean} `true` if the predicate is not satisfied by every element, `false` otherwise.
|
18201 | * @see R.all, R.any
|
18202 | * @example
|
18203 | *
|
18204 | * var isEven = n => n % 2 === 0;
|
18205 | *
|
18206 | * R.none(isEven, [1, 3, 5, 7, 9, 11]); //=> true
|
18207 | * R.none(isEven, [1, 3, 5, 7, 8, 11]); //=> false
|
18208 | */
|
18209 | module.exports = _curry2(_complement(_dispatchable(['any'], _xany, any)));
|
18210 |
|
18211 |
|
18212 | /***/ }),
|
18213 | /* 263 */
|
18214 | /***/ (function(module, exports, __webpack_require__) {
|
18215 |
|
18216 | var _curry1 = __webpack_require__(1);
|
18217 | var curryN = __webpack_require__(5);
|
18218 | var nth = __webpack_require__(24);
|
18219 |
|
18220 |
|
18221 | /**
|
18222 | * Returns a function which returns its nth argument.
|
18223 | *
|
18224 | * @func
|
18225 | * @memberOf R
|
18226 | * @since v0.9.0
|
18227 | * @category Function
|
18228 | * @sig Number -> *... -> *
|
18229 | * @param {Number} n
|
18230 | * @return {Function}
|
18231 | * @example
|
18232 | *
|
18233 | * R.nthArg(1)('a', 'b', 'c'); //=> 'b'
|
18234 | * R.nthArg(-1)('a', 'b', 'c'); //=> 'c'
|
18235 | * @symb R.nthArg(-1)(a, b, c) = c
|
18236 | * @symb R.nthArg(0)(a, b, c) = a
|
18237 | * @symb R.nthArg(1)(a, b, c) = b
|
18238 | */
|
18239 | module.exports = _curry1(function nthArg(n) {
|
18240 | var arity = n < 0 ? 1 : n + 1;
|
18241 | return curryN(arity, function() {
|
18242 | return nth(n, arguments);
|
18243 | });
|
18244 | });
|
18245 |
|
18246 |
|
18247 | /***/ }),
|
18248 | /* 264 */
|
18249 | /***/ (function(module, exports, __webpack_require__) {
|
18250 |
|
18251 | var _curry1 = __webpack_require__(1);
|
18252 | var _of = __webpack_require__(208);
|
18253 |
|
18254 |
|
18255 | /**
|
18256 | * Returns a singleton array containing the value provided.
|
18257 | *
|
18258 | * Note this `of` is different from the ES6 `of`; See
|
18259 | * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/of
|
18260 | *
|
18261 | * @func
|
18262 | * @memberOf R
|
18263 | * @since v0.3.0
|
18264 | * @category Function
|
18265 | * @sig a -> [a]
|
18266 | * @param {*} x any value
|
18267 | * @return {Array} An array wrapping `x`.
|
18268 | * @example
|
18269 | *
|
18270 | * R.of(null); //=> [null]
|
18271 | * R.of([42]); //=> [[42]]
|
18272 | */
|
18273 | module.exports = _curry1(_of);
|
18274 |
|
18275 |
|
18276 | /***/ }),
|
18277 | /* 265 */
|
18278 | /***/ (function(module, exports, __webpack_require__) {
|
18279 |
|
18280 | var _contains = __webpack_require__(17);
|
18281 | var _curry2 = __webpack_require__(0);
|
18282 |
|
18283 |
|
18284 | /**
|
18285 | * Returns a partial copy of an object omitting the keys specified.
|
18286 | *
|
18287 | * @func
|
18288 | * @memberOf R
|
18289 | * @since v0.1.0
|
18290 | * @category Object
|
18291 | * @sig [String] -> {String: *} -> {String: *}
|
18292 | * @param {Array} names an array of String property names to omit from the new object
|
18293 | * @param {Object} obj The object to copy from
|
18294 | * @return {Object} A new object with properties from `names` not on it.
|
18295 | * @see R.pick
|
18296 | * @example
|
18297 | *
|
18298 | * R.omit(['a', 'd'], {a: 1, b: 2, c: 3, d: 4}); //=> {b: 2, c: 3}
|
18299 | */
|
18300 | module.exports = _curry2(function omit(names, obj) {
|
18301 | var result = {};
|
18302 | for (var prop in obj) {
|
18303 | if (!_contains(prop, names)) {
|
18304 | result[prop] = obj[prop];
|
18305 | }
|
18306 | }
|
18307 | return result;
|
18308 | });
|
18309 |
|
18310 |
|
18311 | /***/ }),
|
18312 | /* 266 */
|
18313 | /***/ (function(module, exports, __webpack_require__) {
|
18314 |
|
18315 | var _arity = __webpack_require__(11);
|
18316 | var _curry1 = __webpack_require__(1);
|
18317 |
|
18318 |
|
18319 | /**
|
18320 | * Accepts a function `fn` and returns a function that guards invocation of
|
18321 | * `fn` such that `fn` can only ever be called once, no matter how many times
|
18322 | * the returned function is invoked. The first value calculated is returned in
|
18323 | * subsequent invocations.
|
18324 | *
|
18325 | * @func
|
18326 | * @memberOf R
|
18327 | * @since v0.1.0
|
18328 | * @category Function
|
18329 | * @sig (a... -> b) -> (a... -> b)
|
18330 | * @param {Function} fn The function to wrap in a call-only-once wrapper.
|
18331 | * @return {Function} The wrapped function.
|
18332 | * @example
|
18333 | *
|
18334 | * var addOneOnce = R.once(x => x + 1);
|
18335 | * addOneOnce(10); //=> 11
|
18336 | * addOneOnce(addOneOnce(50)); //=> 11
|
18337 | */
|
18338 | module.exports = _curry1(function once(fn) {
|
18339 | var called = false;
|
18340 | var result;
|
18341 | return _arity(fn.length, function() {
|
18342 | if (called) {
|
18343 | return result;
|
18344 | }
|
18345 | called = true;
|
18346 | result = fn.apply(this, arguments);
|
18347 | return result;
|
18348 | });
|
18349 | });
|
18350 |
|
18351 |
|
18352 | /***/ }),
|
18353 | /* 267 */
|
18354 | /***/ (function(module, exports, __webpack_require__) {
|
18355 |
|
18356 | var _curry2 = __webpack_require__(0);
|
18357 |
|
18358 |
|
18359 | /**
|
18360 | * Takes two arguments, `fst` and `snd`, and returns `[fst, snd]`.
|
18361 | *
|
18362 | * @func
|
18363 | * @memberOf R
|
18364 | * @since v0.18.0
|
18365 | * @category List
|
18366 | * @sig a -> b -> (a,b)
|
18367 | * @param {*} fst
|
18368 | * @param {*} snd
|
18369 | * @return {Array}
|
18370 | * @see R.objOf, R.of
|
18371 | * @example
|
18372 | *
|
18373 | * R.pair('foo', 'bar'); //=> ['foo', 'bar']
|
18374 | */
|
18375 | module.exports = _curry2(function pair(fst, snd) { return [fst, snd]; });
|
18376 |
|
18377 |
|
18378 | /***/ }),
|
18379 | /* 268 */
|
18380 | /***/ (function(module, exports, __webpack_require__) {
|
18381 |
|
18382 | var _concat = __webpack_require__(9);
|
18383 | var _createPartialApplicator = __webpack_require__(80);
|
18384 |
|
18385 |
|
18386 | /**
|
18387 | * Takes a function `f` and a list of arguments, and returns a function `g`.
|
18388 | * When applied, `g` returns the result of applying `f` to the arguments
|
18389 | * provided initially followed by the arguments provided to `g`.
|
18390 | *
|
18391 | * @func
|
18392 | * @memberOf R
|
18393 | * @since v0.10.0
|
18394 | * @category Function
|
18395 | * @sig ((a, b, c, ..., n) -> x) -> [a, b, c, ...] -> ((d, e, f, ..., n) -> x)
|
18396 | * @param {Function} f
|
18397 | * @param {Array} args
|
18398 | * @return {Function}
|
18399 | * @see R.partialRight
|
18400 | * @example
|
18401 | *
|
18402 | * var multiply2 = (a, b) => a * b;
|
18403 | * var double = R.partial(multiply2, [2]);
|
18404 | * double(2); //=> 4
|
18405 | *
|
18406 | * var greet = (salutation, title, firstName, lastName) =>
|
18407 | * salutation + ', ' + title + ' ' + firstName + ' ' + lastName + '!';
|
18408 | *
|
18409 | * var sayHello = R.partial(greet, ['Hello']);
|
18410 | * var sayHelloToMs = R.partial(sayHello, ['Ms.']);
|
18411 | * sayHelloToMs('Jane', 'Jones'); //=> 'Hello, Ms. Jane Jones!'
|
18412 | * @symb R.partial(f, [a, b])(c, d) = f(a, b, c, d)
|
18413 | */
|
18414 | module.exports = _createPartialApplicator(_concat);
|
18415 |
|
18416 |
|
18417 | /***/ }),
|
18418 | /* 269 */
|
18419 | /***/ (function(module, exports, __webpack_require__) {
|
18420 |
|
18421 | var _concat = __webpack_require__(9);
|
18422 | var _createPartialApplicator = __webpack_require__(80);
|
18423 | var flip = __webpack_require__(32);
|
18424 |
|
18425 |
|
18426 | /**
|
18427 | * Takes a function `f` and a list of arguments, and returns a function `g`.
|
18428 | * When applied, `g` returns the result of applying `f` to the arguments
|
18429 | * provided to `g` followed by the arguments provided initially.
|
18430 | *
|
18431 | * @func
|
18432 | * @memberOf R
|
18433 | * @since v0.10.0
|
18434 | * @category Function
|
18435 | * @sig ((a, b, c, ..., n) -> x) -> [d, e, f, ..., n] -> ((a, b, c, ...) -> x)
|
18436 | * @param {Function} f
|
18437 | * @param {Array} args
|
18438 | * @return {Function}
|
18439 | * @see R.partial
|
18440 | * @example
|
18441 | *
|
18442 | * var greet = (salutation, title, firstName, lastName) =>
|
18443 | * salutation + ', ' + title + ' ' + firstName + ' ' + lastName + '!';
|
18444 | *
|
18445 | * var greetMsJaneJones = R.partialRight(greet, ['Ms.', 'Jane', 'Jones']);
|
18446 | *
|
18447 | * greetMsJaneJones('Hello'); //=> 'Hello, Ms. Jane Jones!'
|
18448 | * @symb R.partialRight(f, [a, b])(c, d) = f(c, d, a, b)
|
18449 | */
|
18450 | module.exports = _createPartialApplicator(flip(_concat));
|
18451 |
|
18452 |
|
18453 | /***/ }),
|
18454 | /* 270 */
|
18455 | /***/ (function(module, exports, __webpack_require__) {
|
18456 |
|
18457 | var filter = __webpack_require__(48);
|
18458 | var juxt = __webpack_require__(92);
|
18459 | var reject = __webpack_require__(42);
|
18460 |
|
18461 |
|
18462 | /**
|
18463 | * Takes a predicate and a list or other "filterable" object and returns the
|
18464 | * pair of filterable objects of the same type of elements which do and do not
|
18465 | * satisfy, the predicate, respectively.
|
18466 | *
|
18467 | * @func
|
18468 | * @memberOf R
|
18469 | * @since v0.1.4
|
18470 | * @category List
|
18471 | * @sig Filterable f => (a -> Boolean) -> f a -> [f a, f a]
|
18472 | * @param {Function} pred A predicate to determine which side the element belongs to.
|
18473 | * @param {Array} filterable the list (or other filterable) to partition.
|
18474 | * @return {Array} An array, containing first the subset of elements that satisfy the
|
18475 | * predicate, and second the subset of elements that do not satisfy.
|
18476 | * @see R.filter, R.reject
|
18477 | * @example
|
18478 | *
|
18479 | * R.partition(R.contains('s'), ['sss', 'ttt', 'foo', 'bars']);
|
18480 | * // => [ [ 'sss', 'bars' ], [ 'ttt', 'foo' ] ]
|
18481 | *
|
18482 | * R.partition(R.contains('s'), { a: 'sss', b: 'ttt', foo: 'bars' });
|
18483 | * // => [ { a: 'sss', foo: 'bars' }, { b: 'ttt' } ]
|
18484 | */
|
18485 | module.exports = juxt([filter, reject]);
|
18486 |
|
18487 |
|
18488 | /***/ }),
|
18489 | /* 271 */
|
18490 | /***/ (function(module, exports, __webpack_require__) {
|
18491 |
|
18492 | var _curry3 = __webpack_require__(2);
|
18493 | var equals = __webpack_require__(10);
|
18494 | var path = __webpack_require__(25);
|
18495 |
|
18496 |
|
18497 | /**
|
18498 | * Determines whether a nested path on an object has a specific value, in
|
18499 | * `R.equals` terms. Most likely used to filter a list.
|
18500 | *
|
18501 | * @func
|
18502 | * @memberOf R
|
18503 | * @since v0.7.0
|
18504 | * @category Relation
|
18505 | * @typedefn Idx = String | Int
|
18506 | * @sig [Idx] -> a -> {a} -> Boolean
|
18507 | * @param {Array} path The path of the nested property to use
|
18508 | * @param {*} val The value to compare the nested property with
|
18509 | * @param {Object} obj The object to check the nested property in
|
18510 | * @return {Boolean} `true` if the value equals the nested object property,
|
18511 | * `false` otherwise.
|
18512 | * @example
|
18513 | *
|
18514 | * var user1 = { address: { zipCode: 90210 } };
|
18515 | * var user2 = { address: { zipCode: 55555 } };
|
18516 | * var user3 = { name: 'Bob' };
|
18517 | * var users = [ user1, user2, user3 ];
|
18518 | * var isFamous = R.pathEq(['address', 'zipCode'], 90210);
|
18519 | * R.filter(isFamous, users); //=> [ user1 ]
|
18520 | */
|
18521 | module.exports = _curry3(function pathEq(_path, val, obj) {
|
18522 | return equals(path(_path, obj), val);
|
18523 | });
|
18524 |
|
18525 |
|
18526 | /***/ }),
|
18527 | /* 272 */
|
18528 | /***/ (function(module, exports, __webpack_require__) {
|
18529 |
|
18530 | var _curry3 = __webpack_require__(2);
|
18531 | var defaultTo = __webpack_require__(69);
|
18532 | var path = __webpack_require__(25);
|
18533 |
|
18534 |
|
18535 | /**
|
18536 | * If the given, non-null object has a value at the given path, returns the
|
18537 | * value at that path. Otherwise returns the provided default value.
|
18538 | *
|
18539 | * @func
|
18540 | * @memberOf R
|
18541 | * @since v0.18.0
|
18542 | * @category Object
|
18543 | * @typedefn Idx = String | Int
|
18544 | * @sig a -> [Idx] -> {a} -> a
|
18545 | * @param {*} d The default value.
|
18546 | * @param {Array} p The path to use.
|
18547 | * @param {Object} obj The object to retrieve the nested property from.
|
18548 | * @return {*} The data at `path` of the supplied object or the default value.
|
18549 | * @example
|
18550 | *
|
18551 | * R.pathOr('N/A', ['a', 'b'], {a: {b: 2}}); //=> 2
|
18552 | * R.pathOr('N/A', ['a', 'b'], {c: {b: 2}}); //=> "N/A"
|
18553 | */
|
18554 | module.exports = _curry3(function pathOr(d, p, obj) {
|
18555 | return defaultTo(d, path(p, obj));
|
18556 | });
|
18557 |
|
18558 |
|
18559 | /***/ }),
|
18560 | /* 273 */
|
18561 | /***/ (function(module, exports, __webpack_require__) {
|
18562 |
|
18563 | var _curry3 = __webpack_require__(2);
|
18564 | var path = __webpack_require__(25);
|
18565 |
|
18566 |
|
18567 | /**
|
18568 | * Returns `true` if the specified object property at given path satisfies the
|
18569 | * given predicate; `false` otherwise.
|
18570 | *
|
18571 | * @func
|
18572 | * @memberOf R
|
18573 | * @since v0.19.0
|
18574 | * @category Logic
|
18575 | * @typedefn Idx = String | Int
|
18576 | * @sig (a -> Boolean) -> [Idx] -> {a} -> Boolean
|
18577 | * @param {Function} pred
|
18578 | * @param {Array} propPath
|
18579 | * @param {*} obj
|
18580 | * @return {Boolean}
|
18581 | * @see R.propSatisfies, R.path
|
18582 | * @example
|
18583 | *
|
18584 | * R.pathSatisfies(y => y > 0, ['x', 'y'], {x: {y: 2}}); //=> true
|
18585 | */
|
18586 | module.exports = _curry3(function pathSatisfies(pred, propPath, obj) {
|
18587 | return propPath.length > 0 && pred(path(propPath, obj));
|
18588 | });
|
18589 |
|
18590 |
|
18591 | /***/ }),
|
18592 | /* 274 */
|
18593 | /***/ (function(module, exports, __webpack_require__) {
|
18594 |
|
18595 | var _curry2 = __webpack_require__(0);
|
18596 |
|
18597 |
|
18598 | /**
|
18599 | * Returns a partial copy of an object containing only the keys specified. If
|
18600 | * the key does not exist, the property is ignored.
|
18601 | *
|
18602 | * @func
|
18603 | * @memberOf R
|
18604 | * @since v0.1.0
|
18605 | * @category Object
|
18606 | * @sig [k] -> {k: v} -> {k: v}
|
18607 | * @param {Array} names an array of String property names to copy onto a new object
|
18608 | * @param {Object} obj The object to copy from
|
18609 | * @return {Object} A new object with only properties from `names` on it.
|
18610 | * @see R.omit, R.props
|
18611 | * @example
|
18612 | *
|
18613 | * R.pick(['a', 'd'], {a: 1, b: 2, c: 3, d: 4}); //=> {a: 1, d: 4}
|
18614 | * R.pick(['a', 'e', 'f'], {a: 1, b: 2, c: 3, d: 4}); //=> {a: 1}
|
18615 | */
|
18616 | module.exports = _curry2(function pick(names, obj) {
|
18617 | var result = {};
|
18618 | var idx = 0;
|
18619 | while (idx < names.length) {
|
18620 | if (names[idx] in obj) {
|
18621 | result[names[idx]] = obj[names[idx]];
|
18622 | }
|
18623 | idx += 1;
|
18624 | }
|
18625 | return result;
|
18626 | });
|
18627 |
|
18628 |
|
18629 | /***/ }),
|
18630 | /* 275 */
|
18631 | /***/ (function(module, exports, __webpack_require__) {
|
18632 |
|
18633 | var _curry2 = __webpack_require__(0);
|
18634 |
|
18635 |
|
18636 | /**
|
18637 | * Returns a partial copy of an object containing only the keys that satisfy
|
18638 | * the supplied predicate.
|
18639 | *
|
18640 | * @func
|
18641 | * @memberOf R
|
18642 | * @since v0.8.0
|
18643 | * @category Object
|
18644 | * @sig (v, k -> Boolean) -> {k: v} -> {k: v}
|
18645 | * @param {Function} pred A predicate to determine whether or not a key
|
18646 | * should be included on the output object.
|
18647 | * @param {Object} obj The object to copy from
|
18648 | * @return {Object} A new object with only properties that satisfy `pred`
|
18649 | * on it.
|
18650 | * @see R.pick, R.filter
|
18651 | * @example
|
18652 | *
|
18653 | * var isUpperCase = (val, key) => key.toUpperCase() === key;
|
18654 | * R.pickBy(isUpperCase, {a: 1, b: 2, A: 3, B: 4}); //=> {A: 3, B: 4}
|
18655 | */
|
18656 | module.exports = _curry2(function pickBy(test, obj) {
|
18657 | var result = {};
|
18658 | for (var prop in obj) {
|
18659 | if (test(obj[prop], prop, obj)) {
|
18660 | result[prop] = obj[prop];
|
18661 | }
|
18662 | }
|
18663 | return result;
|
18664 | });
|
18665 |
|
18666 |
|
18667 | /***/ }),
|
18668 | /* 276 */
|
18669 | /***/ (function(module, exports, __webpack_require__) {
|
18670 |
|
18671 | var composeK = __webpack_require__(66);
|
18672 | var reverse = __webpack_require__(43);
|
18673 |
|
18674 | /**
|
18675 | * Returns the left-to-right Kleisli composition of the provided functions,
|
18676 | * each of which must return a value of a type supported by [`chain`](#chain).
|
18677 | *
|
18678 | * `R.pipeK(f, g, h)` is equivalent to `R.pipe(R.chain(f), R.chain(g), R.chain(h))`.
|
18679 | *
|
18680 | * @func
|
18681 | * @memberOf R
|
18682 | * @since v0.16.0
|
18683 | * @category Function
|
18684 | * @sig Chain m => ((a -> m b), (b -> m c), ..., (y -> m z)) -> (a -> m z)
|
18685 | * @param {...Function}
|
18686 | * @return {Function}
|
18687 | * @see R.composeK
|
18688 | * @example
|
18689 | *
|
18690 | * // parseJson :: String -> Maybe *
|
18691 | * // get :: String -> Object -> Maybe *
|
18692 | *
|
18693 | * // getStateCode :: Maybe String -> Maybe String
|
18694 | * var getStateCode = R.pipeK(
|
18695 | * parseJson,
|
18696 | * get('user'),
|
18697 | * get('address'),
|
18698 | * get('state'),
|
18699 | * R.compose(Maybe.of, R.toUpper)
|
18700 | * );
|
18701 | *
|
18702 | * getStateCode('{"user":{"address":{"state":"ny"}}}');
|
18703 | * //=> Just('NY')
|
18704 | * getStateCode('[Invalid JSON]');
|
18705 | * //=> Nothing()
|
18706 | * @symb R.pipeK(f, g, h)(a) = R.chain(h, R.chain(g, f(a)))
|
18707 | */
|
18708 | module.exports = function pipeK() {
|
18709 | if (arguments.length === 0) {
|
18710 | throw new Error('pipeK requires at least one argument');
|
18711 | }
|
18712 | return composeK.apply(this, reverse(arguments));
|
18713 | };
|
18714 |
|
18715 |
|
18716 | /***/ }),
|
18717 | /* 277 */
|
18718 | /***/ (function(module, exports, __webpack_require__) {
|
18719 |
|
18720 | var multiply = __webpack_require__(98);
|
18721 | var reduce = __webpack_require__(13);
|
18722 |
|
18723 |
|
18724 | /**
|
18725 | * Multiplies together all the elements of a list.
|
18726 | *
|
18727 | * @func
|
18728 | * @memberOf R
|
18729 | * @since v0.1.0
|
18730 | * @category Math
|
18731 | * @sig [Number] -> Number
|
18732 | * @param {Array} list An array of numbers
|
18733 | * @return {Number} The product of all the numbers in the list.
|
18734 | * @see R.reduce
|
18735 | * @example
|
18736 | *
|
18737 | * R.product([2,4,6,8,100,1]); //=> 38400
|
18738 | */
|
18739 | module.exports = reduce(multiply, 1);
|
18740 |
|
18741 |
|
18742 | /***/ }),
|
18743 | /* 278 */
|
18744 | /***/ (function(module, exports, __webpack_require__) {
|
18745 |
|
18746 | var _map = __webpack_require__(37);
|
18747 | var identity = __webpack_require__(49);
|
18748 | var pickAll = __webpack_require__(103);
|
18749 | var useWith = __webpack_require__(114);
|
18750 |
|
18751 |
|
18752 | /**
|
18753 | * Reasonable analog to SQL `select` statement.
|
18754 | *
|
18755 | * @func
|
18756 | * @memberOf R
|
18757 | * @since v0.1.0
|
18758 | * @category Object
|
18759 | * @category Relation
|
18760 | * @sig [k] -> [{k: v}] -> [{k: v}]
|
18761 | * @param {Array} props The property names to project
|
18762 | * @param {Array} objs The objects to query
|
18763 | * @return {Array} An array of objects with just the `props` properties.
|
18764 | * @example
|
18765 | *
|
18766 | * var abby = {name: 'Abby', age: 7, hair: 'blond', grade: 2};
|
18767 | * var fred = {name: 'Fred', age: 12, hair: 'brown', grade: 7};
|
18768 | * var kids = [abby, fred];
|
18769 | * R.project(['name', 'grade'], kids); //=> [{name: 'Abby', grade: 2}, {name: 'Fred', grade: 7}]
|
18770 | */
|
18771 | module.exports = useWith(_map, [pickAll, identity]); // passing `identity` gives correct arity
|
18772 |
|
18773 |
|
18774 | /***/ }),
|
18775 | /* 279 */
|
18776 | /***/ (function(module, exports, __webpack_require__) {
|
18777 |
|
18778 | var _curry3 = __webpack_require__(2);
|
18779 | var equals = __webpack_require__(10);
|
18780 |
|
18781 |
|
18782 | /**
|
18783 | * Returns `true` if the specified object property is equal, in `R.equals`
|
18784 | * terms, to the given value; `false` otherwise.
|
18785 | *
|
18786 | * @func
|
18787 | * @memberOf R
|
18788 | * @since v0.1.0
|
18789 | * @category Relation
|
18790 | * @sig String -> a -> Object -> Boolean
|
18791 | * @param {String} name
|
18792 | * @param {*} val
|
18793 | * @param {*} obj
|
18794 | * @return {Boolean}
|
18795 | * @see R.equals, R.propSatisfies
|
18796 | * @example
|
18797 | *
|
18798 | * var abby = {name: 'Abby', age: 7, hair: 'blond'};
|
18799 | * var fred = {name: 'Fred', age: 12, hair: 'brown'};
|
18800 | * var rusty = {name: 'Rusty', age: 10, hair: 'brown'};
|
18801 | * var alois = {name: 'Alois', age: 15, disposition: 'surly'};
|
18802 | * var kids = [abby, fred, rusty, alois];
|
18803 | * var hasBrownHair = R.propEq('hair', 'brown');
|
18804 | * R.filter(hasBrownHair, kids); //=> [fred, rusty]
|
18805 | */
|
18806 | module.exports = _curry3(function propEq(name, val, obj) {
|
18807 | return equals(val, obj[name]);
|
18808 | });
|
18809 |
|
18810 |
|
18811 | /***/ }),
|
18812 | /* 280 */
|
18813 | /***/ (function(module, exports, __webpack_require__) {
|
18814 |
|
18815 | var _curry3 = __webpack_require__(2);
|
18816 | var is = __webpack_require__(91);
|
18817 |
|
18818 |
|
18819 | /**
|
18820 | * Returns `true` if the specified object property is of the given type;
|
18821 | * `false` otherwise.
|
18822 | *
|
18823 | * @func
|
18824 | * @memberOf R
|
18825 | * @since v0.16.0
|
18826 | * @category Type
|
18827 | * @sig Type -> String -> Object -> Boolean
|
18828 | * @param {Function} type
|
18829 | * @param {String} name
|
18830 | * @param {*} obj
|
18831 | * @return {Boolean}
|
18832 | * @see R.is, R.propSatisfies
|
18833 | * @example
|
18834 | *
|
18835 | * R.propIs(Number, 'x', {x: 1, y: 2}); //=> true
|
18836 | * R.propIs(Number, 'x', {x: 'foo'}); //=> false
|
18837 | * R.propIs(Number, 'x', {}); //=> false
|
18838 | */
|
18839 | module.exports = _curry3(function propIs(type, name, obj) {
|
18840 | return is(type, obj[name]);
|
18841 | });
|
18842 |
|
18843 |
|
18844 | /***/ }),
|
18845 | /* 281 */
|
18846 | /***/ (function(module, exports, __webpack_require__) {
|
18847 |
|
18848 | var _curry3 = __webpack_require__(2);
|
18849 | var _has = __webpack_require__(6);
|
18850 |
|
18851 |
|
18852 | /**
|
18853 | * If the given, non-null object has an own property with the specified name,
|
18854 | * returns the value of that property. Otherwise returns the provided default
|
18855 | * value.
|
18856 | *
|
18857 | * @func
|
18858 | * @memberOf R
|
18859 | * @since v0.6.0
|
18860 | * @category Object
|
18861 | * @sig a -> String -> Object -> a
|
18862 | * @param {*} val The default value.
|
18863 | * @param {String} p The name of the property to return.
|
18864 | * @param {Object} obj The object to query.
|
18865 | * @return {*} The value of given property of the supplied object or the default value.
|
18866 | * @example
|
18867 | *
|
18868 | * var alice = {
|
18869 | * name: 'ALICE',
|
18870 | * age: 101
|
18871 | * };
|
18872 | * var favorite = R.prop('favoriteLibrary');
|
18873 | * var favoriteWithDefault = R.propOr('Ramda', 'favoriteLibrary');
|
18874 | *
|
18875 | * favorite(alice); //=> undefined
|
18876 | * favoriteWithDefault(alice); //=> 'Ramda'
|
18877 | */
|
18878 | module.exports = _curry3(function propOr(val, p, obj) {
|
18879 | return (obj != null && _has(p, obj)) ? obj[p] : val;
|
18880 | });
|
18881 |
|
18882 |
|
18883 | /***/ }),
|
18884 | /* 282 */
|
18885 | /***/ (function(module, exports, __webpack_require__) {
|
18886 |
|
18887 | var _curry3 = __webpack_require__(2);
|
18888 |
|
18889 |
|
18890 | /**
|
18891 | * Returns `true` if the specified object property satisfies the given
|
18892 | * predicate; `false` otherwise.
|
18893 | *
|
18894 | * @func
|
18895 | * @memberOf R
|
18896 | * @since v0.16.0
|
18897 | * @category Logic
|
18898 | * @sig (a -> Boolean) -> String -> {String: a} -> Boolean
|
18899 | * @param {Function} pred
|
18900 | * @param {String} name
|
18901 | * @param {*} obj
|
18902 | * @return {Boolean}
|
18903 | * @see R.propEq, R.propIs
|
18904 | * @example
|
18905 | *
|
18906 | * R.propSatisfies(x => x > 0, 'x', {x: 1, y: 2}); //=> true
|
18907 | */
|
18908 | module.exports = _curry3(function propSatisfies(pred, name, obj) {
|
18909 | return pred(obj[name]);
|
18910 | });
|
18911 |
|
18912 |
|
18913 | /***/ }),
|
18914 | /* 283 */
|
18915 | /***/ (function(module, exports, __webpack_require__) {
|
18916 |
|
18917 | var _curry2 = __webpack_require__(0);
|
18918 |
|
18919 |
|
18920 | /**
|
18921 | * Acts as multiple `prop`: array of keys in, array of values out. Preserves
|
18922 | * order.
|
18923 | *
|
18924 | * @func
|
18925 | * @memberOf R
|
18926 | * @since v0.1.0
|
18927 | * @category Object
|
18928 | * @sig [k] -> {k: v} -> [v]
|
18929 | * @param {Array} ps The property names to fetch
|
18930 | * @param {Object} obj The object to query
|
18931 | * @return {Array} The corresponding values or partially applied function.
|
18932 | * @example
|
18933 | *
|
18934 | * R.props(['x', 'y'], {x: 1, y: 2}); //=> [1, 2]
|
18935 | * R.props(['c', 'a', 'b'], {b: 2, a: 1}); //=> [undefined, 1, 2]
|
18936 | *
|
18937 | * var fullName = R.compose(R.join(' '), R.props(['first', 'last']));
|
18938 | * fullName({last: 'Bullet-Tooth', age: 33, first: 'Tony'}); //=> 'Tony Bullet-Tooth'
|
18939 | */
|
18940 | module.exports = _curry2(function props(ps, obj) {
|
18941 | var len = ps.length;
|
18942 | var out = [];
|
18943 | var idx = 0;
|
18944 |
|
18945 | while (idx < len) {
|
18946 | out[idx] = obj[ps[idx]];
|
18947 | idx += 1;
|
18948 | }
|
18949 |
|
18950 | return out;
|
18951 | });
|
18952 |
|
18953 |
|
18954 | /***/ }),
|
18955 | /* 284 */
|
18956 | /***/ (function(module, exports, __webpack_require__) {
|
18957 |
|
18958 | var _curry2 = __webpack_require__(0);
|
18959 | var _isNumber = __webpack_require__(85);
|
18960 |
|
18961 |
|
18962 | /**
|
18963 | * Returns a list of numbers from `from` (inclusive) to `to` (exclusive).
|
18964 | *
|
18965 | * @func
|
18966 | * @memberOf R
|
18967 | * @since v0.1.0
|
18968 | * @category List
|
18969 | * @sig Number -> Number -> [Number]
|
18970 | * @param {Number} from The first number in the list.
|
18971 | * @param {Number} to One more than the last number in the list.
|
18972 | * @return {Array} The list of numbers in tthe set `[a, b)`.
|
18973 | * @example
|
18974 | *
|
18975 | * R.range(1, 5); //=> [1, 2, 3, 4]
|
18976 | * R.range(50, 53); //=> [50, 51, 52]
|
18977 | */
|
18978 | module.exports = _curry2(function range(from, to) {
|
18979 | if (!(_isNumber(from) && _isNumber(to))) {
|
18980 | throw new TypeError('Both arguments to range must be numbers');
|
18981 | }
|
18982 | var result = [];
|
18983 | var n = from;
|
18984 | while (n < to) {
|
18985 | result.push(n);
|
18986 | n += 1;
|
18987 | }
|
18988 | return result;
|
18989 | });
|
18990 |
|
18991 |
|
18992 | /***/ }),
|
18993 | /* 285 */
|
18994 | /***/ (function(module, exports, __webpack_require__) {
|
18995 |
|
18996 | var _curryN = __webpack_require__(33);
|
18997 | var _reduce = __webpack_require__(8);
|
18998 | var _reduced = __webpack_require__(16);
|
18999 |
|
19000 |
|
19001 | /**
|
19002 | * Like `reduce`, `reduceWhile` returns a single item by iterating through
|
19003 | * the list, successively calling the iterator function. `reduceWhile` also
|
19004 | * takes a predicate that is evaluated before each step. If the predicate returns
|
19005 | * `false`, it "short-circuits" the iteration and returns the current value
|
19006 | * of the accumulator.
|
19007 | *
|
19008 | * @func
|
19009 | * @memberOf R
|
19010 | * @since v0.22.0
|
19011 | * @category List
|
19012 | * @sig ((a, b) -> Boolean) -> ((a, b) -> a) -> a -> [b] -> a
|
19013 | * @param {Function} pred The predicate. It is passed the accumulator and the
|
19014 | * current element.
|
19015 | * @param {Function} fn The iterator function. Receives two values, the
|
19016 | * accumulator and the current element.
|
19017 | * @param {*} a The accumulator value.
|
19018 | * @param {Array} list The list to iterate over.
|
19019 | * @return {*} The final, accumulated value.
|
19020 | * @see R.reduce, R.reduced
|
19021 | * @example
|
19022 | *
|
19023 | * var isOdd = (acc, x) => x % 2 === 1;
|
19024 | * var xs = [1, 3, 5, 60, 777, 800];
|
19025 | * R.reduceWhile(isOdd, R.add, 0, xs); //=> 9
|
19026 | *
|
19027 | * var ys = [2, 4, 6]
|
19028 | * R.reduceWhile(isOdd, R.add, 111, ys); //=> 111
|
19029 | */
|
19030 | module.exports = _curryN(4, [], function _reduceWhile(pred, fn, a, list) {
|
19031 | return _reduce(function(acc, x) {
|
19032 | return pred(acc, x) ? fn(acc, x) : _reduced(acc);
|
19033 | }, a, list);
|
19034 | });
|
19035 |
|
19036 |
|
19037 | /***/ }),
|
19038 | /* 286 */
|
19039 | /***/ (function(module, exports, __webpack_require__) {
|
19040 |
|
19041 | var _curry1 = __webpack_require__(1);
|
19042 | var _reduced = __webpack_require__(16);
|
19043 |
|
19044 | /**
|
19045 | * Returns a value wrapped to indicate that it is the final value of the reduce
|
19046 | * and transduce functions. The returned value should be considered a black
|
19047 | * box: the internal structure is not guaranteed to be stable.
|
19048 | *
|
19049 | * Note: this optimization is unavailable to functions not explicitly listed
|
19050 | * above. For instance, it is not currently supported by reduceRight.
|
19051 | *
|
19052 | * @func
|
19053 | * @memberOf R
|
19054 | * @since v0.15.0
|
19055 | * @category List
|
19056 | * @sig a -> *
|
19057 | * @param {*} x The final value of the reduce.
|
19058 | * @return {*} The wrapped value.
|
19059 | * @see R.reduce, R.transduce
|
19060 | * @example
|
19061 | *
|
19062 | * R.reduce(
|
19063 | * R.pipe(R.add, R.when(R.gte(R.__, 10), R.reduced)),
|
19064 | * 0,
|
19065 | * [1, 2, 3, 4, 5]) // 10
|
19066 | */
|
19067 |
|
19068 | module.exports = _curry1(_reduced);
|
19069 |
|
19070 |
|
19071 | /***/ }),
|
19072 | /* 287 */
|
19073 | /***/ (function(module, exports, __webpack_require__) {
|
19074 |
|
19075 | var _curry3 = __webpack_require__(2);
|
19076 |
|
19077 |
|
19078 | /**
|
19079 | * Removes the sub-list of `list` starting at index `start` and containing
|
19080 | * `count` elements. _Note that this is not destructive_: it returns a copy of
|
19081 | * the list with the changes.
|
19082 | * <small>No lists have been harmed in the application of this function.</small>
|
19083 | *
|
19084 | * @func
|
19085 | * @memberOf R
|
19086 | * @since v0.2.2
|
19087 | * @category List
|
19088 | * @sig Number -> Number -> [a] -> [a]
|
19089 | * @param {Number} start The position to start removing elements
|
19090 | * @param {Number} count The number of elements to remove
|
19091 | * @param {Array} list The list to remove from
|
19092 | * @return {Array} A new Array with `count` elements from `start` removed.
|
19093 | * @example
|
19094 | *
|
19095 | * R.remove(2, 3, [1,2,3,4,5,6,7,8]); //=> [1,2,6,7,8]
|
19096 | */
|
19097 | module.exports = _curry3(function remove(start, count, list) {
|
19098 | var result = Array.prototype.slice.call(list, 0);
|
19099 | result.splice(start, count);
|
19100 | return result;
|
19101 | });
|
19102 |
|
19103 |
|
19104 | /***/ }),
|
19105 | /* 288 */
|
19106 | /***/ (function(module, exports, __webpack_require__) {
|
19107 |
|
19108 | var _curry2 = __webpack_require__(0);
|
19109 | var always = __webpack_require__(19);
|
19110 | var times = __webpack_require__(111);
|
19111 |
|
19112 |
|
19113 | /**
|
19114 | * Returns a fixed list of size `n` containing a specified identical value.
|
19115 | *
|
19116 | * @func
|
19117 | * @memberOf R
|
19118 | * @since v0.1.1
|
19119 | * @category List
|
19120 | * @sig a -> n -> [a]
|
19121 | * @param {*} value The value to repeat.
|
19122 | * @param {Number} n The desired size of the output list.
|
19123 | * @return {Array} A new array containing `n` `value`s.
|
19124 | * @example
|
19125 | *
|
19126 | * R.repeat('hi', 5); //=> ['hi', 'hi', 'hi', 'hi', 'hi']
|
19127 | *
|
19128 | * var obj = {};
|
19129 | * var repeatedObjs = R.repeat(obj, 5); //=> [{}, {}, {}, {}, {}]
|
19130 | * repeatedObjs[0] === repeatedObjs[1]; //=> true
|
19131 | * @symb R.repeat(a, 0) = []
|
19132 | * @symb R.repeat(a, 1) = [a]
|
19133 | * @symb R.repeat(a, 2) = [a, a]
|
19134 | */
|
19135 | module.exports = _curry2(function repeat(value, n) {
|
19136 | return times(always(value), n);
|
19137 | });
|
19138 |
|
19139 |
|
19140 | /***/ }),
|
19141 | /* 289 */
|
19142 | /***/ (function(module, exports, __webpack_require__) {
|
19143 |
|
19144 | var _curry3 = __webpack_require__(2);
|
19145 |
|
19146 |
|
19147 | /**
|
19148 | * Replace a substring or regex match in a string with a replacement.
|
19149 | *
|
19150 | * @func
|
19151 | * @memberOf R
|
19152 | * @since v0.7.0
|
19153 | * @category String
|
19154 | * @sig RegExp|String -> String -> String -> String
|
19155 | * @param {RegExp|String} pattern A regular expression or a substring to match.
|
19156 | * @param {String} replacement The string to replace the matches with.
|
19157 | * @param {String} str The String to do the search and replacement in.
|
19158 | * @return {String} The result.
|
19159 | * @example
|
19160 | *
|
19161 | * R.replace('foo', 'bar', 'foo foo foo'); //=> 'bar foo foo'
|
19162 | * R.replace(/foo/, 'bar', 'foo foo foo'); //=> 'bar foo foo'
|
19163 | *
|
19164 | * // Use the "g" (global) flag to replace all occurrences:
|
19165 | * R.replace(/foo/g, 'bar', 'foo foo foo'); //=> 'bar bar bar'
|
19166 | */
|
19167 | module.exports = _curry3(function replace(regex, replacement, str) {
|
19168 | return str.replace(regex, replacement);
|
19169 | });
|
19170 |
|
19171 |
|
19172 | /***/ }),
|
19173 | /* 290 */
|
19174 | /***/ (function(module, exports, __webpack_require__) {
|
19175 |
|
19176 | var _curry3 = __webpack_require__(2);
|
19177 |
|
19178 |
|
19179 | /**
|
19180 | * Scan is similar to reduce, but returns a list of successively reduced values
|
19181 | * from the left
|
19182 | *
|
19183 | * @func
|
19184 | * @memberOf R
|
19185 | * @since v0.10.0
|
19186 | * @category List
|
19187 | * @sig (a,b -> a) -> a -> [b] -> [a]
|
19188 | * @param {Function} fn The iterator function. Receives two values, the accumulator and the
|
19189 | * current element from the array
|
19190 | * @param {*} acc The accumulator value.
|
19191 | * @param {Array} list The list to iterate over.
|
19192 | * @return {Array} A list of all intermediately reduced values.
|
19193 | * @example
|
19194 | *
|
19195 | * var numbers = [1, 2, 3, 4];
|
19196 | * var factorials = R.scan(R.multiply, 1, numbers); //=> [1, 1, 2, 6, 24]
|
19197 | * @symb R.scan(f, a, [b, c]) = [a, f(a, b), f(f(a, b), c)]
|
19198 | */
|
19199 | module.exports = _curry3(function scan(fn, acc, list) {
|
19200 | var idx = 0;
|
19201 | var len = list.length;
|
19202 | var result = [acc];
|
19203 | while (idx < len) {
|
19204 | acc = fn(acc, list[idx]);
|
19205 | result[idx + 1] = acc;
|
19206 | idx += 1;
|
19207 | }
|
19208 | return result;
|
19209 | });
|
19210 |
|
19211 |
|
19212 | /***/ }),
|
19213 | /* 291 */
|
19214 | /***/ (function(module, exports, __webpack_require__) {
|
19215 |
|
19216 | var _curry3 = __webpack_require__(2);
|
19217 | var always = __webpack_require__(19);
|
19218 | var over = __webpack_require__(102);
|
19219 |
|
19220 |
|
19221 | /**
|
19222 | * Returns the result of "setting" the portion of the given data structure
|
19223 | * focused by the given lens to the given value.
|
19224 | *
|
19225 | * @func
|
19226 | * @memberOf R
|
19227 | * @since v0.16.0
|
19228 | * @category Object
|
19229 | * @typedefn Lens s a = Functor f => (a -> f a) -> s -> f s
|
19230 | * @sig Lens s a -> a -> s -> s
|
19231 | * @param {Lens} lens
|
19232 | * @param {*} v
|
19233 | * @param {*} x
|
19234 | * @return {*}
|
19235 | * @see R.prop, R.lensIndex, R.lensProp
|
19236 | * @example
|
19237 | *
|
19238 | * var xLens = R.lensProp('x');
|
19239 | *
|
19240 | * R.set(xLens, 4, {x: 1, y: 2}); //=> {x: 4, y: 2}
|
19241 | * R.set(xLens, 8, {x: 1, y: 2}); //=> {x: 8, y: 2}
|
19242 | */
|
19243 | module.exports = _curry3(function set(lens, v, x) {
|
19244 | return over(lens, always(v), x);
|
19245 | });
|
19246 |
|
19247 |
|
19248 | /***/ }),
|
19249 | /* 292 */
|
19250 | /***/ (function(module, exports, __webpack_require__) {
|
19251 |
|
19252 | var _curry2 = __webpack_require__(0);
|
19253 |
|
19254 |
|
19255 | /**
|
19256 | * Returns a copy of the list, sorted according to the comparator function,
|
19257 | * which should accept two values at a time and return a negative number if the
|
19258 | * first value is smaller, a positive number if it's larger, and zero if they
|
19259 | * are equal. Please note that this is a **copy** of the list. It does not
|
19260 | * modify the original.
|
19261 | *
|
19262 | * @func
|
19263 | * @memberOf R
|
19264 | * @since v0.1.0
|
19265 | * @category List
|
19266 | * @sig (a,a -> Number) -> [a] -> [a]
|
19267 | * @param {Function} comparator A sorting function :: a -> b -> Int
|
19268 | * @param {Array} list The list to sort
|
19269 | * @return {Array} a new array with its elements sorted by the comparator function.
|
19270 | * @example
|
19271 | *
|
19272 | * var diff = function(a, b) { return a - b; };
|
19273 | * R.sort(diff, [4,2,7,5]); //=> [2, 4, 5, 7]
|
19274 | */
|
19275 | module.exports = _curry2(function sort(comparator, list) {
|
19276 | return Array.prototype.slice.call(list, 0).sort(comparator);
|
19277 | });
|
19278 |
|
19279 |
|
19280 | /***/ }),
|
19281 | /* 293 */
|
19282 | /***/ (function(module, exports, __webpack_require__) {
|
19283 |
|
19284 | var _curry2 = __webpack_require__(0);
|
19285 |
|
19286 |
|
19287 | /**
|
19288 | * Sorts the list according to the supplied function.
|
19289 | *
|
19290 | * @func
|
19291 | * @memberOf R
|
19292 | * @since v0.1.0
|
19293 | * @category Relation
|
19294 | * @sig Ord b => (a -> b) -> [a] -> [a]
|
19295 | * @param {Function} fn
|
19296 | * @param {Array} list The list to sort.
|
19297 | * @return {Array} A new list sorted by the keys generated by `fn`.
|
19298 | * @example
|
19299 | *
|
19300 | * var sortByFirstItem = R.sortBy(R.prop(0));
|
19301 | * var sortByNameCaseInsensitive = R.sortBy(R.compose(R.toLower, R.prop('name')));
|
19302 | * var pairs = [[-1, 1], [-2, 2], [-3, 3]];
|
19303 | * sortByFirstItem(pairs); //=> [[-3, 3], [-2, 2], [-1, 1]]
|
19304 | * var alice = {
|
19305 | * name: 'ALICE',
|
19306 | * age: 101
|
19307 | * };
|
19308 | * var bob = {
|
19309 | * name: 'Bob',
|
19310 | * age: -10
|
19311 | * };
|
19312 | * var clara = {
|
19313 | * name: 'clara',
|
19314 | * age: 314.159
|
19315 | * };
|
19316 | * var people = [clara, bob, alice];
|
19317 | * sortByNameCaseInsensitive(people); //=> [alice, bob, clara]
|
19318 | */
|
19319 | module.exports = _curry2(function sortBy(fn, list) {
|
19320 | return Array.prototype.slice.call(list, 0).sort(function(a, b) {
|
19321 | var aa = fn(a);
|
19322 | var bb = fn(b);
|
19323 | return aa < bb ? -1 : aa > bb ? 1 : 0;
|
19324 | });
|
19325 | });
|
19326 |
|
19327 |
|
19328 | /***/ }),
|
19329 | /* 294 */
|
19330 | /***/ (function(module, exports, __webpack_require__) {
|
19331 |
|
19332 | var _curry2 = __webpack_require__(0);
|
19333 |
|
19334 |
|
19335 | /**
|
19336 | * Sorts a list according to a list of comparators.
|
19337 | *
|
19338 | * @func
|
19339 | * @memberOf R
|
19340 | * @since v0.23.0
|
19341 | * @category Relation
|
19342 | * @sig [a -> a -> Number] -> [a] -> [a]
|
19343 | * @param {Array} functions A list of comparator functions.
|
19344 | * @param {Array} list The list to sort.
|
19345 | * @return {Array} A new list sorted according to the comarator functions.
|
19346 | * @example
|
19347 | *
|
19348 | * var alice = {
|
19349 | * name: 'alice',
|
19350 | * age: 40
|
19351 | * };
|
19352 | * var bob = {
|
19353 | * name: 'bob',
|
19354 | * age: 30
|
19355 | * };
|
19356 | * var clara = {
|
19357 | * name: 'clara',
|
19358 | * age: 40
|
19359 | * };
|
19360 | * var people = [clara, bob, alice];
|
19361 | * var ageNameSort = R.sortWith([
|
19362 | * R.descend(R.prop('age')),
|
19363 | * R.ascend(R.prop('name'))
|
19364 | * ]);
|
19365 | * ageNameSort(people); //=> [alice, clara, bob]
|
19366 | */
|
19367 | module.exports = _curry2(function sortWith(fns, list) {
|
19368 | return Array.prototype.slice.call(list, 0).sort(function(a, b) {
|
19369 | var result = 0;
|
19370 | var i = 0;
|
19371 | while (result === 0 && i < fns.length) {
|
19372 | result = fns[i](a, b);
|
19373 | i += 1;
|
19374 | }
|
19375 | return result;
|
19376 | });
|
19377 | });
|
19378 |
|
19379 |
|
19380 | /***/ }),
|
19381 | /* 295 */
|
19382 | /***/ (function(module, exports, __webpack_require__) {
|
19383 |
|
19384 | var invoker = __webpack_require__(22);
|
19385 |
|
19386 |
|
19387 | /**
|
19388 | * Splits a string into an array of strings based on the given
|
19389 | * separator.
|
19390 | *
|
19391 | * @func
|
19392 | * @memberOf R
|
19393 | * @since v0.1.0
|
19394 | * @category String
|
19395 | * @sig (String | RegExp) -> String -> [String]
|
19396 | * @param {String|RegExp} sep The pattern.
|
19397 | * @param {String} str The string to separate into an array.
|
19398 | * @return {Array} The array of strings from `str` separated by `str`.
|
19399 | * @see R.join
|
19400 | * @example
|
19401 | *
|
19402 | * var pathComponents = R.split('/');
|
19403 | * R.tail(pathComponents('/usr/local/bin/node')); //=> ['usr', 'local', 'bin', 'node']
|
19404 | *
|
19405 | * R.split('.', 'a.b.c.xyz.d'); //=> ['a', 'b', 'c', 'xyz', 'd']
|
19406 | */
|
19407 | module.exports = invoker(1, 'split');
|
19408 |
|
19409 |
|
19410 | /***/ }),
|
19411 | /* 296 */
|
19412 | /***/ (function(module, exports, __webpack_require__) {
|
19413 |
|
19414 | var _curry2 = __webpack_require__(0);
|
19415 | var length = __webpack_require__(94);
|
19416 | var slice = __webpack_require__(18);
|
19417 |
|
19418 |
|
19419 | /**
|
19420 | * Splits a given list or string at a given index.
|
19421 | *
|
19422 | * @func
|
19423 | * @memberOf R
|
19424 | * @since v0.19.0
|
19425 | * @category List
|
19426 | * @sig Number -> [a] -> [[a], [a]]
|
19427 | * @sig Number -> String -> [String, String]
|
19428 | * @param {Number} index The index where the array/string is split.
|
19429 | * @param {Array|String} array The array/string to be split.
|
19430 | * @return {Array}
|
19431 | * @example
|
19432 | *
|
19433 | * R.splitAt(1, [1, 2, 3]); //=> [[1], [2, 3]]
|
19434 | * R.splitAt(5, 'hello world'); //=> ['hello', ' world']
|
19435 | * R.splitAt(-1, 'foobar'); //=> ['fooba', 'r']
|
19436 | */
|
19437 | module.exports = _curry2(function splitAt(index, array) {
|
19438 | return [slice(0, index, array), slice(index, length(array), array)];
|
19439 | });
|
19440 |
|
19441 |
|
19442 | /***/ }),
|
19443 | /* 297 */
|
19444 | /***/ (function(module, exports, __webpack_require__) {
|
19445 |
|
19446 | var _curry2 = __webpack_require__(0);
|
19447 | var slice = __webpack_require__(18);
|
19448 |
|
19449 |
|
19450 | /**
|
19451 | * Splits a collection into slices of the specified length.
|
19452 | *
|
19453 | * @func
|
19454 | * @memberOf R
|
19455 | * @since v0.16.0
|
19456 | * @category List
|
19457 | * @sig Number -> [a] -> [[a]]
|
19458 | * @sig Number -> String -> [String]
|
19459 | * @param {Number} n
|
19460 | * @param {Array} list
|
19461 | * @return {Array}
|
19462 | * @example
|
19463 | *
|
19464 | * R.splitEvery(3, [1, 2, 3, 4, 5, 6, 7]); //=> [[1, 2, 3], [4, 5, 6], [7]]
|
19465 | * R.splitEvery(3, 'foobarbaz'); //=> ['foo', 'bar', 'baz']
|
19466 | */
|
19467 | module.exports = _curry2(function splitEvery(n, list) {
|
19468 | if (n <= 0) {
|
19469 | throw new Error('First argument to splitEvery must be a positive integer');
|
19470 | }
|
19471 | var result = [];
|
19472 | var idx = 0;
|
19473 | while (idx < list.length) {
|
19474 | result.push(slice(idx, idx += n, list));
|
19475 | }
|
19476 | return result;
|
19477 | });
|
19478 |
|
19479 |
|
19480 | /***/ }),
|
19481 | /* 298 */
|
19482 | /***/ (function(module, exports, __webpack_require__) {
|
19483 |
|
19484 | var _curry2 = __webpack_require__(0);
|
19485 |
|
19486 |
|
19487 | /**
|
19488 | * Takes a list and a predicate and returns a pair of lists with the following properties:
|
19489 | *
|
19490 | * - the result of concatenating the two output lists is equivalent to the input list;
|
19491 | * - none of the elements of the first output list satisfies the predicate; and
|
19492 | * - if the second output list is non-empty, its first element satisfies the predicate.
|
19493 | *
|
19494 | * @func
|
19495 | * @memberOf R
|
19496 | * @since v0.19.0
|
19497 | * @category List
|
19498 | * @sig (a -> Boolean) -> [a] -> [[a], [a]]
|
19499 | * @param {Function} pred The predicate that determines where the array is split.
|
19500 | * @param {Array} list The array to be split.
|
19501 | * @return {Array}
|
19502 | * @example
|
19503 | *
|
19504 | * R.splitWhen(R.equals(2), [1, 2, 3, 1, 2, 3]); //=> [[1], [2, 3, 1, 2, 3]]
|
19505 | */
|
19506 | module.exports = _curry2(function splitWhen(pred, list) {
|
19507 | var idx = 0;
|
19508 | var len = list.length;
|
19509 | var prefix = [];
|
19510 |
|
19511 | while (idx < len && !pred(list[idx])) {
|
19512 | prefix.push(list[idx]);
|
19513 | idx += 1;
|
19514 | }
|
19515 |
|
19516 | return [prefix, Array.prototype.slice.call(list, idx)];
|
19517 | });
|
19518 |
|
19519 |
|
19520 | /***/ }),
|
19521 | /* 299 */
|
19522 | /***/ (function(module, exports, __webpack_require__) {
|
19523 |
|
19524 | var _curry2 = __webpack_require__(0);
|
19525 |
|
19526 |
|
19527 | /**
|
19528 | * Subtracts its second argument from its first argument.
|
19529 | *
|
19530 | * @func
|
19531 | * @memberOf R
|
19532 | * @since v0.1.0
|
19533 | * @category Math
|
19534 | * @sig Number -> Number -> Number
|
19535 | * @param {Number} a The first value.
|
19536 | * @param {Number} b The second value.
|
19537 | * @return {Number} The result of `a - b`.
|
19538 | * @see R.add
|
19539 | * @example
|
19540 | *
|
19541 | * R.subtract(10, 8); //=> 2
|
19542 | *
|
19543 | * var minus5 = R.subtract(R.__, 5);
|
19544 | * minus5(17); //=> 12
|
19545 | *
|
19546 | * var complementaryAngle = R.subtract(90);
|
19547 | * complementaryAngle(30); //=> 60
|
19548 | * complementaryAngle(72); //=> 18
|
19549 | */
|
19550 | module.exports = _curry2(function subtract(a, b) {
|
19551 | return Number(a) - Number(b);
|
19552 | });
|
19553 |
|
19554 |
|
19555 | /***/ }),
|
19556 | /* 300 */
|
19557 | /***/ (function(module, exports, __webpack_require__) {
|
19558 |
|
19559 | var _curry2 = __webpack_require__(0);
|
19560 | var concat = __webpack_require__(47);
|
19561 | var difference = __webpack_require__(70);
|
19562 |
|
19563 |
|
19564 | /**
|
19565 | * Finds the set (i.e. no duplicates) of all elements contained in the first or
|
19566 | * second list, but not both.
|
19567 | *
|
19568 | * @func
|
19569 | * @memberOf R
|
19570 | * @since v0.19.0
|
19571 | * @category Relation
|
19572 | * @sig [*] -> [*] -> [*]
|
19573 | * @param {Array} list1 The first list.
|
19574 | * @param {Array} list2 The second list.
|
19575 | * @return {Array} The elements in `list1` or `list2`, but not both.
|
19576 | * @see R.symmetricDifferenceWith, R.difference, R.differenceWith
|
19577 | * @example
|
19578 | *
|
19579 | * R.symmetricDifference([1,2,3,4], [7,6,5,4,3]); //=> [1,2,7,6,5]
|
19580 | * R.symmetricDifference([7,6,5,4,3], [1,2,3,4]); //=> [7,6,5,1,2]
|
19581 | */
|
19582 | module.exports = _curry2(function symmetricDifference(list1, list2) {
|
19583 | return concat(difference(list1, list2), difference(list2, list1));
|
19584 | });
|
19585 |
|
19586 |
|
19587 | /***/ }),
|
19588 | /* 301 */
|
19589 | /***/ (function(module, exports, __webpack_require__) {
|
19590 |
|
19591 | var _curry3 = __webpack_require__(2);
|
19592 | var concat = __webpack_require__(47);
|
19593 | var differenceWith = __webpack_require__(71);
|
19594 |
|
19595 |
|
19596 | /**
|
19597 | * Finds the set (i.e. no duplicates) of all elements contained in the first or
|
19598 | * second list, but not both. Duplication is determined according to the value
|
19599 | * returned by applying the supplied predicate to two list elements.
|
19600 | *
|
19601 | * @func
|
19602 | * @memberOf R
|
19603 | * @since v0.19.0
|
19604 | * @category Relation
|
19605 | * @sig ((a, a) -> Boolean) -> [a] -> [a] -> [a]
|
19606 | * @param {Function} pred A predicate used to test whether two items are equal.
|
19607 | * @param {Array} list1 The first list.
|
19608 | * @param {Array} list2 The second list.
|
19609 | * @return {Array} The elements in `list1` or `list2`, but not both.
|
19610 | * @see R.symmetricDifference, R.difference, R.differenceWith
|
19611 | * @example
|
19612 | *
|
19613 | * var eqA = R.eqBy(R.prop('a'));
|
19614 | * var l1 = [{a: 1}, {a: 2}, {a: 3}, {a: 4}];
|
19615 | * var l2 = [{a: 3}, {a: 4}, {a: 5}, {a: 6}];
|
19616 | * R.symmetricDifferenceWith(eqA, l1, l2); //=> [{a: 1}, {a: 2}, {a: 5}, {a: 6}]
|
19617 | */
|
19618 | module.exports = _curry3(function symmetricDifferenceWith(pred, list1, list2) {
|
19619 | return concat(differenceWith(pred, list1, list2), differenceWith(pred, list2, list1));
|
19620 | });
|
19621 |
|
19622 |
|
19623 | /***/ }),
|
19624 | /* 302 */
|
19625 | /***/ (function(module, exports, __webpack_require__) {
|
19626 |
|
19627 | var _curry2 = __webpack_require__(0);
|
19628 | var drop = __webpack_require__(73);
|
19629 |
|
19630 |
|
19631 | /**
|
19632 | * Returns a new list containing the last `n` elements of the given list.
|
19633 | * If `n > list.length`, returns a list of `list.length` elements.
|
19634 | *
|
19635 | * @func
|
19636 | * @memberOf R
|
19637 | * @since v0.16.0
|
19638 | * @category List
|
19639 | * @sig Number -> [a] -> [a]
|
19640 | * @sig Number -> String -> String
|
19641 | * @param {Number} n The number of elements to return.
|
19642 | * @param {Array} xs The collection to consider.
|
19643 | * @return {Array}
|
19644 | * @see R.dropLast
|
19645 | * @example
|
19646 | *
|
19647 | * R.takeLast(1, ['foo', 'bar', 'baz']); //=> ['baz']
|
19648 | * R.takeLast(2, ['foo', 'bar', 'baz']); //=> ['bar', 'baz']
|
19649 | * R.takeLast(3, ['foo', 'bar', 'baz']); //=> ['foo', 'bar', 'baz']
|
19650 | * R.takeLast(4, ['foo', 'bar', 'baz']); //=> ['foo', 'bar', 'baz']
|
19651 | * R.takeLast(3, 'ramda'); //=> 'mda'
|
19652 | */
|
19653 | module.exports = _curry2(function takeLast(n, xs) {
|
19654 | return drop(n >= 0 ? xs.length - n : 0, xs);
|
19655 | });
|
19656 |
|
19657 |
|
19658 | /***/ }),
|
19659 | /* 303 */
|
19660 | /***/ (function(module, exports, __webpack_require__) {
|
19661 |
|
19662 | var _curry2 = __webpack_require__(0);
|
19663 |
|
19664 |
|
19665 | /**
|
19666 | * Returns a new list containing the last `n` elements of a given list, passing
|
19667 | * each value to the supplied predicate function, and terminating when the
|
19668 | * predicate function returns `false`. Excludes the element that caused the
|
19669 | * predicate function to fail. The predicate function is passed one argument:
|
19670 | * *(value)*.
|
19671 | *
|
19672 | * @func
|
19673 | * @memberOf R
|
19674 | * @since v0.16.0
|
19675 | * @category List
|
19676 | * @sig (a -> Boolean) -> [a] -> [a]
|
19677 | * @param {Function} fn The function called per iteration.
|
19678 | * @param {Array} list The collection to iterate over.
|
19679 | * @return {Array} A new array.
|
19680 | * @see R.dropLastWhile, R.addIndex
|
19681 | * @example
|
19682 | *
|
19683 | * var isNotOne = x => x !== 1;
|
19684 | *
|
19685 | * R.takeLastWhile(isNotOne, [1, 2, 3, 4]); //=> [2, 3, 4]
|
19686 | */
|
19687 | module.exports = _curry2(function takeLastWhile(fn, list) {
|
19688 | var idx = list.length - 1;
|
19689 | while (idx >= 0 && fn(list[idx])) {
|
19690 | idx -= 1;
|
19691 | }
|
19692 | return Array.prototype.slice.call(list, idx + 1);
|
19693 | });
|
19694 |
|
19695 |
|
19696 | /***/ }),
|
19697 | /* 304 */
|
19698 | /***/ (function(module, exports, __webpack_require__) {
|
19699 |
|
19700 | var _curry2 = __webpack_require__(0);
|
19701 | var _dispatchable = __webpack_require__(3);
|
19702 | var _xtakeWhile = __webpack_require__(230);
|
19703 |
|
19704 |
|
19705 | /**
|
19706 | * Returns a new list containing the first `n` elements of a given list,
|
19707 | * passing each value to the supplied predicate function, and terminating when
|
19708 | * the predicate function returns `false`. Excludes the element that caused the
|
19709 | * predicate function to fail. The predicate function is passed one argument:
|
19710 | * *(value)*.
|
19711 | *
|
19712 | * Dispatches to the `takeWhile` method of the second argument, if present.
|
19713 | *
|
19714 | * Acts as a transducer if a transformer is given in list position.
|
19715 | *
|
19716 | * @func
|
19717 | * @memberOf R
|
19718 | * @since v0.1.0
|
19719 | * @category List
|
19720 | * @sig (a -> Boolean) -> [a] -> [a]
|
19721 | * @param {Function} fn The function called per iteration.
|
19722 | * @param {Array} list The collection to iterate over.
|
19723 | * @return {Array} A new array.
|
19724 | * @see R.dropWhile, R.transduce, R.addIndex
|
19725 | * @example
|
19726 | *
|
19727 | * var isNotFour = x => x !== 4;
|
19728 | *
|
19729 | * R.takeWhile(isNotFour, [1, 2, 3, 4, 3, 2, 1]); //=> [1, 2, 3]
|
19730 | */
|
19731 | module.exports = _curry2(_dispatchable(['takeWhile'], _xtakeWhile, function takeWhile(fn, list) {
|
19732 | var idx = 0;
|
19733 | var len = list.length;
|
19734 | while (idx < len && fn(list[idx])) {
|
19735 | idx += 1;
|
19736 | }
|
19737 | return Array.prototype.slice.call(list, 0, idx);
|
19738 | }));
|
19739 |
|
19740 |
|
19741 | /***/ }),
|
19742 | /* 305 */
|
19743 | /***/ (function(module, exports, __webpack_require__) {
|
19744 |
|
19745 | var _curry2 = __webpack_require__(0);
|
19746 |
|
19747 |
|
19748 | /**
|
19749 | * Runs the given function with the supplied object, then returns the object.
|
19750 | *
|
19751 | * @func
|
19752 | * @memberOf R
|
19753 | * @since v0.1.0
|
19754 | * @category Function
|
19755 | * @sig (a -> *) -> a -> a
|
19756 | * @param {Function} fn The function to call with `x`. The return value of `fn` will be thrown away.
|
19757 | * @param {*} x
|
19758 | * @return {*} `x`.
|
19759 | * @example
|
19760 | *
|
19761 | * var sayX = x => console.log('x is ' + x);
|
19762 | * R.tap(sayX, 100); //=> 100
|
19763 | * // logs 'x is 100'
|
19764 | * @symb R.tap(f, a) = a
|
19765 | */
|
19766 | module.exports = _curry2(function tap(fn, x) {
|
19767 | fn(x);
|
19768 | return x;
|
19769 | });
|
19770 |
|
19771 |
|
19772 | /***/ }),
|
19773 | /* 306 */
|
19774 | /***/ (function(module, exports, __webpack_require__) {
|
19775 |
|
19776 | var _cloneRegExp = __webpack_require__(78);
|
19777 | var _curry2 = __webpack_require__(0);
|
19778 | var _isRegExp = __webpack_require__(206);
|
19779 | var toString = __webpack_require__(27);
|
19780 |
|
19781 |
|
19782 | /**
|
19783 | * Determines whether a given string matches a given regular expression.
|
19784 | *
|
19785 | * @func
|
19786 | * @memberOf R
|
19787 | * @since v0.12.0
|
19788 | * @category String
|
19789 | * @sig RegExp -> String -> Boolean
|
19790 | * @param {RegExp} pattern
|
19791 | * @param {String} str
|
19792 | * @return {Boolean}
|
19793 | * @see R.match
|
19794 | * @example
|
19795 | *
|
19796 | * R.test(/^x/, 'xyz'); //=> true
|
19797 | * R.test(/^y/, 'xyz'); //=> false
|
19798 | */
|
19799 | module.exports = _curry2(function test(pattern, str) {
|
19800 | if (!_isRegExp(pattern)) {
|
19801 | throw new TypeError('‘test’ requires a value of type RegExp as its first argument; received ' + toString(pattern));
|
19802 | }
|
19803 | return _cloneRegExp(pattern).test(str);
|
19804 | });
|
19805 |
|
19806 |
|
19807 | /***/ }),
|
19808 | /* 307 */
|
19809 | /***/ (function(module, exports, __webpack_require__) {
|
19810 |
|
19811 | var invoker = __webpack_require__(22);
|
19812 |
|
19813 |
|
19814 | /**
|
19815 | * The lower case version of a string.
|
19816 | *
|
19817 | * @func
|
19818 | * @memberOf R
|
19819 | * @since v0.9.0
|
19820 | * @category String
|
19821 | * @sig String -> String
|
19822 | * @param {String} str The string to lower case.
|
19823 | * @return {String} The lower case version of `str`.
|
19824 | * @see R.toUpper
|
19825 | * @example
|
19826 | *
|
19827 | * R.toLower('XYZ'); //=> 'xyz'
|
19828 | */
|
19829 | module.exports = invoker(0, 'toLowerCase');
|
19830 |
|
19831 |
|
19832 | /***/ }),
|
19833 | /* 308 */
|
19834 | /***/ (function(module, exports, __webpack_require__) {
|
19835 |
|
19836 | var _curry1 = __webpack_require__(1);
|
19837 | var _has = __webpack_require__(6);
|
19838 |
|
19839 |
|
19840 | /**
|
19841 | * Converts an object into an array of key, value arrays. Only the object's
|
19842 | * own properties are used.
|
19843 | * Note that the order of the output array is not guaranteed to be consistent
|
19844 | * across different JS platforms.
|
19845 | *
|
19846 | * @func
|
19847 | * @memberOf R
|
19848 | * @since v0.4.0
|
19849 | * @category Object
|
19850 | * @sig {String: *} -> [[String,*]]
|
19851 | * @param {Object} obj The object to extract from
|
19852 | * @return {Array} An array of key, value arrays from the object's own properties.
|
19853 | * @see R.fromPairs
|
19854 | * @example
|
19855 | *
|
19856 | * R.toPairs({a: 1, b: 2, c: 3}); //=> [['a', 1], ['b', 2], ['c', 3]]
|
19857 | */
|
19858 | module.exports = _curry1(function toPairs(obj) {
|
19859 | var pairs = [];
|
19860 | for (var prop in obj) {
|
19861 | if (_has(prop, obj)) {
|
19862 | pairs[pairs.length] = [prop, obj[prop]];
|
19863 | }
|
19864 | }
|
19865 | return pairs;
|
19866 | });
|
19867 |
|
19868 |
|
19869 | /***/ }),
|
19870 | /* 309 */
|
19871 | /***/ (function(module, exports, __webpack_require__) {
|
19872 |
|
19873 | var _curry1 = __webpack_require__(1);
|
19874 |
|
19875 |
|
19876 | /**
|
19877 | * Converts an object into an array of key, value arrays. The object's own
|
19878 | * properties and prototype properties are used. Note that the order of the
|
19879 | * output array is not guaranteed to be consistent across different JS
|
19880 | * platforms.
|
19881 | *
|
19882 | * @func
|
19883 | * @memberOf R
|
19884 | * @since v0.4.0
|
19885 | * @category Object
|
19886 | * @sig {String: *} -> [[String,*]]
|
19887 | * @param {Object} obj The object to extract from
|
19888 | * @return {Array} An array of key, value arrays from the object's own
|
19889 | * and prototype properties.
|
19890 | * @example
|
19891 | *
|
19892 | * var F = function() { this.x = 'X'; };
|
19893 | * F.prototype.y = 'Y';
|
19894 | * var f = new F();
|
19895 | * R.toPairsIn(f); //=> [['x','X'], ['y','Y']]
|
19896 | */
|
19897 | module.exports = _curry1(function toPairsIn(obj) {
|
19898 | var pairs = [];
|
19899 | for (var prop in obj) {
|
19900 | pairs[pairs.length] = [prop, obj[prop]];
|
19901 | }
|
19902 | return pairs;
|
19903 | });
|
19904 |
|
19905 |
|
19906 | /***/ }),
|
19907 | /* 310 */
|
19908 | /***/ (function(module, exports, __webpack_require__) {
|
19909 |
|
19910 | var invoker = __webpack_require__(22);
|
19911 |
|
19912 |
|
19913 | /**
|
19914 | * The upper case version of a string.
|
19915 | *
|
19916 | * @func
|
19917 | * @memberOf R
|
19918 | * @since v0.9.0
|
19919 | * @category String
|
19920 | * @sig String -> String
|
19921 | * @param {String} str The string to upper case.
|
19922 | * @return {String} The upper case version of `str`.
|
19923 | * @see R.toLower
|
19924 | * @example
|
19925 | *
|
19926 | * R.toUpper('abc'); //=> 'ABC'
|
19927 | */
|
19928 | module.exports = invoker(0, 'toUpperCase');
|
19929 |
|
19930 |
|
19931 | /***/ }),
|
19932 | /* 311 */
|
19933 | /***/ (function(module, exports, __webpack_require__) {
|
19934 |
|
19935 | var _reduce = __webpack_require__(8);
|
19936 | var _xwrap = __webpack_require__(90);
|
19937 | var curryN = __webpack_require__(5);
|
19938 |
|
19939 |
|
19940 | /**
|
19941 | * Initializes a transducer using supplied iterator function. Returns a single
|
19942 | * item by iterating through the list, successively calling the transformed
|
19943 | * iterator function and passing it an accumulator value and the current value
|
19944 | * from the array, and then passing the result to the next call.
|
19945 | *
|
19946 | * The iterator function receives two values: *(acc, value)*. It will be
|
19947 | * wrapped as a transformer to initialize the transducer. A transformer can be
|
19948 | * passed directly in place of an iterator function. In both cases, iteration
|
19949 | * may be stopped early with the `R.reduced` function.
|
19950 | *
|
19951 | * A transducer is a function that accepts a transformer and returns a
|
19952 | * transformer and can be composed directly.
|
19953 | *
|
19954 | * A transformer is an an object that provides a 2-arity reducing iterator
|
19955 | * function, step, 0-arity initial value function, init, and 1-arity result
|
19956 | * extraction function, result. The step function is used as the iterator
|
19957 | * function in reduce. The result function is used to convert the final
|
19958 | * accumulator into the return type and in most cases is R.identity. The init
|
19959 | * function can be used to provide an initial accumulator, but is ignored by
|
19960 | * transduce.
|
19961 | *
|
19962 | * The iteration is performed with R.reduce after initializing the transducer.
|
19963 | *
|
19964 | * @func
|
19965 | * @memberOf R
|
19966 | * @since v0.12.0
|
19967 | * @category List
|
19968 | * @sig (c -> c) -> (a,b -> a) -> a -> [b] -> a
|
19969 | * @param {Function} xf The transducer function. Receives a transformer and returns a transformer.
|
19970 | * @param {Function} fn The iterator function. Receives two values, the accumulator and the
|
19971 | * current element from the array. Wrapped as transformer, if necessary, and used to
|
19972 | * initialize the transducer
|
19973 | * @param {*} acc The initial accumulator value.
|
19974 | * @param {Array} list The list to iterate over.
|
19975 | * @return {*} The final, accumulated value.
|
19976 | * @see R.reduce, R.reduced, R.into
|
19977 | * @example
|
19978 | *
|
19979 | * var numbers = [1, 2, 3, 4];
|
19980 | * var transducer = R.compose(R.map(R.add(1)), R.take(2));
|
19981 | *
|
19982 | * R.transduce(transducer, R.flip(R.append), [], numbers); //=> [2, 3]
|
19983 | */
|
19984 | module.exports = curryN(4, function transduce(xf, fn, acc, list) {
|
19985 | return _reduce(xf(typeof fn === 'function' ? _xwrap(fn) : fn), acc, list);
|
19986 | });
|
19987 |
|
19988 |
|
19989 | /***/ }),
|
19990 | /* 312 */
|
19991 | /***/ (function(module, exports, __webpack_require__) {
|
19992 |
|
19993 | var _curry1 = __webpack_require__(1);
|
19994 |
|
19995 |
|
19996 | /**
|
19997 | * Transposes the rows and columns of a 2D list.
|
19998 | * When passed a list of `n` lists of length `x`,
|
19999 | * returns a list of `x` lists of length `n`.
|
20000 | *
|
20001 | *
|
20002 | * @func
|
20003 | * @memberOf R
|
20004 | * @since v0.19.0
|
20005 | * @category List
|
20006 | * @sig [[a]] -> [[a]]
|
20007 | * @param {Array} list A 2D list
|
20008 | * @return {Array} A 2D list
|
20009 | * @example
|
20010 | *
|
20011 | * R.transpose([[1, 'a'], [2, 'b'], [3, 'c']]) //=> [[1, 2, 3], ['a', 'b', 'c']]
|
20012 | * R.transpose([[1, 2, 3], ['a', 'b', 'c']]) //=> [[1, 'a'], [2, 'b'], [3, 'c']]
|
20013 | *
|
20014 | * If some of the rows are shorter than the following rows, their elements are skipped:
|
20015 | *
|
20016 | * R.transpose([[10, 11], [20], [], [30, 31, 32]]) //=> [[10, 20, 30], [11, 31], [32]]
|
20017 | * @symb R.transpose([[a], [b], [c]]) = [a, b, c]
|
20018 | * @symb R.transpose([[a, b], [c, d]]) = [[a, c], [b, d]]
|
20019 | * @symb R.transpose([[a, b], [c]]) = [[a, c], [b]]
|
20020 | */
|
20021 | module.exports = _curry1(function transpose(outerlist) {
|
20022 | var i = 0;
|
20023 | var result = [];
|
20024 | while (i < outerlist.length) {
|
20025 | var innerlist = outerlist[i];
|
20026 | var j = 0;
|
20027 | while (j < innerlist.length) {
|
20028 | if (typeof result[j] === 'undefined') {
|
20029 | result[j] = [];
|
20030 | }
|
20031 | result[j].push(innerlist[j]);
|
20032 | j += 1;
|
20033 | }
|
20034 | i += 1;
|
20035 | }
|
20036 | return result;
|
20037 | });
|
20038 |
|
20039 |
|
20040 | /***/ }),
|
20041 | /* 313 */
|
20042 | /***/ (function(module, exports, __webpack_require__) {
|
20043 |
|
20044 | var _curry3 = __webpack_require__(2);
|
20045 | var map = __webpack_require__(7);
|
20046 | var sequence = __webpack_require__(108);
|
20047 |
|
20048 |
|
20049 | /**
|
20050 | * Maps an [Applicative](https://github.com/fantasyland/fantasy-land#applicative)-returning
|
20051 | * function over a [Traversable](https://github.com/fantasyland/fantasy-land#traversable),
|
20052 | * then uses [`sequence`](#sequence) to transform the resulting Traversable of Applicative
|
20053 | * into an Applicative of Traversable.
|
20054 | *
|
20055 | * Dispatches to the `sequence` method of the third argument, if present.
|
20056 | *
|
20057 | * @func
|
20058 | * @memberOf R
|
20059 | * @since v0.19.0
|
20060 | * @category List
|
20061 | * @sig (Applicative f, Traversable t) => (a -> f a) -> (a -> f b) -> t a -> f (t b)
|
20062 | * @param {Function} of
|
20063 | * @param {Function} f
|
20064 | * @param {*} traversable
|
20065 | * @return {*}
|
20066 | * @see R.sequence
|
20067 | * @example
|
20068 | *
|
20069 | * // Returns `Nothing` if the given divisor is `0`
|
20070 | * safeDiv = n => d => d === 0 ? Nothing() : Just(n / d)
|
20071 | *
|
20072 | * R.traverse(Maybe.of, safeDiv(10), [2, 4, 5]); //=> Just([5, 2.5, 2])
|
20073 | * R.traverse(Maybe.of, safeDiv(10), [2, 0, 5]); //=> Nothing
|
20074 | */
|
20075 | module.exports = _curry3(function traverse(of, f, traversable) {
|
20076 | return sequence(of, map(f, traversable));
|
20077 | });
|
20078 |
|
20079 |
|
20080 | /***/ }),
|
20081 | /* 314 */
|
20082 | /***/ (function(module, exports, __webpack_require__) {
|
20083 |
|
20084 | var _curry1 = __webpack_require__(1);
|
20085 |
|
20086 |
|
20087 | /**
|
20088 | * Removes (strips) whitespace from both ends of the string.
|
20089 | *
|
20090 | * @func
|
20091 | * @memberOf R
|
20092 | * @since v0.6.0
|
20093 | * @category String
|
20094 | * @sig String -> String
|
20095 | * @param {String} str The string to trim.
|
20096 | * @return {String} Trimmed version of `str`.
|
20097 | * @example
|
20098 | *
|
20099 | * R.trim(' xyz '); //=> 'xyz'
|
20100 | * R.map(R.trim, R.split(',', 'x, y, z')); //=> ['x', 'y', 'z']
|
20101 | */
|
20102 | module.exports = (function() {
|
20103 | var ws = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003' +
|
20104 | '\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028' +
|
20105 | '\u2029\uFEFF';
|
20106 | var zeroWidth = '\u200b';
|
20107 | var hasProtoTrim = (typeof String.prototype.trim === 'function');
|
20108 | if (!hasProtoTrim || (ws.trim() || !zeroWidth.trim())) {
|
20109 | return _curry1(function trim(str) {
|
20110 | var beginRx = new RegExp('^[' + ws + '][' + ws + ']*');
|
20111 | var endRx = new RegExp('[' + ws + '][' + ws + ']*$');
|
20112 | return str.replace(beginRx, '').replace(endRx, '');
|
20113 | });
|
20114 | } else {
|
20115 | return _curry1(function trim(str) {
|
20116 | return str.trim();
|
20117 | });
|
20118 | }
|
20119 | }());
|
20120 |
|
20121 |
|
20122 | /***/ }),
|
20123 | /* 315 */
|
20124 | /***/ (function(module, exports, __webpack_require__) {
|
20125 |
|
20126 | var _arity = __webpack_require__(11);
|
20127 | var _concat = __webpack_require__(9);
|
20128 | var _curry2 = __webpack_require__(0);
|
20129 |
|
20130 |
|
20131 | /**
|
20132 | * `tryCatch` takes two functions, a `tryer` and a `catcher`. The returned
|
20133 | * function evaluates the `tryer`; if it does not throw, it simply returns the
|
20134 | * result. If the `tryer` *does* throw, the returned function evaluates the
|
20135 | * `catcher` function and returns its result. Note that for effective
|
20136 | * composition with this function, both the `tryer` and `catcher` functions
|
20137 | * must return the same type of results.
|
20138 | *
|
20139 | * @func
|
20140 | * @memberOf R
|
20141 | * @since v0.20.0
|
20142 | * @category Function
|
20143 | * @sig (...x -> a) -> ((e, ...x) -> a) -> (...x -> a)
|
20144 | * @param {Function} tryer The function that may throw.
|
20145 | * @param {Function} catcher The function that will be evaluated if `tryer` throws.
|
20146 | * @return {Function} A new function that will catch exceptions and send then to the catcher.
|
20147 | * @example
|
20148 | *
|
20149 | * R.tryCatch(R.prop('x'), R.F)({x: true}); //=> true
|
20150 | * R.tryCatch(R.prop('x'), R.F)(null); //=> false
|
20151 | */
|
20152 | module.exports = _curry2(function _tryCatch(tryer, catcher) {
|
20153 | return _arity(tryer.length, function() {
|
20154 | try {
|
20155 | return tryer.apply(this, arguments);
|
20156 | } catch (e) {
|
20157 | return catcher.apply(this, _concat([e], arguments));
|
20158 | }
|
20159 | });
|
20160 | });
|
20161 |
|
20162 |
|
20163 | /***/ }),
|
20164 | /* 316 */
|
20165 | /***/ (function(module, exports, __webpack_require__) {
|
20166 |
|
20167 | var _curry1 = __webpack_require__(1);
|
20168 |
|
20169 |
|
20170 | /**
|
20171 | * Takes a function `fn`, which takes a single array argument, and returns a
|
20172 | * function which:
|
20173 | *
|
20174 | * - takes any number of positional arguments;
|
20175 | * - passes these arguments to `fn` as an array; and
|
20176 | * - returns the result.
|
20177 | *
|
20178 | * In other words, R.unapply derives a variadic function from a function which
|
20179 | * takes an array. R.unapply is the inverse of R.apply.
|
20180 | *
|
20181 | * @func
|
20182 | * @memberOf R
|
20183 | * @since v0.8.0
|
20184 | * @category Function
|
20185 | * @sig ([*...] -> a) -> (*... -> a)
|
20186 | * @param {Function} fn
|
20187 | * @return {Function}
|
20188 | * @see R.apply
|
20189 | * @example
|
20190 | *
|
20191 | * R.unapply(JSON.stringify)(1, 2, 3); //=> '[1,2,3]'
|
20192 | * @symb R.unapply(f)(a, b) = f([a, b])
|
20193 | */
|
20194 | module.exports = _curry1(function unapply(fn) {
|
20195 | return function() {
|
20196 | return fn(Array.prototype.slice.call(arguments, 0));
|
20197 | };
|
20198 | });
|
20199 |
|
20200 |
|
20201 | /***/ }),
|
20202 | /* 317 */
|
20203 | /***/ (function(module, exports, __webpack_require__) {
|
20204 |
|
20205 | var _curry1 = __webpack_require__(1);
|
20206 | var nAry = __webpack_require__(40);
|
20207 |
|
20208 |
|
20209 | /**
|
20210 | * Wraps a function of any arity (including nullary) in a function that accepts
|
20211 | * exactly 1 parameter. Any extraneous parameters will not be passed to the
|
20212 | * supplied function.
|
20213 | *
|
20214 | * @func
|
20215 | * @memberOf R
|
20216 | * @since v0.2.0
|
20217 | * @category Function
|
20218 | * @sig (* -> b) -> (a -> b)
|
20219 | * @param {Function} fn The function to wrap.
|
20220 | * @return {Function} A new function wrapping `fn`. The new function is guaranteed to be of
|
20221 | * arity 1.
|
20222 | * @example
|
20223 | *
|
20224 | * var takesTwoArgs = function(a, b) {
|
20225 | * return [a, b];
|
20226 | * };
|
20227 | * takesTwoArgs.length; //=> 2
|
20228 | * takesTwoArgs(1, 2); //=> [1, 2]
|
20229 | *
|
20230 | * var takesOneArg = R.unary(takesTwoArgs);
|
20231 | * takesOneArg.length; //=> 1
|
20232 | * // Only 1 argument is passed to the wrapped function
|
20233 | * takesOneArg(1, 2); //=> [1, undefined]
|
20234 | * @symb R.unary(f)(a, b, c) = f(a)
|
20235 | */
|
20236 | module.exports = _curry1(function unary(fn) {
|
20237 | return nAry(1, fn);
|
20238 | });
|
20239 |
|
20240 |
|
20241 | /***/ }),
|
20242 | /* 318 */
|
20243 | /***/ (function(module, exports, __webpack_require__) {
|
20244 |
|
20245 | var _curry2 = __webpack_require__(0);
|
20246 | var curryN = __webpack_require__(5);
|
20247 |
|
20248 |
|
20249 | /**
|
20250 | * Returns a function of arity `n` from a (manually) curried function.
|
20251 | *
|
20252 | * @func
|
20253 | * @memberOf R
|
20254 | * @since v0.14.0
|
20255 | * @category Function
|
20256 | * @sig Number -> (a -> b) -> (a -> c)
|
20257 | * @param {Number} length The arity for the returned function.
|
20258 | * @param {Function} fn The function to uncurry.
|
20259 | * @return {Function} A new function.
|
20260 | * @see R.curry
|
20261 | * @example
|
20262 | *
|
20263 | * var addFour = a => b => c => d => a + b + c + d;
|
20264 | *
|
20265 | * var uncurriedAddFour = R.uncurryN(4, addFour);
|
20266 | * uncurriedAddFour(1, 2, 3, 4); //=> 10
|
20267 | */
|
20268 | module.exports = _curry2(function uncurryN(depth, fn) {
|
20269 | return curryN(depth, function() {
|
20270 | var currentDepth = 1;
|
20271 | var value = fn;
|
20272 | var idx = 0;
|
20273 | var endIdx;
|
20274 | while (currentDepth <= depth && typeof value === 'function') {
|
20275 | endIdx = currentDepth === depth ? arguments.length : idx + value.length;
|
20276 | value = value.apply(this, Array.prototype.slice.call(arguments, idx, endIdx));
|
20277 | currentDepth += 1;
|
20278 | idx = endIdx;
|
20279 | }
|
20280 | return value;
|
20281 | });
|
20282 | });
|
20283 |
|
20284 |
|
20285 | /***/ }),
|
20286 | /* 319 */
|
20287 | /***/ (function(module, exports, __webpack_require__) {
|
20288 |
|
20289 | var _curry2 = __webpack_require__(0);
|
20290 |
|
20291 |
|
20292 | /**
|
20293 | * Builds a list from a seed value. Accepts an iterator function, which returns
|
20294 | * either false to stop iteration or an array of length 2 containing the value
|
20295 | * to add to the resulting list and the seed to be used in the next call to the
|
20296 | * iterator function.
|
20297 | *
|
20298 | * The iterator function receives one argument: *(seed)*.
|
20299 | *
|
20300 | * @func
|
20301 | * @memberOf R
|
20302 | * @since v0.10.0
|
20303 | * @category List
|
20304 | * @sig (a -> [b]) -> * -> [b]
|
20305 | * @param {Function} fn The iterator function. receives one argument, `seed`, and returns
|
20306 | * either false to quit iteration or an array of length two to proceed. The element
|
20307 | * at index 0 of this array will be added to the resulting array, and the element
|
20308 | * at index 1 will be passed to the next call to `fn`.
|
20309 | * @param {*} seed The seed value.
|
20310 | * @return {Array} The final list.
|
20311 | * @example
|
20312 | *
|
20313 | * var f = n => n > 50 ? false : [-n, n + 10];
|
20314 | * R.unfold(f, 10); //=> [-10, -20, -30, -40, -50]
|
20315 | * @symb R.unfold(f, x) = [f(x)[0], f(f(x)[1])[0], f(f(f(x)[1])[1])[0], ...]
|
20316 | */
|
20317 | module.exports = _curry2(function unfold(fn, seed) {
|
20318 | var pair = fn(seed);
|
20319 | var result = [];
|
20320 | while (pair && pair.length) {
|
20321 | result[result.length] = pair[0];
|
20322 | pair = fn(pair[1]);
|
20323 | }
|
20324 | return result;
|
20325 | });
|
20326 |
|
20327 |
|
20328 | /***/ }),
|
20329 | /* 320 */
|
20330 | /***/ (function(module, exports, __webpack_require__) {
|
20331 |
|
20332 | var _concat = __webpack_require__(9);
|
20333 | var _curry2 = __webpack_require__(0);
|
20334 | var compose = __webpack_require__(46);
|
20335 | var uniq = __webpack_require__(57);
|
20336 |
|
20337 |
|
20338 | /**
|
20339 | * Combines two lists into a set (i.e. no duplicates) composed of the elements
|
20340 | * of each list.
|
20341 | *
|
20342 | * @func
|
20343 | * @memberOf R
|
20344 | * @since v0.1.0
|
20345 | * @category Relation
|
20346 | * @sig [*] -> [*] -> [*]
|
20347 | * @param {Array} as The first list.
|
20348 | * @param {Array} bs The second list.
|
20349 | * @return {Array} The first and second lists concatenated, with
|
20350 | * duplicates removed.
|
20351 | * @example
|
20352 | *
|
20353 | * R.union([1, 2, 3], [2, 3, 4]); //=> [1, 2, 3, 4]
|
20354 | */
|
20355 | module.exports = _curry2(compose(uniq, _concat));
|
20356 |
|
20357 |
|
20358 | /***/ }),
|
20359 | /* 321 */
|
20360 | /***/ (function(module, exports, __webpack_require__) {
|
20361 |
|
20362 | var _concat = __webpack_require__(9);
|
20363 | var _curry3 = __webpack_require__(2);
|
20364 | var uniqWith = __webpack_require__(58);
|
20365 |
|
20366 |
|
20367 | /**
|
20368 | * Combines two lists into a set (i.e. no duplicates) composed of the elements
|
20369 | * of each list. Duplication is determined according to the value returned by
|
20370 | * applying the supplied predicate to two list elements.
|
20371 | *
|
20372 | * @func
|
20373 | * @memberOf R
|
20374 | * @since v0.1.0
|
20375 | * @category Relation
|
20376 | * @sig (a -> a -> Boolean) -> [*] -> [*] -> [*]
|
20377 | * @param {Function} pred A predicate used to test whether two items are equal.
|
20378 | * @param {Array} list1 The first list.
|
20379 | * @param {Array} list2 The second list.
|
20380 | * @return {Array} The first and second lists concatenated, with
|
20381 | * duplicates removed.
|
20382 | * @see R.union
|
20383 | * @example
|
20384 | *
|
20385 | * var l1 = [{a: 1}, {a: 2}];
|
20386 | * var l2 = [{a: 1}, {a: 4}];
|
20387 | * R.unionWith(R.eqBy(R.prop('a')), l1, l2); //=> [{a: 1}, {a: 2}, {a: 4}]
|
20388 | */
|
20389 | module.exports = _curry3(function unionWith(pred, list1, list2) {
|
20390 | return uniqWith(pred, _concat(list1, list2));
|
20391 | });
|
20392 |
|
20393 |
|
20394 | /***/ }),
|
20395 | /* 322 */
|
20396 | /***/ (function(module, exports, __webpack_require__) {
|
20397 |
|
20398 | var _curry3 = __webpack_require__(2);
|
20399 |
|
20400 |
|
20401 | /**
|
20402 | * Tests the final argument by passing it to the given predicate function. If
|
20403 | * the predicate is not satisfied, the function will return the result of
|
20404 | * calling the `whenFalseFn` function with the same argument. If the predicate
|
20405 | * is satisfied, the argument is returned as is.
|
20406 | *
|
20407 | * @func
|
20408 | * @memberOf R
|
20409 | * @since v0.18.0
|
20410 | * @category Logic
|
20411 | * @sig (a -> Boolean) -> (a -> a) -> a -> a
|
20412 | * @param {Function} pred A predicate function
|
20413 | * @param {Function} whenFalseFn A function to invoke when the `pred` evaluates
|
20414 | * to a falsy value.
|
20415 | * @param {*} x An object to test with the `pred` function and
|
20416 | * pass to `whenFalseFn` if necessary.
|
20417 | * @return {*} Either `x` or the result of applying `x` to `whenFalseFn`.
|
20418 | * @see R.ifElse, R.when
|
20419 | * @example
|
20420 | *
|
20421 | * // coerceArray :: (a|[a]) -> [a]
|
20422 | * var coerceArray = R.unless(R.isArrayLike, R.of);
|
20423 | * coerceArray([1, 2, 3]); //=> [1, 2, 3]
|
20424 | * coerceArray(1); //=> [1]
|
20425 | */
|
20426 | module.exports = _curry3(function unless(pred, whenFalseFn, x) {
|
20427 | return pred(x) ? x : whenFalseFn(x);
|
20428 | });
|
20429 |
|
20430 |
|
20431 | /***/ }),
|
20432 | /* 323 */
|
20433 | /***/ (function(module, exports, __webpack_require__) {
|
20434 |
|
20435 | var _identity = __webpack_require__(52);
|
20436 | var chain = __webpack_require__(45);
|
20437 |
|
20438 |
|
20439 | /**
|
20440 | * Shorthand for `R.chain(R.identity)`, which removes one level of nesting from
|
20441 | * any [Chain](https://github.com/fantasyland/fantasy-land#chain).
|
20442 | *
|
20443 | * @func
|
20444 | * @memberOf R
|
20445 | * @since v0.3.0
|
20446 | * @category List
|
20447 | * @sig Chain c => c (c a) -> c a
|
20448 | * @param {*} list
|
20449 | * @return {*}
|
20450 | * @see R.flatten, R.chain
|
20451 | * @example
|
20452 | *
|
20453 | * R.unnest([1, [2], [[3]]]); //=> [1, 2, [3]]
|
20454 | * R.unnest([[1, 2], [3, 4], [5, 6]]); //=> [1, 2, 3, 4, 5, 6]
|
20455 | */
|
20456 | module.exports = chain(_identity);
|
20457 |
|
20458 |
|
20459 | /***/ }),
|
20460 | /* 324 */
|
20461 | /***/ (function(module, exports, __webpack_require__) {
|
20462 |
|
20463 | var _curry3 = __webpack_require__(2);
|
20464 |
|
20465 |
|
20466 | /**
|
20467 | * Takes a predicate, a transformation function, and an initial value,
|
20468 | * and returns a value of the same type as the initial value.
|
20469 | * It does so by applying the transformation until the predicate is satisfied,
|
20470 | * at which point it returns the satisfactory value.
|
20471 | *
|
20472 | * @func
|
20473 | * @memberOf R
|
20474 | * @since v0.20.0
|
20475 | * @category Logic
|
20476 | * @sig (a -> Boolean) -> (a -> a) -> a -> a
|
20477 | * @param {Function} pred A predicate function
|
20478 | * @param {Function} fn The iterator function
|
20479 | * @param {*} init Initial value
|
20480 | * @return {*} Final value that satisfies predicate
|
20481 | * @example
|
20482 | *
|
20483 | * R.until(R.gt(R.__, 100), R.multiply(2))(1) // => 128
|
20484 | */
|
20485 | module.exports = _curry3(function until(pred, fn, init) {
|
20486 | var val = init;
|
20487 | while (!pred(val)) {
|
20488 | val = fn(val);
|
20489 | }
|
20490 | return val;
|
20491 | });
|
20492 |
|
20493 |
|
20494 | /***/ }),
|
20495 | /* 325 */
|
20496 | /***/ (function(module, exports, __webpack_require__) {
|
20497 |
|
20498 | var _curry1 = __webpack_require__(1);
|
20499 |
|
20500 |
|
20501 | /**
|
20502 | * Returns a list of all the properties, including prototype properties, of the
|
20503 | * supplied object.
|
20504 | * Note that the order of the output array is not guaranteed to be consistent
|
20505 | * across different JS platforms.
|
20506 | *
|
20507 | * @func
|
20508 | * @memberOf R
|
20509 | * @since v0.2.0
|
20510 | * @category Object
|
20511 | * @sig {k: v} -> [v]
|
20512 | * @param {Object} obj The object to extract values from
|
20513 | * @return {Array} An array of the values of the object's own and prototype properties.
|
20514 | * @example
|
20515 | *
|
20516 | * var F = function() { this.x = 'X'; };
|
20517 | * F.prototype.y = 'Y';
|
20518 | * var f = new F();
|
20519 | * R.valuesIn(f); //=> ['X', 'Y']
|
20520 | */
|
20521 | module.exports = _curry1(function valuesIn(obj) {
|
20522 | var prop;
|
20523 | var vs = [];
|
20524 | for (prop in obj) {
|
20525 | vs[vs.length] = obj[prop];
|
20526 | }
|
20527 | return vs;
|
20528 | });
|
20529 |
|
20530 |
|
20531 | /***/ }),
|
20532 | /* 326 */
|
20533 | /***/ (function(module, exports, __webpack_require__) {
|
20534 |
|
20535 | var _curry2 = __webpack_require__(0);
|
20536 |
|
20537 |
|
20538 | /**
|
20539 | * Returns a "view" of the given data structure, determined by the given lens.
|
20540 | * The lens's focus determines which portion of the data structure is visible.
|
20541 | *
|
20542 | * @func
|
20543 | * @memberOf R
|
20544 | * @since v0.16.0
|
20545 | * @category Object
|
20546 | * @typedefn Lens s a = Functor f => (a -> f a) -> s -> f s
|
20547 | * @sig Lens s a -> s -> a
|
20548 | * @param {Lens} lens
|
20549 | * @param {*} x
|
20550 | * @return {*}
|
20551 | * @see R.prop, R.lensIndex, R.lensProp
|
20552 | * @example
|
20553 | *
|
20554 | * var xLens = R.lensProp('x');
|
20555 | *
|
20556 | * R.view(xLens, {x: 1, y: 2}); //=> 1
|
20557 | * R.view(xLens, {x: 4, y: 2}); //=> 4
|
20558 | */
|
20559 | module.exports = (function() {
|
20560 | // `Const` is a functor that effectively ignores the function given to `map`.
|
20561 | var Const = function(x) {
|
20562 | return {value: x, map: function() { return this; }};
|
20563 | };
|
20564 |
|
20565 | return _curry2(function view(lens, x) {
|
20566 | // Using `Const` effectively ignores the setter function of the `lens`,
|
20567 | // leaving the value returned by the getter function unmodified.
|
20568 | return lens(Const)(x).value;
|
20569 | });
|
20570 | }());
|
20571 |
|
20572 |
|
20573 | /***/ }),
|
20574 | /* 327 */
|
20575 | /***/ (function(module, exports, __webpack_require__) {
|
20576 |
|
20577 | var _curry3 = __webpack_require__(2);
|
20578 |
|
20579 |
|
20580 | /**
|
20581 | * Tests the final argument by passing it to the given predicate function. If
|
20582 | * the predicate is satisfied, the function will return the result of calling
|
20583 | * the `whenTrueFn` function with the same argument. If the predicate is not
|
20584 | * satisfied, the argument is returned as is.
|
20585 | *
|
20586 | * @func
|
20587 | * @memberOf R
|
20588 | * @since v0.18.0
|
20589 | * @category Logic
|
20590 | * @sig (a -> Boolean) -> (a -> a) -> a -> a
|
20591 | * @param {Function} pred A predicate function
|
20592 | * @param {Function} whenTrueFn A function to invoke when the `condition`
|
20593 | * evaluates to a truthy value.
|
20594 | * @param {*} x An object to test with the `pred` function and
|
20595 | * pass to `whenTrueFn` if necessary.
|
20596 | * @return {*} Either `x` or the result of applying `x` to `whenTrueFn`.
|
20597 | * @see R.ifElse, R.unless
|
20598 | * @example
|
20599 | *
|
20600 | * // truncate :: String -> String
|
20601 | * var truncate = R.when(
|
20602 | * R.propSatisfies(R.gt(R.__, 10), 'length'),
|
20603 | * R.pipe(R.take(10), R.append('…'), R.join(''))
|
20604 | * );
|
20605 | * truncate('12345'); //=> '12345'
|
20606 | * truncate('0123456789ABC'); //=> '0123456789…'
|
20607 | */
|
20608 | module.exports = _curry3(function when(pred, whenTrueFn, x) {
|
20609 | return pred(x) ? whenTrueFn(x) : x;
|
20610 | });
|
20611 |
|
20612 |
|
20613 | /***/ }),
|
20614 | /* 328 */
|
20615 | /***/ (function(module, exports, __webpack_require__) {
|
20616 |
|
20617 | var _curry2 = __webpack_require__(0);
|
20618 | var equals = __webpack_require__(10);
|
20619 | var map = __webpack_require__(7);
|
20620 | var where = __webpack_require__(116);
|
20621 |
|
20622 |
|
20623 | /**
|
20624 | * Takes a spec object and a test object; returns true if the test satisfies
|
20625 | * the spec, false otherwise. An object satisfies the spec if, for each of the
|
20626 | * spec's own properties, accessing that property of the object gives the same
|
20627 | * value (in `R.equals` terms) as accessing that property of the spec.
|
20628 | *
|
20629 | * `whereEq` is a specialization of [`where`](#where).
|
20630 | *
|
20631 | * @func
|
20632 | * @memberOf R
|
20633 | * @since v0.14.0
|
20634 | * @category Object
|
20635 | * @sig {String: *} -> {String: *} -> Boolean
|
20636 | * @param {Object} spec
|
20637 | * @param {Object} testObj
|
20638 | * @return {Boolean}
|
20639 | * @see R.where
|
20640 | * @example
|
20641 | *
|
20642 | * // pred :: Object -> Boolean
|
20643 | * var pred = R.whereEq({a: 1, b: 2});
|
20644 | *
|
20645 | * pred({a: 1}); //=> false
|
20646 | * pred({a: 1, b: 2}); //=> true
|
20647 | * pred({a: 1, b: 2, c: 3}); //=> true
|
20648 | * pred({a: 1, b: 1}); //=> false
|
20649 | */
|
20650 | module.exports = _curry2(function whereEq(spec, testObj) {
|
20651 | return where(map(equals, spec), testObj);
|
20652 | });
|
20653 |
|
20654 |
|
20655 | /***/ }),
|
20656 | /* 329 */
|
20657 | /***/ (function(module, exports, __webpack_require__) {
|
20658 |
|
20659 | var _contains = __webpack_require__(17);
|
20660 | var _curry2 = __webpack_require__(0);
|
20661 | var flip = __webpack_require__(32);
|
20662 | var reject = __webpack_require__(42);
|
20663 |
|
20664 |
|
20665 | /**
|
20666 | * Returns a new list without values in the first argument.
|
20667 | * `R.equals` is used to determine equality.
|
20668 | *
|
20669 | * Acts as a transducer if a transformer is given in list position.
|
20670 | *
|
20671 | * @func
|
20672 | * @memberOf R
|
20673 | * @since v0.19.0
|
20674 | * @category List
|
20675 | * @sig [a] -> [a] -> [a]
|
20676 | * @param {Array} list1 The values to be removed from `list2`.
|
20677 | * @param {Array} list2 The array to remove values from.
|
20678 | * @return {Array} The new array without values in `list1`.
|
20679 | * @see R.transduce
|
20680 | * @example
|
20681 | *
|
20682 | * R.without([1, 2], [1, 2, 1, 3, 4]); //=> [3, 4]
|
20683 | */
|
20684 | module.exports = _curry2(function(xs, list) {
|
20685 | return reject(flip(_contains)(xs), list);
|
20686 | });
|
20687 |
|
20688 |
|
20689 | /***/ }),
|
20690 | /* 330 */
|
20691 | /***/ (function(module, exports, __webpack_require__) {
|
20692 |
|
20693 | var _curry2 = __webpack_require__(0);
|
20694 |
|
20695 |
|
20696 | /**
|
20697 | * Creates a new list out of the two supplied by creating each possible pair
|
20698 | * from the lists.
|
20699 | *
|
20700 | * @func
|
20701 | * @memberOf R
|
20702 | * @since v0.1.0
|
20703 | * @category List
|
20704 | * @sig [a] -> [b] -> [[a,b]]
|
20705 | * @param {Array} as The first list.
|
20706 | * @param {Array} bs The second list.
|
20707 | * @return {Array} The list made by combining each possible pair from
|
20708 | * `as` and `bs` into pairs (`[a, b]`).
|
20709 | * @example
|
20710 | *
|
20711 | * R.xprod([1, 2], ['a', 'b']); //=> [[1, 'a'], [1, 'b'], [2, 'a'], [2, 'b']]
|
20712 | * @symb R.xprod([a, b], [c, d]) = [[a, c], [a, d], [b, c], [b, d]]
|
20713 | */
|
20714 | module.exports = _curry2(function xprod(a, b) { // = xprodWith(prepend); (takes about 3 times as long...)
|
20715 | var idx = 0;
|
20716 | var ilen = a.length;
|
20717 | var j;
|
20718 | var jlen = b.length;
|
20719 | var result = [];
|
20720 | while (idx < ilen) {
|
20721 | j = 0;
|
20722 | while (j < jlen) {
|
20723 | result[result.length] = [a[idx], b[j]];
|
20724 | j += 1;
|
20725 | }
|
20726 | idx += 1;
|
20727 | }
|
20728 | return result;
|
20729 | });
|
20730 |
|
20731 |
|
20732 | /***/ }),
|
20733 | /* 331 */
|
20734 | /***/ (function(module, exports, __webpack_require__) {
|
20735 |
|
20736 | var _curry2 = __webpack_require__(0);
|
20737 |
|
20738 |
|
20739 | /**
|
20740 | * Creates a new list out of the two supplied by pairing up equally-positioned
|
20741 | * items from both lists. The returned list is truncated to the length of the
|
20742 | * shorter of the two input lists.
|
20743 | * Note: `zip` is equivalent to `zipWith(function(a, b) { return [a, b] })`.
|
20744 | *
|
20745 | * @func
|
20746 | * @memberOf R
|
20747 | * @since v0.1.0
|
20748 | * @category List
|
20749 | * @sig [a] -> [b] -> [[a,b]]
|
20750 | * @param {Array} list1 The first array to consider.
|
20751 | * @param {Array} list2 The second array to consider.
|
20752 | * @return {Array} The list made by pairing up same-indexed elements of `list1` and `list2`.
|
20753 | * @example
|
20754 | *
|
20755 | * R.zip([1, 2, 3], ['a', 'b', 'c']); //=> [[1, 'a'], [2, 'b'], [3, 'c']]
|
20756 | * @symb R.zip([a, b, c], [d, e, f]) = [[a, d], [b, e], [c, f]]
|
20757 | */
|
20758 | module.exports = _curry2(function zip(a, b) {
|
20759 | var rv = [];
|
20760 | var idx = 0;
|
20761 | var len = Math.min(a.length, b.length);
|
20762 | while (idx < len) {
|
20763 | rv[idx] = [a[idx], b[idx]];
|
20764 | idx += 1;
|
20765 | }
|
20766 | return rv;
|
20767 | });
|
20768 |
|
20769 |
|
20770 | /***/ }),
|
20771 | /* 332 */
|
20772 | /***/ (function(module, exports, __webpack_require__) {
|
20773 |
|
20774 | var _curry2 = __webpack_require__(0);
|
20775 |
|
20776 |
|
20777 | /**
|
20778 | * Creates a new object out of a list of keys and a list of values.
|
20779 | * Key/value pairing is truncated to the length of the shorter of the two lists.
|
20780 | * Note: `zipObj` is equivalent to `pipe(zipWith(pair), fromPairs)`.
|
20781 | *
|
20782 | * @func
|
20783 | * @memberOf R
|
20784 | * @since v0.3.0
|
20785 | * @category List
|
20786 | * @sig [String] -> [*] -> {String: *}
|
20787 | * @param {Array} keys The array that will be properties on the output object.
|
20788 | * @param {Array} values The list of values on the output object.
|
20789 | * @return {Object} The object made by pairing up same-indexed elements of `keys` and `values`.
|
20790 | * @example
|
20791 | *
|
20792 | * R.zipObj(['a', 'b', 'c'], [1, 2, 3]); //=> {a: 1, b: 2, c: 3}
|
20793 | */
|
20794 | module.exports = _curry2(function zipObj(keys, values) {
|
20795 | var idx = 0;
|
20796 | var len = Math.min(keys.length, values.length);
|
20797 | var out = {};
|
20798 | while (idx < len) {
|
20799 | out[keys[idx]] = values[idx];
|
20800 | idx += 1;
|
20801 | }
|
20802 | return out;
|
20803 | });
|
20804 |
|
20805 |
|
20806 | /***/ }),
|
20807 | /* 333 */
|
20808 | /***/ (function(module, exports, __webpack_require__) {
|
20809 |
|
20810 | var _curry3 = __webpack_require__(2);
|
20811 |
|
20812 |
|
20813 | /**
|
20814 | * Creates a new list out of the two supplied by applying the function to each
|
20815 | * equally-positioned pair in the lists. The returned list is truncated to the
|
20816 | * length of the shorter of the two input lists.
|
20817 | *
|
20818 | * @function
|
20819 | * @memberOf R
|
20820 | * @since v0.1.0
|
20821 | * @category List
|
20822 | * @sig (a,b -> c) -> [a] -> [b] -> [c]
|
20823 | * @param {Function} fn The function used to combine the two elements into one value.
|
20824 | * @param {Array} list1 The first array to consider.
|
20825 | * @param {Array} list2 The second array to consider.
|
20826 | * @return {Array} The list made by combining same-indexed elements of `list1` and `list2`
|
20827 | * using `fn`.
|
20828 | * @example
|
20829 | *
|
20830 | * var f = (x, y) => {
|
20831 | * // ...
|
20832 | * };
|
20833 | * R.zipWith(f, [1, 2, 3], ['a', 'b', 'c']);
|
20834 | * //=> [f(1, 'a'), f(2, 'b'), f(3, 'c')]
|
20835 | * @symb R.zipWith(fn, [a, b, c], [d, e, f]) = [fn(a, d), fn(b, e), fn(c, f)]
|
20836 | */
|
20837 | module.exports = _curry3(function zipWith(fn, a, b) {
|
20838 | var rv = [];
|
20839 | var idx = 0;
|
20840 | var len = Math.min(a.length, b.length);
|
20841 | while (idx < len) {
|
20842 | rv[idx] = fn(a[idx], b[idx]);
|
20843 | idx += 1;
|
20844 | }
|
20845 | return rv;
|
20846 | });
|
20847 |
|
20848 |
|
20849 | /***/ }),
|
20850 | /* 334 */
|
20851 | /***/ (function(module, exports, __webpack_require__) {
|
20852 |
|
20853 | /* WEBPACK VAR INJECTION */(function(global) {(function () {
|
20854 | var /*
|
20855 | * Rusha, a JavaScript implementation of the Secure Hash Algorithm, SHA-1,
|
20856 | * as defined in FIPS PUB 180-1, tuned for high performance with large inputs.
|
20857 | * (http://github.com/srijs/rusha)
|
20858 | *
|
20859 | * Inspired by Paul Johnstons implementation (http://pajhome.org.uk/crypt/md5).
|
20860 | *
|
20861 | * Copyright (c) 2013 Sam Rijs (http://awesam.de).
|
20862 | * Released under the terms of the MIT license as follows:
|
20863 | *
|
20864 | * Permission is hereby granted, free of charge, to any person obtaining a
|
20865 | * copy of this software and associated documentation files (the "Software"),
|
20866 | * to deal in the Software without restriction, including without limitation
|
20867 | * the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
20868 | * and/or sell copies of the Software, and to permit persons to whom the
|
20869 | * Software is furnished to do so, subject to the following conditions:
|
20870 | *
|
20871 | * The above copyright notice and this permission notice shall be included in
|
20872 | * all copies or substantial portions of the Software.
|
20873 | *
|
20874 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
20875 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
20876 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20877 | * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
20878 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
20879 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
|
20880 | * IN THE SOFTWARE.
|
20881 | */
|
20882 | util = {
|
20883 | getDataType: function (data) {
|
20884 | if (typeof data === 'string') {
|
20885 | return 'string';
|
20886 | }
|
20887 | if (data instanceof Array) {
|
20888 | return 'array';
|
20889 | }
|
20890 | if (typeof global !== 'undefined' && global.Buffer && global.Buffer.isBuffer(data)) {
|
20891 | return 'buffer';
|
20892 | }
|
20893 | if (data instanceof ArrayBuffer) {
|
20894 | return 'arraybuffer';
|
20895 | }
|
20896 | if (data.buffer instanceof ArrayBuffer) {
|
20897 | return 'view';
|
20898 | }
|
20899 | if (data instanceof Blob) {
|
20900 | return 'blob';
|
20901 | }
|
20902 | throw new Error('Unsupported data type.');
|
20903 | }
|
20904 | };
|
20905 | function Rusha(chunkSize) {
|
20906 | 'use strict';
|
20907 | var // Private object structure.
|
20908 | self$2 = { fill: 0 };
|
20909 | var // Calculate the length of buffer that the sha1 routine uses
|
20910 | // including the padding.
|
20911 | padlen = function (len) {
|
20912 | for (len += 9; len % 64 > 0; len += 1);
|
20913 | return len;
|
20914 | };
|
20915 | var padZeroes = function (bin, len) {
|
20916 | var h8 = new Uint8Array(bin.buffer);
|
20917 | var om = len % 4, align = len - om;
|
20918 | switch (om) {
|
20919 | case 0:
|
20920 | h8[align + 3] = 0;
|
20921 | case 1:
|
20922 | h8[align + 2] = 0;
|
20923 | case 2:
|
20924 | h8[align + 1] = 0;
|
20925 | case 3:
|
20926 | h8[align + 0] = 0;
|
20927 | }
|
20928 | for (var i$2 = (len >> 2) + 1; i$2 < bin.length; i$2++)
|
20929 | bin[i$2] = 0;
|
20930 | };
|
20931 | var padData = function (bin, chunkLen, msgLen) {
|
20932 | bin[chunkLen >> 2] |= 128 << 24 - (chunkLen % 4 << 3);
|
20933 | // To support msgLen >= 2 GiB, use a float division when computing the
|
20934 | // high 32-bits of the big-endian message length in bits.
|
20935 | bin[((chunkLen >> 2) + 2 & ~15) + 14] = msgLen / (1 << 29) | 0;
|
20936 | bin[((chunkLen >> 2) + 2 & ~15) + 15] = msgLen << 3;
|
20937 | };
|
20938 | var // Convert a binary string and write it to the heap.
|
20939 | // A binary string is expected to only contain char codes < 256.
|
20940 | convStr = function (H8, H32, start, len, off) {
|
20941 | var str = this, i$2, om = off % 4, lm = (len + om) % 4, j = len - lm;
|
20942 | switch (om) {
|
20943 | case 0:
|
20944 | H8[off] = str.charCodeAt(start + 3);
|
20945 | case 1:
|
20946 | H8[off + 1 - (om << 1) | 0] = str.charCodeAt(start + 2);
|
20947 | case 2:
|
20948 | H8[off + 2 - (om << 1) | 0] = str.charCodeAt(start + 1);
|
20949 | case 3:
|
20950 | H8[off + 3 - (om << 1) | 0] = str.charCodeAt(start);
|
20951 | }
|
20952 | if (len < lm + om) {
|
20953 | return;
|
20954 | }
|
20955 | for (i$2 = 4 - om; i$2 < j; i$2 = i$2 + 4 | 0) {
|
20956 | H32[off + i$2 >> 2] = str.charCodeAt(start + i$2) << 24 | str.charCodeAt(start + i$2 + 1) << 16 | str.charCodeAt(start + i$2 + 2) << 8 | str.charCodeAt(start + i$2 + 3);
|
20957 | }
|
20958 | switch (lm) {
|
20959 | case 3:
|
20960 | H8[off + j + 1 | 0] = str.charCodeAt(start + j + 2);
|
20961 | case 2:
|
20962 | H8[off + j + 2 | 0] = str.charCodeAt(start + j + 1);
|
20963 | case 1:
|
20964 | H8[off + j + 3 | 0] = str.charCodeAt(start + j);
|
20965 | }
|
20966 | };
|
20967 | var // Convert a buffer or array and write it to the heap.
|
20968 | // The buffer or array is expected to only contain elements < 256.
|
20969 | convBuf = function (H8, H32, start, len, off) {
|
20970 | var buf = this, i$2, om = off % 4, lm = (len + om) % 4, j = len - lm;
|
20971 | switch (om) {
|
20972 | case 0:
|
20973 | H8[off] = buf[start + 3];
|
20974 | case 1:
|
20975 | H8[off + 1 - (om << 1) | 0] = buf[start + 2];
|
20976 | case 2:
|
20977 | H8[off + 2 - (om << 1) | 0] = buf[start + 1];
|
20978 | case 3:
|
20979 | H8[off + 3 - (om << 1) | 0] = buf[start];
|
20980 | }
|
20981 | if (len < lm + om) {
|
20982 | return;
|
20983 | }
|
20984 | for (i$2 = 4 - om; i$2 < j; i$2 = i$2 + 4 | 0) {
|
20985 | H32[off + i$2 >> 2 | 0] = buf[start + i$2] << 24 | buf[start + i$2 + 1] << 16 | buf[start + i$2 + 2] << 8 | buf[start + i$2 + 3];
|
20986 | }
|
20987 | switch (lm) {
|
20988 | case 3:
|
20989 | H8[off + j + 1 | 0] = buf[start + j + 2];
|
20990 | case 2:
|
20991 | H8[off + j + 2 | 0] = buf[start + j + 1];
|
20992 | case 1:
|
20993 | H8[off + j + 3 | 0] = buf[start + j];
|
20994 | }
|
20995 | };
|
20996 | var convBlob = function (H8, H32, start, len, off) {
|
20997 | var blob = this, i$2, om = off % 4, lm = (len + om) % 4, j = len - lm;
|
20998 | var buf = new Uint8Array(reader.readAsArrayBuffer(blob.slice(start, start + len)));
|
20999 | switch (om) {
|
21000 | case 0:
|
21001 | H8[off] = buf[3];
|
21002 | case 1:
|
21003 | H8[off + 1 - (om << 1) | 0] = buf[2];
|
21004 | case 2:
|
21005 | H8[off + 2 - (om << 1) | 0] = buf[1];
|
21006 | case 3:
|
21007 | H8[off + 3 - (om << 1) | 0] = buf[0];
|
21008 | }
|
21009 | if (len < lm + om) {
|
21010 | return;
|
21011 | }
|
21012 | for (i$2 = 4 - om; i$2 < j; i$2 = i$2 + 4 | 0) {
|
21013 | H32[off + i$2 >> 2 | 0] = buf[i$2] << 24 | buf[i$2 + 1] << 16 | buf[i$2 + 2] << 8 | buf[i$2 + 3];
|
21014 | }
|
21015 | switch (lm) {
|
21016 | case 3:
|
21017 | H8[off + j + 1 | 0] = buf[j + 2];
|
21018 | case 2:
|
21019 | H8[off + j + 2 | 0] = buf[j + 1];
|
21020 | case 1:
|
21021 | H8[off + j + 3 | 0] = buf[j];
|
21022 | }
|
21023 | };
|
21024 | var convFn = function (data) {
|
21025 | switch (util.getDataType(data)) {
|
21026 | case 'string':
|
21027 | return convStr.bind(data);
|
21028 | case 'array':
|
21029 | return convBuf.bind(data);
|
21030 | case 'buffer':
|
21031 | return convBuf.bind(data);
|
21032 | case 'arraybuffer':
|
21033 | return convBuf.bind(new Uint8Array(data));
|
21034 | case 'view':
|
21035 | return convBuf.bind(new Uint8Array(data.buffer, data.byteOffset, data.byteLength));
|
21036 | case 'blob':
|
21037 | return convBlob.bind(data);
|
21038 | }
|
21039 | };
|
21040 | var slice = function (data, offset) {
|
21041 | switch (util.getDataType(data)) {
|
21042 | case 'string':
|
21043 | return data.slice(offset);
|
21044 | case 'array':
|
21045 | return data.slice(offset);
|
21046 | case 'buffer':
|
21047 | return data.slice(offset);
|
21048 | case 'arraybuffer':
|
21049 | return data.slice(offset);
|
21050 | case 'view':
|
21051 | return data.buffer.slice(offset);
|
21052 | }
|
21053 | };
|
21054 | var // Precompute 00 - ff strings
|
21055 | precomputedHex = new Array(256);
|
21056 | for (var i = 0; i < 256; i++) {
|
21057 | precomputedHex[i] = (i < 16 ? '0' : '') + i.toString(16);
|
21058 | }
|
21059 | var // Convert an ArrayBuffer into its hexadecimal string representation.
|
21060 | hex = function (arrayBuffer) {
|
21061 | var binarray = new Uint8Array(arrayBuffer);
|
21062 | var res = new Array(arrayBuffer.byteLength);
|
21063 | for (var i$2 = 0; i$2 < res.length; i$2++) {
|
21064 | res[i$2] = precomputedHex[binarray[i$2]];
|
21065 | }
|
21066 | return res.join('');
|
21067 | };
|
21068 | var ceilHeapSize = function (v) {
|
21069 | // The asm.js spec says:
|
21070 | // The heap object's byteLength must be either
|
21071 | // 2^n for n in [12, 24) or 2^24 * n for n ≥ 1.
|
21072 | // Also, byteLengths smaller than 2^16 are deprecated.
|
21073 | var p;
|
21074 | if (// If v is smaller than 2^16, the smallest possible solution
|
21075 | // is 2^16.
|
21076 | v <= 65536)
|
21077 | return 65536;
|
21078 | if (// If v < 2^24, we round up to 2^n,
|
21079 | // otherwise we round up to 2^24 * n.
|
21080 | v < 16777216) {
|
21081 | for (p = 1; p < v; p = p << 1);
|
21082 | } else {
|
21083 | for (p = 16777216; p < v; p += 16777216);
|
21084 | }
|
21085 | return p;
|
21086 | };
|
21087 | var // Initialize the internal data structures to a new capacity.
|
21088 | init = function (size) {
|
21089 | if (size % 64 > 0) {
|
21090 | throw new Error('Chunk size must be a multiple of 128 bit');
|
21091 | }
|
21092 | self$2.offset = 0;
|
21093 | self$2.maxChunkLen = size;
|
21094 | self$2.padMaxChunkLen = padlen(size);
|
21095 | // The size of the heap is the sum of:
|
21096 | // 1. The padded input message size
|
21097 | // 2. The extended space the algorithm needs (320 byte)
|
21098 | // 3. The 160 bit state the algoritm uses
|
21099 | self$2.heap = new ArrayBuffer(ceilHeapSize(self$2.padMaxChunkLen + 320 + 20));
|
21100 | self$2.h32 = new Int32Array(self$2.heap);
|
21101 | self$2.h8 = new Int8Array(self$2.heap);
|
21102 | self$2.core = new Rusha._core({
|
21103 | Int32Array: Int32Array,
|
21104 | DataView: DataView
|
21105 | }, {}, self$2.heap);
|
21106 | self$2.buffer = null;
|
21107 | };
|
21108 | // Iinitializethe datastructures according
|
21109 | // to a chunk siyze.
|
21110 | init(chunkSize || 64 * 1024);
|
21111 | var initState = function (heap, padMsgLen) {
|
21112 | self$2.offset = 0;
|
21113 | var io = new Int32Array(heap, padMsgLen + 320, 5);
|
21114 | io[0] = 1732584193;
|
21115 | io[1] = -271733879;
|
21116 | io[2] = -1732584194;
|
21117 | io[3] = 271733878;
|
21118 | io[4] = -1009589776;
|
21119 | };
|
21120 | var padChunk = function (chunkLen, msgLen) {
|
21121 | var padChunkLen = padlen(chunkLen);
|
21122 | var view = new Int32Array(self$2.heap, 0, padChunkLen >> 2);
|
21123 | padZeroes(view, chunkLen);
|
21124 | padData(view, chunkLen, msgLen);
|
21125 | return padChunkLen;
|
21126 | };
|
21127 | var // Write data to the heap.
|
21128 | write = function (data, chunkOffset, chunkLen, off) {
|
21129 | convFn(data)(self$2.h8, self$2.h32, chunkOffset, chunkLen, off || 0);
|
21130 | };
|
21131 | var // Initialize and call the RushaCore,
|
21132 | // assuming an input buffer of length len * 4.
|
21133 | coreCall = function (data, chunkOffset, chunkLen, msgLen, finalize) {
|
21134 | var padChunkLen = chunkLen;
|
21135 | write(data, chunkOffset, chunkLen);
|
21136 | if (finalize) {
|
21137 | padChunkLen = padChunk(chunkLen, msgLen);
|
21138 | }
|
21139 | self$2.core.hash(padChunkLen, self$2.padMaxChunkLen);
|
21140 | };
|
21141 | var getRawDigest = function (heap, padMaxChunkLen) {
|
21142 | var io = new Int32Array(heap, padMaxChunkLen + 320, 5);
|
21143 | var out = new Int32Array(5);
|
21144 | var arr = new DataView(out.buffer);
|
21145 | arr.setInt32(0, io[0], false);
|
21146 | arr.setInt32(4, io[1], false);
|
21147 | arr.setInt32(8, io[2], false);
|
21148 | arr.setInt32(12, io[3], false);
|
21149 | arr.setInt32(16, io[4], false);
|
21150 | return out;
|
21151 | };
|
21152 | var // Calculate the hash digest as an array of 5 32bit integers.
|
21153 | rawDigest = this.rawDigest = function (str) {
|
21154 | var msgLen = str.byteLength || str.length || str.size || 0;
|
21155 | initState(self$2.heap, self$2.padMaxChunkLen);
|
21156 | var chunkOffset = 0, chunkLen = self$2.maxChunkLen, last;
|
21157 | for (chunkOffset = 0; msgLen > chunkOffset + chunkLen; chunkOffset += chunkLen) {
|
21158 | coreCall(str, chunkOffset, chunkLen, msgLen, false);
|
21159 | }
|
21160 | coreCall(str, chunkOffset, msgLen - chunkOffset, msgLen, true);
|
21161 | return getRawDigest(self$2.heap, self$2.padMaxChunkLen);
|
21162 | };
|
21163 | // The digest and digestFrom* interface returns the hash digest
|
21164 | // as a hex string.
|
21165 | this.digest = this.digestFromString = this.digestFromBuffer = this.digestFromArrayBuffer = function (str) {
|
21166 | return hex(rawDigest(str).buffer);
|
21167 | };
|
21168 | this.resetState = function () {
|
21169 | initState(self$2.heap, self$2.padMaxChunkLen);
|
21170 | return this;
|
21171 | };
|
21172 | this.append = function (chunk) {
|
21173 | var chunkOffset = 0;
|
21174 | var chunkLen = chunk.byteLength || chunk.length || chunk.size || 0;
|
21175 | var turnOffset = self$2.offset % self$2.maxChunkLen;
|
21176 | var inputLen;
|
21177 | self$2.offset += chunkLen;
|
21178 | while (chunkOffset < chunkLen) {
|
21179 | inputLen = Math.min(chunkLen - chunkOffset, self$2.maxChunkLen - turnOffset);
|
21180 | write(chunk, chunkOffset, inputLen, turnOffset);
|
21181 | turnOffset += inputLen;
|
21182 | chunkOffset += inputLen;
|
21183 | if (turnOffset === self$2.maxChunkLen) {
|
21184 | self$2.core.hash(self$2.maxChunkLen, self$2.padMaxChunkLen);
|
21185 | turnOffset = 0;
|
21186 | }
|
21187 | }
|
21188 | return this;
|
21189 | };
|
21190 | this.getState = function () {
|
21191 | var turnOffset = self$2.offset % self$2.maxChunkLen;
|
21192 | var heap;
|
21193 | if (!turnOffset) {
|
21194 | var io = new Int32Array(self$2.heap, self$2.padMaxChunkLen + 320, 5);
|
21195 | heap = io.buffer.slice(io.byteOffset, io.byteOffset + io.byteLength);
|
21196 | } else {
|
21197 | heap = self$2.heap.slice(0);
|
21198 | }
|
21199 | return {
|
21200 | offset: self$2.offset,
|
21201 | heap: heap
|
21202 | };
|
21203 | };
|
21204 | this.setState = function (state) {
|
21205 | self$2.offset = state.offset;
|
21206 | if (state.heap.byteLength === 20) {
|
21207 | var io = new Int32Array(self$2.heap, self$2.padMaxChunkLen + 320, 5);
|
21208 | io.set(new Int32Array(state.heap));
|
21209 | } else {
|
21210 | self$2.h32.set(new Int32Array(state.heap));
|
21211 | }
|
21212 | return this;
|
21213 | };
|
21214 | var rawEnd = this.rawEnd = function () {
|
21215 | var msgLen = self$2.offset;
|
21216 | var chunkLen = msgLen % self$2.maxChunkLen;
|
21217 | var padChunkLen = padChunk(chunkLen, msgLen);
|
21218 | self$2.core.hash(padChunkLen, self$2.padMaxChunkLen);
|
21219 | var result = getRawDigest(self$2.heap, self$2.padMaxChunkLen);
|
21220 | initState(self$2.heap, self$2.padMaxChunkLen);
|
21221 | return result;
|
21222 | };
|
21223 | this.end = function () {
|
21224 | return hex(rawEnd().buffer);
|
21225 | };
|
21226 | }
|
21227 | ;
|
21228 | // The low-level RushCore module provides the heart of Rusha,
|
21229 | // a high-speed sha1 implementation working on an Int32Array heap.
|
21230 | // At first glance, the implementation seems complicated, however
|
21231 | // with the SHA1 spec at hand, it is obvious this almost a textbook
|
21232 | // implementation that has a few functions hand-inlined and a few loops
|
21233 | // hand-unrolled.
|
21234 | Rusha._core = function RushaCore(stdlib, foreign, heap) {
|
21235 | 'use asm';
|
21236 | var H = new stdlib.Int32Array(heap);
|
21237 | function hash(k, x) {
|
21238 | // k in bytes
|
21239 | k = k | 0;
|
21240 | x = x | 0;
|
21241 | var i = 0, j = 0, y0 = 0, z0 = 0, y1 = 0, z1 = 0, y2 = 0, z2 = 0, y3 = 0, z3 = 0, y4 = 0, z4 = 0, t0 = 0, t1 = 0;
|
21242 | y0 = H[x + 320 >> 2] | 0;
|
21243 | y1 = H[x + 324 >> 2] | 0;
|
21244 | y2 = H[x + 328 >> 2] | 0;
|
21245 | y3 = H[x + 332 >> 2] | 0;
|
21246 | y4 = H[x + 336 >> 2] | 0;
|
21247 | for (i = 0; (i | 0) < (k | 0); i = i + 64 | 0) {
|
21248 | z0 = y0;
|
21249 | z1 = y1;
|
21250 | z2 = y2;
|
21251 | z3 = y3;
|
21252 | z4 = y4;
|
21253 | for (j = 0; (j | 0) < 64; j = j + 4 | 0) {
|
21254 | t1 = H[i + j >> 2] | 0;
|
21255 | t0 = ((y0 << 5 | y0 >>> 27) + (y1 & y2 | ~y1 & y3) | 0) + ((t1 + y4 | 0) + 1518500249 | 0) | 0;
|
21256 | y4 = y3;
|
21257 | y3 = y2;
|
21258 | y2 = y1 << 30 | y1 >>> 2;
|
21259 | y1 = y0;
|
21260 | y0 = t0;
|
21261 | H[k + j >> 2] = t1;
|
21262 | }
|
21263 | for (j = k + 64 | 0; (j | 0) < (k + 80 | 0); j = j + 4 | 0) {
|
21264 | t1 = (H[j - 12 >> 2] ^ H[j - 32 >> 2] ^ H[j - 56 >> 2] ^ H[j - 64 >> 2]) << 1 | (H[j - 12 >> 2] ^ H[j - 32 >> 2] ^ H[j - 56 >> 2] ^ H[j - 64 >> 2]) >>> 31;
|
21265 | t0 = ((y0 << 5 | y0 >>> 27) + (y1 & y2 | ~y1 & y3) | 0) + ((t1 + y4 | 0) + 1518500249 | 0) | 0;
|
21266 | y4 = y3;
|
21267 | y3 = y2;
|
21268 | y2 = y1 << 30 | y1 >>> 2;
|
21269 | y1 = y0;
|
21270 | y0 = t0;
|
21271 | H[j >> 2] = t1;
|
21272 | }
|
21273 | for (j = k + 80 | 0; (j | 0) < (k + 160 | 0); j = j + 4 | 0) {
|
21274 | t1 = (H[j - 12 >> 2] ^ H[j - 32 >> 2] ^ H[j - 56 >> 2] ^ H[j - 64 >> 2]) << 1 | (H[j - 12 >> 2] ^ H[j - 32 >> 2] ^ H[j - 56 >> 2] ^ H[j - 64 >> 2]) >>> 31;
|
21275 | t0 = ((y0 << 5 | y0 >>> 27) + (y1 ^ y2 ^ y3) | 0) + ((t1 + y4 | 0) + 1859775393 | 0) | 0;
|
21276 | y4 = y3;
|
21277 | y3 = y2;
|
21278 | y2 = y1 << 30 | y1 >>> 2;
|
21279 | y1 = y0;
|
21280 | y0 = t0;
|
21281 | H[j >> 2] = t1;
|
21282 | }
|
21283 | for (j = k + 160 | 0; (j | 0) < (k + 240 | 0); j = j + 4 | 0) {
|
21284 | t1 = (H[j - 12 >> 2] ^ H[j - 32 >> 2] ^ H[j - 56 >> 2] ^ H[j - 64 >> 2]) << 1 | (H[j - 12 >> 2] ^ H[j - 32 >> 2] ^ H[j - 56 >> 2] ^ H[j - 64 >> 2]) >>> 31;
|
21285 | t0 = ((y0 << 5 | y0 >>> 27) + (y1 & y2 | y1 & y3 | y2 & y3) | 0) + ((t1 + y4 | 0) - 1894007588 | 0) | 0;
|
21286 | y4 = y3;
|
21287 | y3 = y2;
|
21288 | y2 = y1 << 30 | y1 >>> 2;
|
21289 | y1 = y0;
|
21290 | y0 = t0;
|
21291 | H[j >> 2] = t1;
|
21292 | }
|
21293 | for (j = k + 240 | 0; (j | 0) < (k + 320 | 0); j = j + 4 | 0) {
|
21294 | t1 = (H[j - 12 >> 2] ^ H[j - 32 >> 2] ^ H[j - 56 >> 2] ^ H[j - 64 >> 2]) << 1 | (H[j - 12 >> 2] ^ H[j - 32 >> 2] ^ H[j - 56 >> 2] ^ H[j - 64 >> 2]) >>> 31;
|
21295 | t0 = ((y0 << 5 | y0 >>> 27) + (y1 ^ y2 ^ y3) | 0) + ((t1 + y4 | 0) - 899497514 | 0) | 0;
|
21296 | y4 = y3;
|
21297 | y3 = y2;
|
21298 | y2 = y1 << 30 | y1 >>> 2;
|
21299 | y1 = y0;
|
21300 | y0 = t0;
|
21301 | H[j >> 2] = t1;
|
21302 | }
|
21303 | y0 = y0 + z0 | 0;
|
21304 | y1 = y1 + z1 | 0;
|
21305 | y2 = y2 + z2 | 0;
|
21306 | y3 = y3 + z3 | 0;
|
21307 | y4 = y4 + z4 | 0;
|
21308 | }
|
21309 | H[x + 320 >> 2] = y0;
|
21310 | H[x + 324 >> 2] = y1;
|
21311 | H[x + 328 >> 2] = y2;
|
21312 | H[x + 332 >> 2] = y3;
|
21313 | H[x + 336 >> 2] = y4;
|
21314 | }
|
21315 | return { hash: hash };
|
21316 | };
|
21317 | if (// If we'e running in Node.JS, export a module.
|
21318 | true) {
|
21319 | module.exports = Rusha;
|
21320 | } else if (// If we're running in a DOM context, export
|
21321 | // the Rusha object to toplevel.
|
21322 | typeof window !== 'undefined') {
|
21323 | window.Rusha = Rusha;
|
21324 | }
|
21325 | if (// If we're running in a webworker, accept
|
21326 | // messages containing a jobid and a buffer
|
21327 | // or blob object, and return the hash result.
|
21328 | typeof FileReaderSync !== 'undefined') {
|
21329 | var reader = new FileReaderSync(), hasher = new Rusha(4 * 1024 * 1024);
|
21330 | self.onmessage = function onMessage(event) {
|
21331 | var hash, data = event.data.data;
|
21332 | try {
|
21333 | hash = hasher.digest(data);
|
21334 | self.postMessage({
|
21335 | id: event.data.id,
|
21336 | hash: hash
|
21337 | });
|
21338 | } catch (e) {
|
21339 | self.postMessage({
|
21340 | id: event.data.id,
|
21341 | error: e.name
|
21342 | });
|
21343 | }
|
21344 | };
|
21345 | }
|
21346 | }());
|
21347 | /* WEBPACK VAR INJECTION */}.call(exports, __webpack_require__(335)))
|
21348 |
|
21349 | /***/ }),
|
21350 | /* 335 */
|
21351 | /***/ (function(module, exports) {
|
21352 |
|
21353 | var g;
|
21354 |
|
21355 | // This works in non-strict mode
|
21356 | g = (function() {
|
21357 | return this;
|
21358 | })();
|
21359 |
|
21360 | try {
|
21361 | // This works if eval is allowed (see CSP)
|
21362 | g = g || Function("return this")() || (1,eval)("this");
|
21363 | } catch(e) {
|
21364 | // This works if the window reference is available
|
21365 | if(typeof window === "object")
|
21366 | g = window;
|
21367 | }
|
21368 |
|
21369 | // g can still be undefined, but nothing to do about it...
|
21370 | // We return undefined, instead of nothing here, so it's
|
21371 | // easier to handle this case. if(!global) { ...}
|
21372 |
|
21373 | module.exports = g;
|
21374 |
|
21375 |
|
21376 | /***/ }),
|
21377 | /* 336 */
|
21378 | /***/ (function(module, __webpack_exports__, __webpack_require__) {
|
21379 |
|
21380 | "use strict";
|
21381 | Object.defineProperty(__webpack_exports__, "__esModule", { value: true });
|
21382 | /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__bin__ = __webpack_require__(117);
|
21383 |
|
21384 |
|
21385 | console.info('Crypto worker registered');
|
21386 |
|
21387 | const runTask = data => {
|
21388 | switch (data.task) {
|
21389 | case 'factorize':
|
21390 | return __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__bin__["a" /* pqPrimeFactorization */])(data.bytes);
|
21391 | case 'mod-pow':
|
21392 | return __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__bin__["b" /* bytesModPow */])(data.x, data.y, data.m);
|
21393 | case 'sha1-hash':
|
21394 | return __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__bin__["c" /* sha1HashSync */])(data.bytes);
|
21395 | case 'aes-encrypt':
|
21396 | return __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__bin__["d" /* aesEncryptSync */])(data.bytes, data.keyBytes, data.ivBytes);
|
21397 | case 'aes-decrypt':
|
21398 | return __webpack_require__.i(__WEBPACK_IMPORTED_MODULE_0__bin__["e" /* aesDecryptSync */])(data.encryptedBytes, data.keyBytes, data.ivBytes);
|
21399 | default:
|
21400 | throw new Error(`Unknown task: ${data.task}`);
|
21401 | }
|
21402 | };
|
21403 |
|
21404 | onmessage = function (e) {
|
21405 | if (e.data === '') {
|
21406 | console.info('empty crypto task');
|
21407 | } else if (typeof e.data === 'string') {
|
21408 | console.info('crypto task string message', e.data);
|
21409 | } else {
|
21410 | const taskID = e.data.taskID;
|
21411 | const result = runTask(e.data);
|
21412 | postMessage({ taskID, result });
|
21413 | }
|
21414 | };
|
21415 |
|
21416 | postMessage('ready');
|
21417 |
|
21418 | /***/ })
|
21419 | /******/ ]);
|
21420 | //# sourceMappingURL=hash.worker.js.map |
\ | No newline at end of file |