ramda-adjunct 2.32.0 → 2.36.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 (86) hide show
  1. package/.nvmrc +1 -0
  2. package/CHANGELOG.md +35 -0
  3. package/README.md +4 -6
  4. package/dist/RA.node.js +1043 -818
  5. package/dist/RA.node.min.js +1 -1
  6. package/dist/RA.web.js +1043 -818
  7. package/dist/RA.web.min.js +1 -1
  8. package/dist/RA.web.standalone.js +1678 -1453
  9. package/dist/RA.web.standalone.min.js +1 -1
  10. package/es/catchP.js +24 -0
  11. package/es/copyKeys.js +34 -0
  12. package/es/dispatch.js +1 -1
  13. package/es/fantasy-land/Identity.js +64 -77
  14. package/es/fantasy-land/mapping.js +20 -23
  15. package/es/fantasy-land/traits.js +1 -1
  16. package/es/flattenDepth.js +1 -1
  17. package/es/index.js +8 -3
  18. package/es/internal/ap.js +1 -1
  19. package/es/internal/isCoercible.js +6 -0
  20. package/es/internal/isOfTypeObject.js +1 -1
  21. package/es/internal/ponyfills/Array.from.js +1 -1
  22. package/es/internal/ponyfills/Promise.allSettled.js +1 -1
  23. package/es/internal/ponyfills/Promise.any.js +10 -6
  24. package/es/isArrayLike.js +1 -1
  25. package/es/isNotNilOrEmpty.js +1 -1
  26. package/es/isSentinelValue.js +26 -0
  27. package/es/isSymbol.js +1 -1
  28. package/es/lastP.js +1 -1
  29. package/es/reduceP.js +1 -1
  30. package/es/reduceRightP.js +1 -1
  31. package/es/sortByProps.js +1 -1
  32. package/es/toNumber.js +22 -0
  33. package/lib/anyP.js +3 -3
  34. package/lib/catchP.js +30 -0
  35. package/lib/copyKeys.js +43 -0
  36. package/lib/dispatch.js +1 -1
  37. package/lib/fantasy-land/Identity.js +68 -78
  38. package/lib/fantasy-land/mapping.js +41 -25
  39. package/lib/fantasy-land/traits.js +19 -13
  40. package/lib/fantasy-land/util.js +1 -1
  41. package/lib/flattenDepth.js +1 -1
  42. package/lib/index.js +19 -3
  43. package/lib/internal/ap.js +9 -3
  44. package/lib/internal/isCoercible.js +18 -0
  45. package/lib/internal/isOfTypeObject.js +1 -1
  46. package/lib/internal/ponyfills/Array.from.js +1 -1
  47. package/lib/internal/ponyfills/Promise.allSettled.js +1 -1
  48. package/lib/internal/ponyfills/Promise.any.js +10 -6
  49. package/lib/isArrayLike.js +1 -1
  50. package/lib/isFinite.js +1 -1
  51. package/lib/isInteger.js +1 -1
  52. package/lib/isNaN.js +1 -1
  53. package/lib/isNotNilOrEmpty.js +1 -1
  54. package/lib/isSafeInteger.js +1 -1
  55. package/lib/isSentinelValue.js +35 -0
  56. package/lib/isSymbol.js +1 -1
  57. package/lib/lastP.js +1 -1
  58. package/lib/padCharsEnd.js +1 -1
  59. package/lib/padCharsStart.js +1 -1
  60. package/lib/reduceP.js +1 -1
  61. package/lib/reduceRightP.js +1 -1
  62. package/lib/repeatStr.js +1 -1
  63. package/lib/replaceAll.js +1 -1
  64. package/lib/sign.js +1 -1
  65. package/lib/sortByProps.js +1 -1
  66. package/lib/thenCatchP.js +1 -1
  67. package/lib/toArray.js +1 -1
  68. package/lib/toNumber.js +31 -0
  69. package/lib/trimEnd.js +1 -1
  70. package/lib/trimStart.js +1 -1
  71. package/lib/trunc.js +1 -1
  72. package/package.json +40 -39
  73. package/src/catchP.js +25 -0
  74. package/src/copyKeys.js +31 -0
  75. package/src/fantasy-land/Identity.js +24 -27
  76. package/src/fantasy-land/mapping.js +20 -24
  77. package/src/fantasy-land/traits.js +1 -1
  78. package/src/index.js +5 -1
  79. package/src/internal/ap.js +1 -1
  80. package/src/internal/isCoercible.js +12 -0
  81. package/src/internal/ponyfills/Promise.allSettled.js +4 -3
  82. package/src/internal/ponyfills/Promise.any.js +1 -1
  83. package/src/isNotNilOrEmpty.js +1 -1
  84. package/src/isSentinelValue.js +26 -0
  85. package/src/toNumber.js +24 -0
  86. package/types/index.d.ts +27 -0
