@zzzzbov/required-parameter
v0.0.1
Published
`requiredParameter` is a utility function for enforcing a required parameter by way of a function call in default parameters.
Downloads
13
Readme
@zzzzbov/required-parameter
requiredParameter
is a utility function for enforcing a required parameter by way of a function call in default parameters.
function example (foo = requiredParameter('foo')) {
console.log(foo)
}
example() // throws TypeError: 'The "foo" parameter is required'
example('lorem ipsum') // writes 'lorem ipsum' to the console