ramda-adjunct 2.36.0 → 3.2.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 (60) hide show
  1. package/CHANGELOG.md +49 -0
  2. package/README.md +2 -2
  3. package/dist/RA.node.js +226 -210
  4. package/dist/RA.node.min.js +1 -1
  5. package/dist/RA.web.js +226 -210
  6. package/dist/RA.web.min.js +1 -1
  7. package/dist/RA.web.standalone.js +5993 -5468
  8. package/dist/RA.web.standalone.min.js +1 -1
  9. package/es/flattenPath.js +2 -2
  10. package/es/included.js +27 -0
  11. package/es/index.js +9 -12
  12. package/es/internal/ponyfills/Promise.any.js +3 -3
  13. package/es/isBlank.js +32 -0
  14. package/es/isUinteger32.js +29 -0
  15. package/es/mergePath.js +2 -3
  16. package/es/omitIndexes.js +2 -2
  17. package/es/pickIndexes.js +2 -2
  18. package/es/sortByPaths.js +52 -0
  19. package/es/spreadPath.js +2 -2
  20. package/es/trimCharsEnd.js +2 -2
  21. package/es/trimCharsStart.js +2 -2
  22. package/lib/flattenPath.js +1 -1
  23. package/lib/included.js +33 -0
  24. package/lib/index.js +18 -21
  25. package/lib/internal/ponyfills/Promise.any.js +3 -3
  26. package/lib/isBlank.js +41 -0
  27. package/lib/isUinteger32.js +38 -0
  28. package/lib/mergePath.js +1 -5
  29. package/lib/omitIndexes.js +1 -1
  30. package/lib/pickIndexes.js +1 -1
  31. package/lib/sortByPaths.js +59 -0
  32. package/lib/spreadPath.js +1 -1
  33. package/lib/trimCharsEnd.js +2 -2
  34. package/lib/trimCharsStart.js +2 -2
  35. package/package.json +33 -49
  36. package/src/flattenPath.js +4 -2
  37. package/src/included.js +28 -0
  38. package/src/index.js +7 -10
  39. package/src/isBlank.js +33 -0
  40. package/src/isUinteger32.js +29 -0
  41. package/src/mergePath.js +2 -4
  42. package/src/omitIndexes.js +2 -2
  43. package/src/pickIndexes.js +2 -2
  44. package/src/sortByPaths.js +55 -0
  45. package/src/spreadPath.js +2 -2
  46. package/src/trimCharsEnd.js +2 -2
  47. package/src/trimCharsStart.js +2 -2
  48. package/types/index.d.ts +21 -34
  49. package/es/contained.js +0 -29
  50. package/es/hasPath.js +0 -38
  51. package/es/mergeRight.js +0 -26
  52. package/es/thenP.js +0 -28
  53. package/lib/contained.js +0 -35
  54. package/lib/hasPath.js +0 -47
  55. package/lib/mergeRight.js +0 -32
  56. package/lib/thenP.js +0 -34
  57. package/src/contained.js +0 -30
  58. package/src/hasPath.js +0 -40
  59. package/src/mergeRight.js +0 -27
  60. package/src/thenP.js +0 -29
@@ -8,7 +8,7 @@ var _ramda = require("ramda");
8
8
  // helpers
9
9
  var rejectIndexed = (0, _ramda.addIndex)(_ramda.reject);
10
10
  var containsIndex = (0, _ramda.curry)(function (indexes, val, index) {
11
- return (0, _ramda.contains)(index, indexes);
11
+ return (0, _ramda.includes)(index, indexes);
12
12
  });