package/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "cookbook",
15
15
  "functional"
16
16
  ],
17
- "version": "2.32.0",
17
+ "version": "2.36.0",
18
18
  "homepage": "https://github.com/char0n/ramda-adjunct",
19
19
  "license": "BSD-3-Clause",
20
20
  "repository": {
@@ -93,7 +93,7 @@
93
93
  }
94
94
  },
95
95
  "test:web": "testem ci",
96
- "test:ramda": "bnr test:ramda0.27.1 && bnr test:ramda0.27.0 && bnr test:ramda0.26.1 && bnr test:ramda0.26.0 && bnr test:ramda0.25.0 && bnr test:ramda0.24.1 && bnr test:ramda0.24.0 && bnr test:ramda0.23.0 && bnr test:ramda0.22.1 && bnr test:ramda0.22.0 && bnr test:ramda0.21.0 && bnr test:ramda0.20.1 && bnr test:ramda0.20.0 && bnr test:ramda0.19.1 && bnr test:ramda0.19.0",
96
+ "test:ramda": "bnr test:ramda0.27.2 && bnr test:ramda0.27.1 && bnr test:ramda0.27.0 && bnr test:ramda0.26.1 && bnr test:ramda0.26.0 && bnr test:ramda0.25.0 && bnr test:ramda0.24.1 && bnr test:ramda0.24.0 && bnr test:ramda0.23.0 && bnr test:ramda0.22.1 && bnr test:ramda0.22.0 && bnr test:ramda0.21.0 && bnr test:ramda0.20.1 && bnr test:ramda0.20.0 && bnr test:ramda0.19.1 && bnr test:ramda0.19.0",
97
97
  "test:ramda0.19.0": "npm install ramda@0.19.0 && npm test",
98
98
  "test:ramda0.19.1": "npm install ramda@0.19.1 && npm test",
99
99
  "test:ramda0.20.0": "npm install ramda@0.20.0 && npm test",
@@ -109,6 +109,7 @@
109
109
  "test:ramda0.26.1": "npm install ramda@0.26.1 && npm test",
110
110
  "test:ramda0.27.0": "npm install ramda@0.27.0 && npm test",
111
111
  "test:ramda0.27.1": "npm install ramda@0.27.1 && npm test",
112
+ "test:ramda0.27.2": "npm install ramda@0.27.1 && npm test",
112
113
  "test:bundle-create": "webpack --config webpack.config-test.web.js --progress",
113
114
  "test:bundle-clean": "rimraf tmp-test-bundle.js",
114
115
  "coverage": {
@@ -136,63 +137,63 @@
136
137
  },
137
138
  "readme": "README.md",
138
139
  "peerDependencies": {
139
- "ramda": ">= 0.19.0 <= 0.27.1"
140
+ "ramda": ">= 0.19.0 <= 0.27.2"
140
141
  },
