ramda-adjunct 2.35.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 +50 -0
- package/README.md +2 -4
- package/dist/RA.node.js +275 -239
- package/dist/RA.node.min.js +1 -1
- package/dist/RA.web.js +275 -239
- package/dist/RA.web.min.js +1 -1
- package/dist/RA.web.standalone.js +6072 -5528
- package/dist/RA.web.standalone.min.js +1 -1
- package/es/copyKeys.js +2 -2
- package/es/fantasy-land/Identity.js +1 -1
- package/es/flattenPath.js +2 -2
- package/es/included.js +27 -0
- package/es/index.js +8 -12
- package/es/internal/isCoercible.js +6 -0
- package/es/internal/isOfTypeObject.js +1 -1
- package/es/internal/ponyfills/Promise.any.js +8 -4
- package/es/isArrayLike.js +1 -1
- package/es/isBlank.js +32 -0
- package/es/isNotNilOrEmpty.js +1 -1
- package/es/isSymbol.js +1 -1
- package/es/mergePath.js +2 -3
- package/es/omitIndexes.js +2 -2
- package/es/pickIndexes.js +2 -2
- package/es/sortByPaths.js +52 -0
- package/es/spreadPath.js +2 -2
- package/es/toNumber.js +22 -0
- package/es/trimCharsEnd.js +2 -2
- package/es/trimCharsStart.js +2 -2
- package/lib/anyP.js +1 -1
- package/lib/copyKeys.js +2 -2
- package/lib/fantasy-land/Identity.js +2 -2
- package/lib/fantasy-land/mapping.js +1 -1
- package/lib/fantasy-land/traits.js +2 -2
- package/lib/fantasy-land/util.js +1 -1
- package/lib/flattenPath.js +1 -1
- package/lib/included.js +33 -0
- package/lib/index.js +17 -21
- package/lib/internal/ap.js +1 -1
- package/lib/internal/isCoercible.js +18 -0
- package/lib/internal/isOfTypeObject.js +1 -1
- package/lib/internal/ponyfills/Promise.any.js +8 -4
- package/lib/isArrayLike.js +1 -1
- package/lib/isBlank.js +41 -0
- package/lib/isFinite.js +1 -1
- package/lib/isInteger.js +1 -1
- package/lib/isNaN.js +1 -1
- package/lib/isNotNilOrEmpty.js +1 -1
- package/lib/isSafeInteger.js +1 -1
- package/lib/isSymbol.js +1 -1
- package/lib/mergePath.js +1 -5
- package/lib/omitIndexes.js +1 -1
- package/lib/padCharsEnd.js +1 -1
- package/lib/padCharsStart.js +1 -1
- package/lib/pickIndexes.js +1 -1
- package/lib/repeatStr.js +1 -1
- package/lib/replaceAll.js +1 -1
- package/lib/sign.js +1 -1
- package/lib/sortByPaths.js +59 -0
- package/lib/spreadPath.js +1 -1
- package/lib/thenCatchP.js +1 -1
- package/lib/toArray.js +1 -1
- package/lib/toNumber.js +31 -0
- package/lib/trimCharsEnd.js +2 -2
- package/lib/trimCharsStart.js +2 -2
- package/lib/trimEnd.js +1 -1
- package/lib/trimStart.js +1 -1
- package/lib/trunc.js +1 -1
- package/package.json +35 -50
- package/src/flattenPath.js +4 -2
- package/src/included.js +28 -0
- package/src/index.js +6 -10
- package/src/internal/isCoercible.js +12 -0
- package/src/internal/ponyfills/Promise.any.js +1 -1
- package/src/isBlank.js +33 -0
- package/src/isNotNilOrEmpty.js +1 -1
- package/src/mergePath.js +2 -4
- package/src/omitIndexes.js +2 -2
- package/src/pickIndexes.js +2 -2
- package/src/sortByPaths.js +55 -0
- package/src/spreadPath.js +2 -2
- package/src/toNumber.js +24 -0
- package/src/trimCharsEnd.js +2 -2
- package/src/trimCharsStart.js +2 -2
- package/types/index.d.ts +20 -34
- package/es/contained.js +0 -29
- package/es/hasPath.js +0 -38
- package/es/mergeRight.js +0 -26
- package/es/thenP.js +0 -28
- package/lib/contained.js +0 -35
- package/lib/hasPath.js +0 -47
- package/lib/mergeRight.js +0 -32
- package/lib/thenP.js +0 -34
- package/src/contained.js +0 -30
- package/src/hasPath.js +0 -40
- package/src/mergeRight.js +0 -27
- package/src/thenP.js +0 -29
package/package.json
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"cookbook",
|
|
15
15
|
"functional"
|
|
16
16
|
],
|
|
17
|
-
"version": "
|
|
17
|
+
"version": "3.1.0",
|
|
18
18
|
"homepage": "https://github.com/char0n/ramda-adjunct",
|
|
19
19
|
"license": "BSD-3-Clause",
|
|
20
20
|
"repository": {
|
|
@@ -93,22 +93,8 @@
|
|
|
93
93
|
}
|
|
94
94
|
},
|
|
95
95
|
"test:web": "testem ci",
|
|
96
|
-
"test:ramda": "bnr test:ramda0.
|
|
97
|
-
"test:ramda0.
|
|
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",
|
|
96
|
+
"test:ramda": "bnr test:ramda0.28.0",
|
|
97
|
+
"test:ramda0.28.0": "npm install ramda@0.28.0 && npm test",
|
|
112
98
|
"test:bundle-create": "webpack --config webpack.config-test.web.js --progress",
|
|
113
99
|
"test:bundle-clean": "rimraf tmp-test-bundle.js",
|
|
114
100
|
"coverage": {
|
|
@@ -134,65 +120,64 @@
|
|
|
134
120
|
"prepublishOnly": "npm run clean && npm run lint && npm run test && npm run build && npm run docs",
|
|
135
121
|
"clean": "rimraf .nyc_output .tmp docs coverage tmp-test-bundle.js dist lib es"
|
|
136
122
|
},
|
|
137
|
-
"readme": "README.md",
|
|
138
123
|
"peerDependencies": {
|
|
139
|
-
"ramda": ">= 0.
|
|
124
|
+
"ramda": ">= 0.28.0 <= 0.28.0"
|
|
140
125
|
},
|
|
141
126
|
"devDependencies": {
|
|
142
|
-
"@babel/cli": "7.
|
|
143
|
-
"@babel/core": "=7.
|
|
144
|
-
"@babel/plugin-transform-modules-commonjs": "7.
|
|
145
|
-
"@babel/preset-env": "=7.
|
|
146
|
-
"@babel/register": "7.
|
|
147
|
-
"@commitlint/cli": "=
|
|
148
|
-
"@commitlint/config-conventional": "=
|
|
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",
|
|
149
134
|
"assert": "=2.0.0",
|
|
150
|
-
"babel-loader": "8.2.
|
|
135
|
+
"babel-loader": "=8.2.5",
|
|
151
136
|
"babel-plugin-annotate-pure-calls": "0.4.0",
|
|
152
137
|
"babel-plugin-istanbul": "6.1.1",
|
|
153
138
|
"better-npm-run": "0.1.1",
|
|
154
|
-
"chai": "4.3.
|
|
139
|
+
"chai": "4.3.6",
|
|
155
140
|
"codecov": "3.8.3",
|
|
156
|
-
"conventional-changelog-cli": "2.
|
|
157
|
-
"core-js": "=3.
|
|
141
|
+
"conventional-changelog-cli": "2.2.2",
|
|
142
|
+
"core-js": "=3.21.1",
|
|
158
143
|
"docdash": "git+https://github.com/char0n/docdash.git#534b44382138a55dd8d93642c979e51e46471185",
|
|
159
|
-
"dtslint": "=4.2.
|
|
160
|
-
"eslint": "
|
|
161
|
-
"eslint-config-airbnb-base": "
|
|
162
|
-
"eslint-config-prettier": "=8.
|
|
163
|
-
"eslint-plugin-import": "=2.
|
|
164
|
-
"eslint-plugin-mocha": "
|
|
144
|
+
"dtslint": "=4.2.1",
|
|
145
|
+
"eslint": "=8.14.0",
|
|
146
|
+
"eslint-config-airbnb-base": "=15.0.0",
|
|
147
|
+
"eslint-config-prettier": "=8.5.0",
|
|
148
|
+
"eslint-plugin-import": "=2.26.0",
|
|
149
|
+
"eslint-plugin-mocha": "=10.0.4",
|
|
165
150
|
"eslint-plugin-prettier": "4.0.0",
|
|
166
151
|
"eslint-plugin-ramda": "2.5.1",
|
|
167
152
|
"fantasy-land": "5.0.0",
|
|
168
|
-
"fantasy-laws": "=
|
|
153
|
+
"fantasy-laws": "=2.0.1",
|
|
169
154
|
"folktale": "=2.3.2",
|
|
170
|
-
"glob": "
|
|
155
|
+
"glob": "=8.0.1",
|
|
171
156
|
"husky": "7.0.4",
|
|
172
157
|
"istanbul": "=0.4.5",
|
|
173
|
-
"jsdoc": "=3.6.
|
|
158
|
+
"jsdoc": "=3.6.10",
|
|
174
159
|
"jsverify": "0.8.4",
|
|
175
160
|
"license-cli": "1.1.6",
|
|
176
|
-
"lint-staged": "
|
|
177
|
-
"mocha": "=9.
|
|
161
|
+
"lint-staged": "12.3.7",
|
|
162
|
+
"mocha": "=9.2.2",
|
|
178
163
|
"mocha-junit-reporter": "2.0.2",
|
|
179
164
|
"mocha-multi-reporters": "1.5.1",
|
|
180
|
-
"monet": "0.9.
|
|
165
|
+
"monet": "0.9.3",
|
|
181
166
|
"nyc": "15.1.0",
|
|
182
|
-
"prettier": "=2.
|
|
167
|
+
"prettier": "=2.6.2",
|
|
183
168
|
"process": "=0.11.10",
|
|
184
|
-
"ramda": "0.
|
|
169
|
+
"ramda": "=0.28.0",
|
|
185
170
|
"ramda-fantasy": "=0.8.0",
|
|
186
171
|
"regenerator-runtime": "=0.13.9",
|
|
187
172
|
"rimraf": "3.0.2",
|
|
188
|
-
"sanctuary-show": "
|
|
189
|
-
"sinon": "=
|
|
190
|
-
"terser-webpack-plugin": "5.
|
|
173
|
+
"sanctuary-show": "3.0.0",
|
|
174
|
+
"sinon": "=13.0.2",
|
|
175
|
+
"terser-webpack-plugin": "5.3.1",
|
|
191
176
|
"testem": "=3.6.0",
|
|
192
177
|
"tslint": "=6.1.3",
|
|
193
|
-
"typescript": "=4.
|
|
194
|
-
"webpack": "=5.
|
|
195
|
-
"webpack-cli": "4.9.
|
|
178
|
+
"typescript": "=4.6.3",
|
|
179
|
+
"webpack": "=5.72.0",
|
|
180
|
+
"webpack-cli": "4.9.2"
|
|
196
181
|
},
|
|
197
182
|
"browserslist": "> 0.25%, ie 10, ie 11, not op_mini all",
|
|
198
183
|
"tonicExampleFilename": "tonicExample.js",
|
package/src/flattenPath.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { pathOr, curry,
|
|
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) =>
|
|
24
|
+
const flattenPath = curry((path, obj) =>
|
|
25
|
+
mergeRight(obj, pathOr({}, path, obj))
|
|
26
|
+
);
|
|
25
27
|
|
|
26
28
|
export default flattenPath;
|
package/src/included.js
ADDED
|
@@ -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
|
|
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
|
|
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';
|
|
@@ -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';
|
|
@@ -113,8 +114,6 @@ export { default as noneP } from './noneP';
|
|
|
113
114
|
export { default as resolveP } from './resolveP';
|
|
114
115
|
export { default as rejectP } from './rejectP';
|
|
115
116
|
export { default as delayP } from './delayP';
|
|
116
|
-
export { default as thenP } from './thenP';
|
|
117
|
-
export { default as then } from './thenP';
|
|
118
117
|
export { default as thenCatchP } from './thenCatchP';
|
|
119
118
|
export { default as allSettledP } from './allSettledP';
|
|
120
119
|
export { default as Y } from './Y';
|
|
@@ -142,8 +141,7 @@ export { default as sliceTo } from './sliceTo';
|
|
|
142
141
|
export { default as omitIndexes } from './omitIndexes';
|
|
143
142
|
export { default as compact } from './compact';
|
|
144
143
|
export { default as appendFlipped } from './appendFlipped';
|
|
145
|
-
export { default as
|
|
146
|
-
export { default as included } from './contained';
|
|
144
|
+
export { default as included } from './included';
|
|
147
145
|
export { default as move } from './move';
|
|
148
146
|
export { default as lengthGt } from './lengthGt';
|
|
149
147
|
export { default as lengthLt } from './lengthLt';
|
|
@@ -161,6 +159,7 @@ export { default as toArray } from './toArray';
|
|
|
161
159
|
export { default as allUnique } from './allUnique';
|
|
162
160
|
export { default as notAllUnique } from './notAllUnique';
|
|
163
161
|
export { default as sortByProps } from './sortByProps';
|
|
162
|
+
export { default as sortByPaths } from './sortByPaths';
|
|
164
163
|
export { default as skipTake } from './skipTake';
|
|
165
164
|
export { default as rangeStep } from './rangeStep';
|
|
166
165
|
export { default as findOr } from './findOr';
|
|
@@ -172,9 +171,6 @@ export { default as renameKeys } from './renameKeys';
|
|
|
172
171
|
export { default as renameKeysWith } from './renameKeysWith';
|
|
173
172
|
export { default as renameKeyWith } from './renameKeyWith';
|
|
174
173
|
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
174
|
export { default as mergeProps } from './mergeProps';
|
|
179
175
|
export { default as mergePaths } from './mergePaths';
|
|
180
176
|
export { default as mergeProp } from './mergeProp';
|
|
@@ -182,7 +178,6 @@ export { default as mergePath } from './mergePath';
|
|
|
182
178
|
export { default as omitBy } from './omitBy';
|
|
183
179
|
export { default as pathOrLazy } from './pathOrLazy';
|
|
184
180
|
export { default as viewOr } from './viewOr';
|
|
185
|
-
export { default as hasPath } from './hasPath';
|
|
186
181
|
export { default as spreadProp } from './spreadProp';
|
|
187
182
|
export { default as spreadPath } from './spreadPath';
|
|
188
183
|
export { default as flattenProp } from './flattenProp';
|
|
@@ -225,6 +220,7 @@ export { default as toInteger32 } from './toInteger32';
|
|
|
225
220
|
export { default as toInt32 } from './toInteger32'; // alias of toInteger32
|
|
226
221
|
export { default as toUinteger32 } from './toUinteger32';
|
|
227
222
|
export { default as toUint32 } from './toUinteger32'; // alias of to toUinteger32
|
|
223
|
+
export { default as toNumber } from './toNumber';
|
|
228
224
|
// String
|
|
229
225
|
export { default as replaceAll } from './replaceAll';
|
|
230
226
|
export { default as escapeRegExp } from './escapeRegExp';
|
|
@@ -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;
|
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;
|
package/src/isNotNilOrEmpty.js
CHANGED
|
@@ -3,7 +3,7 @@ import { complement } from 'ramda';
|
|
|
3
3
|
import isNilOrEmpty from './isNilOrEmpty';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* Returns `
|
|
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
|
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),
|
|
27
|
+
over(lensPath(path), mergeLeft(source), obj)
|
|
30
28
|
);
|
|
31
29
|
|
|
32
30
|
export default mergePath;
|
package/src/omitIndexes.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
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) =>
|
|
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.
|
package/src/pickIndexes.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { filter, addIndex, curry,
|
|
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) =>
|
|
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,
|
|
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(
|
|
24
|
+
const spreadPath = curryN(2, converge(mergeRight, [dissocPath, pathOr({})]));
|
|
25
25
|
|
|
26
26
|
export default spreadPath;
|
package/src/toNumber.js
ADDED
|
@@ -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/src/trimCharsEnd.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { curry, dropLastWhile, join, pipe, split } from 'ramda';
|
|
2
2
|
|
|
3
|
-
import
|
|
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(
|
|
22
|
+
pipe(split(''), dropLastWhile(included(chars)), join(''))(value)
|
|
23
23
|
);
|
|
24
24
|
|
|
25
25
|
export default trimCharsEnd;
|
package/src/trimCharsStart.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { curry, dropWhile, join, pipe, split } from 'ramda';
|
|
2
2
|
|
|
3
|
-
import
|
|
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(
|
|
22
|
+
pipe(split(''), dropWhile(included(chars)), join(''))(value)
|
|
23
23
|
);
|
|
24
24
|
|
|
25
25
|
export default trimCharsStart;
|
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
|
*/
|
|
@@ -629,19 +635,6 @@ declare namespace RamdaAdjunct {
|
|
|
629
635
|
(key: string): (obj: object) => object;
|
|
630
636
|
};
|
|
631
637
|
|
|
632
|
-
/**
|
|
633
|
-
* Create a new object with the own properties of the second object merged with
|
|
634
|
-
* the own properties of the first object. If a key exists in both objects,
|
|
635
|
-
* the value from the first object will be used. *
|
|
636
|
-
* Putting it simply: it sets properties only if they don't exist.
|
|
637
|
-
*/
|
|
638
|
-
mergeRight(source: object, destination: object): object;
|
|
639
|
-
mergeRight(source: object): (destination: object) => object;
|
|
640
|
-
mergeLeft(source: object, destination: object): object; // alias
|
|
641
|
-
mergeLeft(source: object): (destination: object) => object; // alias
|
|
642
|
-
resetToDefault(defaultOptions: object, options: object): object; // alias of mergeRight
|
|
643
|
-
resetToDefault(defaultOptions: object): (options: object) => object; // alias of mergeRight
|
|
644
|
-
|
|
645
638
|
/**
|
|
646
639
|
* Functional equivalent of merging object properties with object spread.
|
|
647
640
|
*/
|
|
@@ -901,12 +894,6 @@ declare namespace RamdaAdjunct {
|
|
|
901
894
|
(high: number): (value: number) => boolean;
|
|
902
895
|
};
|
|
903
896
|
|
|
904
|
-
/**
|
|
905
|
-
* Returns whether or not an object has an own property with the specified name at a given path.
|
|
906
|
-
*/
|
|
907
|
-
hasPath(path: Array<string | number>, obj: object): boolean;
|
|
908
|
-
hasPath(path: Array<string | number>): (obj: object) => boolean;
|
|
909
|
-
|
|
910
897
|
/**
|
|
911
898
|
* Spreads object under property path onto provided object.
|
|
912
899
|
*/
|
|
@@ -1018,16 +1005,6 @@ declare namespace RamdaAdjunct {
|
|
|
1018
1005
|
catchP<A, B = unknown>(onRejected: (error: any) => B | Promise<B>, promise: Promise<A>): Promise<A | B>;
|
|
1019
1006
|
catchP<A, B = unknown>(onRejected: (error: any) => B | Promise<B>): (promise: Promise<A>) => Promise<A | B>;
|
|
1020
1007
|
|
|
1021
|
-
/**
|
|
1022
|
-
* Composable shortcut for `Promise.then`.
|
|
1023
|
-
* The thenP function returns a Promise. It takes two arguments: a callback function for the success of the Promise
|
|
1024
|
-
* and the promise instance itself.
|
|
1025
|
-
*/
|
|
1026
|
-
thenP<T>(onFulfilled: Function, thenable: Promise<T>): Promise<T>;
|
|
1027
|
-
thenP<T>(onFulfilled: Function): (thenable: Promise<T>) => Promise<T>;
|
|
1028
|
-
then<T>(onFulfilled: Function, thenable: Promise<T>): Promise<T>;
|
|
1029
|
-
then<T>(onFulfilled: Function): (thenable: Promise<T>) => Promise<T>;
|
|
1030
|
-
|
|
1031
1008
|
/**
|
|
1032
1009
|
* Composable shortcut for `Promise.then` that allows for success and failure call backs.
|
|
1033
1010
|
* The thenCatchP function returns a Promise. It takes three arguments: a callback function for the success of the Promise,
|
|
@@ -1323,12 +1300,10 @@ declare namespace RamdaAdjunct {
|
|
|
1323
1300
|
* to at least one element of the given list or false otherwise.
|
|
1324
1301
|
* Given list can be a string.
|
|
1325
1302
|
*
|
|
1326
|
-
* Like {@link http://ramdajs.com/docs/#contains|R.
|
|
1303
|
+
* Like {@link http://ramdajs.com/docs/#contains|R.includes} but with argument order reversed.
|
|
1327
1304
|
*/
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
included<T>(list: T[], val: T): boolean; // alias
|
|
1331
|
-
included<T>(list: T[]): (val: T) => boolean; // alias
|
|
1305
|
+
included<T>(list: T[], val: T): boolean;
|
|
1306
|
+
included<T>(list: T[]): (val: T) => boolean;
|
|
1332
1307
|
|
|
1333
1308
|
/**
|
|
1334
1309
|
* Can be used as a way to compose multiple invokers together to form polymorphic functions,
|
|
@@ -1508,6 +1483,12 @@ declare namespace RamdaAdjunct {
|
|
|
1508
1483
|
skipTake<T>(n: number, list: T[]): T[];
|
|
1509
1484
|
skipTake<T>(n: number): (list: T[]) => T[];
|
|
1510
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
|
+
|
|
1511
1492
|
/**
|
|
1512
1493
|
* Determine if input value is an indexed data type.
|
|
1513
1494
|
*/
|
|
@@ -1538,6 +1519,11 @@ declare namespace RamdaAdjunct {
|
|
|
1538
1519
|
toUinteger32(val: number): number;
|
|
1539
1520
|
toUint32(val: number): number; // alias
|
|
1540
1521
|
|
|
1522
|
+
/**
|
|
1523
|
+
* Converts value to a number.
|
|
1524
|
+
*/
|
|
1525
|
+
toNumber(val: any): number;
|
|
1526
|
+
|
|
1541
1527
|
/**
|
|
1542
1528
|
* Creates an array of numbers (positive and/or negative) progressing from start up to, but not including, end.
|
|
1543
1529
|
*
|
package/es/contained.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
import { flip, contains } from 'ramda';
|
|
2
|
-
/**
|
|
3
|
-
* Returns true if the specified value is equal, in R.equals terms,
|
|
4
|
-
* to at least one element of the given list or false otherwise.
|
|
5
|
-
* Given list can be a string.
|
|
6
|
-
*
|
|
7
|
-
* Like {@link http://ramdajs.com/docs/#contains|R.contains} but with argument order reversed.
|
|
8
|
-
*
|
|
9
|
-
* @func contained
|
|
10
|
-
* @aliases included
|
|
11
|
-
* @memberOf RA
|
|
12
|
-
* @since {@link https://char0n.github.io/ramda-adjunct/2.8.0|v2.8.0}
|
|
13
|
-
* @deprecated since v2.12.0; please use RA.included alias
|
|
14
|
-
* @category List
|
|
15
|
-
* @sig [a] -> a -> Boolean
|
|
16
|
-
* @param {Array|String} list The list to consider
|
|
17
|
-
* @param {*} a The item to compare against
|
|
18
|
-
* @return {boolean} Returns Boolean `true` if an equivalent item is in the list or `false` otherwise
|
|
19
|
-
* @see {@link http://ramdajs.com/docs/#contains|R.contains}
|
|
20
|
-
* @example
|
|
21
|
-
*
|
|
22
|
-
* RA.contained([1, 2, 3], 3); //=> true
|
|
23
|
-
* RA.contained([1, 2, 3], 4); //=> false
|
|
24
|
-
* RA.contained([{ name: 'Fred' }], { name: 'Fred' }); //=> true
|
|
25
|
-
* RA.contained([[42]], [42]); //=> true
|
|
26
|
-
*/
|
|
27
|
-
|
|
28
|
-
var contained = flip(contains);
|
|
29
|
-
export default contained;
|