ramda-adjunct 2.31.1 → 2.35.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/.nvmrc +1 -0
- package/CHANGELOG.md +48 -0
- package/README.md +3 -3
- package/dist/RA.node.js +1144 -797
- package/dist/RA.node.min.js +1 -1
- package/dist/RA.web.js +1144 -797
- package/dist/RA.web.min.js +1 -1
- package/dist/RA.web.standalone.js +1782 -1435
- package/dist/RA.web.standalone.min.js +1 -1
- package/es/catchP.js +24 -0
- package/es/copyKeys.js +34 -0
- package/es/dispatch.js +1 -1
- package/es/fantasy-land/Identity.js +63 -76
- package/es/fantasy-land/mapping.js +20 -23
- package/es/fantasy-land/traits.js +1 -1
- package/es/findOr.js +28 -0
- package/es/flattenDepth.js +1 -1
- package/es/index.js +11 -2
- package/es/internal/ap.js +1 -1
- package/es/internal/ponyfills/Array.from.js +1 -1
- package/es/internal/ponyfills/Promise.allSettled.js +1 -1
- package/es/internal/ponyfills/Promise.any.js +3 -3
- package/es/isInteger32.js +28 -0
- package/es/isNotPrimitive.js +22 -0
- package/es/isPrimitive.js +31 -0
- package/es/isSentinelValue.js +26 -0
- package/es/lastP.js +1 -1
- package/es/reduceP.js +1 -1
- package/es/reduceRightP.js +1 -1
- package/es/sortByProps.js +1 -1
- package/lib/anyP.js +2 -2
- package/lib/catchP.js +30 -0
- package/lib/copyKeys.js +43 -0
- package/lib/dispatch.js +1 -1
- package/lib/fantasy-land/Identity.js +67 -77
- package/lib/fantasy-land/mapping.js +41 -25
- package/lib/fantasy-land/traits.js +18 -12
- package/lib/findOr.js +34 -0
- package/lib/flattenDepth.js +1 -1
- package/lib/index.js +32 -3
- package/lib/internal/ap.js +9 -3
- package/lib/internal/ponyfills/Array.from.js +1 -1
- package/lib/internal/ponyfills/Promise.allSettled.js +1 -1
- package/lib/internal/ponyfills/Promise.any.js +3 -3
- package/lib/isInteger32.js +37 -0
- package/lib/isNotPrimitive.js +31 -0
- package/lib/isPrimitive.js +47 -0
- package/lib/isSentinelValue.js +35 -0
- package/lib/lastP.js +1 -1
- package/lib/reduceP.js +1 -1
- package/lib/reduceRightP.js +1 -1
- package/lib/sortByProps.js +1 -1
- package/package.json +35 -35
- package/src/catchP.js +25 -0
- package/src/copyKeys.js +31 -0
- package/src/fantasy-land/Identity.js +24 -27
- package/src/fantasy-land/mapping.js +20 -24
- package/src/fantasy-land/traits.js +1 -1
- package/src/findOr.js +30 -0
- package/src/index.js +8 -0
- package/src/internal/ap.js +1 -1
- package/src/internal/ponyfills/Promise.allSettled.js +4 -3
- package/src/isInteger32.js +28 -0
- package/src/isNotPrimitive.js +25 -0
- package/src/isPrimitive.js +45 -0
- package/src/isSentinelValue.js +26 -0
- package/types/index.d.ts +55 -1
- package/.husky/commit-msg +0 -4
- package/.husky/pre-commit +0 -4
- 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/copyKeys.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
2
|
+
|
|
3
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
4
|
+
|
|
5
|
+
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; }
|
|
6
|
+
|
|
7
|
+
import { curryN } from 'ramda';
|
|
8
|
+
import renameKeys from './renameKeys';
|
|
9
|
+
/**
|
|
10
|
+
* Creates a new object with the own properties of the provided object, and the
|
|
11
|
+
* keys copied according to the keysMap object as `{oldKey: newKey}`.
|
|
12
|
+
* When no key from the keysMap is found, then a shallow clone of an object is returned.
|
|
13
|
+
*
|
|
14
|
+
* Keep in mind that in the case of keys conflict is behaviour undefined and
|
|
15
|
+
* the result may vary between various JS engines!
|
|
16
|
+
*
|
|
17
|
+
* @func copyKeys
|
|
18
|
+
* @memberOf RA
|
|
19
|
+
* @category Object
|
|
20
|
+
* @sig {a: b} -> {a: *} -> {b: *}
|
|
21
|
+
* @param {!Object} keysMap
|
|
22
|
+
* @param {!Object} obj
|
|
23
|
+
* @return {!Object} New object with copied keys
|
|
24
|
+
* @see {@link RA.renameKeys|renameKeys}
|
|
25
|
+
* @example
|
|
26
|
+
*
|
|
27
|
+
* copyKeys({ a: 'b' }, { a: true }); //=> { a: true, b: true }
|
|
28
|
+
* copyKeys({ a: 'b' }, { a: true, b: false }); //=> { a: true, b: true }
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
var copyKeys = curryN(2, function (keysMap, obj) {
|
|
32
|
+
return _objectSpread(_objectSpread({}, obj), renameKeys(keysMap, obj));
|
|
33
|
+
});
|
|
34
|
+
export default copyKeys;
|
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
|
|
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';
|
|
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.
|
|
@@ -41,47 +31,13 @@ var of = fl.of,
|
|
|
41
31
|
* @since {@link https://char0n.github.io/ramda-adjunct/1.8.0|v1.8.0}
|
|
42
32
|
*/
|
|
43
33
|
|
|
44
|
-
var Identity = /*#__PURE__*/function () {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
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
|
-
|
|
34
|
+
var Identity = /*#__PURE__*/function (_fl$of, _fl$ap, _fl$map, _fl$equals, _fl$concat, _fl$chain, _fl$lte, _fl$empty, _fl$contramap) {
|
|
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:
|
|
76
|
+
key: _fl$ap,
|
|
121
77
|
value: function value(applyWithFn) {
|
|
122
|
-
return applyTrait[
|
|
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[
|
|
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:
|
|
98
|
+
key: _fl$map,
|
|
143
99
|
value: function value(fn) {
|
|
144
|
-
return functorTrait[
|
|
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[
|
|
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:
|
|
124
|
+
key: _fl$equals,
|
|
169
125
|
value: function value(setoid) {
|
|
170
|
-
return setoidTrait[
|
|
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[
|
|
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:
|
|
155
|
+
key: _fl$concat,
|
|
200
156
|
value: function value(semigroup) {
|
|
201
|
-
return semigroupTrait[
|
|
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[
|
|
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:
|
|
179
|
+
key: _fl$chain,
|
|
224
180
|
value: function value(fn) {
|
|
225
|
-
return chainTrait[
|
|
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[
|
|
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:
|
|
206
|
+
key: _fl$lte,
|
|
251
207
|
value: function value(ord) {
|
|
252
|
-
return ordTrait[
|
|
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[
|
|
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:
|
|
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[
|
|
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:
|
|
260
|
+
key: _fl$contramap,
|
|
305
261
|
value: function value(fn) {
|
|
306
262
|
var _this = this;
|
|
307
263
|
|
|
@@ -312,11 +268,42 @@ var Identity = /*#__PURE__*/function () {
|
|
|
312
268
|
}, {
|
|
313
269
|
key: "contramap",
|
|
314
270
|
value: function contramap(fn) {
|
|
315
|
-
return this[
|
|
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
|
|
|
319
306
|
return Identity;
|
|
320
|
-
}();
|
|
307
|
+
}(fl.of, fl.ap, fl.map, fl.equals, fl.concat, fl.chain, fl.lte, fl.empty, fl.contramap);
|
|
321
308
|
|
|
322
309
|
export default Identity;
|
|
@@ -1,23 +1,20 @@
|
|
|
1
|
-
var
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
});
|
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;
|
package/es/flattenDepth.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
|
|
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';
|
|
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';
|
|
@@ -162,7 +169,8 @@ export { default as allUnique } from './allUnique';
|
|
|
162
169
|
export { default as notAllUnique } from './notAllUnique';
|
|
163
170
|
export { default as sortByProps } from './sortByProps';
|
|
164
171
|
export { default as skipTake } from './skipTake';
|
|
165
|
-
export { default as rangeStep } from './rangeStep';
|
|
172
|
+
export { default as rangeStep } from './rangeStep';
|
|
173
|
+
export { default as findOr } from './findOr'; // Object
|
|
166
174
|
|
|
167
175
|
export { default as invoke } from './invoke';
|
|
168
176
|
export { default as invokeArgs } from './invokeArgs';
|
|
@@ -170,6 +178,7 @@ export { default as paths } from './paths';
|
|
|
170
178
|
export { default as renameKeys } from './renameKeys';
|
|
171
179
|
export { default as renameKeysWith } from './renameKeysWith';
|
|
172
180
|
export { default as renameKeyWith } from './renameKeyWith';
|
|
181
|
+
export { default as copyKeys } from './copyKeys';
|
|
173
182
|
export { default as mergeRight } from './mergeRight';
|
|
174
183
|
export { default as mergeLeft } from './mergeRight';
|
|
175
184
|
export { default as resetToDefault } from './mergeRight';
|
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
|
|
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
|
|
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
|
|
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
|
|
|
@@ -18,7 +18,7 @@ function _inherits(subClass, superClass) { if (typeof superClass !== "function"
|
|
|
18
18
|
|
|
19
19
|
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
|
|
20
20
|
|
|
21
|
-
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }
|
|
21
|
+
function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
|
|
22
22
|
|
|
23
23
|
function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
|
|
24
24
|
|
|
@@ -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 {
|
|
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
|
|
|
@@ -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,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
|
|
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
|
|