141
142
  "devDependencies": {
142
- "@babel/cli": "7.13.14",
143
- "@babel/core": "7.13.15",
144
- "@babel/plugin-transform-modules-commonjs": "7.13.8",
145
- "@babel/preset-env": "7.12.11",
146
- "@babel/register": "7.13.14",
147
- "@commitlint/cli": "=12.1.1",
148
- "@commitlint/config-conventional": "=12.1.1",
143
+ "@babel/cli": "7.16.8",
144
+ "@babel/core": "=7.16.7",
145
+ "@babel/plugin-transform-modules-commonjs": "7.16.8",
146
+ "@babel/preset-env": "=7.16.8",
147
+ "@babel/register": "7.16.9",
148
+ "@commitlint/cli": "=16.0.2",
149
+ "@commitlint/config-conventional": "=16.0.0",
149
150
  "assert": "=2.0.0",
150
- "babel-loader": "8.2.2",
151
+ "babel-loader": "8.2.3",
151
152
  "babel-plugin-annotate-pure-calls": "0.4.0",
152
- "babel-plugin-istanbul": "6.0.0",
153
+ "babel-plugin-istanbul": "6.1.1",
153
154
  "better-npm-run": "0.1.1",
154
155
  "chai": "4.3.4",
155
- "codecov": "3.8.1",
156
- "conventional-changelog-cli": "2.1.1",
157
- "core-js": "=3.10.1",
156
+ "codecov": "3.8.3",
157
+ "conventional-changelog-cli": "2.2.2",
158
+ "core-js": "=3.20.3",
158
159
  "docdash": "git+https://github.com/char0n/docdash.git#534b44382138a55dd8d93642c979e51e46471185",
159
- "dtslint": "=4.0.9",
160
- "eslint": "7.23.0",
161
- "eslint-config-airbnb-base": "14.2.1",
162
- "eslint-config-prettier": "=8.1.0",
163
- "eslint-plugin-import": "2.22.1",
164
- "eslint-plugin-mocha": "8.1.0",
165
- "eslint-plugin-prettier": "3.3.1",
160
+ "dtslint": "=4.2.1",
161
+ "eslint": "=8.7.0",
162
+ "eslint-config-airbnb-base": "=15.0.0",
163
+ "eslint-config-prettier": "=8.3.0",
164
+ "eslint-plugin-import": "=2.25.4",
165
+ "eslint-plugin-mocha": "10.0.3",
166
+ "eslint-plugin-prettier": "4.0.0",
166
167
  "eslint-plugin-ramda": "2.5.1",
167
- "fantasy-land": "4.1.0",
168
+ "fantasy-land": "5.0.0",
168
169
  "fantasy-laws": "=1.2.0",
169
170
  "folktale": "=2.3.2",
170
- "glob": "7.1.6",
171
- "husky": "6.0.0",
171
+ "glob": "7.2.0",
172
+ "husky": "7.0.4",
172
173
  "istanbul": "=0.4.5",
173
- "jsdoc": "3.6.6",
174
+ "jsdoc": "=3.6.7",
174
175
  "jsverify": "0.8.4",
175
176
  "license-cli": "1.1.6",
176
- "lint-staged": "10.5.4",
177
- "mocha": "=8.3.2",
178
- "mocha-junit-reporter": "2.0.0",
177
+ "lint-staged": "12.1.7",
178
+ "mocha": "=9.1.4",
179
+ "mocha-junit-reporter": "2.0.2",
179
180
  "mocha-multi-reporters": "1.5.1",
180
- "monet": "0.9.2",
181
+ "monet": "0.9.3",
181
182
  "nyc": "15.1.0",
182
- "prettier": "=2.2.1",
183
+ "prettier": "=2.5.1",
183
184
  "process": "=0.11.10",
184
- "ramda": "0.27.1",
185
+ "ramda": "0.27.2",
185
186
  "ramda-fantasy": "=0.8.0",
186
- "regenerator-runtime": "=0.13.7",
187
+ "regenerator-runtime": "=0.13.9",
187
188
  "rimraf": "3.0.2",
188
189
  "sanctuary-show": "2.0.0",
189
- "sinon": "10.0.1",
190
- "terser-webpack-plugin": "5.1.1",
191
- "testem": "=3.4.0",
190
+ "sinon": "=11.1.2",
191
+ "terser-webpack-plugin": "5.3.0",
192
+ "testem": "=3.6.0",
192
193
  "tslint": "=6.1.3",
193
- "typescript": "=4.2.4",
194
- "webpack": "=5.31.0",
195
- "webpack-cli": "4.6.0"
194
+ "typescript": "=4.5.4",
195
+ "webpack": "=5.66.0",
196
+ "webpack-cli": "4.9.1"
196
197
  },
