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

utils/construct-n
v1.1.0
1.1.0
1.0.0
MIT
PUBLIC
3
Build: fail
BuildFail
Build Status: fail
Wraps a constructor function inside a curried function that can be called

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/construct-n in your project
npm i @bit/bit.ramda.utils.construct-n
Copied

constructN (n:Number, Fn:Function) : Function

Wraps a constructor function inside a curried function that can be called with the same arguments and returns the same type. The arity of the function returned is specified to allow using variadic constructor functions.

Example

// Variadic Constructor function
     function Salad() {
       this.ingredients = arguments;
     }

     Salad.prototype.recipe = function() {
       var instructions = R.map(ingredient => 'Add a dollop of ' + ingredient, this.ingredients);
       return R.join('\n', instructions);
     };

     var ThreeLayerSalad = R.constructN(3, Salad);

     // Notice we no longer need the 'new' keyword, and the constructor is curried for 3 arguments.
     var salad = ThreeLayerSalad('Mayonnaise')('Potato Chips')('Ketchup');

     console.log(salad.recipe());
     // Add a dollop of Mayonnaise
     // Add a dollop of Potato Chips
     // Add a dollop of Ketchup

Arguments

n: Number

The arity of the constructor function.

Fn: Function

The constructor function to wrap.

Returns

Function

A wrapped, curried constructor function.