defined
Advanced tools
Weekly downloads
Changelog
v1.0.1 - 2022-10-12
84801c0
7ccb011
03917f0
tape
ac57011
9bf7583
auto-changelog
ec13b5f
npmignore
to autogenerate an npmignore file 549e1ff
11dfedc
safe-publish-latest
efadc76
aa9c486
aud
in posttest
a0cf2fb
funding
in package.json b05fc5e
Readme
return the first argument that is !== undefined
Most of the time when I chain together ||
s, I actually just want the first
item that is not undefined
, not the first non-falsy item.
This module is like the defined-or (//
) operator in perl 5.10+.
var defined = require('defined');
var opts = { y : false, w : 4 };
var x = defined(opts.x, opts.y, opts.w, 100);
console.log(x);
$ node example/defined.js
false
The return value is false
because false
is the first item that is
!== undefined
.
var defined = require('defined')
Return the first item in the argument list a, b, c...
that is !== undefined
.
If all the items are === undefined
, return undefined.
With npm do:
npm install defined
MIT
FAQs
return the first argument that is `!== undefined`
The npm package defined receives a total of 4,174,949 weekly downloads. As such, defined popularity was classified as popular.
We found that defined demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers collaborating on the project.
Did you know?
Socket installs a GitHub app to automatically flag issues on every pull request and report the health of your dependencies. Find out what is inside your node modules and prevent malicious activity before you update the dependencies.