13
13
  /**
14
14
  * Returns a partial copy of an array omitting the indexes specified.
@@ -8,7 +8,7 @@ var _ramda = require("ramda");
8
8
  // helpers
9
9
  var filterIndexed = (0, _ramda.addIndex)(_ramda.filter);
10
10
  var containsIndex = (0, _ramda.curry)(function (indexes, val, index) {
11
- return (0, _ramda.contains)(index, indexes);
11
+ return (0, _ramda.includes)(index, indexes);
12
12
  });
13
13
  /**
14
14
  * Picks values from list by indexes.
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+
3
+ exports.__esModule = true;
4
+ exports["default"] = void 0;
5
+
6
+ var _ramda = require("ramda");
7
+
8
+ var pathToAscendSort = (0, _ramda.pipe)(_ramda.path, _ramda.ascend);
9
+ var mapPathsToAscendSort = (0, _ramda.map)(pathToAscendSort);
10
+ /**
11
+ * Sort a list of objects by a list of paths (if first path value is equivalent, sort by second, etc).
12
+ *
13
+ * @func sortByPaths
14
+ * @memberOf RA
15
+ * @since {@link https://char0n.github.io/ramda-adjunct/3.1.0|v3.1.0}
16
+ * @category List
17
+ * @sig [[k]] -> [{k: v}] -> [{k: v}]
18
+ * @param {Array.<Array.<string>>} paths A list of paths in the list param to sort by
19
+ * @param {Array.<object>} list A list of objects to be sorted
20
+ * @return {Array.<object>} A new list sorted by the paths in the paths param
21
+ * @example
22
+ *
23
+ * const alice = {
24
+ * name: 'Alice',
25
+ * address: {
26
+ * street: 31,
27
+ * zipCode: 97777,
28
+ * },
29
+ * };
30
+ * const bob = {
31
+ * name: 'Bob',
32
+ * address: {
33
+ * street: 31,
34
+ * zipCode: 55555,
35
+ * },
36
+ * };
37
+ * const clara = {
38
+ * name: 'Clara',
39
+ * address: {
40
+ * street: 32,
41
+ * zipCode: 90210,
42
+ * },
43
+ * };
44
+ * const people = [clara, bob, alice]
45
+ *
46
+ * RA.sortByPaths([
47
+ * ['address', 'street'],
48
+ * ['address', 'zipCode'],
49
+ * ], people); // => [bob, alice, clara]
50
+ *
51
+ * RA.sortByPaths([
52
+ * ['address', 'zipCode'],
53
+ * ['address', 'street'],
54
+ * ], people); // => [bob, clara, alice]
55
+ */
56
+
57
+ var sortByPaths = (0, _ramda.useWith)(_ramda.sortWith, [mapPathsToAscendSort, _ramda.identity]);
58
+ var _default = sortByPaths;
59
+ exports["default"] = _default;
package/lib/spreadPath.js CHANGED
@@ -26,6 +26,6 @@ var _ramda = require("ramda");
26
26
  * { a: 1, b1: { b2: { c: 3, d: 4 } } }
27
27
  * ); // => { a: 1, c: 3, d: 4, b1: {} };
28
28
  */
29
- var spreadPath = (0, _ramda.curryN)(2, (0, _ramda.converge)(_ramda.merge, [_ramda.dissocPath, (0, _ramda.pathOr)({})]));
29
+ var spreadPath = (0, _ramda.curryN)(2, (0, _ramda.converge)(_ramda.mergeRight, [_ramda.dissocPath, (0, _ramda.pathOr)({})]));
30
30
  var _default = spreadPath;
31
31
  exports["default"] = _default;
@@ -5,7 +5,7 @@ exports["default"] = void 0;
5
5
 
6
6
  var _ramda = require("ramda");
7
7
 
8
- var _contained = _interopRequireDefault(require("./contained"));
8
+ var _included = _interopRequireDefault(require("./included"));
9
9
 
10
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
11
11
 
@@ -25,7 +25,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
25
25
  * RA.trimCharsEnd('_-', '-_-abc-_-'); //=> '-_-abc'
26
26
  */
27
27
  var trimCharsEnd = (0, _ramda.curry)(function (chars, value) {
28
- return (0, _ramda.pipe)((0, _ramda.split)(''), (0, _ramda.dropLastWhile)((0, _contained["default"])(chars)), (0, _ramda.join)(''))(value);
28
+ return (0, _ramda.pipe)((0, _ramda.split)(''), (0, _ramda.dropLastWhile)((0, _included["default"])(chars)), (0, _ramda.join)(''))(value);
29
29
  });
