@bemoje/is-args-defined
v1.0.1
Published
Returns whether or not the passed arguments are defined - ie. not undefined
Downloads
11
Maintainers
Readme
@bemoje/is-args-defined
Returns whether or not the passed arguments are defined - ie. not undefined
Version
Travis CI
Dependencies
Stats
Donate
Installation
npm install @bemoje/is-args-defined
npm install --save @bemoje/is-args-defined
npm install --save-dev @bemoje/is-args-defined
Usage
import isArgsDefined from '@bemoje/is-args-defined'
// require arguments for multiple parameters
function add(a, b) {
if (!isArgsDefined(a, b)) {
throw new Error('lol')
}
return a + b
}
// require arguments for single parameter
function add_safe(a, b) {
if (!isArgsDefined(a)) {
throw new Error('lol')
}
if (!isArgsDefined(b)) {
return a
}
return a + b
}
Benchmark
84800 nanoseconds
Tests
Uses Jest to test module functionality. Run tests to get coverage details.
npm run test
API
isArgsDefined
Returns
whether or not the passed arguments are defined - ie. not undefined
Returns
boolean boolean