ramda-adjunct 2.30.0 → 2.33.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.
Files changed (81) hide show
  1. package/.nvmrc +1 -0
  2. package/CHANGELOG.md +44 -0
  3. package/README.md +6 -6
  4. package/dist/RA.node.js +7544 -7169
  5. package/dist/RA.node.min.js +1 -1
  6. package/dist/RA.web.js +7544 -7169
  7. package/dist/RA.web.min.js +1 -1
  8. package/dist/RA.web.standalone.js +20077 -18989
  9. package/dist/RA.web.standalone.min.js +1 -1
  10. package/es/catchP.js +24 -0
  11. package/es/dispatch.js +1 -1
  12. package/es/fantasy-land/Identity.js +61 -74
  13. package/es/fantasy-land/mapping.js +20 -23
  14. package/es/fantasy-land/traits.js +1 -1
  15. package/es/filterIndexed.js +27 -0
  16. package/es/findOr.js +28 -0
  17. package/es/flattenDepth.js +1 -1
  18. package/es/index.js +14 -3
  19. package/es/internal/ap.js +1 -1
  20. package/es/internal/ponyfills/Array.from.js +1 -1
  21. package/es/internal/ponyfills/Promise.allSettled.js +1 -1
  22. package/es/internal/ponyfills/Promise.any.js +2 -2
  23. package/es/invoke.js +20 -0
  24. package/es/isInteger32.js +28 -0
  25. package/es/isNotPrimitive.js +22 -0
  26. package/es/isPrimitive.js +31 -0
  27. package/es/isPrototypeOf.js +34 -0
  28. package/es/isSentinelValue.js +26 -0
  29. package/es/lastP.js +1 -1
  30. package/es/pathOrLazy.js +1 -1
  31. package/es/reduceP.js +1 -1
  32. package/es/reduceRightP.js +1 -1
  33. package/es/sortByProps.js +1 -1
  34. package/lib/anyP.js +2 -2
  35. package/lib/catchP.js +30 -0
  36. package/lib/dispatch.js +1 -1
  37. package/lib/fantasy-land/Identity.js +65 -75
  38. package/lib/fantasy-land/mapping.js +41 -25
  39. package/lib/fantasy-land/traits.js +18 -12
  40. package/lib/filterIndexed.js +33 -0
  41. package/lib/findOr.js +34 -0
  42. package/lib/flattenDepth.js +1 -1
  43. package/lib/index.js +40 -3
  44. package/lib/internal/ap.js +9 -3
  45. package/lib/internal/ponyfills/Array.from.js +1 -1
  46. package/lib/internal/ponyfills/Promise.allSettled.js +1 -1
  47. package/lib/internal/ponyfills/Promise.any.js +2 -2
  48. package/lib/invoke.js +29 -0
  49. package/lib/isInteger32.js +37 -0
  50. package/lib/isNotPrimitive.js +31 -0
  51. package/lib/isPrimitive.js +47 -0
  52. package/lib/isPrototypeOf.js +43 -0
  53. package/lib/isSentinelValue.js +35 -0
  54. package/lib/lastP.js +1 -1
  55. package/lib/pathOrLazy.js +1 -1
  56. package/lib/reduceP.js +1 -1
  57. package/lib/reduceRightP.js +1 -1
  58. package/lib/sortByProps.js +1 -1
  59. package/package.json +34 -32
  60. package/src/catchP.js +25 -0
  61. package/src/fantasy-land/Identity.js +24 -27
  62. package/src/fantasy-land/mapping.js +20 -24
  63. package/src/fantasy-land/traits.js +1 -1
  64. package/src/filterIndexed.js +28 -0
  65. package/src/findOr.js +30 -0
  66. package/src/fnull.js +4 -4
  67. package/src/index.js +10 -0
  68. package/src/internal/ap.js +1 -1
  69. package/src/internal/makeFlat.js +2 -3
  70. package/src/internal/ponyfills/Promise.allSettled.js +4 -3
  71. package/src/invoke.js +22 -0
  72. package/src/isInteger32.js +28 -0
  73. package/src/isNotPrimitive.js +25 -0
  74. package/src/isPrimitive.js +45 -0
  75. package/src/isPrototypeOf.js +36 -0
  76. package/src/isSentinelValue.js +26 -0
  77. package/src/isSymbol.js +4 -4
  78. package/src/pathOrLazy.js +4 -4
  79. package/src/replaceAll.js +0 -1
  80. package/types/index.d.ts +85 -1
  81. package/.mocharc.js +0 -9