30
30
  var _default = trimCharsEnd;
31
31
  exports["default"] = _default;
@@ -5,7 +5,7 @@ exports["default"] = void 0;
5
5
 
6
6
  var _ramda = require("ramda");
7
7
 
8
- var _contained = _interopRequireDefault(require("./contained"));
8
+ var _included = _interopRequireDefault(require("./included"));
9
9
 
10
10
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
11
11
 
@@ -25,7 +25,7 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
25
25
  * RA.trimCharsStart('_-', '-_-abc-_-'); //=> 'abc-_-'
26
26
  */
27
27
  var trimCharsStart = (0, _ramda.curry)(function (chars, value) {
28
- return (0, _ramda.pipe)((0, _ramda.split)(''), (0, _ramda.dropWhile)((0, _contained["default"])(chars)), (0, _ramda.join)(''))(value);
28
+ return (0, _ramda.pipe)((0, _ramda.split)(''), (0, _ramda.dropWhile)((0, _included["default"])(chars)), (0, _ramda.join)(''))(value);
29
29
  });
30
30
  var _default = trimCharsStart;
31
31
  exports["default"] = _default;
package/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "cookbook",
15
15
  "functional"
16
16
  ],
17
- "version": "2.36.0",
17
+ "version": "3.2.0",
18
18
  "homepage": "https://github.com/char0n/ramda-adjunct",
19
19
  "license": "BSD-3-Clause",
20
20
  "repository": {
@@ -93,23 +93,8 @@
93
93
  }
94
94
  },
95
95
  "test:web": "testem ci",
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
- "test:ramda0.19.0": "npm install ramda@0.19.0 && npm test",
98
- "test:ramda0.19.1": "npm install ramda@0.19.1 && npm test",
99
- "test:ramda0.20.0": "npm install ramda@0.20.0 && npm test",
100
- "test:ramda0.20.1": "npm install ramda@0.20.1 && npm test",
101
- "test:ramda0.21.0": "npm install ramda@0.21.0 && npm test",
102
- "test:ramda0.22.0": "npm install ramda@0.22.0 && npm test",
103
- "test:ramda0.22.1": "npm install ramda@0.22.1 && npm test",
104
- "test:ramda0.23.0": "npm install ramda@0.23.0 && npm test",
105
- "test:ramda0.24.0": "npm install ramda@0.24.0 && npm test",
106
- "test:ramda0.24.1": "npm install ramda@0.24.1 && npm test",
107
- "test:ramda0.25.0": "npm install ramda@0.25.0 && npm test",
108
- "test:ramda0.26.0": "npm install ramda@0.26.0 && npm test",
109
- "test:ramda0.26.1": "npm install ramda@0.26.1 && npm test",
110
- "test:ramda0.27.0": "npm install ramda@0.27.0 && npm test",
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",
96
+ "test:ramda": "bnr test:ramda0.28.0",
97
+ "test:ramda0.28.0": "npm install ramda@0.28.0 && npm test",
113
98
  "test:bundle-create": "webpack --config webpack.config-test.web.js --progress",
114
99
  "test:bundle-clean": "rimraf tmp-test-bundle.js",
115
100
  "coverage": {
@@ -135,65 +120,64 @@
135
120
  "prepublishOnly": "npm run clean && npm run lint && npm run test && npm run build && npm run docs",
136
121
  "clean": "rimraf .nyc_output .tmp docs coverage tmp-test-bundle.js dist lib es"
137
122
  },
138
- "readme": "README.md",
139
123
  "peerDependencies": {
140
- "ramda": ">= 0.19.0 <= 0.27.2"
124
+ "ramda": ">= 0.28.0 <= 0.28.0"
141
125
  },
