ramda-adjunct 2.33.0 → 3.0.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 +55 -0
- package/README.md +3 -5
- package/dist/RA.node.js +854 -885
- package/dist/RA.node.min.js +1 -1
- package/dist/RA.web.js +854 -885
- package/dist/RA.web.min.js +1 -1
- package/dist/RA.web.standalone.js +6398 -5923
- package/dist/RA.web.standalone.min.js +1 -1
- package/es/copyKeys.js +34 -0
- package/es/fantasy-land/Identity.js +12 -12
- package/es/flattenPath.js +2 -2
- package/es/included.js +27 -0
- package/es/index.js +6 -11
- package/es/internal/isCoercible.js +6 -0
- package/es/internal/isOfTypeObject.js +1 -1
- package/es/internal/ponyfills/Promise.any.js +9 -5
- package/es/isArrayLike.js +1 -1
- 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/reduceP.js +1 -1
- package/es/reduceRightP.js +1 -1
- 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 +43 -0
- package/lib/fantasy-land/Identity.js +13 -13
- 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 +11 -19
- 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 +9 -5
- package/lib/isArrayLike.js +1 -1
- 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/reduceP.js +1 -1
- package/lib/reduceRightP.js +1 -1
- package/lib/repeatStr.js +1 -1
- package/lib/replaceAll.js +1 -1
- package/lib/sign.js +1 -1
- 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 +38 -52
- package/src/copyKeys.js +31 -0
- package/src/flattenPath.js +4 -2
- package/src/included.js +28 -0
- package/src/index.js +5 -10
- package/src/internal/isCoercible.js +12 -0
- package/src/internal/ponyfills/Promise.any.js +1 -1
- 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/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 +16 -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.0.0",
|
|
18
18
|
"homepage": "https://github.com/char0n/ramda-adjunct",
|
|
19
19
|
"license": "BSD-3-Clause",
|
|
20
20
|
"repository": {
|
|
@@ -78,6 +78,7 @@
|
|
|
78
78
|
"build:es": "better-npm-run build:es",
|
|
79
79
|
"build:commonjs": "better-npm-run build:commonjs",
|
|
80
80
|
"build:umd": "better-npm-run build:umd",
|
|
81
|
+
"prepublishOnly": "better-npm-run prepublishOnly",
|
|
81
82
|
"clean": "better-npm-run clean"
|
|
82
83
|
},
|
|
83
84
|
"betterScripts": {
|
|
@@ -92,22 +93,8 @@
|
|
|
92
93
|
}
|
|
93
94
|
},
|
|
94
95
|
"test:web": "testem ci",
|
|
95
|
-
"test:ramda": "bnr test:ramda0.
|
|
96
|
-
"test:ramda0.
|
|
97
|
-
"test:ramda0.19.1": "npm install ramda@0.19.1 && npm test",
|
|
98
|
-
"test:ramda0.20.0": "npm install ramda@0.20.0 && npm test",
|
|
99
|
-
"test:ramda0.20.1": "npm install ramda@0.20.1 && npm test",
|
|
100
|
-
"test:ramda0.21.0": "npm install ramda@0.21.0 && npm test",
|
|
101
|
-
"test:ramda0.22.0": "npm install ramda@0.22.0 && npm test",
|
|
102
|
-
"test:ramda0.22.1": "npm install ramda@0.22.1 && npm test",
|
|
103
|
-
"test:ramda0.23.0": "npm install ramda@0.23.0 && npm test",
|
|
104
|
-
"test:ramda0.24.0": "npm install ramda@0.24.0 && npm test",
|
|
105
|
-
"test:ramda0.24.1": "npm install ramda@0.24.1 && npm test",
|
|
106
|
-
"test:ramda0.25.0": "npm install ramda@0.25.0 && npm test",
|
|
107
|
-
"test:ramda0.26.0": "npm install ramda@0.26.0 && npm test",
|
|
108
|
-
"test:ramda0.26.1": "npm install ramda@0.26.1 && npm test",
|
|
109
|
-
"test:ramda0.27.0": "npm install ramda@0.27.0 && npm test",
|
|
110
|
-
"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",
|
|
111
98
|
"test:bundle-create": "webpack --config webpack.config-test.web.js --progress",
|
|
112
99
|
"test:bundle-clean": "rimraf tmp-test-bundle.js",
|
|
113
100
|
"coverage": {
|
|
@@ -133,65 +120,64 @@
|
|
|
133
120
|
"prepublishOnly": "npm run clean && npm run lint && npm run test && npm run build && npm run docs",
|
|
134
121
|
"clean": "rimraf .nyc_output .tmp docs coverage tmp-test-bundle.js dist lib es"
|
|
135
122
|
},
|
|
136
|
-
"readme": "README.md",
|
|
137
123
|
"peerDependencies": {
|
|
138
|
-
"ramda": ">= 0.
|
|
124
|
+
"ramda": ">= 0.28.0 <= 0.28.0"
|
|
139
125
|
},
|
|
140
126
|
"devDependencies": {
|
|
141
|
-
"@babel/cli": "7.
|
|
142
|
-
"@babel/core": "=7.
|
|
143
|
-
"@babel/plugin-transform-modules-commonjs": "7.
|
|
144
|
-
"@babel/preset-env": "=7.
|
|
145
|
-
"@babel/register": "7.
|
|
146
|
-
"@commitlint/cli": "=
|
|
147
|
-
"@commitlint/config-conventional": "=
|
|
127
|
+
"@babel/cli": "7.16.8",
|
|
128
|
+
"@babel/core": "=7.16.7",
|
|
129
|
+
"@babel/plugin-transform-modules-commonjs": "7.16.8",
|
|
130
|
+
"@babel/preset-env": "=7.16.8",
|
|
131
|
+
"@babel/register": "7.16.9",
|
|
132
|
+
"@commitlint/cli": "=16.0.2",
|
|
133
|
+
"@commitlint/config-conventional": "=16.0.0",
|
|
148
134
|
"assert": "=2.0.0",
|
|
149
|
-
"babel-loader": "8.2.
|
|
135
|
+
"babel-loader": "8.2.3",
|
|
150
136
|
"babel-plugin-annotate-pure-calls": "0.4.0",
|
|
151
|
-
"babel-plugin-istanbul": "6.
|
|
137
|
+
"babel-plugin-istanbul": "6.1.1",
|
|
152
138
|
"better-npm-run": "0.1.1",
|
|
153
139
|
"chai": "4.3.4",
|
|
154
|
-
"codecov": "3.8.
|
|
155
|
-
"conventional-changelog-cli": "2.
|
|
156
|
-
"core-js": "=3.
|
|
140
|
+
"codecov": "3.8.3",
|
|
141
|
+
"conventional-changelog-cli": "2.2.2",
|
|
142
|
+
"core-js": "=3.20.3",
|
|
157
143
|
"docdash": "git+https://github.com/char0n/docdash.git#534b44382138a55dd8d93642c979e51e46471185",
|
|
158
|
-
"dtslint": "=4.
|
|
159
|
-
"eslint": "7.
|
|
160
|
-
"eslint-config-airbnb-base": "
|
|
144
|
+
"dtslint": "=4.2.1",
|
|
145
|
+
"eslint": "=8.7.0",
|
|
146
|
+
"eslint-config-airbnb-base": "=15.0.0",
|
|
161
147
|
"eslint-config-prettier": "=8.3.0",
|
|
162
|
-
"eslint-plugin-import": "2.
|
|
163
|
-
"eslint-plugin-mocha": "
|
|
164
|
-
"eslint-plugin-prettier": "
|
|
148
|
+
"eslint-plugin-import": "=2.25.4",
|
|
149
|
+
"eslint-plugin-mocha": "10.0.3",
|
|
150
|
+
"eslint-plugin-prettier": "4.0.0",
|
|
165
151
|
"eslint-plugin-ramda": "2.5.1",
|
|
166
152
|
"fantasy-land": "5.0.0",
|
|
167
153
|
"fantasy-laws": "=1.2.0",
|
|
168
154
|
"folktale": "=2.3.2",
|
|
169
|
-
"glob": "7.
|
|
170
|
-
"husky": "
|
|
155
|
+
"glob": "7.2.0",
|
|
156
|
+
"husky": "7.0.4",
|
|
171
157
|
"istanbul": "=0.4.5",
|
|
172
158
|
"jsdoc": "=3.6.7",
|
|
173
159
|
"jsverify": "0.8.4",
|
|
174
160
|
"license-cli": "1.1.6",
|
|
175
|
-
"lint-staged": "
|
|
176
|
-
"mocha": "=
|
|
177
|
-
"mocha-junit-reporter": "2.0.
|
|
161
|
+
"lint-staged": "12.1.7",
|
|
162
|
+
"mocha": "=9.1.4",
|
|
163
|
+
"mocha-junit-reporter": "2.0.2",
|
|
178
164
|
"mocha-multi-reporters": "1.5.1",
|
|
179
|
-
"monet": "0.9.
|
|
165
|
+
"monet": "0.9.3",
|
|
180
166
|
"nyc": "15.1.0",
|
|
181
|
-
"prettier": "=2.
|
|
167
|
+
"prettier": "=2.5.1",
|
|
182
168
|
"process": "=0.11.10",
|
|
183
|
-
"ramda": "0.
|
|
169
|
+
"ramda": "=0.28.0",
|
|
184
170
|
"ramda-fantasy": "=0.8.0",
|
|
185
|
-
"regenerator-runtime": "=0.13.
|
|
171
|
+
"regenerator-runtime": "=0.13.9",
|
|
186
172
|
"rimraf": "3.0.2",
|
|
187
173
|
"sanctuary-show": "2.0.0",
|
|
188
|
-
"sinon": "
|
|
189
|
-
"terser-webpack-plugin": "5.
|
|
190
|
-
"testem": "=3.
|
|
174
|
+
"sinon": "=11.1.2",
|
|
175
|
+
"terser-webpack-plugin": "5.3.0",
|
|
176
|
+
"testem": "=3.6.0",
|
|
191
177
|
"tslint": "=6.1.3",
|
|
192
|
-
"typescript": "=4.
|
|
193
|
-
"webpack": "=5.
|
|
194
|
-
"webpack-cli": "4.
|
|
178
|
+
"typescript": "=4.5.4",
|
|
179
|
+
"webpack": "=5.66.0",
|
|
180
|
+
"webpack-cli": "4.9.1"
|
|
195
181
|
},
|
|
196
182
|
"browserslist": "> 0.25%, ie 10, ie 11, not op_mini all",
|
|
197
183
|
"tonicExampleFilename": "tonicExample.js",
|
package/src/copyKeys.js
ADDED
|
@@ -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;
|
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';
|
|
@@ -113,8 +113,6 @@ export { default as noneP } from './noneP';
|
|
|
113
113
|
export { default as resolveP } from './resolveP';
|
|
114
114
|
export { default as rejectP } from './rejectP';
|
|
115
115
|
export { default as delayP } from './delayP';
|
|
116
|
-
export { default as thenP } from './thenP';
|
|
117
|
-
export { default as then } from './thenP';
|
|
118
116
|
export { default as thenCatchP } from './thenCatchP';
|
|
119
117
|
export { default as allSettledP } from './allSettledP';
|
|
120
118
|
export { default as Y } from './Y';
|
|
@@ -142,8 +140,7 @@ export { default as sliceTo } from './sliceTo';
|
|
|
142
140
|
export { default as omitIndexes } from './omitIndexes';
|
|
143
141
|
export { default as compact } from './compact';
|
|
144
142
|
export { default as appendFlipped } from './appendFlipped';
|
|
145
|
-
export { default as
|
|
146
|
-
export { default as included } from './contained';
|
|
143
|
+
export { default as included } from './included';
|
|
147
144
|
export { default as move } from './move';
|
|
148
145
|
export { default as lengthGt } from './lengthGt';
|
|
149
146
|
export { default as lengthLt } from './lengthLt';
|
|
@@ -171,9 +168,7 @@ export { default as paths } from './paths';
|
|
|
171
168
|
export { default as renameKeys } from './renameKeys';
|
|
172
169
|
export { default as renameKeysWith } from './renameKeysWith';
|
|
173
170
|
export { default as renameKeyWith } from './renameKeyWith';
|
|
174
|
-
export { default as
|
|
175
|
-
export { default as mergeLeft } from './mergeRight';
|
|
176
|
-
export { default as resetToDefault } from './mergeRight';
|
|
171
|
+
export { default as copyKeys } from './copyKeys';
|
|
177
172
|
export { default as mergeProps } from './mergeProps';
|
|
178
173
|
export { default as mergePaths } from './mergePaths';
|
|
179
174
|
export { default as mergeProp } from './mergeProp';
|
|
@@ -181,7 +176,6 @@ export { default as mergePath } from './mergePath';
|
|
|
181
176
|
export { default as omitBy } from './omitBy';
|
|
182
177
|
export { default as pathOrLazy } from './pathOrLazy';
|
|
183
178
|
export { default as viewOr } from './viewOr';
|
|
184
|
-
export { default as hasPath } from './hasPath';
|
|
185
179
|
export { default as spreadProp } from './spreadProp';
|
|
186
180
|
export { default as spreadPath } from './spreadPath';
|
|
187
181
|
export { default as flattenProp } from './flattenProp';
|
|
@@ -224,6 +218,7 @@ export { default as toInteger32 } from './toInteger32';
|
|
|
224
218
|
export { default as toInt32 } from './toInteger32'; // alias of toInteger32
|
|
225
219
|
export { default as toUinteger32 } from './toUinteger32';
|
|
226
220
|
export { default as toUint32 } from './toUinteger32'; // alias of to toUinteger32
|
|
221
|
+
export { default as toNumber } from './toNumber';
|
|
227
222
|
// String
|
|
228
223
|
export { default as replaceAll } from './replaceAll';
|
|
229
224
|
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/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.
|
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
|
@@ -594,6 +594,14 @@ declare namespace RamdaAdjunct {
|
|
|
594
594
|
renameKeys(keysMap: Dictionary<string>, obj: object): object;
|
|
595
595
|
renameKeys(keysMap: Dictionary<string>): (obj: object) => object;
|
|
596
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
|
+
|
|
597
605
|
/**
|
|
598
606
|
* Creates a new object with the own properties of the provided object, but the
|
|
599
607
|
* keys renamed according to logic of renaming function.
|
|
@@ -621,19 +629,6 @@ declare namespace RamdaAdjunct {
|
|
|
621
629
|
(key: string): (obj: object) => object;
|
|
622
630
|
};
|
|
623
631
|
|
|
624
|
-
/**
|
|
625
|
-
* Create a new object with the own properties of the second object merged with
|
|
626
|
-
* the own properties of the first object. If a key exists in both objects,
|
|
627
|
-
* the value from the first object will be used. *
|
|
628
|
-
* Putting it simply: it sets properties only if they don't exist.
|
|
629
|
-
*/
|
|
630
|
-
mergeRight(source: object, destination: object): object;
|
|
631
|
-
mergeRight(source: object): (destination: object) => object;
|
|
632
|
-
mergeLeft(source: object, destination: object): object; // alias
|
|
633
|
-
mergeLeft(source: object): (destination: object) => object; // alias
|
|
634
|
-
resetToDefault(defaultOptions: object, options: object): object; // alias of mergeRight
|
|
635
|
-
resetToDefault(defaultOptions: object): (options: object) => object; // alias of mergeRight
|
|
636
|
-
|
|
637
632
|
/**
|
|
638
633
|
* Functional equivalent of merging object properties with object spread.
|
|
639
634
|
*/
|
|
@@ -893,12 +888,6 @@ declare namespace RamdaAdjunct {
|
|
|
893
888
|
(high: number): (value: number) => boolean;
|
|
894
889
|
};
|
|
895
890
|
|
|
896
|
-
/**
|
|
897
|
-
* Returns whether or not an object has an own property with the specified name at a given path.
|
|
898
|
-
*/
|
|
899
|
-
hasPath(path: Array<string | number>, obj: object): boolean;
|
|
900
|
-
hasPath(path: Array<string | number>): (obj: object) => boolean;
|
|
901
|
-
|
|
902
891
|
/**
|
|
903
892
|
* Spreads object under property path onto provided object.
|
|
904
893
|
*/
|
|
@@ -1010,16 +999,6 @@ declare namespace RamdaAdjunct {
|
|
|
1010
999
|
catchP<A, B = unknown>(onRejected: (error: any) => B | Promise<B>, promise: Promise<A>): Promise<A | B>;
|
|
1011
1000
|
catchP<A, B = unknown>(onRejected: (error: any) => B | Promise<B>): (promise: Promise<A>) => Promise<A | B>;
|
|
1012
1001
|
|
|
1013
|
-
/**
|
|
1014
|
-
* Composable shortcut for `Promise.then`.
|
|
1015
|
-
* The thenP function returns a Promise. It takes two arguments: a callback function for the success of the Promise
|
|
1016
|
-
* and the promise instance itself.
|
|
1017
|
-
*/
|
|
1018
|
-
thenP<T>(onFulfilled: Function, thenable: Promise<T>): Promise<T>;
|
|
1019
|
-
thenP<T>(onFulfilled: Function): (thenable: Promise<T>) => Promise<T>;
|
|
1020
|
-
then<T>(onFulfilled: Function, thenable: Promise<T>): Promise<T>;
|
|
1021
|
-
then<T>(onFulfilled: Function): (thenable: Promise<T>) => Promise<T>;
|
|
1022
|
-
|
|
1023
1002
|
/**
|
|
1024
1003
|
* Composable shortcut for `Promise.then` that allows for success and failure call backs.
|
|
1025
1004
|
* The thenCatchP function returns a Promise. It takes three arguments: a callback function for the success of the Promise,
|
|
@@ -1315,12 +1294,10 @@ declare namespace RamdaAdjunct {
|
|
|
1315
1294
|
* to at least one element of the given list or false otherwise.
|
|
1316
1295
|
* Given list can be a string.
|
|
1317
1296
|
*
|
|
1318
|
-
* Like {@link http://ramdajs.com/docs/#contains|R.
|
|
1297
|
+
* Like {@link http://ramdajs.com/docs/#contains|R.includes} but with argument order reversed.
|
|
1319
1298
|
*/
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
included<T>(list: T[], val: T): boolean; // alias
|
|
1323
|
-
included<T>(list: T[]): (val: T) => boolean; // alias
|
|
1299
|
+
included<T>(list: T[], val: T): boolean;
|
|
1300
|
+
included<T>(list: T[]): (val: T) => boolean;
|
|
1324
1301
|
|
|
1325
1302
|
/**
|
|
1326
1303
|
* Can be used as a way to compose multiple invokers together to form polymorphic functions,
|
|
@@ -1530,6 +1507,11 @@ declare namespace RamdaAdjunct {
|
|
|
1530
1507
|
toUinteger32(val: number): number;
|
|
1531
1508
|
toUint32(val: number): number; // alias
|
|
1532
1509
|
|
|
1510
|
+
/**
|
|
1511
|
+
* Converts value to a number.
|
|
1512
|
+
*/
|
|
1513
|
+
toNumber(val: any): number;
|
|
1514
|
+
|
|
1533
1515
|
/**
|
|
1534
1516
|
* Creates an array of numbers (positive and/or negative) progressing from start up to, but not including, end.
|
|
1535
1517
|
*
|
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;
|
package/es/hasPath.js
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { length, has, path, head, tail, curryN } from 'ramda';
|
|
2
|
-
import isObj from './isObj';
|
|
3
|
-
/**
|
|
4
|
-
* Returns whether or not an object has an own property with the specified name at a given path.
|
|
5
|
-
*
|
|
6
|
-
* @func hasPath
|
|
7
|
-
* @memberOf RA
|
|
8
|
-
* @since {@link https://char0n.github.io/ramda-adjunct/1.14.0|v1.14.0}
|
|
9
|
-
* @deprecated since v2.12.0; ramda@0.26.0 contains hasPath
|
|
10
|
-
* @category Object
|
|
11
|
-
* @typedef Idx = String | Int
|
|
12
|
-
* @sig [Idx] -> {a} -> Boolean
|
|
13
|
-
* @param {Array.<string|number>} path The path of the nested property
|
|
14
|
-
* @param {Object} obj The object to test
|
|
15
|
-
* @return {boolean}
|
|
16
|
-
* @see {@link http://ramdajs.com/docs/#has|R.has}
|
|
17
|
-
* @example
|
|
18
|
-
*
|
|
19
|
-
* RA.hasPath(['a', 'b'], { a: { b: 1 } }); //=> true
|
|
20
|
-
* RA.hasPath(['a', 'b', 'c'], { a: { b: 1 } }); //=> false
|
|
21
|
-
* RA.hasPath(['a', 'b'], { a: { } }); //=> false
|
|
22
|
-
* RA.hasPath([0], [1, 2]); //=> true
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
var hasPath = curryN(2, function (objPath, obj) {
|
|
26
|
-
var prop = head(objPath); // termination conditions
|
|
27
|
-
|
|
28
|
-
if (length(objPath) === 0 || !isObj(obj)) {
|
|
29
|
-
return false;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
if (length(objPath) === 1) {
|
|
33
|
-
return has(prop, obj);
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return hasPath(tail(objPath), path([prop], obj)); // base case
|
|
37
|
-
});
|
|
38
|
-
export default hasPath;
|
package/es/mergeRight.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import { merge, flip } from 'ramda';
|
|
2
|
-
/**
|
|
3
|
-
* Create a new object with the own properties of the second object merged with
|
|
4
|
-
* the own properties of the first object. If a key exists in both objects,
|
|
5
|
-
* the value from the first object will be used. *
|
|
6
|
-
* Putting it simply: it sets properties only if they don't exist.
|
|
7
|
-
*
|
|
8
|
-
* @func mergeRight
|
|
9
|
-
* @deprecated since v2.12.0; available in ramda@0.26.0 as R.mergeLeft
|
|
10
|
-
* @aliases mergeLeft, resetToDefault
|
|
11
|
-
* @memberOf RA
|
|
12
|
-
* @since {@link https://char0n.github.io/ramda-adjunct/1.6.0|v1.6.0}
|
|
13
|
-
* @category Object
|
|
14
|
-
* @sig {k: v} -> {k: v} -> {k: v}
|
|
15
|
-
* @param {Object} r Destination
|
|
16
|
-
* @param {Object} l Source
|
|
17
|
-
* @return {Object}
|
|
18
|
-
* @see {@link http://ramdajs.com/docs/#merge|R.merge}, {@link https://github.com/ramda/ramda/wiki/Cookbook#set-properties-only-if-they-dont-exist|Ramda Cookbook}
|
|
19
|
-
* @example
|
|
20
|
-
*
|
|
21
|
-
* RA.mergeRight({ 'age': 40 }, { 'name': 'fred', 'age': 10 });
|
|
22
|
-
* //=> { 'name': 'fred', 'age': 40 }
|
|
23
|
-
*/
|
|
24
|
-
|
|
25
|
-
var mergeRight = flip(merge);
|
|
26
|
-
export default mergeRight;
|
package/es/thenP.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { invoker } from 'ramda';
|
|
2
|
-
/**
|
|
3
|
-
* Composable shortcut for `Promise.then`.
|
|
4
|
-
* The thenP function returns a Promise. It takes two arguments: a callback function for the success of the Promise
|
|
5
|
-
* and the promise instance itself.
|
|
6
|
-
*
|
|
7
|
-
* @func thenP
|
|
8
|
-
* @memberOf RA
|
|
9
|
-
* @aliases then
|
|
10
|
-
* @since {@link https://char0n.github.io/ramda-adjunct/2.8.0|v2.8.0}
|
|
11
|
-
* @deprecated since v2.12.0; available in ramda@0.26.0 as R.then
|
|
12
|
-
* @category Function
|
|
13
|
-
* @sig (a -> Promise b | b) -> Promise b
|
|
14
|
-
* @param {Function} onFulfilled A Function called if the Promise is fulfilled. This function has one argument, the fulfillment value
|
|
15
|
-
* @param {Promise} promise Any Promise or Thenable object
|
|
16
|
-
* @return {Promise} A Promise in the pending status
|
|
17
|
-
|
|
18
|
-
* @see {@link RA.resolveP|resolveP}, {@link RA.rejectP|rejectP}, {@link RA.allP|allP}
|
|
19
|
-
* @example
|
|
20
|
-
*
|
|
21
|
-
* const promise = Promise.resolve(1);
|
|
22
|
-
* const add1 = v => v + 1;
|
|
23
|
-
*
|
|
24
|
-
* RA.thenP(add1, promise); // => Promise(2)
|
|
25
|
-
*/
|
|
26
|
-
|
|
27
|
-
var thenP = invoker(1, 'then');
|
|
28
|
-
export default thenP;
|