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
package/es/catchP.js ADDED
@@ -0,0 +1,24 @@
1
+ import { invoker } from 'ramda';
2
+ /**
3
+ * Composable shortcut for `Promise.catch`.
4
+ * The catchP function returns a Promise. It takes two arguments: a callback function for the failure of the Promise
5
+ * and the promise instance itself.
6
+ *
7
+ * @func catchP
8
+ * @memberOf RA
9
+ * @since {@link https://char0n.github.io/ramda-adjunct/2.29.0|v2.29.0}
10
+ * @category Function
11
+ * @sig (a -> Promise b | b) -> Promise b
12
+ * @param {Function} onRejected A Function called if the Promise is rejected. This function has one argument, the rejection reason.
13
+ * @param {Promise} promise Any Promise
14
+ * @return {Promise} Returns a Promise with dealt rejected cases
15
+ * @see {@link RA.thenP|thenP}, {@link RA.resolveP|resolveP}, {@link RA.rejectP|rejectP}, {@link RA.allP|allP}
16
+ *
17
+ * @example
18
+ *
19
+ * RA.catchP(() => 'b', Promise.resolve('a')); //=> Promise('a')
20
+ * RA.catchP(() => 'b', Promise.reject('a')); //=> Promise('b')
21
+ */
22
+
23
+ var catchP = invoker(1, 'catch');
24
+ export default catchP;
package/es/dispatch.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
 
