ramda-adjunct 3.0.0 → 3.1.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/CHANGELOG.md +10 -0
- package/README.md +1 -1
- package/dist/RA.node.js +124 -4
- package/dist/RA.node.min.js +1 -1
- package/dist/RA.web.js +124 -4
- package/dist/RA.web.min.js +1 -1
- package/dist/RA.web.standalone.js +126 -4
- package/dist/RA.web.standalone.min.js +1 -1
- package/es/index.js +3 -1
- package/es/isBlank.js +32 -0
- package/es/sortByPaths.js +52 -0
- package/lib/index.js +11 -3
- package/lib/isBlank.js +41 -0
- package/lib/sortByPaths.js +59 -0
- package/package.json +27 -27
- package/src/index.js +2 -0
- package/src/isBlank.js +33 -0
- package/src/sortByPaths.js +55 -0
- package/types/index.d.ts +12 -0
package/es/index.js
CHANGED
|
@@ -97,7 +97,8 @@ export { default as isError } from './isError';
|
|
|
97
97
|
export { default as isNaturalNumber } from './isNaturalNumber';
|
|
98
98
|
export { default as isPrimitive } from './isPrimitive';
|
|
99
99
|
export { default as isNotPrimitive } from './isNotPrimitive';
|
|
100
|
-
export { default as isSentinelValue } from './isSentinelValue';
|
|
100
|
+
export { default as isSentinelValue } from './isSentinelValue';
|
|
101
|
+
export { default as isBlank } from './isBlank'; // Function
|
|
101
102
|
|
|
102
103
|
export { default as stubUndefined } from './stubUndefined';
|
|
103
104
|
export { default as stubNull } from './stubNull';
|
|
@@ -165,6 +166,7 @@ export { default as toArray } from './toArray';
|
|
|
165
166
|
export { default as allUnique } from './allUnique';
|
|
166
167
|
export { default as notAllUnique } from './notAllUnique';
|
|
167
168
|
export { default as sortByProps } from './sortByProps';
|
|
169
|
+
export { default as sortByPaths } from './sortByPaths';
|
|
168
170
|
export { default as skipTake } from './skipTake';
|
|
169
171
|
export { default as rangeStep } from './rangeStep';
|
|
170
172
|
export { default as findOr } from './findOr'; // Object
|
package/es/isBlank.js
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { isEmpty, isNil, anyPass, test } from 'ramda';
|
|
2
|
+
import isFalse from './isFalse';
|
|
3
|
+
/**
|
|
4
|
+
* Returns `true` if the given value is its type's empty value, `false`, `undefined`
|
|
5
|
+
* as well as strings containing only whitespace characters; `false` otherwise.
|
|
6
|
+
*
|
|
7
|
+
* @func isBlank
|
|
8
|
+
* @memberOf RA
|
|
9
|
+
* @since {@link https://char0n.github.io/ramda-adjunct/3.1.0|v3.1.0}
|
|
10
|
+
* @category Type
|
|
11
|
+
* @sig * -> Boolean
|
|
12
|
+
* @param {*} val The value to test
|
|
13
|
+
* @return {boolean}
|
|
14
|
+
* @see {@link https://blog.appsignal.com/2018/09/11/differences-between-nil-empty-blank-and-present.html|Differences Between #nil?, #empty?, #blank?, and #present?}
|
|
15
|
+
* @example
|
|
16
|
+
*
|
|
17
|
+
* RA.isBlank(''); //=> true
|
|
18
|
+
* RA.isBlank(' '); //=> true
|
|
19
|
+
* RA.isBlank('\t\n'); //=> true
|
|
20
|
+
* RA.isBlank({}); //=> true
|
|
21
|
+
* RA.isBlank(null); //=> true
|
|
22
|
+
* RA.isBlank(undefined); //=> true
|
|
23
|
+
* RA.isBlank([]); //=> true
|
|
24
|
+
* RA.isBlank(false); //=> true
|
|
25
|
+
* RA.isBlank('value'); //=> false
|
|
26
|
+
* RA.isBlank({ foo: 'foo' }); //=> false
|
|
27
|
+
* RA.isBlank([1, 2, 3]); //=> false
|
|
28
|
+
* RA.isBlank(true); //=> false
|
|
29
|
+
*/
|
|
30
|
+
|
|
31
|
+
var isBlank = anyPass([isFalse, isNil, isEmpty, test(/^\s+$/gm)]);
|
|
32
|
+
export default isBlank;
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { ascend, identity, map, path, pipe, sortWith, useWith } from 'ramda';
|
|
2
|
+
var pathToAscendSort = pipe(path, ascend);
|
|
3
|
+
var mapPathsToAscendSort = map(pathToAscendSort);
|
|
4
|
+
/**
|
|
5
|
+
* Sort a list of objects by a list of paths (if first path value is equivalent, sort by second, etc).
|
|
6
|
+
*
|
|
7
|
+
* @func sortByPaths
|
|
8
|
+
* @memberOf RA
|
|
9
|
+
* @since {@link https://char0n.github.io/ramda-adjunct/3.1.0|v3.1.0}
|
|
10
|
+
* @category List
|
|
11
|
+
* @sig [[k]] -> [{k: v}] -> [{k: v}]
|
|
12
|
+
* @param {Array.<Array.<string>>} paths A list of paths in the list param to sort by
|
|
13
|
+
* @param {Array.<object>} list A list of objects to be sorted
|
|
14
|
+
* @return {Array.<object>} A new list sorted by the paths in the paths param
|
|
15
|
+
* @example
|
|
16
|
+
*
|
|
17
|
+
* const alice = {
|
|
18
|
+
* name: 'Alice',
|
|
19
|
+
* address: {
|
|
20
|
+
* street: 31,
|
|
21
|
+
* zipCode: 97777,
|
|
22
|
+
* },
|
|
23
|
+
* };
|
|
24
|
+
* const bob = {
|
|
25
|
+
* name: 'Bob',
|
|
26
|
+
* address: {
|
|
27
|
+
* street: 31,
|
|
28
|
+
* zipCode: 55555,
|
|
29
|
+
* },
|
|
30
|
+
* };
|
|
31
|
+
* const clara = {
|
|
32
|
+
* name: 'Clara',
|
|
33
|
+
* address: {
|
|
34
|
+
* street: 32,
|
|
35
|
+
* zipCode: 90210,
|
|
36
|
+
* },
|
|
37
|
+
* };
|
|
38
|
+
* const people = [clara, bob, alice]
|
|
39
|
+
*
|
|
40
|
+
* RA.sortByPaths([
|
|
41
|
+
* ['address', 'street'],
|
|
42
|
+
* ['address', 'zipCode'],
|
|
43
|
+
* ], people); // => [bob, alice, clara]
|
|
44
|
+
*
|
|
45
|
+
* RA.sortByPaths([
|
|
46
|
+
* ['address', 'zipCode'],
|
|
47
|
+
* ['address', 'street'],
|
|
48
|
+
* ], people); // => [bob, clara, alice]
|
|
49
|
+
*/
|
|
50
|
+
|
|
51
|
+
var sortByPaths = useWith(sortWith, [mapPathsToAscendSort, identity]);
|
|
52
|
+
export default sortByPaths;
|
package/lib/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
exports.__esModule = true;
|
|
4
|
-
exports.
|
|
5
|
-
exports.
|
|
6
|
-
exports.zipObjWith = exports.weaveLazy = exports.weave = exports.viewOr = exports.unzipObjWith = exports.trunc = exports.trimStart = exports.trimRight = exports.trimLeft = exports.trimEnd = exports.trimCharsStart = exports.trimCharsEnd = exports.toUinteger32 = exports.toUint32 = exports.toNumber = exports.toInteger32 = exports.toInt32 = exports.toArray = exports.thenCatchP = exports.subtractNum = exports.stubUndefined = exports.stubString = exports.stubObject = exports.stubObj = exports.stubNull =
|
|
4
|
+
exports.isNotRegExp = exports.isNotPrimitive = exports.isNotPlainObject = exports.isNotPlainObj = exports.isNotPair = exports.isNotObjectLike = exports.isNotObject = exports.isNotObjLike = exports.isNotObj = exports.isNotNumber = exports.isNotNull = exports.isNotNilOrEmpty = exports.isNotNil = exports.isNotNaN = exports.isNotMap = exports.isNotInteger = exports.isNotGeneratorFunction = exports.isNotFunction = exports.isNotFloat = exports.isNotFinite = exports.isNotEmpty = exports.isNotDate = exports.isNotBoolean = exports.isNotAsyncFunction = exports.isNotArrayLike = exports.isNotArray = exports.isNonPositive = exports.isNonNegative = exports.isNonEmptyString = exports.isNonEmptyArray = exports.isNilOrEmpty = exports.isNegativeZero = exports.isNegative = exports.isNaturalNumber = exports.isNaN = exports.isMap = exports.isIterable = exports.isInvalidDate = exports.isInteger32 = exports.isInteger = exports.isInt32 = exports.isIndexed = exports.isGeneratorFunction = exports.isFunction = exports.isFloat = exports.isFinite = exports.isFalsy = exports.isFalse = exports.isEven = exports.isError = exports.isEmptyString = exports.isEmptyArray = exports.isDate = exports.isBoolean = exports.isBlank = exports.isBigInt = exports.isAsyncFunction = exports.isArrayLike = exports.isArray = exports.invokeArgs = exports.invoke = exports.included = exports.inRange = exports.fnull = exports.floor = exports.flattenProp = exports.flattenPath = exports.flattenDepth = exports.firstP = exports.findOr = exports.filterIndexed = exports.escapeRegExp = exports.ensureArray = exports.dropArgs = exports.divideNum = exports.dispatch = exports.delayP = exports.defaultWhen = exports.curryRightN = exports.curryRight = exports.copyKeys = exports.concatRight = exports.concatAll = exports.compact = exports.ceil = exports.catchP = exports.cata = exports.async = exports.argsPass = exports.appendFlipped = exports.anyP = exports.allUnique = exports.allSettledP = exports.allP = exports.allIdenticalTo = exports.allIdentical = exports.allEqualTo = exports.allEqual = exports.Y = exports.Identity = void 0;
|
|
5
|
+
exports.stubArray = exports.spreadProp = exports.spreadPath = exports.sortByProps = exports.sortByPaths = exports.sliceTo = exports.sliceFrom = exports.skipTake = exports.sign = exports.sequencing = exports.seq = exports.round = exports.resolveP = exports.replaceAll = exports.repeatStr = exports.renameKeysWith = exports.renameKeys = exports.renameKeyWith = exports.rejectP = exports.reduceRightP = exports.reduceP = exports.reduceIndexed = exports.rangeStep = exports.propNotEq = exports.pickIndexes = exports.paths = exports.pathOrLazy = exports.pathNotEq = exports.padStart = exports.padEnd = exports.padCharsStart = exports.padCharsEnd = exports.overlaps = exports.omitIndexes = exports.omitBy = exports.notEqual = exports.notBoth = exports.notAllUnique = exports.notAllPass = exports.nor = exports.noop = exports.nonePass = exports.noneP = exports.neither = exports.nand = exports.move = exports.mergeProps = exports.mergeProp = exports.mergePaths = exports.mergePath = exports.mapIndexed = exports.list = exports.liftFN = exports.liftF = exports.lensTraverse = exports.lensSatisfies = exports.lensNotSatisfy = exports.lensNotEq = exports.lensIso = exports.lensEq = exports.lengthNotEq = exports.lengthLte = exports.lengthLt = exports.lengthGte = exports.lengthGt = exports.lengthEq = exports.lastP = exports.isValidNumber = exports.isValidDate = exports.isUndefined = exports.isTruthy = exports.isTrue = exports.isThenable = exports.isSymbol = exports.isString = exports.isSparseArray = exports.isSet = exports.isSentinelValue = exports.isSafeInteger = exports.isRegExp = exports.isPrototypeOf = exports.isPromise = exports.isPrimitive = exports.isPositiveZero = exports.isPositive = exports.isPlainObject = exports.isPlainObj = exports.isPair = exports.isOdd = exports.isObjectLike = exports.isObject = exports.isObjLike = exports.isObj = exports.isNumber = exports.isNull = exports.isNotValidNumber = exports.isNotValidDate = exports.isNotUndefined = exports.isNotString = exports.isNotSet = void 0;
|
|
6
|
+
exports.zipObjWith = exports.weaveLazy = exports.weave = exports.viewOr = exports.unzipObjWith = exports.trunc = exports.trimStart = exports.trimRight = exports.trimLeft = exports.trimEnd = exports.trimCharsStart = exports.trimCharsEnd = exports.toUinteger32 = exports.toUint32 = exports.toNumber = exports.toInteger32 = exports.toInt32 = exports.toArray = exports.thenCatchP = exports.subtractNum = exports.stubUndefined = exports.stubString = exports.stubObject = exports.stubObj = exports.stubNull = void 0;
|
|
7
7
|
|
|
8
8
|
var _isNotUndefined = _interopRequireDefault(require("./isNotUndefined"));
|
|
9
9
|
|
|
@@ -337,6 +337,10 @@ var _isSentinelValue = _interopRequireDefault(require("./isSentinelValue"));
|
|
|
337
337
|
|
|
338
338
|
exports.isSentinelValue = _isSentinelValue["default"];
|
|
339
339
|
|
|
340
|
+
var _isBlank = _interopRequireDefault(require("./isBlank"));
|
|
341
|
+
|
|
342
|
+
exports.isBlank = _isBlank["default"];
|
|
343
|
+
|
|
340
344
|
var _stubUndefined = _interopRequireDefault(require("./stubUndefined"));
|
|
341
345
|
|
|
342
346
|
exports.stubUndefined = _stubUndefined["default"];
|
|
@@ -584,6 +588,10 @@ var _sortByProps = _interopRequireDefault(require("./sortByProps"));
|
|
|
584
588
|
|
|
585
589
|
exports.sortByProps = _sortByProps["default"];
|
|
586
590
|
|
|
591
|
+
var _sortByPaths = _interopRequireDefault(require("./sortByPaths"));
|
|
592
|
+
|
|
593
|
+
exports.sortByPaths = _sortByPaths["default"];
|
|
594
|
+
|
|
587
595
|
var _skipTake = _interopRequireDefault(require("./skipTake"));
|
|
588
596
|
|
|
589
597
|
exports.skipTake = _skipTake["default"];
|
package/lib/isBlank.js
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
exports.__esModule = true;
|
|
4
|
+
exports["default"] = void 0;
|
|
5
|
+
|
|
6
|
+
var _ramda = require("ramda");
|
|
7
|
+
|
|
8
|
+
var _isFalse = _interopRequireDefault(require("./isFalse"));
|
|
9
|
+
|
|
10
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Returns `true` if the given value is its type's empty value, `false`, `undefined`
|
|
14
|
+
* as well as strings containing only whitespace characters; `false` otherwise.
|
|
15
|
+
*
|
|
16
|
+
* @func isBlank
|
|
17
|
+
* @memberOf RA
|
|
18
|
+
* @since {@link https://char0n.github.io/ramda-adjunct/3.1.0|v3.1.0}
|
|
19
|
+
* @category Type
|
|
20
|
+
* @sig * -> Boolean
|
|
21
|
+
* @param {*} val The value to test
|
|
22
|
+
* @return {boolean}
|
|
23
|
+
* @see {@link https://blog.appsignal.com/2018/09/11/differences-between-nil-empty-blank-and-present.html|Differences Between #nil?, #empty?, #blank?, and #present?}
|
|
24
|
+
* @example
|
|
25
|
+
*
|
|
26
|
+
* RA.isBlank(''); //=> true
|
|
27
|
+
* RA.isBlank(' '); //=> true
|
|
28
|
+
* RA.isBlank('\t\n'); //=> true
|
|
29
|
+
* RA.isBlank({}); //=> true
|
|
30
|
+
* RA.isBlank(null); //=> true
|
|
31
|
+
* RA.isBlank(undefined); //=> true
|
|
32
|
+
* RA.isBlank([]); //=> true
|
|
33
|
+
* RA.isBlank(false); //=> true
|
|
34
|
+
* RA.isBlank('value'); //=> false
|
|
35
|
+
* RA.isBlank({ foo: 'foo' }); //=> false
|
|
36
|
+
* RA.isBlank([1, 2, 3]); //=> false
|
|
37
|
+
* RA.isBlank(true); //=> false
|
|
38
|
+
*/
|
|
39
|
+
var isBlank = (0, _ramda.anyPass)([_isFalse["default"], _ramda.isNil, _ramda.isEmpty, (0, _ramda.test)(/^\s+$/gm)]);
|
|
40
|
+
var _default = isBlank;
|
|
41
|
+
exports["default"] = _default;
|
|
@@ -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/package.json
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"cookbook",
|
|
15
15
|
"functional"
|
|
16
16
|
],
|
|
17
|
-
"version": "3.
|
|
17
|
+
"version": "3.1.0",
|
|
18
18
|
"homepage": "https://github.com/char0n/ramda-adjunct",
|
|
19
19
|
"license": "BSD-3-Clause",
|
|
20
20
|
"repository": {
|
|
@@ -124,60 +124,60 @@
|
|
|
124
124
|
"ramda": ">= 0.28.0 <= 0.28.0"
|
|
125
125
|
},
|
|
126
126
|
"devDependencies": {
|
|
127
|
-
"@babel/cli": "7.
|
|
128
|
-
"@babel/core": "=7.
|
|
129
|
-
"@babel/plugin-transform-modules-commonjs": "7.
|
|
130
|
-
"@babel/preset-env": "=7.16.
|
|
131
|
-
"@babel/register": "7.
|
|
132
|
-
"@commitlint/cli": "=16.
|
|
133
|
-
"@commitlint/config-conventional": "=16.
|
|
127
|
+
"@babel/cli": "7.17.6",
|
|
128
|
+
"@babel/core": "=7.17.9",
|
|
129
|
+
"@babel/plugin-transform-modules-commonjs": "=7.17.9",
|
|
130
|
+
"@babel/preset-env": "=7.16.11",
|
|
131
|
+
"@babel/register": "7.17.7",
|
|
132
|
+
"@commitlint/cli": "=16.2.3",
|
|
133
|
+
"@commitlint/config-conventional": "=16.2.1",
|
|
134
134
|
"assert": "=2.0.0",
|
|
135
|
-
"babel-loader": "8.2.
|
|
135
|
+
"babel-loader": "=8.2.5",
|
|
136
136
|
"babel-plugin-annotate-pure-calls": "0.4.0",
|
|
137
137
|
"babel-plugin-istanbul": "6.1.1",
|
|
138
138
|
"better-npm-run": "0.1.1",
|
|
139
|
-
"chai": "4.3.
|
|
139
|
+
"chai": "4.3.6",
|
|
140
140
|
"codecov": "3.8.3",
|
|
141
141
|
"conventional-changelog-cli": "2.2.2",
|
|
142
|
-
"core-js": "=3.
|
|
142
|
+
"core-js": "=3.21.1",
|
|
143
143
|
"docdash": "git+https://github.com/char0n/docdash.git#534b44382138a55dd8d93642c979e51e46471185",
|
|
144
144
|
"dtslint": "=4.2.1",
|
|
145
|
-
"eslint": "=8.
|
|
145
|
+
"eslint": "=8.14.0",
|
|
146
146
|
"eslint-config-airbnb-base": "=15.0.0",
|
|
147
|
-
"eslint-config-prettier": "=8.
|
|
148
|
-
"eslint-plugin-import": "=2.
|
|
149
|
-
"eslint-plugin-mocha": "10.0.
|
|
147
|
+
"eslint-config-prettier": "=8.5.0",
|
|
148
|
+
"eslint-plugin-import": "=2.26.0",
|
|
149
|
+
"eslint-plugin-mocha": "=10.0.4",
|
|
150
150
|
"eslint-plugin-prettier": "4.0.0",
|
|
151
151
|
"eslint-plugin-ramda": "2.5.1",
|
|
152
152
|
"fantasy-land": "5.0.0",
|
|
153
|
-
"fantasy-laws": "=
|
|
153
|
+
"fantasy-laws": "=2.0.1",
|
|
154
154
|
"folktale": "=2.3.2",
|
|
155
|
-
"glob": "
|
|
155
|
+
"glob": "=8.0.1",
|
|
156
156
|
"husky": "7.0.4",
|
|
157
157
|
"istanbul": "=0.4.5",
|
|
158
|
-
"jsdoc": "=3.6.
|
|
158
|
+
"jsdoc": "=3.6.10",
|
|
159
159
|
"jsverify": "0.8.4",
|
|
160
160
|
"license-cli": "1.1.6",
|
|
161
|
-
"lint-staged": "12.
|
|
162
|
-
"mocha": "=9.
|
|
161
|
+
"lint-staged": "12.3.7",
|
|
162
|
+
"mocha": "=9.2.2",
|
|
163
163
|
"mocha-junit-reporter": "2.0.2",
|
|
164
164
|
"mocha-multi-reporters": "1.5.1",
|
|
165
165
|
"monet": "0.9.3",
|
|
166
166
|
"nyc": "15.1.0",
|
|
167
|
-
"prettier": "=2.
|
|
167
|
+
"prettier": "=2.6.2",
|
|
168
168
|
"process": "=0.11.10",
|
|
169
169
|
"ramda": "=0.28.0",
|
|
170
170
|
"ramda-fantasy": "=0.8.0",
|
|
171
171
|
"regenerator-runtime": "=0.13.9",
|
|
172
172
|
"rimraf": "3.0.2",
|
|
173
|
-
"sanctuary-show": "
|
|
174
|
-
"sinon": "=
|
|
175
|
-
"terser-webpack-plugin": "5.3.
|
|
173
|
+
"sanctuary-show": "3.0.0",
|
|
174
|
+
"sinon": "=13.0.2",
|
|
175
|
+
"terser-webpack-plugin": "5.3.1",
|
|
176
176
|
"testem": "=3.6.0",
|
|
177
177
|
"tslint": "=6.1.3",
|
|
178
|
-
"typescript": "=4.
|
|
179
|
-
"webpack": "=5.
|
|
180
|
-
"webpack-cli": "4.9.
|
|
178
|
+
"typescript": "=4.6.3",
|
|
179
|
+
"webpack": "=5.72.0",
|
|
180
|
+
"webpack-cli": "4.9.2"
|
|
181
181
|
},
|
|
182
182
|
"browserslist": "> 0.25%, ie 10, ie 11, not op_mini all",
|
|
183
183
|
"tonicExampleFilename": "tonicExample.js",
|
package/src/index.js
CHANGED
|
@@ -92,6 +92,7 @@ export { default as isNaturalNumber } from './isNaturalNumber';
|
|
|
92
92
|
export { default as isPrimitive } from './isPrimitive';
|
|
93
93
|
export { default as isNotPrimitive } from './isNotPrimitive';
|
|
94
94
|
export { default as isSentinelValue } from './isSentinelValue';
|
|
95
|
+
export { default as isBlank } from './isBlank';
|
|
95
96
|
// Function
|
|
96
97
|
export { default as stubUndefined } from './stubUndefined';
|
|
97
98
|
export { default as stubNull } from './stubNull';
|
|
@@ -158,6 +159,7 @@ export { default as toArray } from './toArray';
|
|
|
158
159
|
export { default as allUnique } from './allUnique';
|
|
159
160
|
export { default as notAllUnique } from './notAllUnique';
|
|
160
161
|
export { default as sortByProps } from './sortByProps';
|
|
162
|
+
export { default as sortByPaths } from './sortByPaths';
|
|
161
163
|
export { default as skipTake } from './skipTake';
|
|
162
164
|
export { default as rangeStep } from './rangeStep';
|
|
163
165
|
export { default as findOr } from './findOr';
|
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,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/types/index.d.ts
CHANGED
|
@@ -370,6 +370,12 @@ declare namespace RamdaAdjunct {
|
|
|
370
370
|
*/
|
|
371
371
|
isBigInt(val: any): boolean;
|
|
372
372
|
|
|
373
|
+
/**
|
|
374
|
+
* Returns `true` if the given value is its type's empty value, `false`, `undefined`
|
|
375
|
+
* as well as strings containing only whitespace characters; `false` otherwise.
|
|
376
|
+
*/
|
|
377
|
+
isBlank(val: any): boolean;
|
|
378
|
+
|
|
373
379
|
/**
|
|
374
380
|
* Checks whether the passed value is a `float`.
|
|
375
381
|
*/
|
|
@@ -1477,6 +1483,12 @@ declare namespace RamdaAdjunct {
|
|
|
1477
1483
|
skipTake<T>(n: number, list: T[]): T[];
|
|
1478
1484
|
skipTake<T>(n: number): (list: T[]) => T[];
|
|
1479
1485
|
|
|
1486
|
+
/**
|
|
1487
|
+
* Sort a list of objects by a list of paths (if first path value is equivalent, sort by second, etc).
|
|
1488
|
+
*/
|
|
1489
|
+
sortByPaths(props: string[][], list: object[]): object[];
|
|
1490
|
+
sortByPaths(props: string[][]): (list: object[]) => object[];
|
|
1491
|
+
|
|
1480
1492
|
/**
|
|
1481
1493
|
* Determine if input value is an indexed data type.
|
|
1482
1494
|
*/
|