142
126
  "devDependencies": {
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",
127
+ "@babel/cli": "7.17.10",
128
+ "@babel/core": "=7.18.5",
129
+ "@babel/plugin-transform-modules-commonjs": "=7.18.2",
130
+ "@babel/preset-env": "=7.18.2",
131
+ "@babel/register": "7.17.7",
132
+ "@commitlint/cli": "=17.0.2",
133
+ "@commitlint/config-conventional": "=17.0.2",
150
134
  "assert": "=2.0.0",
151
- "babel-loader": "8.2.3",
135
+ "babel-loader": "=8.2.5",
152
136
  "babel-plugin-annotate-pure-calls": "0.4.0",
153
137
  "babel-plugin-istanbul": "6.1.1",
154
138
  "better-npm-run": "0.1.1",
155
- "chai": "4.3.4",
139
+ "chai": "4.3.6",
156
140
  "codecov": "3.8.3",
157
141
  "conventional-changelog-cli": "2.2.2",
158
- "core-js": "=3.20.3",
142
+ "core-js": "=3.23.1",
159
143
  "docdash": "git+https://github.com/char0n/docdash.git#534b44382138a55dd8d93642c979e51e46471185",
160
144
  "dtslint": "=4.2.1",
161
- "eslint": "=8.7.0",
145
+ "eslint": "=8.18.0",
162
146
  "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",
147
+ "eslint-config-prettier": "=8.5.0",
148
+ "eslint-plugin-import": "=2.26.0",
149
+ "eslint-plugin-mocha": "=10.0.5",
166
150
  "eslint-plugin-prettier": "4.0.0",
167
151
  "eslint-plugin-ramda": "2.5.1",
168
152
  "fantasy-land": "5.0.0",
169
- "fantasy-laws": "=1.2.0",
153
+ "fantasy-laws": "=2.0.1",
170
154
  "folktale": "=2.3.2",
171
- "glob": "7.2.0",
172
- "husky": "7.0.4",
155
+ "glob": "=8.0.3",
156
+ "husky": "8.0.1",
173
157
  "istanbul": "=0.4.5",
174
- "jsdoc": "=3.6.7",
158
+ "jsdoc": "=3.6.10",
175
159
  "jsverify": "0.8.4",
176
160
  "license-cli": "1.1.6",
177
- "lint-staged": "12.1.7",
178
- "mocha": "=9.1.4",
161
+ "lint-staged": "13.0.2",
162
+ "mocha": "=10.0.0",
179
163
  "mocha-junit-reporter": "2.0.2",
180
164
  "mocha-multi-reporters": "1.5.1",
181
165
  "monet": "0.9.3",
182
166
  "nyc": "15.1.0",
183
- "prettier": "=2.5.1",
167
+ "prettier": "=2.7.1",
184
168
  "process": "=0.11.10",
185
- "ramda": "0.27.2",
169
+ "ramda": "=0.28.0",
186
170
  "ramda-fantasy": "=0.8.0",
187
171
  "regenerator-runtime": "=0.13.9",
188
172
  "rimraf": "3.0.2",
189
- "sanctuary-show": "2.0.0",
190
- "sinon": "=11.1.2",
191
- "terser-webpack-plugin": "5.3.0",
192
- "testem": "=3.6.0",
173
+ "sanctuary-show": "3.0.0",
174
+ "sinon": "=14.0.0",
175
+ "terser-webpack-plugin": "5.3.3",
176
+ "testem": "=3.8.0",
193
177
  "tslint": "=6.1.3",
194
- "typescript": "=4.5.4",
195
- "webpack": "=5.66.0",
196
- "webpack-cli": "4.9.1"
178
+ "typescript": "=4.7.4",
179
+ "webpack": "=5.73.0",
180
+ "webpack-cli": "4.10.0"
197
181
  },
198
182
  "browserslist": "> 0.25%, ie 10, ie 11, not op_mini all",
199
183
  "tonicExampleFilename": "tonicExample.js",
@@ -1,4 +1,4 @@
1
- import { pathOr, curry, merge } from 'ramda';
1
+ import { pathOr, curry, mergeRight } from 'ramda';
2
2
 
3
3
  /**
4
4
  * Flattens a property path so that its fields are spread out into the provided object.
@@ -21,6 +21,8 @@ import { pathOr, curry, merge } from 'ramda';
21
21
  * { a: 1, b1: { b2: { c: 3, d: 4 } } }
22
22
  * ); // => { a: 1, c: 3, d: 4, b1: { b2: { c: 3, d: 4 } } };
23
23
  */
