@mtes-mct/monitor-ui 7.5.0 → 7.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -284,12 +284,14 @@ const THEME = {
284
284
  opal: '#A5BCC0',
285
285
  // Regulation Areas
286
286
  yaleBlue: '#295375',
287
+ queenBlue: '#367096',
287
288
  glaucous: '#6284A6',
288
289
  blueNcs: '#3690C0',
289
290
  iceberg: '#67A9CF',
290
291
  lightSteelBlue: '#9AB4D6',
291
292
  lightPeriwinkle: '#CDCFEA',
292
293
  aliceBlue: '#EBF0F4',
294
+ lightBlue: '#B9DDE5',
293
295
  lightCyan: '#C7EAE5',
294
296
  middleBlueGreen: '#91CFC9',
295
297
  verdigris: '#56B3AB',
@@ -298,7 +300,23 @@ const THEME = {
298
300
  skobeloff: '#01686B',
299
301
  blueSapphire: '#01536A',
300
302
  indigoDye: '#033E54',
301
- lightCoral: '#FA8282'
303
+ skyBlue: '#77C1DE',
304
+ frenchBlue: '#2E75AB',
305
+ prussianBlue: '#003E54',
306
+ lightCoral: '#FA8282',
307
+ // AMP Zones
308
+ brownSugar: '#B26A53',
309
+ rust: '#B1502F',
310
+ burntSienna: '#D46E49',
311
+ persianOrange: '#D6814F',
312
+ jasper: '#DB503D',
313
+ bittersweet: '#F0755C',
314
+ coral: '#F78A69',
315
+ peach: '#FCB394',
316
+ apricot: '#F0C1A1',
317
+ melon: '#E7A58D',
318
+ paleDogwood: '#F8D7CE',
319
+ seashell: '#FCECE4'
302
320
  }
303
321
  };
304
322
 
@@ -640,224 +658,56 @@ var _xfBase = {
640
658
  }
641
659
  };
642
660
 