197
198
  "browserslist": "> 0.25%, ie 10, ie 11, not op_mini all",
198
199
  "tonicExampleFilename": "tonicExample.js",
package/src/catchP.js ADDED
@@ -0,0 +1,25 @@
1
+ import { invoker } from 'ramda';
2
+
3
+ /**
4
+ * Composable shortcut for `Promise.catch`.
5
+ * The catchP function returns a Promise. It takes two arguments: a callback function for the failure of the Promise
6
+ * and the promise instance itself.
7
+ *
8
+ * @func catchP
9
+ * @memberOf RA
10
+ * @since {@link https://char0n.github.io/ramda-adjunct/2.29.0|v2.29.0}
11
+ * @category Function
12
+ * @sig (a -> Promise b | b) -> Promise b
13
+ * @param {Function} onRejected A Function called if the Promise is rejected. This function has one argument, the rejection reason.
14
+ * @param {Promise} promise Any Promise
15
+ * @return {Promise} Returns a Promise with dealt rejected cases
16
+ * @see {@link RA.thenP|thenP}, {@link RA.resolveP|resolveP}, {@link RA.rejectP|rejectP}, {@link RA.allP|allP}
17
+ *
18
+ * @example
19
+ *
20
+ * RA.catchP(() => 'b', Promise.resolve('a')); //=> Promise('a')
21
+ * RA.catchP(() => 'b', Promise.reject('a')); //=> Promise('b')
22
+ */
23
+ const catchP = invoker(1, 'catch');
24
+
25
+ export default catchP;
@@ -0,0 +1,31 @@
1
+ import { curryN } from 'ramda';
2
+
3
+ import renameKeys from './renameKeys';
4
+
5
+ /**
6
+ * Creates a new object with the own properties of the provided object, and the
7
+ * keys copied according to the keysMap object as `{oldKey: newKey}`.
8
+ * When no key from the keysMap is found, then a shallow clone of an object is returned.
9
+ *
10
+ * Keep in mind that in the case of keys conflict is behaviour undefined and
11
+ * the result may vary between various JS engines!
12
+ *
13
+ * @func copyKeys
14
+ * @memberOf RA
15
+ * @category Object
16
+ * @sig {a: b} -> {a: *} -> {b: *}
17
+ * @param {!Object} keysMap
18
+ * @param {!Object} obj
19
+ * @return {!Object} New object with copied keys
20
+ * @see {@link RA.renameKeys|renameKeys}
21
+ * @example
22
+ *
23
+ * copyKeys({ a: 'b' }, { a: true }); //=> { a: true, b: true }
24
+ * copyKeys({ a: 'b' }, { a: true, b: false }); //=> { a: true, b: true }
25
+ */
26
+ const copyKeys = curryN(2, (keysMap, obj) => ({
27
+ ...obj,
28
+ ...renameKeys(keysMap, obj),
29
+ }));
30
+
31
+ export default copyKeys;
@@ -1,6 +1,6 @@
1
1
  import { empty as emptyR } from 'ramda';
2
2
 