24
- const flattenPath = curry((path, obj) => merge(obj, pathOr({}, path, obj)));
24
+ const flattenPath = curry((path, obj) =>
25
+ mergeRight(obj, pathOr({}, path, obj))
26
+ );
25
27
 
26
28
  export default flattenPath;
@@ -0,0 +1,28 @@
1
+ import { flip, includes } from 'ramda';
2
+
3
+ /**
4
+ * Returns true if the specified value is equal, in R.equals terms,
5
+ * to at least one element of the given list or false otherwise.
6
+ * Given list can be a string.
7
+ *
8
+ * Like {@link http://ramdajs.com/docs/#includes|R.includes} but with argument order reversed.
9
+ *
10
+ * @func included
11
+ * @memberOf RA
12
+ * @since {@link https://char0n.github.io/ramda-adjunct/3.0.0|v3.0.0}
13
+ * @category List
14
+ * @sig [a] -> a -> Boolean
15
+ * @param {Array|String} list The list to consider
16
+ * @param {*} a The item to compare against
17
+ * @return {boolean} Returns Boolean `true` if an equivalent item is in the list or `false` otherwise
18
+ * @see {@link http://ramdajs.com/docs/#includes|R.includes}
19
+ * @example
20
+ *
21
+ * RA.included([1, 2, 3], 3); //=> true
22
+ * RA.included([1, 2, 3], 4); //=> false
23
+ * RA.included([{ name: 'Fred' }], { name: 'Fred' }); //=> true
24
+ * RA.included([[42]], [42]); //=> true
25
+ */
26
+ const included = flip(includes);
27
+
28
+ export default included;
package/src/index.js CHANGED
@@ -29,7 +29,7 @@ export { default as isNotAsyncFunction } from './isNotAsyncFunction';
29
29
  export { default as isFunction } from './isFunction';
30
30
  export { default as isNotFunction } from './isNotFunction';
31
31
  export { default as isObj } from './isObj';
32
- export { default as isObject } from './isObj'; // alias of isObject
32
+ export { default as isObject } from './isObj'; // alias of isObj
33
33
  export { default as isNotObj } from './isNotObj';
34
34
  export { default as isNotObject } from './isNotObj'; // alias of isNotObj
35
35
  export { default as isObjLike } from './isObjLike';
@@ -39,7 +39,7 @@ export { default as isNotObjectLike } from './isNotObjLike'; // alias of isNotOb
39
39
  export { default as isPlainObj } from './isPlainObj';
40
40
  export { default as isPlainObject } from './isPlainObj';
41
41
  export { default as isNotPlainObj } from './isNotPlainObj';
42
- export { default as isNotPlainObject } from './isNotPlainObj'; // alias of isNotPlainObject
42
+ export { default as isNotPlainObject } from './isNotPlainObj'; // alias of isNotPlainObj
43
43
  export { default as isDate } from './isDate';
44
44
  export { default as isNotDate } from './isNotDate';
45
45
  export { default as isValidDate } from './isValidDate';
@@ -63,6 +63,8 @@ export { default as isNotFinite } from './isNotFinite';
63
63
  export { default as isInteger } from './isInteger';
64
64
  export { default as isInteger32 } from './isInteger32';
65
65
  export { default as isInt32 } from './isInteger32'; // alias of isInteger32
66
+ export { default as isUinteger32 } from './isUinteger32';
67
+ export { default as isUint32 } from './isUinteger32'; // alias of isUinteger32
66
68
  export { default as isNotInteger } from './isNotInteger';
67
69
  export { default as isBigInt } from './isBigInt';
68
70
  export { default as isFloat } from './isFloat';
@@ -92,6 +94,7 @@ export { default as isNaturalNumber } from './isNaturalNumber';
92
94
  export { default as isPrimitive } from './isPrimitive';
93
95
  export { default as isNotPrimitive } from './isNotPrimitive';
94
96
  export { default as isSentinelValue } from './isSentinelValue';