@@ -0,0 +1,26 @@
1
+ import { curryN } from 'ramda';
2
+ import isInteger32 from './isInteger32';
3
+ /**
4
+ * Checks whether the passed value is {@link https://github.com/getify/You-Dont-Know-JS/blob/9959fc904d584bbf0b02cf41c192f74ff4238581/types-grammar/ch4.md#the-curious-case-of-the-|a sentinel value}.
5
+ *
6
+ * @func isSentinelValue
7
+ * @memberOf RA
8
+ * @since {@link https://char0n.github.io/ramda-adjunct/2.33.0|v2.33.0}
9
+ * @category Type
10
+ * @sig * -> Boolean
11
+ * @param {*} val The value to test
12
+ * @return {boolean}
13
+ * @example
14
+ *
15
+ * RA.isSentinelValue(-1); //=> true
16
+ *
17
+ * RA.isSentinelValue('-1'); //=> false
18
+ * RA.isSentinelValue(1); //=> false
19
+ * RA.isSentinelValue([-1]); //=> false
20
+ */
21
+ // eslint-disable-next-line no-bitwise
22
+
23
+ var isSentinelValue = curryN(1, function (val) {
24
+ return isInteger32(val) && ~val === 0;
25
+ });
26
+ export default isSentinelValue;
package/es/lastP.js CHANGED
@@ -4,7 +4,7 @@ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread n
4
4
 
5
5
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
6
6
 
7
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
7
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
8
8
 
9
9
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
10
10
 
package/es/pathOrLazy.js CHANGED
@@ -19,7 +19,7 @@ import { curryN, identical, partial, pathOr, unary, when } from 'ramda';
19
19
  * RA.pathOrLazy(() => 'N/A', ['a', 'b'], {c: {b: 2}}); //=> "N/A"
20
20
  */
21
21
 
