Bolter
Bolter is a tool for making functions with optional arguments (I mean, it can be in the middle of the function argument list, not in the end). It will fill missing args with undefined
, so you don't need to make a lot of conditions.
Installation
npm i bolter
Usage
const bolter = ; // these examples will help you to understand how all it worksconst getArgs = ; // The list of possible arguments ; // => ["test", undefined, undefined]; // => [undefined, 1, [Function]]; // => ["test", undefined, [Function]]; // => ["test", undefined, [Function]]; // => [undefined, undefined, undefined] // example with static args228; // => [1, 228]