97
+ export { default as isBlank } from './isBlank';
95
98
  // Function
96
99
  export { default as stubUndefined } from './stubUndefined';
97
100
  export { default as stubNull } from './stubNull';
@@ -113,8 +116,6 @@ export { default as noneP } from './noneP';
113
116
  export { default as resolveP } from './resolveP';
114
117
  export { default as rejectP } from './rejectP';
115
118
  export { default as delayP } from './delayP';
116
- export { default as thenP } from './thenP';
117
- export { default as then } from './thenP'; // eslint-disable-line no-restricted-exports
118
119
  export { default as thenCatchP } from './thenCatchP';
119
120
  export { default as allSettledP } from './allSettledP';
120
121
  export { default as Y } from './Y';
@@ -142,8 +143,7 @@ export { default as sliceTo } from './sliceTo';
142
143
  export { default as omitIndexes } from './omitIndexes';
143
144
  export { default as compact } from './compact';
144
145
  export { default as appendFlipped } from './appendFlipped';
145
- export { default as contained } from './contained';
146
- export { default as included } from './contained';
146
+ export { default as included } from './included';
147
147
  export { default as move } from './move';
148
148
  export { default as lengthGt } from './lengthGt';
149
149
  export { default as lengthLt } from './lengthLt';
@@ -161,6 +161,7 @@ export { default as toArray } from './toArray';
161
161
  export { default as allUnique } from './allUnique';
162
162
  export { default as notAllUnique } from './notAllUnique';
163
163
  export { default as sortByProps } from './sortByProps';
164
+ export { default as sortByPaths } from './sortByPaths';
164
165
  export { default as skipTake } from './skipTake';
165
166
  export { default as rangeStep } from './rangeStep';
166
167
  export { default as findOr } from './findOr';
@@ -172,9 +173,6 @@ export { default as renameKeys } from './renameKeys';
172
173
  export { default as renameKeysWith } from './renameKeysWith';
173
174
  export { default as renameKeyWith } from './renameKeyWith';
174
175
  export { default as copyKeys } from './copyKeys';
175
- export { default as mergeRight } from './mergeRight';
176
- export { default as mergeLeft } from './mergeRight';
177
- export { default as resetToDefault } from './mergeRight';
178
176
  export { default as mergeProps } from './mergeProps';
179
177
  export { default as mergePaths } from './mergePaths';
180
178
  export { default as mergeProp } from './mergeProp';
@@ -182,7 +180,6 @@ export { default as mergePath } from './mergePath';
182
180
  export { default as omitBy } from './omitBy';
183
181
  export { default as pathOrLazy } from './pathOrLazy';
184
182
  export { default as viewOr } from './viewOr';
185
- export { default as hasPath } from './hasPath';
186
183
  export { default as spreadProp } from './spreadProp';
187
184
  export { default as spreadPath } from './spreadPath';
188
185
  export { default as flattenProp } from './flattenProp';