22
- var pathOrLazy = curryN(3, function pathOrLazy(defaultFn, path, obj) {
22
+ var pathOrLazy = curryN(3, function (defaultFn, path, obj) {
23
23
  return when(identical(defaultFn), partial(unary(defaultFn), [obj]), pathOr(defaultFn, path, obj));
24
24
  });
25
25
  export default pathOrLazy;
package/es/reduceP.js CHANGED
@@ -6,7 +6,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
6
6
 
7
7
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
8
8
 
9
- function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
9
+ function _iterableToArrayLimit(arr, i) { var _i = arr && (typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]); if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
10
10
 
11
11
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
12
 
@@ -6,7 +6,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
6
6
 
7
7
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
8
8
 
9
- function _iterableToArrayLimit(arr, i) { if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return; var _arr = []; var _n = true; var _d = false; var _e = undefined; try { for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
9
+ function _iterableToArrayLimit(arr, i) { var _i = arr && (typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]); if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
10
10
 
11
11
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
12
 
package/es/sortByProps.js CHANGED
@@ -6,7 +6,7 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
6
6
 
7
7
  function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
8
8
 
9
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
9
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
10
10
 
11
11
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
12
12
 
package/lib/anyP.js CHANGED
@@ -13,9 +13,9 @@ var _Promise = _interopRequireWildcard(require("./internal/ponyfills/Promise.any
13
13
 
14
14
  exports.AggregatedError = _Promise.AggregatedError;
15
15
 
16
- function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function _getRequireWildcardCache() { return cache; }; return cache; }
16
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
17
17
 
18
- function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
18
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
19
19
 
20
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
21
21
 
package/lib/catchP.js ADDED
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports["default"] = void 0;
5
+
6
+ var _ramda = require("ramda");
7
+
8
+ /**
9
+ * Composable shortcut for `Promise.catch`.
10
+ * The catchP function returns a Promise. It takes two arguments: a callback function for the failure of the Promise
11
+ * and the promise instance itself.
12
+ *
13
+ * @func catchP
14
+ * @memberOf RA
15
+ * @since {@link https://char0n.github.io/ramda-adjunct/2.29.0|v2.29.0}
16
+ * @category Function
17
+ * @sig (a -> Promise b | b) -> Promise b
18
+ * @param {Function} onRejected A Function called if the Promise is rejected. This function has one argument, the rejection reason.
19
+ * @param {Promise} promise Any Promise
20
+ * @return {Promise} Returns a Promise with dealt rejected cases
21
+ * @see {@link RA.thenP|thenP}, {@link RA.resolveP|resolveP}, {@link RA.rejectP|rejectP}, {@link RA.allP|allP}
22
+ *
23
+ * @example
24
+ *
25
+ * RA.catchP(() => 'b', Promise.resolve('a')); //=> Promise('a')
26
+ * RA.catchP(() => 'b', Promise.reject('a')); //=> Promise('b')
27
+ */
28
+ var catchP = (0, _ramda.invoker)(1, 'catch');
29
+ var _default = catchP;
30
+ exports["default"] = _default;
package/lib/dispatch.js CHANGED
@@ -19,7 +19,7 @@ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread n
19
19
 
20
20
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
21
21
 
22
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
22
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
23
23
 
24
24
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
25
25
 
@@ -1,15 +1,19 @@
1
1
  "use strict";
2
2
 
3
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
4
+
3
5
  exports.__esModule = true;
4
6
  exports["default"] = void 0;
5
7
 
6
8
  var _ramda = require("ramda");
7
9
 
8
- var _mapping = _interopRequireDefault(require("./mapping"));
10
+ var fl = _interopRequireWildcard(require("./mapping"));
9
11
 
10
12
  var _traits = require("./traits");
11
13
 
12
- function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
14
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
15
+
16
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
13
17
 
14
18
  function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
15
19
 
@@ -17,16 +21,6 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
17
21
 
18
22
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
19
23
 
20
- // we do this here for jsdocs generate properly
21
- var of = _mapping["default"].of,
22
- _ap = _mapping["default"].ap,
23
- _map = _mapping["default"].map,
24
- _equals = _mapping["default"].equals,
25
- _concat = _mapping["default"].concat,
26
- _chain = _mapping["default"].chain,
27
- _lte = _mapping["default"].lte,
28
- _empty = _mapping["default"].empty,
29
- _contramap = _mapping["default"].contramap;
30
24
  /**
31
25
  * The simplest {@link https://github.com/fantasyland/fantasy-land|fantasy-land}
32
26
  * compatible monad which attaches no information to values.
@@ -50,48 +44,13 @@ var of = _mapping["default"].of,
50
44
  * {@link https://github.com/fantasyland/fantasy-land#contravariant|Contravariant}
51
45
  * @since {@link https://char0n.github.io/ramda-adjunct/1.8.0|v1.8.0}
52
46
  */
53
-
54
47
  var Identity = /*#__PURE__*/function () {
55
- _createClass(Identity, null, [{
56
- key: of,
57
-
58
- /**
59
- * Fantasy land {@link https://github.com/fantasyland/fantasy-land#applicative|Applicative} specification.
60
- *
61
- * @static
62
- * @sig of :: Applicative f => a -> f a
63
- * @param {*} value
64
- * @returns {RA.Identity}
65
- * @example
66
- *
67
- * const a = Identity.of(1); //=> Identity(1)
68
- */
69
- value: function value(_value) {
70
- return new Identity(_value);
71
- }
72
- }, {
73
- key: "of",
74
- value: function of(value) {
75
- return new Identity(value);
76
- }
77
- /**
78
- * @static
79
- */
80
-
81
- }, {
82
- key: '@@type',
83
- get: function get() {
84
- return 'RA/Identity';
85
- }
86
- /**
87
- * Private constructor. Use {@link RA.Identity.of|Identity.of} instead.
88
- *
89
- * @param {*} value
90
- * @return {RA.Identity}
91
- */
92
-
93
- }]);
94
-
48
+ /**
49
+ * Private constructor. Use {@link RA.Identity.of|Identity.of} instead.
50
+ *
51
+ * @param {*} value
52
+ * @return {RA.Identity}
53
+ */
95
54
  function Identity(value) {
96
55
  _classCallCheck(this, Identity);
97
56
 
@@ -127,14 +86,14 @@ var Identity = /*#__PURE__*/function () {
127
86
  */
128
87
 
129
88
  }, {
130
- key: _ap,
89
+ key: fl.ap,
131
90
  value: function value(applyWithFn) {
132
- return _traits.applyTrait[_ap].call(this, applyWithFn);
91
+ return _traits.applyTrait[fl.ap].call(this, applyWithFn);
133
92
  }
134
93
  }, {
135
94
  key: "ap",
136
95
  value: function ap(applyWithFn) {
137
- return this[_ap](applyWithFn);
96
+ return this[fl.ap](applyWithFn);
138
97
  }
139
98
  /**
140
99
  * Fantasy land {@link https://github.com/fantasyland/fantasy-land#functor|Functor} specification.
@@ -149,14 +108,14 @@ var Identity = /*#__PURE__*/function () {
149
108
  */
150
109
 
151
110
  }, {
152
- key: _map,
111
+ key: fl.map,
153
112
  value: function value(fn) {
154
- return _traits.functorTrait[_map].call(this, fn);
113
+ return _traits.functorTrait[fl.map].call(this, fn);
155
114
  }
156
115
  }, {
157
116
  key: "map",
158
117
  value: function map(fn) {
159
- return this[_map](fn);
118
+ return this[fl.map](fn);
160
119
  }
161
120
  /**
162
121
  * Fantasy land {@link https://github.com/fantasyland/fantasy-land#setoid|Setoid} specification.
@@ -175,14 +134,14 @@ var Identity = /*#__PURE__*/function () {
175
134
  */
176
135
 
177
136
  }, {
178
- key: _equals,
137
+ key: fl.equals,
179
138
  value: function value(setoid) {
180
- return _traits.setoidTrait[_equals].call(this, setoid);
139
+ return _traits.setoidTrait[fl.equals].call(this, setoid);
181
140
  }
182
141
  }, {
183
142
  key: "equals",
184
143
  value: function equals(setoid) {
185
- return this[_equals](setoid);
144
+ return this[fl.equals](setoid);
186
145
  }
187
146
  /**
188
147
  * Fantasy land {@link https://github.com/fantasyland/fantasy-land#semigroup|Semigroup} specification.
@@ -206,14 +165,14 @@ var Identity = /*#__PURE__*/function () {
206
165
  */
207
166
 
208
167
  }, {
209
- key: _concat,
168
+ key: fl.concat,
210
169
  value: function value(semigroup) {
211
- return _traits.semigroupTrait[_concat].call(this, semigroup);
170
+ return _traits.semigroupTrait[fl.concat].call(this, semigroup);
212
171
  }
213
172
  }, {
214
173
  key: "concat",
215
174
  value: function concat(semigroup) {
216
- return this[_concat](semigroup);
175
+ return this[fl.concat](semigroup);
217
176
  }
218
177
  /**
219
178
  * Fantasy land {@link https://github.com/fantasyland/fantasy-land#chain|Chain} specification.
@@ -230,14 +189,14 @@ var Identity = /*#__PURE__*/function () {
230
189
  */
231
190
 
232
191
  }, {
233
- key: _chain,
192
+ key: fl.chain,
234
193
  value: function value(fn) {
235
- return _traits.chainTrait[_chain].call(this, fn);
194
+ return _traits.chainTrait[fl.chain].call(this, fn);
236
195
  }
237
196
  }, {
238
197
  key: "chain",
239
198
  value: function chain(fn) {
240
- return this[_chain](fn);
199
+ return this[fl.chain](fn);
241
200
  }
242
201
  /**
243
202
  * Fantasy land {@link https://github.com/fantasyland/fantasy-land#ord|Ord} specification.
@@ -257,14 +216,14 @@ var Identity = /*#__PURE__*/function () {
257
216
  */
258
217
 
259
218
  }, {
260
- key: _lte,
219
+ key: fl.lte,
261
220
  value: function value(ord) {
262
- return _traits.ordTrait[_lte].call(this, ord);
221
+ return _traits.ordTrait[fl.lte].call(this, ord);
263
222
  }
264
223
  }, {
265
224
  key: "lte",
266
225
  value: function lte(ord) {
267
- return this[_lte](ord);
226
+ return this[fl.lte](ord);
268
227
  }
269
228
  /**
270
229
  * Fantasy land {@link https://github.com/fantasyland/fantasy-land#monoid|Monoid*} specification.
@@ -284,14 +243,14 @@ var Identity = /*#__PURE__*/function () {
284
243
  */
285
244
 
286
245
  }, {
287
- key: _empty,
246
+ key: fl.empty,
288
247
  value: function value() {
289
248
  return this.constructor.of((0, _ramda.empty)(this.value));
290
249
  }
291
250
  }, {
292
251
  key: "empty",
293
252
  value: function empty() {
294
- return this[_empty]();
253
+ return this[fl.empty]();
295
254
  }
296
255
  /**
297
256
  * Fantasy land {@link https://github.com/fantasyland/fantasy-land#contravariant|Contravariant} specification.
@@ -311,7 +270,7 @@ var Identity = /*#__PURE__*/function () {
311
270
  */
312
271
 
313
272
  }, {
314
- key: _contramap,
273
+ key: fl.contramap,
315
274
  value: function value(fn) {
316
275
  var _this = this;
317
276
 
@@ -322,7 +281,38 @@ var Identity = /*#__PURE__*/function () {
322
281
  }, {
323
282
  key: "contramap",
324
283
  value: function contramap(fn) {
325
- return this[_contramap](fn);
284
+ return this[fl.contramap](fn);
285
+ }
286
+ }], [{
287
+ key: fl.of,
288
+ value:
289
+ /**
290
+ * Fantasy land {@link https://github.com/fantasyland/fantasy-land#applicative|Applicative} specification.
291
+ *
292
+ * @static
293
+ * @sig of :: Applicative f => a -> f a
294
+ * @param {*} value
295
+ * @returns {RA.Identity}
296
+ * @example
297
+ *
298
+ * const a = Identity.of(1); //=> Identity(1)
299
+ */
300
+ function value(_value) {
301
+ return new Identity(_value);
302
+ }
303
+ }, {
304
+ key: "of",
305
+ value: function of(value) {
306
+ return new Identity(value);
307
+ }
308
+ /**
309
+ * @static
310
+ */
311
+
312
+ }, {
313
+ key: '@@type',
314
+ get: function get() {
315
+ return 'RA/Identity';
326
316
  }
327
317
  }]);
328
318
 
@@ -1,28 +1,44 @@
1
1
  "use strict";
2
2
 
3
3
  exports.__esModule = true;
4
- exports["default"] = void 0;
5
- var mapping = Object.freeze({
6
- equals: 'fantasy-land/equals',
7
- lte: 'fantasy-land/lte',
8
- compose: 'fantasy-land/compose',
9
- id: 'fantasy-land/id',
10
- concat: 'fantasy-land/concat',
11
- empty: 'fantasy-land/empty',
12
- map: 'fantasy-land/map',
13
- contramap: 'fantasy-land/contramap',
14
- ap: 'fantasy-land/ap',
15
- of: 'fantasy-land/of',
16
- alt: 'fantasy-land/alt',
17
- zero: 'fantasy-land/zero',
18
- reduce: 'fantasy-land/reduce',
19
- traverse: 'fantasy-land/traverse',
20
- chain: 'fantasy-land/chain',
21
- chainRec: 'fantasy-land/chainRec',
22
- extend: 'fantasy-land/extend',
23
- extract: 'fantasy-land/extract',
24
- bimap: 'fantasy-land/bimap',
25
- promap: 'fantasy-land/promap'
26
- });
27
- var _default = mapping;
28
- exports["default"] = _default;
4
+ exports.promap = exports.bimap = exports.extract = exports.extend = exports.chainRec = exports.chain = exports.traverse = exports.reduce = exports.zero = exports.alt = exports.of = exports.ap = exports.contramap = exports.map = exports.empty = exports.concat = exports.id = exports.compose = exports.lte = exports.equals = void 0;
5
+ var equals = 'fantasy-land/equals';
6
+ exports.equals = equals;
7
+ var lte = 'fantasy-land/lte';
8
+ exports.lte = lte;
9
+ var compose = 'fantasy-land/compose';
10
+ exports.compose = compose;
11
+ var id = 'fantasy-land/id';
12
+ exports.id = id;
13
+ var concat = 'fantasy-land/concat';
14
+ exports.concat = concat;
15
+ var empty = 'fantasy-land/empty';
16
+ exports.empty = empty;
17
+ var map = 'fantasy-land/map';
18
+ exports.map = map;
19
+ var contramap = 'fantasy-land/contramap';
20
+ exports.contramap = contramap;
21
+ var ap = 'fantasy-land/ap';
22
+ exports.ap = ap;
23
+ var of = 'fantasy-land/of';
24
+ exports.of = of;
25
+ var alt = 'fantasy-land/alt';
26
+ exports.alt = alt;
27
+ var zero = 'fantasy-land/zero';
28
+ exports.zero = zero;
29
+ var reduce = 'fantasy-land/reduce';
30
+ exports.reduce = reduce;
31
+ var traverse = 'fantasy-land/traverse';
32
+ exports.traverse = traverse;
33
+ var chain = 'fantasy-land/chain';
34
+ exports.chain = chain;
35
+ var chainRec = 'fantasy-land/chainRec';
36
+ exports.chainRec = chainRec;
37
+ var extend = 'fantasy-land/extend';
38
+ exports.extend = extend;
39
+ var extract = 'fantasy-land/extract';
40
+ exports.extract = extract;
41
+ var bimap = 'fantasy-land/bimap';
42
+ exports.bimap = bimap;
43
+ var promap = 'fantasy-land/promap';
44
+ exports.promap = promap;
@@ -1,5 +1,7 @@
1
1
  "use strict";
2
2
 
3
+ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }
4
+
3
5
  exports.__esModule = true;
4
6
  exports.ordTrait = exports.chainTrait = exports.semigroupTrait = exports.setoidTrait = exports.applyTrait = exports.functorTrait = void 0;
5
7
 
@@ -13,19 +15,23 @@ var _isFunction = _interopRequireDefault(require("../isFunction"));
13
15
 
14
16
  var _util = require("./util");
15
17
 
16
- var _mapping = _interopRequireDefault(require("./mapping"));
18
+ var fl = _interopRequireWildcard(require("./mapping"));
19
+
20
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
21
+
22
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
17
23
 
18
24
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
19
25
 
20
26
  function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
21
27
 
22
- var functorTrait = _defineProperty({}, _mapping["default"].map, function (fn) {
23
- return this.constructor[_mapping["default"].of](fn(this.value));
28
+ var functorTrait = _defineProperty({}, fl.map, function (fn) {
29
+ return this.constructor[fl.of](fn(this.value));
24
30
  });
25
31
 
26
32
  exports.functorTrait = functorTrait;
27
33
 
28
- var applyTrait = _defineProperty({}, _mapping["default"].ap, function (applyWithFn) {
34
+ var applyTrait = _defineProperty({}, fl.ap, function (applyWithFn) {
29
35
  var _this = this;
30
36
 
31
37
  return applyWithFn.map(function (fn) {
@@ -35,37 +41,37 @@ var applyTrait = _defineProperty({}, _mapping["default"].ap, function (applyWith
35
41
 
36
42
  exports.applyTrait = applyTrait;
37
43
 
38
- var setoidTrait = _defineProperty({}, _mapping["default"].equals, function (setoid) {
44
+ var setoidTrait = _defineProperty({}, fl.equals, function (setoid) {
39
45
  return (0, _util.isSameType)(this, setoid) && (0, _ramda.equals)(this.value, setoid.value);
40
46
  });
41
47
 
42
48
  exports.setoidTrait = setoidTrait;
43
49
 
44
- var semigroupTrait = _defineProperty({}, _mapping["default"].concat, function (semigroup) {
50
+ var semigroupTrait = _defineProperty({}, fl.concat, function (semigroup) {
45
51
  var concatenatedValue = this.value;
46
52
 
47
53
  if ((0, _isString["default"])(this.value) || (0, _isNumber["default"])(this.value)) {
48
54
  concatenatedValue = this.value + semigroup.value;
49
- } else if ((0, _ramda.pathSatisfies)(_isFunction["default"], ['value', _mapping["default"].concat], this)) {
50
- concatenatedValue = this.value[_mapping["default"].concat](semigroup.value);
55
+ } else if ((0, _ramda.pathSatisfies)(_isFunction["default"], ['value', fl.concat], this)) {
56
+ concatenatedValue = this.value[fl.concat](semigroup.value);
51
57
  } else if ((0, _ramda.pathSatisfies)(_isFunction["default"], ['value', 'concat'], this)) {
52
58
  concatenatedValue = this.value.concat(semigroup.value);
53
59
  }
54
60
 
55
- return this.constructor[_mapping["default"].of](concatenatedValue);
61
+ return this.constructor[fl.of](concatenatedValue);
56
62
  });
57
63
 
58
64
  exports.semigroupTrait = semigroupTrait;
59
65
 
60
- var chainTrait = _defineProperty({}, _mapping["default"].chain, function (fn) {
66
+ var chainTrait = _defineProperty({}, fl.chain, function (fn) {
61
67
  var newChain = fn(this.value);
62
68
  return (0, _util.isSameType)(this, newChain) ? newChain : this;
63
69
  });
64
70
 
65
71
  exports.chainTrait = chainTrait;
66
72
 
67
- var ordTrait = _defineProperty({}, _mapping["default"].lte, function (ord) {
68
- return (0, _util.isSameType)(this, ord) && (this.value < ord.value || this[_mapping["default"].equals](ord));
73
+ var ordTrait = _defineProperty({}, fl.lte, function (ord) {
74
+ return (0, _util.isSameType)(this, ord) && (this.value < ord.value || this[fl.equals](ord));
69
75
  });
70
76
 
71
77
  exports.ordTrait = ordTrait;
@@ -0,0 +1,33 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports["default"] = void 0;
5
+
6
+ var _ramda = require("ramda");
7
+
8
+ /**
9
+ * {@link http://ramdajs.com/docs/#filter|R.filter} function that more closely resembles `Array.prototype.filter`.
10
+ * It takes two new parameters to its callback function: the current index, and the entire list.
11
+ *
12
+ * `filterIndexed` implementation is simple: `
13
+ * const filterIndexed = R.addIndex(R.filter);
14
+ * `
15
+ *
16
+ * @func filterIndexed
17
+ * @memberOf RA
18
+ * @since {@link https://char0n.github.io/ramda-adjunct/2.31.0|v2.31.0}
19
+ * @category List
20
+ * @typedef Idx = Number
21
+ * @sig Filterable f => ((a, Idx, f a) -> Boolean) -> f a -> f a
22
+ * @param {Function} pred The predicate function
23
+ * @param {Array} list The collection to filter
24
+ * @return {Array} Filterable
25
+ * @see {@link http://ramdajs.com/docs/#addIndex|R.addIndex}, {@link http://ramdajs.com/docs/#filter|R.filter}
26
+ * @example
27
+ *
28
+ * const isValueGtIndex = (val, idx) => val > idx;
29
+ * RA.filterIndexed(isValueGtIndex, [5, 4, 3, 2, 1, 0]); //=> [5, 4, 3]
30
+ */
31
+ var filterIndexed = (0, _ramda.addIndex)(_ramda.filter);
32
+ var _default = filterIndexed;
33
+ exports["default"] = _default;
package/lib/findOr.js ADDED
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports["default"] = void 0;
5
+
6
+ var _ramda = require("ramda");
7
+
8
+ /**
9
+ * Returns the first element of the list which matches the predicate.
10
+ * Returns default value if no element matches or matched element is `null`, `undefined` or `NaN`.
11
+ * Dispatches to the find method of the second argument, if present.
12
+ * Acts as a transducer if a transformer is given in list position.
13
+ *
14
+ * @func findOr
15
+ * @memberOf RA
16
+ * @since {@link https://char0n.github.io/ramda-adjunct/2.32.0|v2.32.0}
17
+ * @category List
18
+ * @sig a -> (b -> Boolean) -> [b] -> b | a
19
+ * @param {*} defaultValue The default value
20
+ * @param {Function} fn The predicate function used to determine if the element is the desired one.
21
+ * @param {Array} list The array to consider.
22
+ * @return {*} The element found, or the default value.
23
+ * @see {@link http://ramdajs.com/docs/#defaultTo|R.defaultTo}, {@link http://ramdajs.com/docs/#find|R.find}
24
+ * @example
25
+ *
26
+ * RA.findOr(1, isUndefined, [1, 2, undefined]); // => 1
27
+ * RA.findOr(1, val => val === 2, [1, 2, undefined]); // => 2
28
+ * RA.findOr(1, val => val === 3, [1, 2, undefined]); // => 1
29
+ */
30
+ var findOr = (0, _ramda.curry)(function (defaultVal, fn, list) {
31
+ return (0, _ramda.pipe)((0, _ramda.find)(fn), (0, _ramda.defaultTo)(defaultVal))(list);
32
+ });
33
+ var _default = findOr;
34
+ exports["default"] = _default;
@@ -15,7 +15,7 @@ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread n
15
15
 
16
16
  function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
17
17
 
18
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter); }
18
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
19
19
 
20
20
  function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
21
21