update
This commit is contained in:
parent
d9becc67b6
commit
9308795b8b
964 changed files with 104265 additions and 16 deletions
54
node_modules/ramda/src/paths.js
generated
vendored
Normal file
54
node_modules/ramda/src/paths.js
generated
vendored
Normal file
|
@ -0,0 +1,54 @@
|
|||
var _curry2 =
|
||||
/*#__PURE__*/
|
||||
require("./internal/_curry2");
|
||||
|
||||
var _isInteger =
|
||||
/*#__PURE__*/
|
||||
require("./internal/_isInteger");
|
||||
|
||||
var nth =
|
||||
/*#__PURE__*/
|
||||
require("./nth");
|
||||
/**
|
||||
* Retrieves the values at given paths of an object.
|
||||
*
|
||||
* @func
|
||||
* @memberOf R
|
||||
* @since v0.27.0
|
||||
* @category Object
|
||||
* @typedefn Idx = [String | Int]
|
||||
* @sig [Idx] -> {a} -> [a | Undefined]
|
||||
* @param {Array} pathsArray The array of paths to be fetched.
|
||||
* @param {Object} obj The object to retrieve the nested properties from.
|
||||
* @return {Array} A list consisting of values at paths specified by "pathsArray".
|
||||
* @see R.path
|
||||
* @example
|
||||
*
|
||||
* R.paths([['a', 'b'], ['p', 0, 'q']], {a: {b: 2}, p: [{q: 3}]}); //=> [2, 3]
|
||||
* R.paths([['a', 'b'], ['p', 'r']], {a: {b: 2}, p: [{q: 3}]}); //=> [2, undefined]
|
||||
*/
|
||||
|
||||
|
||||
var paths =
|
||||
/*#__PURE__*/
|
||||
_curry2(function paths(pathsArray, obj) {
|
||||
return pathsArray.map(function (paths) {
|
||||
var val = obj;
|
||||
var idx = 0;
|
||||
var p;
|
||||
|
||||
while (idx < paths.length) {
|
||||
if (val == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
p = paths[idx];
|
||||
val = _isInteger(p) ? nth(p, val) : val[p];
|
||||
idx += 1;
|
||||
}
|
||||
|
||||
return val;
|
||||
});
|
||||
});
|
||||
|
||||
module.exports = paths;
|
Loading…
Add table
Add a link
Reference in a new issue