package/src/isBlank.js ADDED
@@ -0,0 +1,33 @@
1
+ import { isEmpty, isNil, anyPass, test } from 'ramda';
2
+
3
+ import isFalse from './isFalse';
4
+ /**
5
+ * Returns `true` if the given value is its type's empty value, `false`, `undefined`
6
+ * as well as strings containing only whitespace characters; `false` otherwise.
7
+ *
8
+ * @func isBlank
9
+ * @memberOf RA
10
+ * @since {@link https://char0n.github.io/ramda-adjunct/3.1.0|v3.1.0}
11
+ * @category Type
12
+ * @sig * -> Boolean
13
+ * @param {*} val The value to test
14
+ * @return {boolean}
15
+ * @see {@link https://blog.appsignal.com/2018/09/11/differences-between-nil-empty-blank-and-present.html|Differences Between #nil?, #empty?, #blank?, and #present?}
16
+ * @example
17
+ *
18
+ * RA.isBlank(''); //=> true
19
+ * RA.isBlank(' '); //=> true
20
+ * RA.isBlank('\t\n'); //=> true
21
+ * RA.isBlank({}); //=> true
22
+ * RA.isBlank(null); //=> true
23
+ * RA.isBlank(undefined); //=> true
24
+ * RA.isBlank([]); //=> true
25
+ * RA.isBlank(false); //=> true
26
+ * RA.isBlank('value'); //=> false
27
+ * RA.isBlank({ foo: 'foo' }); //=> false
28
+ * RA.isBlank([1, 2, 3]); //=> false
29
+ * RA.isBlank(true); //=> false
30
+ */
31
+ const isBlank = anyPass([isFalse, isNil, isEmpty, test(/^\s+$/gm)]);
32
+
33
+ export default isBlank;
@@ -0,0 +1,29 @@
1
+ import { curryN } from 'ramda';
2
+
3
+ import toUinteger32 from './toUinteger32';
4
+
5
+ /**
6
+ * Checks whether the passed value is an unsigned 32 bit integer.
7
+ *
8
+ * @func isUinteger32
9
+ * @aliases isUint32
10
+ * @memberOf RA
11
+ * @since {@link https://char0n.github.io/ramda-adjunct/3.2.0|v3.2.0}
12
+ * @category Type
13
+ * @sig * -> Boolean
14
+ * @param {*} val The value to test
15
+ * @return {boolean}
16
+ * @see {@link RA.toUinteger32|toUinteger32}
17
+ * @example
18
+ *
19
+ * RA.isUinteger32(0); //=> true
20
+ * RA.isUinteger32(2 ** 32 - 1); //=> true
21
+ *
22
+ * RA.isUinteger32(Infinity); //=> false
23
+ * RA.isUinteger32(NaN); //=> false
24
+ * RA.isUinteger32(-1); //=> false
25
+ * RA.isUinteger32(2 ** 32); //=> false
26
+ */
27
+ const isUinteger32 = curryN(1, (val) => toUinteger32(val) === val);
28
+
29
+ export default isUinteger32;
package/src/mergePath.js CHANGED
@@ -1,6 +1,4 @@
1
- import { curry, over, lensPath } from 'ramda';
2
-
3
- import mergeRight from './mergeRight';
1
+ import { curry, over, lensPath, mergeLeft } from 'ramda';
4
2
 
5
3
  /**
6
4
  * Create a new object with the own properties of the object under the `path`
@@ -26,7 +24,7 @@ import mergeRight from './mergeRight';
26
24
  * ); //=> { outer: { inner: { foo: 3, bar: 4 } }
27
25
  */
28
26
  const mergePath = curry((path, source, obj) =>
29
- over(lensPath(path), mergeRight(source), obj)
27
+ over(lensPath(path), mergeLeft(source), obj)
30
28
  );
31
29
 
32
30
  export default mergePath;
@@ -1,8 +1,8 @@
1
- import { contains, curry, addIndex, reject } from 'ramda';
1
+ import { includes, curry, addIndex, reject } from 'ramda';
2
2
 
3
3
  // helpers
4
4
  const rejectIndexed = addIndex(reject);
5
- const containsIndex = curry((indexes, val, index) => contains(index, indexes));
5
+ const containsIndex = curry((indexes, val, index) => includes(index, indexes));
6
6
 