643
- function _map(fn, functor) {
644
- var idx = 0;
645
- var len = functor.length;
646
- var result = Array(len);
647
-
648
- while (idx < len) {
649
- result[idx] = fn(functor[idx]);
650
- idx += 1;
651
- }
652
-
653
- return result;
654
- }
655
-
656
- function _isString(x) {
657
- return Object.prototype.toString.call(x) === '[object String]';
658
- }
659
-
660
- /**
661
- * Tests whether or not an object is similar to an array.
662
- *
663
- * @private
664
- * @category Type
665
- * @category List
666
- * @sig * -> Boolean
667
- * @param {*} x The object to test.
668
- * @return {Boolean} `true` if `x` has a numeric length property and extreme indices defined; `false` otherwise.
669
- * @example
670
- *
671
- * _isArrayLike([]); //=> true
672
- * _isArrayLike(true); //=> false
673
- * _isArrayLike({}); //=> false
674
- * _isArrayLike({length: 10}); //=> false
675
- * _isArrayLike({0: 'zero', 9: 'nine', length: 10}); //=> true
676
- * _isArrayLike({nodeType: 1, length: 1}) // => false
677
- */
678
-
679
- var _isArrayLike =
680
- /*#__PURE__*/
681
- _curry1(function isArrayLike(x) {
682
- if (_isArray(x)) {
683
- return true;
684
- }
685
-
686
- if (!x) {
687
- return false;
688
- }
689
-
690
- if (typeof x !== 'object') {
691
- return false;
692
- }
693
-
694
- if (_isString(x)) {
695
- return false;
696
- }
697
-
698
- if (x.length === 0) {
699
- return true;
700
- }
701
-
702
- if (x.length > 0) {
703
- return x.hasOwnProperty(0) && x.hasOwnProperty(x.length - 1);
704
- }
705
-
706
- return false;
707
- });
661
+ function _arrayFromIterator(iter) {
662
+ var list = [];
663
+ var next;
708
664
 
709
- var XWrap =
710
- /*#__PURE__*/
711
- function () {
712
- function XWrap(fn) {
713
- this.f = fn;
665
+ while (!(next = iter.next()).done) {
666
+ list.push(next.value);
714
667
  }
715
668
 
716
- XWrap.prototype['@@transducer/init'] = function () {
717
- throw new Error('init not implemented on XWrap');
718
- };
719
-
720
- XWrap.prototype['@@transducer/result'] = function (acc) {
721
- return acc;
722
- };
723
-
724
- XWrap.prototype['@@transducer/step'] = function (acc, x) {
725
- return this.f(acc, x);
726
- };
727
-
728
- return XWrap;
729
- }();
730
-
731
- function _xwrap(fn) {
732
- return new XWrap(fn);
669
+ return list;
733
670
  }
734
671
 
735
- /**
736
- * Creates a function that is bound to a context.
737
- * Note: `R.bind` does not provide the additional argument-binding capabilities of
738
- * [Function.prototype.bind](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind).
739
- *
740
- * @func
741
- * @memberOf R
742
- * @since v0.6.0
743
- * @category Function
744
- * @category Object
745
- * @sig (* -> *) -> {*} -> (* -> *)
746
- * @param {Function} fn The function to bind to context
747
- * @param {Object} thisObj The context to bind `fn` to
748
- * @return {Function} A function that will execute in the context of `thisObj`.
749
- * @see R.partial
750
- * @example
751
- *
752
- * const log = R.bind(console.log, console);
753
- * R.pipe(R.assoc('a', 2), R.tap(log), R.assoc('a', 3))({a: 1}); //=> {a: 3}
754
- * // logs {a: 2}
755
- * @symb R.bind(f, o)(a, b) = f.call(o, a, b)
756
- */
757
-
758
- var bind =
759
- /*#__PURE__*/
760
- _curry2(function bind(fn, thisObj) {
761
- return _arity(fn.length, function () {
762
- return fn.apply(thisObj, arguments);
763
- });
764
- });
765
-
766
- function _arrayReduce(xf, acc, list) {
672
+ function _includesWith(pred, x, list) {
767
673
  var idx = 0;
768
674
  var len = list.length;
769
675
 
770
676
  while (idx < len) {
771
- acc = xf['@@transducer/step'](acc, list[idx]);
772
-
773
- if (acc && acc['@@transducer/reduced']) {
774
- acc = acc['@@transducer/value'];
775
- break;
677
+ if (pred(x, list[idx])) {
678
+ return true;
776
679
  }
777
680
 
778
681
  idx += 1;
779
682
  }
780
683
 
781
- return xf['@@transducer/result'](acc);
684
+ return false;
782
685
  }
783
686
 
784
- function _iterableReduce(xf, acc, iter) {
785
- var step = iter.next();
786
-
787
- while (!step.done) {
788
- acc = xf['@@transducer/step'](acc, step.value);
789
-
790
- if (acc && acc['@@transducer/reduced']) {
791
- acc = acc['@@transducer/value'];
792
- break;
793
- }
794
-
795
- step = iter.next();
796
- }
797
-
798
- return xf['@@transducer/result'](acc);
687
+ function _functionName(f) {
688
+ // String(x => x) evaluates to "x => x", so the pattern may not match.
689
+ var match = String(f).match(/^function (\w*)/);
690
+ return match == null ? '' : match[1];
799
691
  }
800
692
 
801
- function _methodReduce(xf, acc, obj, methodName) {
802
- return xf['@@transducer/result'](obj[methodName](bind(xf['@@transducer/step'], xf), acc));
693
+ function _has(prop, obj) {
694
+ return Object.prototype.hasOwnProperty.call(obj, prop);
803
695
  }
804
696
 
805
- var symIterator = typeof Symbol !== 'undefined' ? Symbol.iterator : '@@iterator';
806
- function _reduce(fn, acc, list) {
807
- if (typeof fn === 'function') {
808
- fn = _xwrap(fn);
809
- }
810
-
811
- if (_isArrayLike(list)) {
812
- return _arrayReduce(fn, acc, list);
813
- }
814
-
815
- if (typeof list['fantasy-land/reduce'] === 'function') {
816
- return _methodReduce(fn, acc, list, 'fantasy-land/reduce');
817
- }
818
-
819
- if (list[symIterator] != null) {
820
- return _iterableReduce(fn, acc, list[symIterator]());
821
- }
822
-
823
- if (typeof list.next === 'function') {
824
- return _iterableReduce(fn, acc, list);
825
- }
826
-
827
- if (typeof list.reduce === 'function') {
828
- return _methodReduce(fn, acc, list, 'reduce');
697
+ // Based on https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
698
+ function _objectIs(a, b) {
699
+ // SameValue algorithm
700
+ if (a === b) {
701
+ // Steps 1-5, 7-10
702
+ // Steps 6.b-6.e: +0 != -0
703
+ return a !== 0 || 1 / a === 1 / b;
704
+ } else {
705
+ // Step 6.a: NaN == NaN
706
+ return a !== a && b !== b;
829
707
  }
830
-
831
- throw new TypeError('reduce: list must be array or iterable');
832
708
  }
833
709
 
834
- var XMap =
835
- /*#__PURE__*/
836
- function () {
837
- function XMap(f, xf) {
838
- this.xf = xf;
839
- this.f = f;
840
- }
841
-
842
- XMap.prototype['@@transducer/init'] = _xfBase.init;
843
- XMap.prototype['@@transducer/result'] = _xfBase.result;
844
-
845
- XMap.prototype['@@transducer/step'] = function (result, input) {
846
- return this.xf['@@transducer/step'](result, this.f(input));
847
- };
848
-
849
- return XMap;
850
- }();
851
-
852
- var _xmap =
853
- /*#__PURE__*/
854
- _curry2(function _xmap(f, xf) {
855
- return new XMap(f, xf);
856
- });
857
-
858
- function _has(prop, obj) {
859
- return Object.prototype.hasOwnProperty.call(obj, prop);
860
- }
710
+ var _objectIs$1 = typeof Object.is === 'function' ? Object.is : _objectIs;
861
711
 
862
712
  var toString$1 = Object.prototype.toString;
863
713
 
@@ -958,830 +808,1025 @@ _curry1(function keys(obj) {
958
808
  });
959
809
 
960
810
  /**
961
- * Takes a function and
962
- * a [functor](https://github.com/fantasyland/fantasy-land#functor),
963
- * applies the function to each of the functor's values, and returns
964
- * a functor of the same shape.
965
- *
966
- * Ramda provides suitable `map` implementations for `Array` and `Object`,
967
- * so this function may be applied to `[1, 2, 3]` or `{x: 1, y: 2, z: 3}`.
968
- *
969
- * Dispatches to the `map` method of the second argument, if present.
970
- *
971
- * Acts as a transducer if a transformer is given in list position.
972
- *
973
- * Also treats functions as functors and will compose them together.
811
+ * Gives a single-word string description of the (native) type of a value,
812
+ * returning such answers as 'Object', 'Number', 'Array', or 'Null'. Does not
813
+ * attempt to distinguish user Object types any further, reporting them all as
814
+ * 'Object'.
974
815
  *
975
816
  * @func
976
817
  * @memberOf R
977
- * @since v0.1.0
978
- * @category List
979
- * @sig Functor f => (a -> b) -> f a -> f b
980
- * @param {Function} fn The function to be called on every element of the input `list`.
981
- * @param {Array} list The list to be iterated over.
982
- * @return {Array} The new list.
983
- * @see R.transduce, R.addIndex, R.pluck, R.project
818
+ * @since v0.8.0
819
+ * @category Type
820
+ * @sig * -> String
821
+ * @param {*} val The value to test
822
+ * @return {String}
984
823
  * @example
985
824
  *
986
- * const double = x => x * 2;
987
- *
988
- * R.map(double, [1, 2, 3]); //=> [2, 4, 6]
989
- *
990
- * R.map(double, {x: 1, y: 2, z: 3}); //=> {x: 2, y: 4, z: 6}
991
- * @symb R.map(f, [a, b]) = [f(a), f(b)]
992
- * @symb R.map(f, { x: a, y: b }) = { x: f(a), y: f(b) }
993
- * @symb R.map(f, functor_o) = functor_o.map(f)
825
+ * R.type({}); //=> "Object"
826
+ * R.type(1); //=> "Number"
827
+ * R.type(false); //=> "Boolean"
828
+ * R.type('s'); //=> "String"
829
+ * R.type(null); //=> "Null"
830
+ * R.type([]); //=> "Array"
831
+ * R.type(/[A-z]/); //=> "RegExp"
832
+ * R.type(() => {}); //=> "Function"
833
+ * R.type(undefined); //=> "Undefined"
994
834
  */
995
835
 
996
- var map =
997
- /*#__PURE__*/
998
- _curry2(
836
+ var type =
999
837
  /*#__PURE__*/
1000
- _dispatchable(['fantasy-land/map', 'map'], _xmap, function map(fn, functor) {
1001
- switch (Object.prototype.toString.call(functor)) {
1002
- case '[object Function]':
1003
- return curryN(functor.length, function () {
1004
- return fn.call(this, functor.apply(this, arguments));
1005
- });
838
+ _curry1(function type(val) {
839
+ return val === null ? 'Null' : val === undefined ? 'Undefined' : Object.prototype.toString.call(val).slice(8, -1);
840
+ });
1006
841
 
1007
- case '[object Object]':
1008
- return _reduce(function (acc, key) {
1009
- acc[key] = fn(functor[key]);
1010
- return acc;
1011
- }, {}, keys(functor));
842
+ /**
843
+ * private _uniqContentEquals function.
844
+ * That function is checking equality of 2 iterator contents with 2 assumptions
845
+ * - iterators lengths are the same
846
+ * - iterators values are unique
847
+ *
848
+ * false-positive result will be returned for comparison of, e.g.
849
+ * - [1,2,3] and [1,2,3,4]
850
+ * - [1,1,1] and [1,2,3]
851
+ * */
852
+
853
+ function _uniqContentEquals(aIterator, bIterator, stackA, stackB) {
854
+ var a = _arrayFromIterator(aIterator);
855
+
856
+ var b = _arrayFromIterator(bIterator);
857
+
858
+ function eq(_a, _b) {
859
+ return _equals(_a, _b, stackA.slice(), stackB.slice());
860
+ } // if *a* array contains any element that is not included in *b*
861
+
862
+
863
+ return !_includesWith(function (b, aItem) {
864
+ return !_includesWith(eq, aItem, b);
865
+ }, b, a);
866
+ }
867
+
868
+ function _equals(a, b, stackA, stackB) {
869
+ if (_objectIs$1(a, b)) {
870
+ return true;
871
+ }
872
+
873
+ var typeA = type(a);
874
+
875
+ if (typeA !== type(b)) {
876
+ return false;
877
+ }
878
+
879
+ if (typeof a['fantasy-land/equals'] === 'function' || typeof b['fantasy-land/equals'] === 'function') {
880
+ return typeof a['fantasy-land/equals'] === 'function' && a['fantasy-land/equals'](b) && typeof b['fantasy-land/equals'] === 'function' && b['fantasy-land/equals'](a);
881
+ }
882
+
883
+ if (typeof a.equals === 'function' || typeof b.equals === 'function') {
884
+ return typeof a.equals === 'function' && a.equals(b) && typeof b.equals === 'function' && b.equals(a);
885
+ }
886
+
887
+ switch (typeA) {
888
+ case 'Arguments':
889
+ case 'Array':
890
+ case 'Object':
891
+ if (typeof a.constructor === 'function' && _functionName(a.constructor) === 'Promise') {
892
+ return a === b;
893
+ }
894
+
895
+ break;
896
+
897
+ case 'Boolean':
898
+ case 'Number':
899
+ case 'String':
900
+ if (!(typeof a === typeof b && _objectIs$1(a.valueOf(), b.valueOf()))) {
901
+ return false;
902
+ }
903
+
904
+ break;
905
+
906
+ case 'Date':
907
+ if (!_objectIs$1(a.valueOf(), b.valueOf())) {
908
+ return false;
909
+ }
910
+
911
+ break;
912
+
913
+ case 'Error':
914
+ return a.name === b.name && a.message === b.message;
915
+
916
+ case 'RegExp':
917
+ if (!(a.source === b.source && a.global === b.global && a.ignoreCase === b.ignoreCase && a.multiline === b.multiline && a.sticky === b.sticky && a.unicode === b.unicode)) {
918
+ return false;
919
+ }
920
+
921
+ break;
922
+ }
923
+
924
+ var idx = stackA.length - 1;
925
+
926
+ while (idx >= 0) {
927
+ if (stackA[idx] === a) {
928
+ return stackB[idx] === b;
929
+ }
930
+
931
+ idx -= 1;
932
+ }
933
+
934
+ switch (typeA) {
935
+ case 'Map':
936
+ if (a.size !== b.size) {
937
+ return false;
938
+ }
939
+
940
+ return _uniqContentEquals(a.entries(), b.entries(), stackA.concat([a]), stackB.concat([b]));
941
+
942
+ case 'Set':
943
+ if (a.size !== b.size) {
944
+ return false;
945
+ }
946
+
947
+ return _uniqContentEquals(a.values(), b.values(), stackA.concat([a]), stackB.concat([b]));
948
+
949
+ case 'Arguments':
950
+ case 'Array':
951
+ case 'Object':
952
+ case 'Boolean':
953
+ case 'Number':
954
+ case 'String':
955
+ case 'Date':
956
+ case 'Error':
957
+ case 'RegExp':
958
+ case 'Int8Array':
959
+ case 'Uint8Array':
960
+ case 'Uint8ClampedArray':
961
+ case 'Int16Array':
962
+ case 'Uint16Array':
963
+ case 'Int32Array':
964
+ case 'Uint32Array':
965
+ case 'Float32Array':
966
+ case 'Float64Array':
967
+ case 'ArrayBuffer':
968
+ break;
1012
969
 
1013
970
  default:
1014
- return _map(fn, functor);
971
+ // Values of other types are only equal if identical.
972
+ return false;
1015
973
  }
1016
- }));
1017
974
 
1018
- var map$1 = map;
975
+ var keysA = keys(a);
976
+
977
+ if (keysA.length !== keys(b).length) {
978
+ return false;
979
+ }
980
+
981
+ var extendedStackA = stackA.concat([a]);
982
+ var extendedStackB = stackB.concat([b]);
983
+ idx = keysA.length - 1;
984
+
985
+ while (idx >= 0) {
986
+ var key = keysA[idx];
987
+
988
+ if (!(_has(key, b) && _equals(b[key], a[key], extendedStackA, extendedStackB))) {
989
+ return false;
990
+ }
991
+
992
+ idx -= 1;
993
+ }
994
+
995
+ return true;
996
+ }
1019
997
 
1020
998
  /**
1021
- * Returns a single item by iterating through the list, successively calling
1022
- * the iterator function and passing it an accumulator value and the current
1023
- * value from the array, and then passing the result to the next call.
1024
- *
1025
- * The iterator function receives two values: *(acc, value)*. It may use
1026
- * [`R.reduced`](#reduced) to shortcut the iteration.
1027
- *
1028
- * The arguments' order of [`reduceRight`](#reduceRight)'s iterator function
1029
- * is *(value, acc)*.
1030
- *
1031
- * Note: `R.reduce` does not skip deleted or unassigned indices (sparse
1032
- * arrays), unlike the native `Array.prototype.reduce` method. For more details
1033
- * on this behavior, see:
1034
- * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce#Description
999
+ * Returns `true` if its arguments are equivalent, `false` otherwise. Handles
1000
+ * cyclical data structures.
1035
1001
  *
1036
- * Dispatches to the `reduce` method of the third argument, if present. When
1037
- * doing so, it is up to the user to handle the [`R.reduced`](#reduced)
1038
- * shortcuting, as this is not implemented by `reduce`.
1002
+ * Dispatches symmetrically to the `equals` methods of both arguments, if
1003
+ * present.
1039
1004
  *
1040
1005
  * @func
1041
1006
  * @memberOf R
1042
- * @since v0.1.0
1043
- * @category List
1044
- * @sig ((a, b) -> a) -> a -> [b] -> a
1045
- * @param {Function} fn The iterator function. Receives two values, the accumulator and the
1046
- * current element from the array.
1047
- * @param {*} acc The accumulator value.
1048
- * @param {Array} list The list to iterate over.
1049
- * @return {*} The final, accumulated value.
1050
- * @see R.reduced, R.addIndex, R.reduceRight
1007
+ * @since v0.15.0
1008
+ * @category Relation
1009
+ * @sig a -> b -> Boolean
1010
+ * @param {*} a
1011
+ * @param {*} b
1012
+ * @return {Boolean}
1051
1013
  * @example
1052
1014
  *
1053
- * R.reduce(R.subtract, 0, [1, 2, 3, 4]) // => ((((0 - 1) - 2) - 3) - 4) = -10
1054
- * // - -10
1055
- * // / \ / \
1056
- * // - 4 -6 4
1057
- * // / \ / \
1058
- * // - 3 ==> -3 3
1059
- * // / \ / \
1060
- * // - 2 -1 2
1061
- * // / \ / \
1062
- * // 0 1 0 1
1015
+ * R.equals(1, 1); //=> true
1016
+ * R.equals(1, '1'); //=> false
1017
+ * R.equals([1, 2, 3], [1, 2, 3]); //=> true
1063
1018
  *
1064
- * @symb R.reduce(f, a, [b, c, d]) = f(f(f(a, b), c), d)
1019
+ * const a = {}; a.v = a;
1020
+ * const b = {}; b.v = b;
1021
+ * R.equals(a, b); //=> true
1065
1022
  */
1066
1023
 
1067
- var reduce =
1068
- /*#__PURE__*/
1069
- _curry3(_reduce);
1024
+ var equals =
1025
+ /*#__PURE__*/
1026
+ _curry2(function equals(a, b) {
1027
+ return _equals(a, b, [], []);
1028
+ });
1029
+
1030
+ var equals$1 = equals;
1031
+
1032
+ function _indexOf(list, a, idx) {
1033
+ var inf, item; // Array.prototype.indexOf doesn't exist below IE9
1034
+
1035
+ if (typeof list.indexOf === 'function') {
1036
+ switch (typeof a) {
1037
+ case 'number':
1038
+ if (a === 0) {
1039
+ // manually crawl the list to distinguish between +0 and -0
1040
+ inf = 1 / a;
1041
+
1042
+ while (idx < list.length) {
1043
+ item = list[idx];
1044
+
1045
+ if (item === 0 && 1 / item === inf) {
1046
+ return idx;
1047
+ }
1048
+
1049
+ idx += 1;
1050
+ }
1051
+
1052
+ return -1;
1053
+ } else if (a !== a) {
1054
+ // NaN
1055
+ while (idx < list.length) {
1056
+ item = list[idx];
1057
+
1058
+ if (typeof item === 'number' && item !== item) {
1059
+ return idx;
1060
+ }
1061
+
1062
+ idx += 1;
1063
+ }
1064
+
1065
+ return -1;
1066
+ } // non-zero numbers can utilise Set
1067
+
1068
+
1069
+ return list.indexOf(a, idx);
1070
+ // all these types can utilise Set
1071
+
1072
+ case 'string':
1073
+ case 'boolean':
1074
+ case 'function':
1075
+ case 'undefined':
1076
+ return list.indexOf(a, idx);
1077
+
1078
+ case 'object':
1079
+ if (a === null) {
1080
+ // null can utilise Set
1081
+ return list.indexOf(a, idx);
1082
+ }
1083
+
1084
+ }
1085
+ } // anything else not covered above, defer to R.equals
1070
1086
 
1071
- var reduce$1 = reduce;
1072
1087
 
1073
- var XAny =
1074
- /*#__PURE__*/
1075
- function () {
1076
- function XAny(f, xf) {
1077
- this.xf = xf;
1078
- this.f = f;
1079
- this.any = false;
1088
+ while (idx < list.length) {
1089
+ if (equals$1(list[idx], a)) {
1090
+ return idx;
1091
+ }
1092
+
1093
+ idx += 1;
1080
1094
  }
1081
1095
 
1082
- XAny.prototype['@@transducer/init'] = _xfBase.init;
1096
+ return -1;
1097
+ }
1083
1098
 
1084
- XAny.prototype['@@transducer/result'] = function (result) {
1085
- if (!this.any) {
1086
- result = this.xf['@@transducer/step'](result, false);
1087
- }
1099
+ function _includes(a, list) {
1100
+ return _indexOf(list, a, 0) >= 0;
1101
+ }
1088
1102
 
1089
- return this.xf['@@transducer/result'](result);
1090
- };
1103
+ function _map(fn, functor) {
1104
+ var idx = 0;
1105
+ var len = functor.length;
1106
+ var result = Array(len);
1091
1107
 
1092
- XAny.prototype['@@transducer/step'] = function (result, input) {
1093
- if (this.f(input)) {
1094
- this.any = true;
1095
- result = _reduced(this.xf['@@transducer/step'](result, true));
1096
- }
1108
+ while (idx < len) {
1109
+ result[idx] = fn(functor[idx]);
1110
+ idx += 1;
1111
+ }
1097
1112
 
1098
- return result;
1113
+ return result;
1114
+ }
1115
+
1116
+ function _complement(f) {
1117
+ return function () {
1118
+ return !f.apply(this, arguments);
1099
1119
  };
1120
+ }
1100
1121
 
1101
- return XAny;
1102
- }();
1122
+ function _arrayReduce(reducer, acc, list) {
1123
+ var index = 0;
1124
+ var length = list.length;
1103
1125
 
1104
- var _xany =
1105
- /*#__PURE__*/
1106
- _curry2(function _xany(f, xf) {
1107
- return new XAny(f, xf);
1108
- });
1126
+ while (index < length) {
1127
+ acc = reducer(acc, list[index]);
1128
+ index += 1;
1129
+ }
1109
1130
 
1110
- /**
1111
- * Returns `true` if at least one of the elements of the list match the predicate,
1112
- * `false` otherwise.
1113
- *
1114
- * Dispatches to the `any` method of the second argument, if present.
1115
- *
1116
- * Acts as a transducer if a transformer is given in list position.
1117
- *
1118
- * @func
1119
- * @memberOf R
1120
- * @since v0.1.0
1121
- * @category List
1122
- * @sig (a -> Boolean) -> [a] -> Boolean
1123
- * @param {Function} fn The predicate function.
1124
- * @param {Array} list The array to consider.
1125
- * @return {Boolean} `true` if the predicate is satisfied by at least one element, `false`
1126
- * otherwise.
1127
- * @see R.all, R.none, R.transduce
1128
- * @example
1129
- *
1130
- * const lessThan0 = R.flip(R.lt)(0);
1131
- * const lessThan2 = R.flip(R.lt)(2);
1132
- * R.any(lessThan0)([1, 2]); //=> false
1133
- * R.any(lessThan2)([1, 2]); //=> true
1134
- */
1131
+ return acc;
1132
+ }
1135
1133
 
1136
- var any =
1137
- /*#__PURE__*/
1138
- _curry2(
1139
- /*#__PURE__*/
1140
- _dispatchable(['any'], _xany, function any(fn, list) {
1134
+ function _filter(fn, list) {
1141
1135
  var idx = 0;
1136
+ var len = list.length;
1137
+ var result = [];
1142
1138
 
1143
- while (idx < list.length) {
1139
+ while (idx < len) {
1144
1140
  if (fn(list[idx])) {
1145
- return true;
1141
+ result[result.length] = list[idx];
1146
1142
  }
1147
1143
 
1148
1144
  idx += 1;
1149
1145
  }
1150
1146
 
1151
- return false;
1152
- }));
1153
-
1154
- var any$1 = any;
1147
+ return result;
1148
+ }
1155
1149
 
1156
- /**
1157
- * Gives a single-word string description of the (native) type of a value,
1158
- * returning such answers as 'Object', 'Number', 'Array', or 'Null'. Does not
1159
- * attempt to distinguish user Object types any further, reporting them all as
1160
- * 'Object'.
1161
- *
1162
- * @func
1163
- * @memberOf R
1164
- * @since v0.8.0
1165
- * @category Type
1166
- * @sig (* -> {*}) -> String
1167
- * @param {*} val The value to test
1168
- * @return {String}
1169
- * @example
1170
- *
1171
- * R.type({}); //=> "Object"
1172
- * R.type(1); //=> "Number"
1173
- * R.type(false); //=> "Boolean"
1174
- * R.type('s'); //=> "String"
1175
- * R.type(null); //=> "Null"
1176
- * R.type([]); //=> "Array"
1177
- * R.type(/[A-z]/); //=> "RegExp"
1178
- * R.type(() => {}); //=> "Function"
1179
- * R.type(undefined); //=> "Undefined"
1180
- */
1150
+ function _isObject(x) {
1151
+ return Object.prototype.toString.call(x) === '[object Object]';
1152
+ }
1181
1153
 
1182
- var type =
1154
+ var XFilter =
1183
1155
  /*#__PURE__*/
1184
- _curry1(function type(val) {
1185
- return val === null ? 'Null' : val === undefined ? 'Undefined' : Object.prototype.toString.call(val).slice(8, -1);
1186
- });
1187
-
1188
- function _pipe(f, g) {
1189
- return function () {
1190
- return g.call(this, f.apply(this, arguments));
1191
- };
1192
- }
1156
+ function () {
1157
+ function XFilter(f, xf) {
1158
+ this.xf = xf;
1159
+ this.f = f;
1160
+ }
1193
1161
 
1194
- /**
1195
- * This checks whether a function has a [methodname] function. If it isn't an
1196
- * array it will execute that function otherwise it will default to the ramda
1197
- * implementation.
1198
- *
1199
- * @private
1200
- * @param {Function} fn ramda implementation
1201
- * @param {String} methodname property to check for a custom implementation
1202
- * @return {Object} Whatever the return value of the method is.
1203
- */
1162
+ XFilter.prototype['@@transducer/init'] = _xfBase.init;
1163
+ XFilter.prototype['@@transducer/result'] = _xfBase.result;
1204
1164
 
1205
- function _checkForMethod(methodname, fn) {
1206
- return function () {
1207
- var length = arguments.length;
1165
+ XFilter.prototype['@@transducer/step'] = function (result, input) {
1166
+ return this.f(input) ? this.xf['@@transducer/step'](result, input) : result;
1167
+ };
1208
1168
 
1209
- if (length === 0) {
1210
- return fn();
1211
- }
1169
+ return XFilter;
1170
+ }();
1212
1171
 
1213
- var obj = arguments[length - 1];
1214
- return _isArray(obj) || typeof obj[methodname] !== 'function' ? fn.apply(this, arguments) : obj[methodname].apply(obj, Array.prototype.slice.call(arguments, 0, length - 1));
1172
+ function _xfilter(f) {
1173
+ return function (xf) {
1174
+ return new XFilter(f, xf);
1215
1175
  };
1216
1176
  }
1217
1177
 
1218
1178
  /**
1219
- * Returns the elements of the given list or string (or object with a `slice`
1220
- * method) from `fromIndex` (inclusive) to `toIndex` (exclusive).
1221
- *
1222
- * Dispatches to the `slice` method of the third argument, if present.
1223
- *
1224
- * @func
1225
- * @memberOf R
1226
- * @since v0.1.4
1227
- * @category List
1228
- * @sig Number -> Number -> [a] -> [a]
1229
- * @sig Number -> Number -> String -> String
1230
- * @param {Number} fromIndex The start index (inclusive).
1231
- * @param {Number} toIndex The end index (exclusive).
1232
- * @param {*} list
1233
- * @return {*}
1234
- * @example
1179
+ * Takes a predicate and a `Filterable`, and returns a new filterable of the
1180
+ * same type containing the members of the given filterable which satisfy the
1181
+ * given predicate. Filterable objects include plain objects or any object
1182
+ * that has a filter method such as `Array`.
1235
1183
  *
1236
- * R.slice(1, 3, ['a', 'b', 'c', 'd']); //=> ['b', 'c']
1237
- * R.slice(1, Infinity, ['a', 'b', 'c', 'd']); //=> ['b', 'c', 'd']
1238
- * R.slice(0, -1, ['a', 'b', 'c', 'd']); //=> ['a', 'b', 'c']
1239
- * R.slice(-3, -1, ['a', 'b', 'c', 'd']); //=> ['b', 'c']
1240
- * R.slice(0, 3, 'ramda'); //=> 'ram'
1241
- */
1242
-
1243
- var slice =
1244
- /*#__PURE__*/
1245
- _curry3(
1246
- /*#__PURE__*/
1247
- _checkForMethod('slice', function slice(fromIndex, toIndex, list) {
1248
- return Array.prototype.slice.call(list, fromIndex, toIndex);
1249
- }));
1250
-
1251
- /**
1252
- * Returns all but the first element of the given list or string (or object
1253
- * with a `tail` method).
1184
+ * Dispatches to the `filter` method of the second argument, if present.
1254
1185
  *
1255
- * Dispatches to the `slice` method of the first argument, if present.
1186
+ * Acts as a transducer if a transformer is given in list position.
1256
1187
  *
1257
1188
  * @func
1258
1189
  * @memberOf R
1259
1190
  * @since v0.1.0
1260
1191
  * @category List
1261
- * @sig [a] -> [a]
1262
- * @sig String -> String
1263
- * @param {*} list
1264
- * @return {*}
1265
- * @see R.head, R.init, R.last
1192
+ * @category Object
1193
+ * @sig Filterable f => (a -> Boolean) -> f a -> f a
1194
+ * @param {Function} pred
1195
+ * @param {Array} filterable
1196
+ * @return {Array} Filterable
1197
+ * @see R.reject, R.transduce, R.addIndex
1266
1198
  * @example
1267
1199
  *
1268
- * R.tail([1, 2, 3]); //=> [2, 3]
1269
- * R.tail([1, 2]); //=> [2]
1270
- * R.tail([1]); //=> []
1271
- * R.tail([]); //=> []
1200
+ * const isEven = n => n % 2 === 0;
1272
1201
  *
1273
- * R.tail('abc'); //=> 'bc'
1274
- * R.tail('ab'); //=> 'b'
1275
- * R.tail('a'); //=> ''
1276
- * R.tail(''); //=> ''
1202
+ * R.filter(isEven, [1, 2, 3, 4]); //=> [2, 4]
1203
+ *
1204
+ * R.filter(isEven, {a: 1, b: 2, c: 3, d: 4}); //=> {b: 2, d: 4}
1277
1205
  */
1278
1206
 
1279
- var tail =
1280
- /*#__PURE__*/
1281
- _curry1(
1207
+ var filter =
1282
1208
  /*#__PURE__*/
1283
- _checkForMethod('tail',
1209
+ _curry2(
1284
1210
  /*#__PURE__*/
1285
- slice(1, Infinity)));
1211
+ _dispatchable(['fantasy-land/filter', 'filter'], _xfilter, function (pred, filterable) {
1212
+ return _isObject(filterable) ? _arrayReduce(function (acc, key) {
1213
+ if (pred(filterable[key])) {
1214
+ acc[key] = filterable[key];
1215
+ }
1286
1216
 
1287
- var tail$1 = tail;
1217
+ return acc;
1218
+ }, {}, keys(filterable)) : // else
1219
+ _filter(pred, filterable);
1220
+ }));
1288
1221
 
1289
1222
  /**
1290
- * Performs left-to-right function composition. The first argument may have
1291
- * any arity; the remaining arguments must be unary.
1292
- *
1293
- * In some libraries this function is named `sequence`.
1223
+ * The complement of [`filter`](#filter).
1294
1224
  *
1295
- * **Note:** The result of pipe is not automatically curried.
1225
+ * Acts as a transducer if a transformer is given in list position. Filterable
1226
+ * objects include plain objects or any object that has a filter method such
1227
+ * as `Array`.
1296
1228
  *
1297
1229
  * @func
1298
1230
  * @memberOf R
1299
1231
  * @since v0.1.0
1300
- * @category Function
1301
- * @sig (((a, b, ..., n) -> o), (o -> p), ..., (x -> y), (y -> z)) -> ((a, b, ..., n) -> z)
1302
- * @param {...Function} functions
1303
- * @return {Function}
1304
- * @see R.compose
1232
+ * @category List
1233
+ * @sig Filterable f => (a -> Boolean) -> f a -> f a
1234
+ * @param {Function} pred
1235
+ * @param {Array} filterable
1236
+ * @return {Array}
1237
+ * @see R.filter, R.transduce, R.addIndex
1305
1238
  * @example
1306
1239
  *
1307
- * const f = R.pipe(Math.pow, R.negate, R.inc);
1240
+ * const isOdd = (n) => n % 2 !== 0;
1308
1241
  *
1309
- * f(3, 4); // -(3^4) + 1
1310
- * @symb R.pipe(f, g, h)(a, b) = h(g(f(a, b)))
1311
- * @symb R.pipe(f, g, h)(a)(b) = h(g(f(a)))(b)
1242
+ * R.reject(isOdd, [1, 2, 3, 4]); //=> [2, 4]
1243
+ *
1244
+ * R.reject(isOdd, {a: 1, b: 2, c: 3, d: 4}); //=> {b: 2, d: 4}
1312
1245
  */
1313
1246
 
1314
- function pipe$1() {
1315
- if (arguments.length === 0) {
1316
- throw new Error('pipe requires at least one argument');
1247
+ var reject =
1248
+ /*#__PURE__*/
1249
+ _curry2(function reject(pred, filterable) {
1250
+ return filter(_complement(pred), filterable);
1251
+ });
1252
+
1253
+ var reject$1 = reject;
1254
+
1255
+ var XMap =
1256
+ /*#__PURE__*/
1257
+ function () {
1258
+ function XMap(f, xf) {
1259
+ this.xf = xf;
1260
+ this.f = f;
1317
1261
  }
1318
1262
 
1319
- return _arity(arguments[0].length, reduce$1(_pipe, arguments[0], tail$1(arguments)));
1320
- }
1263
+ XMap.prototype['@@transducer/init'] = _xfBase.init;
1264
+ XMap.prototype['@@transducer/result'] = _xfBase.result;
1321
1265
 
1322
- function _identity(x) {
1323
- return x;
1324
- }
1266
+ XMap.prototype['@@transducer/step'] = function (result, input) {
1267
+ return this.xf['@@transducer/step'](result, this.f(input));
1268
+ };
1269
+
1270
+ return XMap;
1271
+ }();
1272
+
1273
+ var _xmap = function _xmap(f) {
1274
+ return function (xf) {
1275
+ return new XMap(f, xf);
1276
+ };
1277
+ };
1325
1278
 
1326
1279
  /**
1327
- * A function that does nothing but return the parameter supplied to it. Good
1328
- * as a default or placeholder function.
1280
+ * Takes a function and
1281
+ * a [functor](https://github.com/fantasyland/fantasy-land#functor),
1282
+ * applies the function to each of the functor's values, and returns
1283
+ * a functor of the same shape.
1284
+ *
1285
+ * Ramda provides suitable `map` implementations for `Array` and `Object`,
1286
+ * so this function may be applied to `[1, 2, 3]` or `{x: 1, y: 2, z: 3}`.
1287
+ *
1288
+ * Dispatches to the `map` method of the second argument, if present.
1289
+ *
1290
+ * Acts as a transducer if a transformer is given in list position.
1291
+ *
1292
+ * Also treats functions as functors and will compose them together.
1329
1293
  *
1330
1294
  * @func
1331
1295
  * @memberOf R
1332
1296
  * @since v0.1.0
1333
- * @category Function
1334
- * @sig a -> a
1335
- * @param {*} x The value to return.
1336
- * @return {*} The input value, `x`.
1297
+ * @category List
1298
+ * @sig Functor f => (a -> b) -> f a -> f b
1299
+ * @param {Function} fn The function to be called on every element of the input `list`.
1300
+ * @param {Array} list The list to be iterated over.
1301
+ * @return {Array} The new list.
1302
+ * @see R.transduce, R.addIndex, R.pluck, R.project
1337
1303
  * @example
1338
1304
  *
1339
- * R.identity(1); //=> 1
1305
+ * const double = x => x * 2;
1340
1306
  *
1341
- * const obj = {};
1342
- * R.identity(obj) === obj; //=> true
1343
- * @symb R.identity(a) = a
1307
+ * R.map(double, [1, 2, 3]); //=> [2, 4, 6]
1308
+ *
1309
+ * R.map(double, {x: 1, y: 2, z: 3}); //=> {x: 2, y: 4, z: 6}
1310
+ * @symb R.map(f, [a, b]) = [f(a), f(b)]
1311
+ * @symb R.map(f, { x: a, y: b }) = { x: f(a), y: f(b) }
1312
+ * @symb R.map(f, functor_o) = functor_o.map(f)
1344
1313
  */
1345
1314
 
1346
- var identity =
1315
+ var map =
1347
1316
  /*#__PURE__*/
1348
- _curry1(_identity);
1349
-
1350
- var identity$1 = identity;
1351
-
1352
- function _arrayFromIterator(iter) {
1353
- var list = [];
1354
- var next;
1355
-
1356
- while (!(next = iter.next()).done) {
1357
- list.push(next.value);
1358
- }
1359
-
1360
- return list;
1361
- }
1362
-
1363
- function _includesWith(pred, x, list) {
1364
- var idx = 0;
1365
- var len = list.length;
1317
+ _curry2(
1318
+ /*#__PURE__*/
1319
+ _dispatchable(['fantasy-land/map', 'map'], _xmap, function map(fn, functor) {
1320
+ switch (Object.prototype.toString.call(functor)) {
1321
+ case '[object Function]':
1322
+ return curryN(functor.length, function () {
1323
+ return fn.call(this, functor.apply(this, arguments));
1324
+ });
1366
1325
 
1367
- while (idx < len) {
1368
- if (pred(x, list[idx])) {
1369
- return true;
1370
- }
1326
+ case '[object Object]':
1327
+ return _arrayReduce(function (acc, key) {
1328
+ acc[key] = fn(functor[key]);
1329
+ return acc;
1330
+ }, {}, keys(functor));
1371
1331
 
1372
- idx += 1;
1332
+ default:
1333
+ return _map(fn, functor);
1373
1334
  }
1335
+ }));
1374
1336
 
1375
- return false;
1376
- }
1377
-
1378
- function _functionName(f) {
1379
- // String(x => x) evaluates to "x => x", so the pattern may not match.
1380
- var match = String(f).match(/^function (\w*)/);
1381
- return match == null ? '' : match[1];
1382
- }
1337
+ var map$1 = map;
1383
1338
 
1384
- // Based on https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
1385
- function _objectIs(a, b) {
1386
- // SameValue algorithm
1387
- if (a === b) {
1388
- // Steps 1-5, 7-10
1389
- // Steps 6.b-6.e: +0 != -0
1390
- return a !== 0 || 1 / a === 1 / b;
1391
- } else {
1392
- // Step 6.a: NaN == NaN
1393
- return a !== a && b !== b;
1394
- }
1339
+ function _isString(x) {
1340
+ return Object.prototype.toString.call(x) === '[object String]';
1395
1341
  }
1396
1342
 
1397
- var _objectIs$1 = typeof Object.is === 'function' ? Object.is : _objectIs;
1398
-
1399
1343
  /**
1400
- * private _uniqContentEquals function.
1401
- * That function is checking equality of 2 iterator contents with 2 assumptions
1402
- * - iterators lengths are the same
1403
- * - iterators values are unique
1344
+ * Tests whether or not an object is similar to an array.
1404
1345
  *
1405
- * false-positive result will be returned for comparison of, e.g.
1406
- * - [1,2,3] and [1,2,3,4]
1407
- * - [1,1,1] and [1,2,3]
1408
- * */
1409
-
1410
- function _uniqContentEquals(aIterator, bIterator, stackA, stackB) {
1411
- var a = _arrayFromIterator(aIterator);
1412
-
1413
- var b = _arrayFromIterator(bIterator);
1414
-
1415
- function eq(_a, _b) {
1416
- return _equals(_a, _b, stackA.slice(), stackB.slice());
1417
- } // if *a* array contains any element that is not included in *b*
1418
-
1419
-
1420
- return !_includesWith(function (b, aItem) {
1421
- return !_includesWith(eq, aItem, b);
1422
- }, b, a);
1423
- }
1346
+ * @private
1347
+ * @category Type
1348
+ * @category List
1349
+ * @sig * -> Boolean
1350
+ * @param {*} x The object to test.
1351
+ * @return {Boolean} `true` if `x` has a numeric length property and extreme indices defined; `false` otherwise.
1352
+ * @example
1353
+ *
1354
+ * _isArrayLike([]); //=> true
1355
+ * _isArrayLike(true); //=> false
1356
+ * _isArrayLike({}); //=> false
1357
+ * _isArrayLike({length: 10}); //=> false
1358
+ * _isArrayLike({0: 'zero', 9: 'nine', length: 10}); //=> true
1359
+ * _isArrayLike({nodeType: 1, length: 1}) // => false
1360
+ */
1424
1361
 
1425
- function _equals(a, b, stackA, stackB) {
1426
- if (_objectIs$1(a, b)) {
1362
+ var _isArrayLike =
1363
+ /*#__PURE__*/
1364
+ _curry1(function isArrayLike(x) {
1365
+ if (_isArray(x)) {
1427
1366
  return true;
1428
1367
  }
1429
1368
 
1430
- var typeA = type(a);
1431
-
1432
- if (typeA !== type(b)) {
1369
+ if (!x) {
1433
1370
  return false;
1434
1371
  }
1435
1372
 
1436
- if (typeof a['fantasy-land/equals'] === 'function' || typeof b['fantasy-land/equals'] === 'function') {
1437
- return typeof a['fantasy-land/equals'] === 'function' && a['fantasy-land/equals'](b) && typeof b['fantasy-land/equals'] === 'function' && b['fantasy-land/equals'](a);
1438
- }
1439
-
1440
- if (typeof a.equals === 'function' || typeof b.equals === 'function') {
1441
- return typeof a.equals === 'function' && a.equals(b) && typeof b.equals === 'function' && b.equals(a);
1442
- }
1443
-
1444
- switch (typeA) {
1445
- case 'Arguments':
1446
- case 'Array':
1447
- case 'Object':
1448
- if (typeof a.constructor === 'function' && _functionName(a.constructor) === 'Promise') {
1449
- return a === b;
1450
- }
1451
-
1452
- break;
1453
-
1454
- case 'Boolean':
1455
- case 'Number':
1456
- case 'String':
1457
- if (!(typeof a === typeof b && _objectIs$1(a.valueOf(), b.valueOf()))) {
1458
- return false;
1459
- }
1460
-
1461
- break;
1462
-
1463
- case 'Date':
1464
- if (!_objectIs$1(a.valueOf(), b.valueOf())) {
1465
- return false;
1466
- }
1467
-
1468
- break;
1469
-
1470
- case 'Error':
1471
- return a.name === b.name && a.message === b.message;
1472
-
1473
- case 'RegExp':
1474
- if (!(a.source === b.source && a.global === b.global && a.ignoreCase === b.ignoreCase && a.multiline === b.multiline && a.sticky === b.sticky && a.unicode === b.unicode)) {
1475
- return false;
1476
- }
1477
-
1478
- break;
1373
+ if (typeof x !== 'object') {
1374
+ return false;
1479
1375
  }
1480
1376
 
1481
- var idx = stackA.length - 1;
1482
-
1483
- while (idx >= 0) {
1484
- if (stackA[idx] === a) {
1485
- return stackB[idx] === b;
1486
- }
1377
+ if (_isString(x)) {
1378
+ return false;
1379
+ }
1487
1380
 
1488
- idx -= 1;
1381
+ if (x.length === 0) {
1382
+ return true;
1489
1383
  }
1490
1384
 
1491
- switch (typeA) {
1492
- case 'Map':
1493
- if (a.size !== b.size) {
1494
- return false;
1495
- }
1385
+ if (x.length > 0) {
1386
+ return x.hasOwnProperty(0) && x.hasOwnProperty(x.length - 1);
1387
+ }
1496
1388
 
1497
- return _uniqContentEquals(a.entries(), b.entries(), stackA.concat([a]), stackB.concat([b]));
1389
+ return false;
1390
+ });
1498
1391
 
1499
- case 'Set':
1500
- if (a.size !== b.size) {
1501
- return false;
1502
- }
1392
+ var symIterator = typeof Symbol !== 'undefined' ? Symbol.iterator : '@@iterator';
1393
+ function _createReduce(arrayReduce, methodReduce, iterableReduce) {
1394
+ return function _reduce(xf, acc, list) {
1395
+ if (_isArrayLike(list)) {
1396
+ return arrayReduce(xf, acc, list);
1397
+ }
1503
1398
 
1504
- return _uniqContentEquals(a.values(), b.values(), stackA.concat([a]), stackB.concat([b]));
1399
+ if (list == null) {
1400
+ return acc;
1401
+ }
1505
1402
 
1506
- case 'Arguments':
1507
- case 'Array':
1508
- case 'Object':
1509
- case 'Boolean':
1510
- case 'Number':
1511
- case 'String':
1512
- case 'Date':
1513
- case 'Error':
1514
- case 'RegExp':
1515
- case 'Int8Array':
1516
- case 'Uint8Array':
1517
- case 'Uint8ClampedArray':
1518
- case 'Int16Array':
1519
- case 'Uint16Array':
1520
- case 'Int32Array':
1521
- case 'Uint32Array':
1522
- case 'Float32Array':
1523
- case 'Float64Array':
1524
- case 'ArrayBuffer':
1525
- break;
1403
+ if (typeof list['fantasy-land/reduce'] === 'function') {
1404
+ return methodReduce(xf, acc, list, 'fantasy-land/reduce');
1405
+ }
1526
1406
 
1527
- default:
1528
- // Values of other types are only equal if identical.
1529
- return false;
1530
- }
1407
+ if (list[symIterator] != null) {
1408
+ return iterableReduce(xf, acc, list[symIterator]());
1409
+ }
1531
1410
 
1532
- var keysA = keys(a);
1411
+ if (typeof list.next === 'function') {
1412
+ return iterableReduce(xf, acc, list);
1413
+ }
1533
1414
 
1534
- if (keysA.length !== keys(b).length) {
1535
- return false;
1536
- }
1415
+ if (typeof list.reduce === 'function') {
1416
+ return methodReduce(xf, acc, list, 'reduce');
1417
+ }
1537
1418
 
1538
- var extendedStackA = stackA.concat([a]);
1539
- var extendedStackB = stackB.concat([b]);
1540
- idx = keysA.length - 1;
1419
+ throw new TypeError('reduce: list must be array or iterable');
1420
+ };
1421
+ }
1541
1422
 
1542
- while (idx >= 0) {
1543
- var key = keysA[idx];
1423
+ function _xArrayReduce(xf, acc, list) {
1424
+ var idx = 0;
1425
+ var len = list.length;
1544
1426
 
1545
- if (!(_has(key, b) && _equals(b[key], a[key], extendedStackA, extendedStackB))) {
1546
- return false;
1427
+ while (idx < len) {
1428
+ acc = xf['@@transducer/step'](acc, list[idx]);
1429
+
1430
+ if (acc && acc['@@transducer/reduced']) {
1431
+ acc = acc['@@transducer/value'];
1432
+ break;
1547
1433
  }
1548
1434
 
1549
- idx -= 1;
1435
+ idx += 1;
1550
1436
  }
1551
1437
 
1552
- return true;
1438
+ return xf['@@transducer/result'](acc);
1553
1439
  }
1554
1440
 
1555
1441
  /**
1556
- * Returns `true` if its arguments are equivalent, `false` otherwise. Handles
1557
- * cyclical data structures.
1558
- *
1559
- * Dispatches symmetrically to the `equals` methods of both arguments, if
1560
- * present.
1442
+ * Creates a function that is bound to a context.
1443
+ * Note: `R.bind` does not provide the additional argument-binding capabilities of
1444
+ * [Function.prototype.bind](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind).
1561
1445
  *
1562
1446
  * @func
1563
1447
  * @memberOf R
1564
- * @since v0.15.0
1565
- * @category Relation
1566
- * @sig a -> b -> Boolean
1567
- * @param {*} a
1568
- * @param {*} b
1569
- * @return {Boolean}
1448
+ * @since v0.6.0
1449
+ * @category Function
1450
+ * @category Object
1451
+ * @sig (* -> *) -> {*} -> (* -> *)
1452
+ * @param {Function} fn The function to bind to context
1453
+ * @param {Object} thisObj The context to bind `fn` to
1454
+ * @return {Function} A function that will execute in the context of `thisObj`.
1455
+ * @see R.partial
1570
1456
  * @example
1571
1457
  *
1572
- * R.equals(1, 1); //=> true
1573
- * R.equals(1, '1'); //=> false
1574
- * R.equals([1, 2, 3], [1, 2, 3]); //=> true
1575
- *
1576
- * const a = {}; a.v = a;
1577
- * const b = {}; b.v = b;
1578
- * R.equals(a, b); //=> true
1458
+ * const log = R.bind(console.log, console);
1459
+ * R.pipe(R.assoc('a', 2), R.tap(log), R.assoc('a', 3))({a: 1}); //=> {a: 3}
1460
+ * // logs {a: 2}
1461
+ * @symb R.bind(f, o)(a, b) = f.call(o, a, b)
1579
1462
  */
1580
1463
 
1581
- var equals =
1464
+ var bind =
1582
1465
  /*#__PURE__*/
1583
- _curry2(function equals(a, b) {
1584
- return _equals(a, b, [], []);
1466
+ _curry2(function bind(fn, thisObj) {
1467
+ return _arity(fn.length, function () {
1468
+ return fn.apply(thisObj, arguments);
1469
+ });
1585
1470
  });
1586
1471
 
1587
- var equals$1 = equals;
1472
+ function _xIterableReduce(xf, acc, iter) {
1473
+ var step = iter.next();
1588
1474
 
1589
- function _indexOf(list, a, idx) {
1590
- var inf, item; // Array.prototype.indexOf doesn't exist below IE9
1475
+ while (!step.done) {
1476
+ acc = xf['@@transducer/step'](acc, step.value);
1591
1477
 
1592
- if (typeof list.indexOf === 'function') {
1593
- switch (typeof a) {
1594
- case 'number':
1595
- if (a === 0) {
1596
- // manually crawl the list to distinguish between +0 and -0
1597
- inf = 1 / a;
1478
+ if (acc && acc['@@transducer/reduced']) {
1479
+ acc = acc['@@transducer/value'];
1480
+ break;
1481
+ }
1598
1482
 
1599
- while (idx < list.length) {
1600
- item = list[idx];
1483
+ step = iter.next();
1484
+ }
1601
1485
 
1602
- if (item === 0 && 1 / item === inf) {
1603
- return idx;
1604
- }
1486
+ return xf['@@transducer/result'](acc);
1487
+ }
1605
1488
 
1606
- idx += 1;
1607
- }
1489
+ function _xMethodReduce(xf, acc, obj, methodName) {
1490
+ return xf['@@transducer/result'](obj[methodName](bind(xf['@@transducer/step'], xf), acc));
1491
+ }
1608
1492
 
1609
- return -1;
1610
- } else if (a !== a) {
1611
- // NaN
1612
- while (idx < list.length) {
1613
- item = list[idx];
1493
+ var _xReduce =
1494
+ /*#__PURE__*/
1495
+ _createReduce(_xArrayReduce, _xMethodReduce, _xIterableReduce);
1614
1496
 
1615
- if (typeof item === 'number' && item !== item) {
1616
- return idx;
1617
- }
1497
+ var XWrap =
1498
+ /*#__PURE__*/
1499
+ function () {
1500
+ function XWrap(fn) {
1501
+ this.f = fn;
1502
+ }
1618
1503
 
1619
- idx += 1;
1620
- }
1504
+ XWrap.prototype['@@transducer/init'] = function () {
1505
+ throw new Error('init not implemented on XWrap');
1506
+ };
1621
1507
 
1622
- return -1;
1623
- } // non-zero numbers can utilise Set
1508
+ XWrap.prototype['@@transducer/result'] = function (acc) {
1509
+ return acc;
1510
+ };
1624
1511
 
1512
+ XWrap.prototype['@@transducer/step'] = function (acc, x) {
1513
+ return this.f(acc, x);
1514
+ };
1625
1515
 
1626
- return list.indexOf(a, idx);
1627
- // all these types can utilise Set
1516
+ return XWrap;
1517
+ }();
1628
1518
 
1629
- case 'string':
1630
- case 'boolean':
1631
- case 'function':
1632
- case 'undefined':
1633
- return list.indexOf(a, idx);
1519
+ function _xwrap(fn) {
1520
+ return new XWrap(fn);
1521
+ }
1634
1522
 
1635
- case 'object':
1636
- if (a === null) {
1637
- // null can utilise Set
1638
- return list.indexOf(a, idx);
1639
- }
1523
+ /**
1524
+ * Returns a single item by iterating through the list, successively calling
1525
+ * the iterator function and passing it an accumulator value and the current
1526
+ * value from the array, and then passing the result to the next call.
1527
+ *
1528
+ * The iterator function receives two values: *(acc, value)*. It may use
1529
+ * [`R.reduced`](#reduced) to shortcut the iteration.
1530
+ *
1531
+ * The arguments' order of [`reduceRight`](#reduceRight)'s iterator function
1532
+ * is *(value, acc)*.
1533
+ *
1534
+ * Note: `R.reduce` does not skip deleted or unassigned indices (sparse
1535
+ * arrays), unlike the native `Array.prototype.reduce` method. For more details
1536
+ * on this behavior, see:
1537
+ * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce#Description
1538
+ *
1539
+ * Be cautious of mutating and returning the accumulator. If you reuse it across
1540
+ * invocations, it will continue to accumulate onto the same value. The general
1541
+ * recommendation is to always return a new value. If you can't do so for
1542
+ * performance reasons, then be sure to reinitialize the accumulator on each
1543
+ * invocation.
1544
+ *
1545
+ * Dispatches to the `reduce` method of the third argument, if present. When
1546
+ * doing so, it is up to the user to handle the [`R.reduced`](#reduced)
1547
+ * shortcuting, as this is not implemented by `reduce`.
1548
+ *
1549
+ * @func
1550
+ * @memberOf R
1551
+ * @since v0.1.0
1552
+ * @category List
1553
+ * @sig ((a, b) -> a) -> a -> [b] -> a
1554
+ * @param {Function} fn The iterator function. Receives two values, the accumulator and the
1555
+ * current element from the array.
1556
+ * @param {*} acc The accumulator value.
1557
+ * @param {Array} list The list to iterate over.
1558
+ * @return {*} The final, accumulated value.
1559
+ * @see R.reduced, R.addIndex, R.reduceRight
1560
+ * @example
1561
+ *
1562
+ * R.reduce(R.subtract, 0, [1, 2, 3, 4]) // => ((((0 - 1) - 2) - 3) - 4) = -10
1563
+ * // - -10
1564
+ * // / \ / \
1565
+ * // - 4 -6 4
1566
+ * // / \ / \
1567
+ * // - 3 ==> -3 3
1568
+ * // / \ / \
1569
+ * // - 2 -1 2
1570
+ * // / \ / \
1571
+ * // 0 1 0 1
1572
+ *
1573
+ * @symb R.reduce(f, a, [b, c, d]) = f(f(f(a, b), c), d)
1574
+ */
1575
+
1576
+ var reduce =
1577
+ /*#__PURE__*/
1578
+ _curry3(function (xf, acc, list) {
1579
+ return _xReduce(typeof xf === 'function' ? _xwrap(xf) : xf, acc, list);
1580
+ });
1581
+
1582
+ var reduce$1 = reduce;
1583
+
1584
+ var XAny =
1585
+ /*#__PURE__*/
1586
+ function () {
1587
+ function XAny(f, xf) {
1588
+ this.xf = xf;
1589
+ this.f = f;
1590
+ this.any = false;
1591
+ }
1592
+
1593
+ XAny.prototype['@@transducer/init'] = _xfBase.init;
1640
1594
 
1595
+ XAny.prototype['@@transducer/result'] = function (result) {
1596
+ if (!this.any) {
1597
+ result = this.xf['@@transducer/step'](result, false);
1641
1598
  }
1642
- } // anything else not covered above, defer to R.equals
1643
1599
 
1600
+ return this.xf['@@transducer/result'](result);
1601
+ };
1644
1602
 
1645
- while (idx < list.length) {
1646
- if (equals$1(list[idx], a)) {
1647
- return idx;
1603
+ XAny.prototype['@@transducer/step'] = function (result, input) {
1604
+ if (this.f(input)) {
1605
+ this.any = true;
1606
+ result = _reduced(this.xf['@@transducer/step'](result, true));
1648
1607
  }
1649
1608
 
1650
- idx += 1;
1651
- }
1652
-
1653
- return -1;
1654
- }
1609
+ return result;
1610
+ };
1655
1611
 
1656
- function _includes(a, list) {
1657
- return _indexOf(list, a, 0) >= 0;
1658
- }
1612
+ return XAny;
1613
+ }();
1659
1614
 
1660
- function _complement(f) {
1661
- return function () {
1662
- return !f.apply(this, arguments);
1615
+ function _xany(f) {
1616
+ return function (xf) {
1617
+ return new XAny(f, xf);
1663
1618
  };
1664
1619
  }
1665
1620
 
1666
- function _filter(fn, list) {
1621
+ /**
1622
+ * Returns `true` if at least one of the elements of the list match the predicate,
1623
+ * `false` otherwise.
1624
+ *
1625
+ * Dispatches to the `any` method of the second argument, if present.
1626
+ *
1627
+ * Acts as a transducer if a transformer is given in list position.
1628
+ *
1629
+ * @func
1630
+ * @memberOf R
1631
+ * @since v0.1.0
1632
+ * @category List
1633
+ * @sig (a -> Boolean) -> [a] -> Boolean
1634
+ * @param {Function} fn The predicate function.
1635
+ * @param {Array} list The array to consider.
1636
+ * @return {Boolean} `true` if the predicate is satisfied by at least one element, `false`
1637
+ * otherwise.
1638
+ * @see R.all, R.none, R.transduce
1639
+ * @example
1640
+ *
1641
+ * const lessThan0 = R.flip(R.lt)(0);
1642
+ * const lessThan2 = R.flip(R.lt)(2);
1643
+ * R.any(lessThan0)([1, 2]); //=> false
1644
+ * R.any(lessThan2)([1, 2]); //=> true
1645
+ */
1646
+
1647
+ var any =
1648
+ /*#__PURE__*/
1649
+ _curry2(
1650
+ /*#__PURE__*/
1651
+ _dispatchable(['any'], _xany, function any(fn, list) {
1667
1652
  var idx = 0;
1668
- var len = list.length;
1669
- var result = [];
1670
1653
 
1671
- while (idx < len) {
1654
+ while (idx < list.length) {
1672
1655
  if (fn(list[idx])) {
1673
- result[result.length] = list[idx];
1656
+ return true;
1674
1657
  }
1675
1658
 
1676
1659
  idx += 1;
1677
1660
  }
1678
1661
 
1679
- return result;
1680
- }
1662
+ return false;
1663
+ }));
1681
1664
 
1682
- function _isObject(x) {
1683
- return Object.prototype.toString.call(x) === '[object Object]';
1665
+ var any$1 = any;
1666
+
1667
+ function _pipe(f, g) {
1668
+ return function () {
1669
+ return g.call(this, f.apply(this, arguments));
1670
+ };
1684
1671
  }
1685
1672
 
1686
- var XFilter =
1687
- /*#__PURE__*/
1688
- function () {
1689
- function XFilter(f, xf) {
1690
- this.xf = xf;
1691
- this.f = f;
1692
- }
1673
+ /**
1674
+ * This checks whether a function has a [methodname] function. If it isn't an
1675
+ * array it will execute that function otherwise it will default to the ramda
1676
+ * implementation.
1677
+ *
1678
+ * @private
1679
+ * @param {Function} fn ramda implementation
1680
+ * @param {String} methodname property to check for a custom implementation
1681
+ * @return {Object} Whatever the return value of the method is.
1682
+ */
1693
1683
 
1694
- XFilter.prototype['@@transducer/init'] = _xfBase.init;
1695
- XFilter.prototype['@@transducer/result'] = _xfBase.result;
1684
+ function _checkForMethod(methodname, fn) {
1685
+ return function () {
1686
+ var length = arguments.length;
1696
1687
 
1697
- XFilter.prototype['@@transducer/step'] = function (result, input) {
1698
- return this.f(input) ? this.xf['@@transducer/step'](result, input) : result;
1688
+ if (length === 0) {
1689
+ return fn();
1690
+ }
1691
+
1692
+ var obj = arguments[length - 1];
1693
+ return _isArray(obj) || typeof obj[methodname] !== 'function' ? fn.apply(this, arguments) : obj[methodname].apply(obj, Array.prototype.slice.call(arguments, 0, length - 1));
1699
1694
  };
1695
+ }
1700
1696
 
1701
- return XFilter;
1702
- }();
1697
+ /**
1698
+ * Returns the elements of the given list or string (or object with a `slice`
1699
+ * method) from `fromIndex` (inclusive) to `toIndex` (exclusive).
1700
+ *
1701
+ * Dispatches to the `slice` method of the third argument, if present.
1702
+ *
1703
+ * @func
1704
+ * @memberOf R
1705
+ * @since v0.1.4
1706
+ * @category List
1707
+ * @sig Number -> Number -> [a] -> [a]
1708
+ * @sig Number -> Number -> String -> String
1709
+ * @param {Number} fromIndex The start index (inclusive).
1710
+ * @param {Number} toIndex The end index (exclusive).
1711
+ * @param {*} list
1712
+ * @return {*}
1713
+ * @example
1714
+ *
1715
+ * R.slice(1, 3, ['a', 'b', 'c', 'd']); //=> ['b', 'c']
1716
+ * R.slice(1, Infinity, ['a', 'b', 'c', 'd']); //=> ['b', 'c', 'd']
1717
+ * R.slice(0, -1, ['a', 'b', 'c', 'd']); //=> ['a', 'b', 'c']
1718
+ * R.slice(-3, -1, ['a', 'b', 'c', 'd']); //=> ['b', 'c']
1719
+ * R.slice(0, 3, 'ramda'); //=> 'ram'
1720
+ */
1703
1721
 
1704
- var _xfilter =
1722
+ var slice =
1705
1723
  /*#__PURE__*/
1706
- _curry2(function _xfilter(f, xf) {
1707
- return new XFilter(f, xf);
1708
- });
1724
+ _curry3(
1725
+ /*#__PURE__*/
1726
+ _checkForMethod('slice', function slice(fromIndex, toIndex, list) {
1727
+ return Array.prototype.slice.call(list, fromIndex, toIndex);
1728
+ }));
1709
1729
 
1710
1730
  /**
1711
- * Takes a predicate and a `Filterable`, and returns a new filterable of the
1712
- * same type containing the members of the given filterable which satisfy the
1713
- * given predicate. Filterable objects include plain objects or any object
1714
- * that has a filter method such as `Array`.
1715
- *
1716
- * Dispatches to the `filter` method of the second argument, if present.
1731
+ * Returns all but the first element of the given list or string (or object
1732
+ * with a `tail` method).
1717
1733
  *
1718
- * Acts as a transducer if a transformer is given in list position.
1734
+ * Dispatches to the `slice` method of the first argument, if present.
1719
1735
  *
1720
1736
  * @func
1721
1737
  * @memberOf R
1722
1738
  * @since v0.1.0
1723
1739
  * @category List
1724
- * @sig Filterable f => (a -> Boolean) -> f a -> f a
1725
- * @param {Function} pred
1726
- * @param {Array} filterable
1727
- * @return {Array} Filterable
1728
- * @see R.reject, R.transduce, R.addIndex
1740
+ * @sig [a] -> [a]
1741
+ * @sig String -> String
1742
+ * @param {*} list
1743
+ * @return {*}
1744
+ * @see R.head, R.init, R.last
1729
1745
  * @example
1730
1746
  *
1731
- * const isEven = n => n % 2 === 0;
1732
- *
1733
- * R.filter(isEven, [1, 2, 3, 4]); //=> [2, 4]
1747
+ * R.tail([1, 2, 3]); //=> [2, 3]
1748
+ * R.tail([1, 2]); //=> [2]
1749
+ * R.tail([1]); //=> []
1750
+ * R.tail([]); //=> []
1734
1751
  *
1735
- * R.filter(isEven, {a: 1, b: 2, c: 3, d: 4}); //=> {b: 2, d: 4}
1752
+ * R.tail('abc'); //=> 'bc'
1753
+ * R.tail('ab'); //=> 'b'
1754
+ * R.tail('a'); //=> ''
1755
+ * R.tail(''); //=> ''
1736
1756
  */
1737
1757
 
1738
- var filter =
1758
+ var tail =
1739
1759
  /*#__PURE__*/
1740
- _curry2(
1760
+ _curry1(
1741
1761
  /*#__PURE__*/
1742
- _dispatchable(['fantasy-land/filter', 'filter'], _xfilter, function (pred, filterable) {
1743
- return _isObject(filterable) ? _reduce(function (acc, key) {
1744
- if (pred(filterable[key])) {
1745
- acc[key] = filterable[key];
1746
- }
1762
+ _checkForMethod('tail',
1763
+ /*#__PURE__*/
1764
+ slice(1, Infinity)));
1747
1765
 
1748
- return acc;
1749
- }, {}, keys(filterable)) : // else
1750
- _filter(pred, filterable);
1751
- }));
1766
+ var tail$1 = tail;
1752
1767
 
1753
1768
  /**
1754
- * The complement of [`filter`](#filter).
1769
+ * Performs left-to-right function composition. The first argument may have
1770
+ * any arity; the remaining arguments must be unary.
1755
1771
  *
1756
- * Acts as a transducer if a transformer is given in list position. Filterable
1757
- * objects include plain objects or any object that has a filter method such
1758
- * as `Array`.
1772
+ * In some libraries this function is named `sequence`.
1773
+ *
1774
+ * **Note:** The result of pipe is not automatically curried.
1759
1775
  *
1760
1776
  * @func
1761
1777
  * @memberOf R
1762
1778
  * @since v0.1.0
1763
- * @category List
1764
- * @sig Filterable f => (a -> Boolean) -> f a -> f a
1765
- * @param {Function} pred
1766
- * @param {Array} filterable
1767
- * @return {Array}
1768
- * @see R.filter, R.transduce, R.addIndex
1779
+ * @category Function
1780
+ * @sig (((a, b, ..., n) -> o), (o -> p), ..., (x -> y), (y -> z)) -> ((a, b, ..., n) -> z)
1781
+ * @param {...Function} functions
1782
+ * @return {Function}
1783
+ * @see R.compose
1769
1784
  * @example
1770
1785
  *
1771
- * const isOdd = (n) => n % 2 !== 0;
1786
+ * const f = R.pipe(Math.pow, R.negate, R.inc);
1772
1787
  *
1773
- * R.reject(isOdd, [1, 2, 3, 4]); //=> [2, 4]
1788
+ * f(3, 4); // -(3^4) + 1
1789
+ * @symb R.pipe(f, g, h)(a, b) = h(g(f(a, b)))
1790
+ * @symb R.pipe(f, g, h)(a)(b) = h(g(f(a)))(b)
1791
+ */
1792
+
1793
+ function pipe$1() {
1794
+ if (arguments.length === 0) {
1795
+ throw new Error('pipe requires at least one argument');
1796
+ }
1797
+
1798
+ return _arity(arguments[0].length, reduce$1(_pipe, arguments[0], tail$1(arguments)));
1799
+ }
1800
+
1801
+ function _identity(x) {
1802
+ return x;
1803
+ }
1804
+
1805
+ /**
1806
+ * A function that does nothing but return the parameter supplied to it. Good
1807
+ * as a default or placeholder function.
1774
1808
  *
1775
- * R.reject(isOdd, {a: 1, b: 2, c: 3, d: 4}); //=> {b: 2, d: 4}
1809
+ * @func
1810
+ * @memberOf R
1811
+ * @since v0.1.0
1812
+ * @category Function
1813
+ * @sig a -> a
1814
+ * @param {*} x The value to return.
1815
+ * @return {*} The input value, `x`.
1816
+ * @example
1817
+ *
1818
+ * R.identity(1); //=> 1
1819
+ *
1820
+ * const obj = {};
1821
+ * R.identity(obj) === obj; //=> true
1822
+ * @symb R.identity(a) = a
1776
1823
  */
1777
1824
 
1778
- var reject =
1825
+ var identity =
1779
1826
  /*#__PURE__*/
1780
- _curry2(function reject(pred, filterable) {
1781
- return filter(_complement(pred), filterable);
1782
- });
1827
+ _curry1(_identity);
1783
1828
 
1784
- var reject$1 = reject;
1829
+ var identity$1 = identity;
1785
1830
 
1786
1831
  /**
1787
1832
  * Removes the sub-list of `list` starting at index `start` and containing
@@ -1959,6 +2004,8 @@ var mergeWithKey =
1959
2004
  _curry3(function mergeWithKey(fn, l, r) {
1960
2005
  var result = {};
1961
2006
  var k;
2007
+ l = l || {};
2008
+ r = r || {};
1962
2009
 
1963
2010
  for (k in l) {
1964
2011
  if (_has(k, l)) {