mirror of
https://github.com/react/react-native-devtools-frontend.git
synced 2026-11-01 10:49:03 +08:00
DISABLE_THIRD_PARTY_CHECK=new npm module causes package-lock change We can get rid of a custom script and use ESLint for these rules. Additionally this means editors will highlight the issue in the editor. Change-Id: I552b52e7f07b4e7430b3f685dbc3b5fad36ffff2 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/2052167 Reviewed-by: Paul Lewis <aerotwist@chromium.org> Commit-Queue: Jack Franklin <jacktfranklin@chromium.org>
65 lines
2.0 KiB
JavaScript
65 lines
2.0 KiB
JavaScript
var _curry1 = /*#__PURE__*/require('./internal/_curry1');
|
|
|
|
var apply = /*#__PURE__*/require('./apply');
|
|
|
|
var curryN = /*#__PURE__*/require('./curryN');
|
|
|
|
var max = /*#__PURE__*/require('./max');
|
|
|
|
var pluck = /*#__PURE__*/require('./pluck');
|
|
|
|
var reduce = /*#__PURE__*/require('./reduce');
|
|
|
|
var keys = /*#__PURE__*/require('./keys');
|
|
|
|
var values = /*#__PURE__*/require('./values');
|
|
|
|
// Use custom mapValues function to avoid issues with specs that include a "map" key and R.map
|
|
// delegating calls to .map
|
|
|
|
|
|
function mapValues(fn, obj) {
|
|
return keys(obj).reduce(function (acc, key) {
|
|
acc[key] = fn(obj[key]);
|
|
return acc;
|
|
}, {});
|
|
}
|
|
|
|
/**
|
|
* Given a spec object recursively mapping properties to functions, creates a
|
|
* function producing an object of the same structure, by mapping each property
|
|
* to the result of calling its associated function with the supplied arguments.
|
|
*
|
|
* @func
|
|
* @memberOf R
|
|
* @since v0.20.0
|
|
* @category Function
|
|
* @sig {k: ((a, b, ..., m) -> v)} -> ((a, b, ..., m) -> {k: v})
|
|
* @param {Object} spec an object recursively mapping properties to functions for
|
|
* producing the values for these properties.
|
|
* @return {Function} A function that returns an object of the same structure
|
|
* as `spec', with each property set to the value returned by calling its
|
|
* associated function with the supplied arguments.
|
|
* @see R.converge, R.juxt
|
|
* @example
|
|
*
|
|
* const getMetrics = R.applySpec({
|
|
* sum: R.add,
|
|
* nested: { mul: R.multiply }
|
|
* });
|
|
* getMetrics(2, 4); // => { sum: 6, nested: { mul: 8 } }
|
|
* @symb R.applySpec({ x: f, y: { z: g } })(a, b) = { x: f(a, b), y: { z: g(a, b) } }
|
|
*/
|
|
var applySpec = /*#__PURE__*/_curry1(function applySpec(spec) {
|
|
spec = mapValues(function (v) {
|
|
return typeof v == 'function' ? v : applySpec(v);
|
|
}, spec);
|
|
|
|
return curryN(reduce(max, 0, pluck('length', values(spec))), function () {
|
|
var args = arguments;
|
|
return mapValues(function (f) {
|
|
return apply(f, args);
|
|
}, spec);
|
|
});
|
|
});
|
|
module.exports = applySpec; |