7
7
  /**
8
8
  * Returns a partial copy of an array omitting the indexes specified.
@@ -1,8 +1,8 @@
1
- import { filter, addIndex, curry, contains } from 'ramda';
1
+ import { filter, addIndex, curry, includes } from 'ramda';
2
2
 
3
3
  // helpers
4
4
  const filterIndexed = addIndex(filter);
5
- const containsIndex = curry((indexes, val, index) => contains(index, indexes));
5
+ const containsIndex = curry((indexes, val, index) => includes(index, indexes));
6
6
 
7
7
  /**
8
8
  * Picks values from list by indexes.
@@ -0,0 +1,55 @@
1
+ import { ascend, identity, map, path, pipe, sortWith, useWith } from 'ramda';
2
+
3
+ const pathToAscendSort = pipe(path, ascend);
4
+ const mapPathsToAscendSort = map(pathToAscendSort);
5
+
6
+ /**
7
+ * Sort a list of objects by a list of paths (if first path value is equivalent, sort by second, etc).
8
+ *
9
+ * @func sortByPaths
10
+ * @memberOf RA
11
+ * @since {@link https://char0n.github.io/ramda-adjunct/3.1.0|v3.1.0}
12
+ * @category List
13
+ * @sig [[k]] -> [{k: v}] -> [{k: v}]
14
+ * @param {Array.<Array.<string>>} paths A list of paths in the list param to sort by
15
+ * @param {Array.<object>} list A list of objects to be sorted
16
+ * @return {Array.<object>} A new list sorted by the paths in the paths param
17
+ * @example
18
+ *
19
+ * const alice = {
20
+ * name: 'Alice',
21
+ * address: {
22
+ * street: 31,
23
+ * zipCode: 97777,
24
+ * },
25
+ * };
26
+ * const bob = {
27
+ * name: 'Bob',
28
+ * address: {
29
+ * street: 31,
30
+ * zipCode: 55555,
31
+ * },
32
+ * };
33
+ * const clara = {
34
+ * name: 'Clara',
35
+ * address: {
36
+ * street: 32,
37
+ * zipCode: 90210,
38
+ * },
39
+ * };
40
+ * const people = [clara, bob, alice]
41
+ *
42
+ * RA.sortByPaths([
43
+ * ['address', 'street'],
44
+ * ['address', 'zipCode'],
45
+ * ], people); // => [bob, alice, clara]
46
+ *
47
+ * RA.sortByPaths([
48
+ * ['address', 'zipCode'],
49
+ * ['address', 'street'],
50
+ * ], people); // => [bob, clara, alice]
51
+ */
52
+
53
+ const sortByPaths = useWith(sortWith, [mapPathsToAscendSort, identity]);
54
+
55
+ export default sortByPaths;
package/src/spreadPath.js CHANGED
@@ -1,4 +1,4 @@
1
- import { curryN, converge, merge, dissocPath, pathOr } from 'ramda';
1
+ import { curryN, converge, mergeRight, dissocPath, pathOr } from 'ramda';
2
2
 
3
3
  /**
4
4
  * Spreads object under property path onto provided object.
@@ -21,6 +21,6 @@ import { curryN, converge, merge, dissocPath, pathOr } from 'ramda';
21
21
  * { a: 1, b1: { b2: { c: 3, d: 4 } } }
22
22
  * ); // => { a: 1, c: 3, d: 4, b1: {} };
23
23
  */
24
- const spreadPath = curryN(2, converge(merge, [dissocPath, pathOr({})]));
24
+ const spreadPath = curryN(2, converge(mergeRight, [dissocPath, pathOr({})]));
25
25
 
26
26
  export default spreadPath;
@@ -1,6 +1,6 @@
1
1
  import { curry, dropLastWhile, join, pipe, split } from 'ramda';
2
2
 
3
- import contained from './contained';
3
+ import included from './included';
4
4
 
5
5
  /**
6
6
  * Removes specified characters from the end of a string.
@@ -19,7 +19,7 @@ import contained from './contained';
19
19
  */
20
20
 
21
21
  const trimCharsEnd = curry((chars, value) =>
22
- pipe(split(''), dropLastWhile(contained(chars)), join(''))(value)
22
+ pipe(split(''), dropLastWhile(included(chars)), join(''))(value)
23
23
  );
24
24
 
25
25
  export default trimCharsEnd;
@@ -1,6 +1,6 @@
1
1
  import { curry, dropWhile, join, pipe, split } from 'ramda';
2
2
 
3
- import contained from './contained';
3
+ import included from './included';
4
4
 
5
5
  /**
6
6
  * Removes specified characters from the beginning of a string.
@@ -19,7 +19,7 @@ import contained from './contained';
19
19
  */
20
20
 
21
21
  const trimCharsStart = curry((chars, value) =>
22
- pipe(split(''), dropWhile(contained(chars)), join(''))(value)
22
+ pipe(split(''), dropWhile(included(chars)), join(''))(value)
23
23
  );
24
24
 
25
25
  export default trimCharsStart;