Share your code. Components are building blocks, you are the architect.

utils/apply-spec
v1.1.0
1.1.0
Given a spec object recursively mapping properties to functions, creates a

Please configure Bit as a scoped registry to install components with NPM.Learn more

npm config set '@bit:registry' https://node.bitsrc.io
Use utils/apply-spec in your project
npm i @bit/bit.ramda.utils.apply-spec
Copied

applySpec (spec:Object) : Function

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.

Example

var getMetrics = R.applySpec({
       sum: R.add,
       nested: { mul: R.multiply }
     });
     getMetrics(2, 4); // => { sum: 6, nested: { mul: 8 } }

Argument

spec: Object

an object recursively mapping properties to functions for producing the values for these properties.

Returns

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.