@@ -5,18 +5,8 @@ function _defineProperties(target, props) { for (var i = 0; i < props.length; i+
5
5
  function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }
6
6
 
7
7
  import { empty as emptyR } from 'ramda';
8
- import fl from './mapping';
9
- import { applyTrait, functorTrait, setoidTrait, semigroupTrait, chainTrait, ordTrait } from './traits'; // we do this here for jsdocs generate properly
10
-
11
- var of = fl.of,
12
- _ap = fl.ap,
13
- _map = fl.map,
14
- _equals = fl.equals,
15
- _concat = fl.concat,
16
- _chain = fl.chain,
17
- _lte = fl.lte,
18
- _empty = fl.empty,
19
- _contramap = fl.contramap;
8
+ import * as fl from './mapping';
9
+ import { applyTrait, functorTrait, setoidTrait, semigroupTrait, chainTrait, ordTrait } from './traits';
20
10
  /**
21
11
  * The simplest {@link https://github.com/fantasyland/fantasy-land|fantasy-land}
22
12
  * compatible monad which attaches no information to values.
@@ -42,46 +32,12 @@ var of = fl.of,
42
32
  */
43
33
 
44
34
  var Identity = /*#__PURE__*/function () {
45
- _createClass(Identity, null, [{
46
- key: of,
47
-
48
- /**
49
- * Fantasy land {@link https://github.com/fantasyland/fantasy-land#applicative|Applicative} specification.
50
- *
51
- * @static
52
- * @sig of :: Applicative f => a -> f a
53
- * @param {*} value
54
- * @returns {RA.Identity}
55
- * @example
56
- *
57
- * const a = Identity.of(1); //=> Identity(1)
58
- */
59
- value: function value(_value) {
60
- return new Identity(_value);
61
- }
62
- }, {
63
- key: "of",
64
- value: function of(value) {
65
- return new Identity(value);
66
- }
67
- /**
68
- * @static
69
- */
70
-
71
- }, {
72
- key: '@@type',
73
- get: function get() {
74
- return 'RA/Identity';
75
- }
76
- /**
77
- * Private constructor. Use {@link RA.Identity.of|Identity.of} instead.
78
- *
79
- * @param {*} value
80
- * @return {RA.Identity}
81
- */
82
-
83
- }]);
84
-
35
+ /**
36
+ * Private constructor. Use {@link RA.Identity.of|Identity.of} instead.
37
+ *
38
+ * @param {*} value
39
+ * @return {RA.Identity}
40
+ */
85
41
  function Identity(value) {
86
42
  _classCallCheck(this, Identity);
87
43
 
@@ -117,14 +73,14 @@ var Identity = /*#__PURE__*/function () {
117
73
  */
118
74
 
119
75
  }, {
120
- key: _ap,
76
+ key: fl.ap,
121
77
  value: function value(applyWithFn) {
122
- return applyTrait[_ap].call(this, applyWithFn);
78
+ return applyTrait[fl.ap].call(this, applyWithFn);
123
79
  }
124
80
  }, {
125
81
  key: "ap",
126
82
  value: function ap(applyWithFn) {
127
- return this[_ap](applyWithFn);
83
+ return this[fl.ap](applyWithFn);
128
84
  }
129
85
  /**
130
86
  * Fantasy land {@link https://github.com/fantasyland/fantasy-land#functor|Functor} specification.
@@ -139,14 +95,14 @@ var Identity = /*#__PURE__*/function () {
139
95
  */
140
96
 
141
97
  }, {
142
- key: _map,
98
+ key: fl.map,
143
99
  value: function value(fn) {
144
- return functorTrait[_map].call(this, fn);
100
+ return functorTrait[fl.map].call(this, fn);
145
101
  }
146
102
  }, {
147
103
  key: "map",
148
104
  value: function map(fn) {
149
- return this[_map](fn);
105
+ return this[fl.map](fn);
150
106
  }
151
107
  /**
152
108
  * Fantasy land {@link https://github.com/fantasyland/fantasy-land#setoid|Setoid} specification.
@@ -165,14 +121,14 @@ var Identity = /*#__PURE__*/function () {
165
121
  */
166
122
 
167
123
  }, {
168
- key: _equals,
124
+ key: fl.equals,
169
125
  value: function value(setoid) {
170
- return setoidTrait[_equals].call(this, setoid);
126
+ return setoidTrait[fl.equals].call(this, setoid);
171
127
  }
172
128
  }, {
173
129
  key: "equals",
174
130
  value: function equals(setoid) {
175
- return this[_equals](setoid);
131
+ return this[fl.equals](setoid);
176
132
  }
177
133
  /**
178
134
  * Fantasy land {@link https://github.com/fantasyland/fantasy-land#semigroup|Semigroup} specification.
@@ -196,14 +152,14 @@ var Identity = /*#__PURE__*/function () {
196
152
  */
197
153
 
198
154
  }, {
199
- key: _concat,
155
+ key: fl.concat,
200
156
  value: function value(semigroup) {
201
- return semigroupTrait[_concat].call(this, semigroup);
157
+ return semigroupTrait[fl.concat].call(this, semigroup);
202
158
  }
203
159
  }, {
204
160
  key: "concat",
205
161
  value: function concat(semigroup) {
206
- return this[_concat](semigroup);
162
+ return this[fl.concat](semigroup);
207
163
  }
208
164
  /**
209
165
  * Fantasy land {@link https://github.com/fantasyland/fantasy-land#chain|Chain} specification.
@@ -220,14 +176,14 @@ var Identity = /*#__PURE__*/function () {
220
176
  */
221
177
 
222
178
  }, {
223
- key: _chain,
179
+ key: fl.chain,
224
180
  value: function value(fn) {
225
- return chainTrait[_chain].call(this, fn);
181
+ return chainTrait[fl.chain].call(this, fn);
226
182
  }
227
183
  }, {
228
184
  key: "chain",
229
185
  value: function chain(fn) {
230
- return this[_chain](fn);
186
+ return this[fl.chain](fn);
231
187
  }
232
188
  /**
233
189
  * Fantasy land {@link https://github.com/fantasyland/fantasy-land#ord|Ord} specification.
@@ -247,14 +203,14 @@ var Identity = /*#__PURE__*/function () {
247
203
  */
248
204
 
249
205
  }, {
250
- key: _lte,
206
+ key: fl.lte,
251
207
  value: function value(ord) {
252
- return ordTrait[_lte].call(this, ord);
208
+ return ordTrait[fl.lte].call(this, ord);
253
209
  }
254
210
  }, {
255
211
  key: "lte",
256
212
  value: function lte(ord) {
257
- return this[_lte](ord);
213
+ return this[fl.lte](ord);
258
214
  }
259
215
  /**
260
216
  * Fantasy land {@link https://github.com/fantasyland/fantasy-land#monoid|Monoid*} specification.
@@ -274,14 +230,14 @@ var Identity = /*#__PURE__*/function () {
274
230
  */
275
231
 
276
232
  }, {
277
- key: _empty,
233
+ key: fl.empty,
278
234
  value: function value() {
279
235
  return this.constructor.of(emptyR(this.value));
280
236
  }
281
237
  }, {
282
238
  key: "empty",
283
239
  value: function empty() {
284
- return this[_empty]();
240
+ return this[fl.empty]();
285
241
  }
286
242
  /**
287
243
  * Fantasy land {@link https://github.com/fantasyland/fantasy-land#contravariant|Contravariant} specification.
@@ -301,7 +257,7 @@ var Identity = /*#__PURE__*/function () {
301
257
  */
302
258
 
303
259
  }, {
304
- key: _contramap,
260
+ key: fl.contramap,
305
261
  value: function value(fn) {
306
262
  var _this = this;
307
263
 
@@ -312,7 +268,38 @@ var Identity = /*#__PURE__*/function () {
312
268
  }, {
313
269
  key: "contramap",
314
270
  value: function contramap(fn) {
315
- return this[_contramap](fn);
271
+ return this[fl.contramap](fn);
272
+ }
273
+ }], [{
274
+ key: fl.of,
275
+ value:
276
+ /**
277
+ * Fantasy land {@link https://github.com/fantasyland/fantasy-land#applicative|Applicative} specification.
278
+ *
279
+ * @static
280
+ * @sig of :: Applicative f => a -> f a
281
+ * @param {*} value
282
+ * @returns {RA.Identity}
283
+ * @example
284
+ *
285
+ * const a = Identity.of(1); //=> Identity(1)
286
+ */
287
+ function value(_value) {
288
+ return new Identity(_value);
289
+ }
290
+ }, {
291
+ key: "of",
292
+ value: function of(value) {
293
+ return new Identity(value);
294
+ }
295
+ /**
296
+ * @static
297
+ */
298
+
299
+ }, {
300
+ key: '@@type',
301
+ get: function get() {
302
+ return 'RA/Identity';
316
303
  }
317
304
  }]);
318
305
 
@@ -1,23 +1,20 @@
1
- var mapping = Object.freeze({
2
- equals: 'fantasy-land/equals',
3
- lte: 'fantasy-land/lte',
4
- compose: 'fantasy-land/compose',
5
- id: 'fantasy-land/id',
6
- concat: 'fantasy-land/concat',
7
- empty: 'fantasy-land/empty',
8
- map: 'fantasy-land/map',
9
- contramap: 'fantasy-land/contramap',
10
- ap: 'fantasy-land/ap',
11
- of: 'fantasy-land/of',
12
- alt: 'fantasy-land/alt',
13
- zero: 'fantasy-land/zero',
14
- reduce: 'fantasy-land/reduce',
15
- traverse: 'fantasy-land/traverse',
16
- chain: 'fantasy-land/chain',
17
- chainRec: 'fantasy-land/chainRec',
18
- extend: 'fantasy-land/extend',
19
- extract: 'fantasy-land/extract',
20
- bimap: 'fantasy-land/bimap',
21
- promap: 'fantasy-land/promap'
22
- });
23
- export default mapping;
1
+ export var equals = 'fantasy-land/equals';
2
+ export var lte = 'fantasy-land/lte';
3
+ export var compose = 'fantasy-land/compose';
4
+ export var id = 'fantasy-land/id';
5
+ export var concat = 'fantasy-land/concat';
6
+ export var empty = 'fantasy-land/empty';
7
+ export var map = 'fantasy-land/map';
8
+ export var contramap = 'fantasy-land/contramap';
9
+ export var ap = 'fantasy-land/ap';
10
+ export var of = 'fantasy-land/of';
11
+ export var alt = 'fantasy-land/alt';
12
+ export var zero = 'fantasy-land/zero';
13
+ export var reduce = 'fantasy-land/reduce';
14
+ export var traverse = 'fantasy-land/traverse';
15
+ export var chain = 'fantasy-land/chain';
16
+ export var chainRec = 'fantasy-land/chainRec';
17
+ export var extend = 'fantasy-land/extend';
18
+ export var extract = 'fantasy-land/extract';
19
+ export var bimap = 'fantasy-land/bimap';
20
+ export var promap = 'fantasy-land/promap';
@@ -5,7 +5,7 @@ import isString from '../isString';
5
5
  import isNumber from '../isNumber';
6
6
  import isFunction from '../isFunction';
7
7
  import { isSameType } from './util';
8
- import fl from './mapping';
8
+ import * as fl from './mapping';
9
9
  export var functorTrait = _defineProperty({}, fl.map, function (fn) {
10
10
  return this.constructor[fl.of](fn(this.value));
11
11
  });
@@ -0,0 +1,27 @@
1
+ import { addIndex, filter } from 'ramda';
2
+ /**
3
+ * {@link http://ramdajs.com/docs/#filter|R.filter} function that more closely resembles `Array.prototype.filter`.
4
+ * It takes two new parameters to its callback function: the current index, and the entire list.
5
+ *
6
+ * `filterIndexed` implementation is simple: `
7
+ * const filterIndexed = R.addIndex(R.filter);
8
+ * `
9
+ *
10
+ * @func filterIndexed
11
+ * @memberOf RA
12
+ * @since {@link https://char0n.github.io/ramda-adjunct/2.31.0|v2.31.0}
13
+ * @category List
14
+ * @typedef Idx = Number
15
+ * @sig Filterable f => ((a, Idx, f a) -> Boolean) -> f a -> f a
16
+ * @param {Function} pred The predicate function
17
+ * @param {Array} list The collection to filter
18
+ * @return {Array} Filterable
19
+ * @see {@link http://ramdajs.com/docs/#addIndex|R.addIndex}, {@link http://ramdajs.com/docs/#filter|R.filter}
20
+ * @example
21
+ *
22
+ * const isValueGtIndex = (val, idx) => val > idx;
23
+ * RA.filterIndexed(isValueGtIndex, [5, 4, 3, 2, 1, 0]); //=> [5, 4, 3]
24
+ */
25
+
26
+ var filterIndexed = addIndex(filter);
27
+ export default filterIndexed;
package/es/findOr.js ADDED
@@ -0,0 +1,28 @@
1
+ import { pipe, curry, find, defaultTo } from 'ramda';
2
+ /**
3
+ * Returns the first element of the list which matches the predicate.
4
+ * Returns default value if no element matches or matched element is `null`, `undefined` or `NaN`.
5
+ * Dispatches to the find method of the second argument, if present.
6
+ * Acts as a transducer if a transformer is given in list position.
7
+ *
8
+ * @func findOr
9
+ * @memberOf RA
10
+ * @since {@link https://char0n.github.io/ramda-adjunct/2.32.0|v2.32.0}
11
+ * @category List
12
+ * @sig a -> (b -> Boolean) -> [b] -> b | a
13
+ * @param {*} defaultValue The default value
14
+ * @param {Function} fn The predicate function used to determine if the element is the desired one.
15
+ * @param {Array} list The array to consider.
16
+ * @return {*} The element found, or the default value.
17
+ * @see {@link http://ramdajs.com/docs/#defaultTo|R.defaultTo}, {@link http://ramdajs.com/docs/#find|R.find}
18
+ * @example
19
+ *
20
+ * RA.findOr(1, isUndefined, [1, 2, undefined]); // => 1
21
+ * RA.findOr(1, val => val === 2, [1, 2, undefined]); // => 2
22
+ * RA.findOr(1, val => val === 3, [1, 2, undefined]); // => 1
23
+ */
24
+
25
+ var findOr = curry(function (defaultVal, fn, list) {
26
+ return pipe(find(fn), defaultTo(defaultVal))(list);
27
+ });
28
+ export default findOr;
@@ -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/index.js CHANGED
@@ -66,6 +66,9 @@ export { default as isNotNaN } from './isNotNaN';
66
66
  export { default as isFinite } from './isFinite';
67
67
  export { default as isNotFinite } from './isNotFinite';
68
68
  export { default as isInteger } from './isInteger';
69
+ export { default as isInteger32 } from './isInteger32';
70
+ export { default as isInt32 } from './isInteger32'; // alias of isInteger32
71
+
69
72
  export { default as isNotInteger } from './isNotInteger';
70
73
  export { default as isBigInt } from './isBigInt';
71
74
  export { default as isFloat } from './isFloat';
@@ -91,7 +94,10 @@ export { default as isSymbol } from './isSymbol';
91
94
  export { default as isSafeInteger } from './isSafeInteger';
92
95
  export { default as isIndexed } from './isIndexed';
93
96
  export { default as isError } from './isError';
94
- export { default as isNaturalNumber } from './isNaturalNumber'; // Function
97
+ export { default as isNaturalNumber } from './isNaturalNumber';
98
+ export { default as isPrimitive } from './isPrimitive';
99
+ export { default as isNotPrimitive } from './isNotPrimitive';
100
+ export { default as isSentinelValue } from './isSentinelValue'; // Function
95
101
 
96
102
  export { default as stubUndefined } from './stubUndefined';
97
103
  export { default as stubNull } from './stubNull';
@@ -108,6 +114,7 @@ export { default as weaveLazy } from './weaveLazy';
108
114
  export { default as curryRightN } from './curryRightN';
109
115
  export { default as curryRight } from './curryRight';
110
116
  export { default as allP } from './allP';
117
+ export { default as catchP } from './catchP';
111
118
  export { default as noneP } from './noneP';
112
119
  export { default as resolveP } from './resolveP';
113
120
  export { default as rejectP } from './rejectP';
@@ -129,6 +136,7 @@ export { default as fnull } from './fnull'; // List
129
136
 
130
137
  export { default as mapIndexed } from './mapIndexed';
131
138
  export { default as reduceIndexed } from './reduceIndexed';
139
+ export { default as filterIndexed } from './filterIndexed';
132
140
  export { default as pickIndexes } from './pickIndexes';
133
141
  export { default as list } from './list';
134
142
  export { default as ensureArray } from './ensureArray';
@@ -161,8 +169,10 @@ export { default as allUnique } from './allUnique';
161
169
  export { default as notAllUnique } from './notAllUnique';
162
170
  export { default as sortByProps } from './sortByProps';
163
171
  export { default as skipTake } from './skipTake';
164
- export { default as rangeStep } from './rangeStep'; // Object
172
+ export { default as rangeStep } from './rangeStep';
173
+ export { default as findOr } from './findOr'; // Object
165
174
 
175
+ export { default as invoke } from './invoke';
166
176
  export { default as invokeArgs } from './invokeArgs';
167
177
  export { default as paths } from './paths';
168
178
  export { default as renameKeys } from './renameKeys';
@@ -184,7 +194,8 @@ export { default as spreadPath } from './spreadPath';
184
194
  export { default as flattenProp } from './flattenProp';
185
195
  export { default as flattenPath } from './flattenPath';
186
196
  export { default as unzipObjWith } from './unzipObjWith';
187
- export { default as zipObjWith } from './zipObjWith'; // Relation
197
+ export { default as zipObjWith } from './zipObjWith';
198
+ export { default as isPrototypeOf } from './isPrototypeOf'; // Relation
188
199
 
189
200
  export { default as lensEq } from './lensEq';
190
201
  export { default as lensNotEq } from './lensNotEq';
package/es/internal/ap.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { ap as apR, curryN, pathSatisfies, both, either } from 'ramda';
2
2
  import isFunction from '../isFunction';
3
- import fl from '../fantasy-land/mapping';
3
+ import * as fl from '../fantasy-land/mapping';
4
4
  var isFunctor = either(pathSatisfies(isFunction, ['map']), pathSatisfies(isFunction, [fl.map]));
5
5
  var isApply = both(isFunctor, either(pathSatisfies(isFunction, ['ap']), pathSatisfies(isFunction, [fl.ap])));
6
6
  var ap = curryN(2, function (applyF, applyX) {
@@ -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
 
@@ -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
 
@@ -6,7 +6,7 @@ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread n
6
6
 
7
7
  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); }
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 _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
12
12
 
@@ -26,7 +26,7 @@ function _wrapNativeSuper(Class) { var _cache = typeof Map === "function" ? new
26
26
 
27
27
  function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct; } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
28
28
 
29
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
29
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
30
30
 
31
31
  function _isNativeFunction(fn) { return Function.toString.call(fn).indexOf("[native code]") !== -1; }
32
32
 
package/es/invoke.js ADDED
@@ -0,0 +1,20 @@
1
+ import { __ } from 'ramda';
2
+ import invokeArgs from './invokeArgs';
3
+ /**
4
+ * Invokes the method at path of object.
5
+ *
6
+ * @func invoke
7
+ * @memberOf RA
8
+ * @since {@link https://char0n.github.io/ramda-adjunct/2.31.0|v2.31.0}
9
+ * @category Object
10
+ * @sig Array -> Object -> *
11
+ * @param {Array.<string|number>} path The path of the method to invoke
12
+ * @param {Object} obj The object to query
13
+ * @return {*}
14
+ * @example
15
+ *
16
+ * RA.invoke(['random'], Math); //=> 0.5113253820009047
17
+ */
18
+
19
+ var invoke = invokeArgs(__, [], __);
20
+ export default invoke;
@@ -0,0 +1,28 @@
1
+ import { curryN } from 'ramda';
2
+ import toInteger32 from './toInteger32';
3
+ /**
4
+ * Checks whether the passed value is a signed 32 bit integer.
5
+ *
6
+ * @func isInteger32
7
+ * @aliases isInt32
8
+ * @memberOf RA
9
+ * @since {@link https://char0n.github.io/ramda-adjunct/2.32.0|v2.32.0}
10
+ * @category Type
11
+ * @sig * -> Boolean
12
+ * @param {*} val The value to test
13
+ * @return {boolean}
14
+ * @see {@link RA.toInteger32|toInteger32}
15
+ * @example
16
+ *
17
+ * RA.isInteger32(0); //=> true
18
+ * RA.isInteger32((-2) ** 31); //=> true
19
+ *
20
+ * RA.isInteger32(Infinity); //=> false
21
+ * RA.isInteger32(NaN); //=> false
22
+ * RA.isInteger32(2 ** 31); //=> false
23
+ */
24
+
25
+ var isInteger32 = curryN(1, function (val) {
26
+ return toInteger32(val) === val;
27
+ });
28
+ export default isInteger32;
@@ -0,0 +1,22 @@
1
+ import { complement, curryN } from 'ramda';
2
+ import isPrimitive from './isPrimitive';
3
+ /**
4
+ * Checks if value is not a primitive data type. There are 6 primitive data types: `string`, `number`, `bigint`, `boolean`, `undefined`, `symbol` and a special case of `null`.
5
+ *
6
+ * @func isNotPrimitive
7
+ * @category Type
8
+ * @sig * -> Boolean
9
+ * @since {@link https://char0n.github.io/ramda-adjunct/2.32.0|v2.32.0}
10
+ * @param {*} val The value to test
11
+ * @return {boolean}
12
+ * @see {@link RA.isPrimitive|isPrimitive}, {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#primitive_values|MDN Primitive values}, {@link https://developer.mozilla.org/en-US/docs/Glossary/Primitive|MDN Primitive}
13
+ * @example
14
+ *
15
+ * RA.isNotPrimitive(new String("string")); //=> true
16
+ * RA.isNotPrimitive(new Number(1)); //=> true
17
+ * RA.isNotPrimitive("string"); //=> false
18
+ * RA.isNotPrimitive(1); //=> false
19
+ */
20
+
21
+ var isNotPrimitive = curryN(1, complement(isPrimitive));
22
+ export default isNotPrimitive;
@@ -0,0 +1,31 @@
1
+ import { both, anyPass } from 'ramda';
2
+ import isNotObj from './isNotObj';
3
+ import isString from './isString';
4
+ import isNumber from './isNumber';
5
+ import isBigInt from './isBigInt';
6
+ import isBoolean from './isBoolean';
7
+ import isUndefined from './isUndefined';
8
+ import isNull from './isNull';
9
+ import isSymbol from './isSymbol';
10
+ /**
11
+ * Checks if value is a primitive data type. There are 6 primitive data types: `string`, `number`, `bigint`, `boolean`, `undefined`, `symbol` and a special case of `null`.
12
+ * See https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#Primitive_values
13
+ * for definition of what sub-types comprise a primitive.
14
+ *
15
+ * @func isPrimitive
16
+ * @category Type
17
+ * @sig * -> Boolean
18
+ * @since {@link https://char0n.github.io/ramda-adjunct/2.32.0|v2.32.0}
19
+ * @param {*} val The value to test
20
+ * @return {boolean}
21
+ * @see {@link RA.isNotPrimitive|isNotPrimitive}, {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Data_structures#primitive_values|MDN Primitive values}, {@link https://developer.mozilla.org/en-US/docs/Glossary/Primitive|MDN Primitive}
22
+ * @example
23
+ *
24
+ * RA.isPrimitive("string"); //=> true
25
+ * RA.isPrimitive(1); //=> true
26
+ * RA.isPrimitive(new String("string")); //=> false
27
+ * RA.isPrimitive(new Number(1)); //=> false
28
+ */
29
+
30
+ var isPrimitive = both(isNotObj, anyPass([isString, isNumber, isBigInt, isBoolean, isUndefined, isNull, isSymbol]));
31
+ export default isPrimitive;
@@ -0,0 +1,34 @@
1
+ import { curry } from 'ramda';
2
+ import invokeArgs from './invokeArgs';
3
+ /**
4
+ * Checks if an object exists in another object's prototype chain.
5
+ *
6
+ * @func isPrototypeOf
7
+ * @category Object
8
+ * @memberOf RA
9
+ * @since {@link https://char0n.github.io/ramda-adjunct/2.31.0|v2.31.0}
10
+ * @sig * -> Boolean
11
+ * @param {Object} type The prototype that we're searching for
12
+ * @param {Object} object The object whose prototype chain will be searched
13
+ * @return {boolean}
14
+ * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/isPrototypeOf|Object.prorotype.isPrototypeOf}
15
+ * @example
16
+ * function Foo() {}
17
+ * function Bar() {}
18
+ * function Baz() {}
19
+ *
20
+ * Bar.prototype = Object.create(Foo.prototype);
21
+ * Baz.prototype = Object.create(Bar.prototype);
22
+ *
23
+ * const baz = new Baz();
24
+ *
25
+ * RA.isPrototypeOf(Baz, baz); // => true
26
+ * RA.isPrototypeOf(Bar, baz); // => true
27
+ * RA.isPrototypeOf(Foo, baz); // => true
28
+ * RA.isPrototypeOf(Object, baz); // => true
29
+ */
30
+
31
+ var isPrototypeOf = curry(function (type, object) {
32
+ return Boolean(invokeArgs(['prototype', 'isPrototypeOf'], [object], type));
33
+ });
34
+ export default isPrototypeOf;