3
- import fl from './mapping';
3
+ import * as fl from './mapping';
4
4
  import {
5
5
  applyTrait,
6
6
  functorTrait,
@@ -10,9 +10,6 @@ import {
10
10
  ordTrait,
11
11
  } from './traits';
12
12
 
13
- // we do this here for jsdocs generate properly
14
- const { of, ap, map, equals, concat, chain, lte, empty, contramap } = fl;
15
-
16
13
  /**
17
14
  * The simplest {@link https://github.com/fantasyland/fantasy-land|fantasy-land}
18
15
  * compatible monad which attaches no information to values.
@@ -48,7 +45,7 @@ class Identity {
48
45
  *
49
46
  * const a = Identity.of(1); //=> Identity(1)
50
47
  */
51
- static [of](value) {
48
+ static [fl.of](value) {
52
49
  return new Identity(value);
53
50
  }
54
51
 
@@ -98,12 +95,12 @@ class Identity {
98
95
  *
99
96
  * a.ap(b); //=> Identity(2)
100
97
  */
101
- [ap](applyWithFn) {
102
- return applyTrait[ap].call(this, applyWithFn);
98
+ [fl.ap](applyWithFn) {
99
+ return applyTrait[fl.ap].call(this, applyWithFn);
103
100
  }
104
101
 
105
102
  ap(applyWithFn) {
106
- return this[ap](applyWithFn);
103
+ return this[fl.ap](applyWithFn);
107
104
  }
108
105
 
109
106
  /**
@@ -117,12 +114,12 @@ class Identity {
117
114
  * const a = Identity.of(1);
118
115
  * a.map(a => a + 1); //=> Identity(2)
119
116
  */
120
- [map](fn) {
121
- return functorTrait[map].call(this, fn);
117
+ [fl.map](fn) {
118
+ return functorTrait[fl.map].call(this, fn);
122
119
  }
123
120
 
124
121
  map(fn) {
125
- return this[map](fn);
122
+ return this[fl.map](fn);
126
123
  }
127
124
 
128
125
  /**
@@ -140,12 +137,12 @@ class Identity {
140
137
  * a.equals(b); //=> true
141
138
  * a.equals(c); //=> false
142
139
  */
143
- [equals](setoid) {
144
- return setoidTrait[equals].call(this, setoid);
140
+ [fl.equals](setoid) {
141
+ return setoidTrait[fl.equals].call(this, setoid);
145
142
  }
146
143
 
147
144
  equals(setoid) {
148
- return this[equals](setoid);
145
+ return this[fl.equals](setoid);
149
146
  }
150
147
 
151
148
  /**
@@ -168,12 +165,12 @@ class Identity {
168
165
  * const f = Identity.of(['f']);
169
166
  * e.concat(f); //=> ['e', 'f']
170
167
  */
171
- [concat](semigroup) {
172
- return semigroupTrait[concat].call(this, semigroup);
168
+ [fl.concat](semigroup) {
169
+ return semigroupTrait[fl.concat].call(this, semigroup);
173
170
  }
174
171
 
175
172
  concat(semigroup) {
176
- return this[concat](semigroup);
173
+ return this[fl.concat](semigroup);
177
174
  }
178
175
 
179
176
  /**
@@ -189,12 +186,12 @@ class Identity {
189
186
  *
190
187
  * a.chain(fn).chain(fn); //=> Identity(3)
191
188
  */
192
- [chain](fn) {
193
- return chainTrait[chain].call(this, fn);
189
+ [fl.chain](fn) {
190
+ return chainTrait[fl.chain].call(this, fn);
194
191
  }
195
192
 
196
193
  chain(fn) {
197
- return this[chain](fn);
194
+ return this[fl.chain](fn);
198
195
  }
199
196
 
200
197
  /**
@@ -213,12 +210,12 @@ class Identity {
213
210
  * a.lte(c); //=> true
214
211
  * c.lte(a); //=> false
215
212
  */
216
- [lte](ord) {
217
- return ordTrait[lte].call(this, ord);
213
+ [fl.lte](ord) {
214
+ return ordTrait[fl.lte].call(this, ord);
218
215
  }
219
216
 
220
217
  lte(ord) {
221
- return this[lte](ord);
218
+ return this[fl.lte](ord);
222
219
  }
223
220
 
224
221
  /**
@@ -237,12 +234,12 @@ class Identity {
237
234
  * a.concat(i); //=> Identity('string');
238
235
  * i.concat(a); //=> Identity('string');
239
236
  */
240
- [empty]() {
237
+ [fl.empty]() {
241
238
  return this.constructor.of(emptyR(this.value));
242
239
  }
243
240
 
244
241
  empty() {
245
- return this[empty]();
242
+ return this[fl.empty]();
246
243
  }
247
244
 
248
245
  /**
@@ -261,12 +258,12 @@ class Identity {
261
258
  * Identity.of(identity).contramap(divide2).contramap(add1).get()(3); //=> 2
262
259
  * Identity.of(identity).contramap(a => divide2(add1(a))).get()(3); //=> 2
263
260
  */
264
- [contramap](fn) {
261
+ [fl.contramap](fn) {
265
262
  return this.constructor.of((value) => this.value(fn(value)));
266
263
  }
267
264
 
268
265
  contramap(fn) {
269
- return this[contramap](fn);
266
+ return this[fl.contramap](fn);
270
267
  }
271
268
  }
272
269
 
@@ -1,24 +1,20 @@
1
- const 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
-
24
- export default mapping;
1
+ export const equals = 'fantasy-land/equals';
2
+ export const lte = 'fantasy-land/lte';
3
+ export const compose = 'fantasy-land/compose';
4
+ export const id = 'fantasy-land/id';
5
+ export const concat = 'fantasy-land/concat';
6
+ export const empty = 'fantasy-land/empty';
7
+ export const map = 'fantasy-land/map';
8
+ export const contramap = 'fantasy-land/contramap';
9
+ export const ap = 'fantasy-land/ap';
10
+ export const of = 'fantasy-land/of';
11
+ export const alt = 'fantasy-land/alt';
12
+ export const zero = 'fantasy-land/zero';
13
+ export const reduce = 'fantasy-land/reduce';
14
+ export const traverse = 'fantasy-land/traverse';
15
+ export const chain = 'fantasy-land/chain';
16
+ export const chainRec = 'fantasy-land/chainRec';
17
+ export const extend = 'fantasy-land/extend';
18
+ export const extract = 'fantasy-land/extract';
19
+ export const bimap = 'fantasy-land/bimap';
20
+ export const promap = 'fantasy-land/promap';
@@ -4,7 +4,7 @@ import isString from '../isString';
4
4
  import isNumber from '../isNumber';
5
5
  import isFunction from '../isFunction';
6
6
  import { isSameType } from './util';
7
- import fl from './mapping';
7
+ import * as fl from './mapping';
8
8
 
9
9
  export const functorTrait = {
10
10
  [fl.map](fn) {
package/src/index.js CHANGED
@@ -91,6 +91,7 @@ export { default as isError } from './isError';
91
91
  export { default as isNaturalNumber } from './isNaturalNumber';
92
92
  export { default as isPrimitive } from './isPrimitive';
93
93
  export { default as isNotPrimitive } from './isNotPrimitive';
94
+ export { default as isSentinelValue } from './isSentinelValue';
94
95
  // Function
95
96
  export { default as stubUndefined } from './stubUndefined';
96
97
  export { default as stubNull } from './stubNull';
@@ -107,12 +108,13 @@ export { default as weaveLazy } from './weaveLazy';
107
108
  export { default as curryRightN } from './curryRightN';
108
109
  export { default as curryRight } from './curryRight';
109
110
  export { default as allP } from './allP';
111
+ export { default as catchP } from './catchP';
110
112
  export { default as noneP } from './noneP';
111
113
  export { default as resolveP } from './resolveP';
112
114
  export { default as rejectP } from './rejectP';
113
115
  export { default as delayP } from './delayP';
114
116
  export { default as thenP } from './thenP';
115
- export { default as then } from './thenP';
117
+ export { default as then } from './thenP'; // eslint-disable-line no-restricted-exports
116
118
  export { default as thenCatchP } from './thenCatchP';
117
119
  export { default as allSettledP } from './allSettledP';
118
120
  export { default as Y } from './Y';
@@ -169,6 +171,7 @@ export { default as paths } from './paths';
169
171
  export { default as renameKeys } from './renameKeys';
170
172
  export { default as renameKeysWith } from './renameKeysWith';
171
173
  export { default as renameKeyWith } from './renameKeyWith';
174
+ export { default as copyKeys } from './copyKeys';
172
175
  export { default as mergeRight } from './mergeRight';
173
176
  export { default as mergeLeft } from './mergeRight';
174
177
  export { default as resetToDefault } from './mergeRight';
@@ -222,6 +225,7 @@ export { default as toInteger32 } from './toInteger32';
222
225
  export { default as toInt32 } from './toInteger32'; // alias of toInteger32
223
226
  export { default as toUinteger32 } from './toUinteger32';
224
227
  export { default as toUint32 } from './toUinteger32'; // alias of to toUinteger32
228
+ export { default as toNumber } from './toNumber';
225
229
  // String
226
230
  export { default as replaceAll } from './replaceAll';
227
231
  export { default as escapeRegExp } from './escapeRegExp';
@@ -1,7 +1,7 @@
1
1
  import { ap as apR, curryN, pathSatisfies, both, either } from 'ramda';
2
2
 
3
3
  import isFunction from '../isFunction';
4
- import fl from '../fantasy-land/mapping';
4
+ import * as fl from '../fantasy-land/mapping';
5
5
 
6
6
  const isFunctor = either(
7
7
  pathSatisfies(isFunction, ['map']),
@@ -0,0 +1,12 @@
1
+ import { both, hasIn } from 'ramda';
2
+
3
+ import isObj from '../isObj';
4
+ import isSymbol from '../isSymbol';
5
+ import neither from '../neither';
6
+
7
+ const isCoercible = neither(
8
+ isSymbol,
9
+ both(isObj, neither(hasIn('toString'), hasIn('valueOf')))
10
+ );
11
+
12
+ export default isCoercible;
@@ -7,9 +7,10 @@ const onFulfill = (value) => ({ status: 'fulfilled', value });
7
7
  const onReject = (reason) => ({ status: 'rejected', reason });
8
8
 
9
9
  const allSettledPonyfill = (iterable) => {
10
- const array = map((p) => resolveP(p).then(onFulfill).catch(onReject), [
11
- ...iterable,
12
- ]);
10
+ const array = map(
11
+ (p) => resolveP(p).then(onFulfill).catch(onReject),
12
+ [...iterable]
13
+ );
13
14
 
14
15
  return allP(array);
15
16
  };
@@ -3,7 +3,7 @@ import { map } from 'ramda';
3
3
  import resolveP from '../../resolveP';
4
4
 
5
5
  export class AggregatedError extends Error {
6
- constructor(errors = [], message) {
6
+ constructor(errors = [], message = '') {
7
7
  super(message);
8
8
 
9
9
  this.errors = errors;
@@ -3,7 +3,7 @@ import { complement } from 'ramda';
3
3
  import isNilOrEmpty from './isNilOrEmpty';
4
4
 
5
5
  /**
6
- * Returns `true` if the given value is its type's empty value, `null` or `undefined`.
6
+ * Returns `false` if the given value is its type's empty value, `null` or `undefined`.
7
7
  *
8
8
  * @func isNotNilOrEmpty
9
9
  * @memberOf RA
@@ -0,0 +1,26 @@
1
+ import { curryN } from 'ramda';
2
+
3
+ import isInteger32 from './isInteger32';
4
+
5
+ /**
6
+ * 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}.
7
+ *
8
+ * @func isSentinelValue
9
+ * @memberOf RA
10
+ * @since {@link https://char0n.github.io/ramda-adjunct/2.33.0|v2.33.0}
11
+ * @category Type
12
+ * @sig * -> Boolean
13
+ * @param {*} val The value to test
14
+ * @return {boolean}
15
+ * @example
16
+ *
17
+ * RA.isSentinelValue(-1); //=> true
18
+ *
19
+ * RA.isSentinelValue('-1'); //=> false
20
+ * RA.isSentinelValue(1); //=> false
21
+ * RA.isSentinelValue([-1]); //=> false
22
+ */
23
+ // eslint-disable-next-line no-bitwise
24
+ const isSentinelValue = curryN(1, (val) => isInteger32(val) && ~val === 0);
25
+
26
+ export default isSentinelValue;
@@ -0,0 +1,24 @@
1
+ import { ifElse, always } from 'ramda';
2
+
3
+ import isCoercible from './internal/isCoercible';
4
+
5
+ /**
6
+ * Converts value to a number.
7
+ *
8
+ * @func toNumber
9
+ * @memberOf RA
10
+ * @since {@link https://char0n.github.io/ramda-adjunct/2.36.0|v2.36.0}
11
+ * @category Type
12
+ * @param {*} val The value to convert
13
+ * @return {Number}
14
+ * @example
15
+ *
16
+ * RA.toNumber(3.2); //=> 3.2
17
+ * RA.toNumber(Number.MIN_VALUE); //=> 5e-324
18
+ * RA.toNumber(Infinity); //=> Infinity
19
+ * RA.toNumber('3.2'); //=> 3.2
20
+ * RA.toNumber(Symbol('3.2')); //=> NaN
21
+ */
22
+ const toNumber = ifElse(isCoercible, Number, always(NaN));
23
+
24
+ export default toNumber;
package/types/index.d.ts CHANGED
@@ -455,6 +455,12 @@ declare namespace RamdaAdjunct {
455
455
  */
456
456
  isSparseArray(val: any): boolean;
457
457
 
458
+ /**
459
+ * Checks whether the passed value is
460
+ * {@link https://github.com/getify/You-Dont-Know-JS/blob/9959fc904d584bbf0b02cf41c192f74ff4238581/types-grammar/ch4.md#the-curious-case-of-the-|a sentinel value}.
461
+ */
462
+ isSentinelValue(val: any): boolean;
463
+
458
464
  /**
459
465
  * A function that returns `undefined`.
460
466
  */
@@ -588,6 +594,14 @@ declare namespace RamdaAdjunct {
588
594
  renameKeys(keysMap: Dictionary<string>, obj: object): object;
589
595
  renameKeys(keysMap: Dictionary<string>): (obj: object) => object;
590
596
 
597
+ /**
598
+ * Creates a new object with the own properties of the provided object, and the
599
+ * keys copied according to the keysMap object as `{oldKey: newKey}`.
600
+ * When no key from the keysMap is found, then a shallow clone of an object is returned.
601
+ */
602
+ copyKeys(keysMap: Dictionary<string>, obj: object): object;
603
+ copyKeys(keysMap: Dictionary<string>): (obj: object) => object;
604
+
591
605
  /**
592
606
  * Creates a new object with the own properties of the provided object, but the
593
607
  * keys renamed according to logic of renaming function.
@@ -996,6 +1010,14 @@ declare namespace RamdaAdjunct {
996
1010
  reject<T>(options: { timeout: number, value: T }): Promise<T>
997
1011
  };
998
1012
 
1013
+ /**
1014
+ * Composable shortcut for `Promise.catch`.
1015
+ * The catchP function returns a Promise. It takes two arguments: a callback function for the rejections of the Promise
1016
+ * and the promise instance itself.
1017
+ */
1018
+ catchP<A, B = unknown>(onRejected: (error: any) => B | Promise<B>, promise: Promise<A>): Promise<A | B>;
1019
+ catchP<A, B = unknown>(onRejected: (error: any) => B | Promise<B>): (promise: Promise<A>) => Promise<A | B>;
1020
+
999
1021
  /**
1000
1022
  * Composable shortcut for `Promise.then`.
1001
1023
  * The thenP function returns a Promise. It takes two arguments: a callback function for the success of the Promise
@@ -1516,6 +1538,11 @@ declare namespace RamdaAdjunct {
1516
1538
  toUinteger32(val: number): number;
1517
1539
  toUint32(val: number): number; // alias
1518
1540
 
1541
+ /**
1542
+ * Converts value to a number.
1543
+ */
1544
+ toNumber(val: any): number;
1545
+
1519
1546
  /**
1520
1547
  * Creates an array of numbers (positive and/or negative) progressing from start up to, but not including, end.
1521
1548
  *