1.0.1 • Published 10 years ago
not-null v1.0.1
not-null
Return the first argument that is != null (i.e., null or
undefined).
This is a fork of defined which is the same except with
!== undefined.
Most of the time when I chain together ||s, I actually just want the
first item that is not undefined or null, not the first non-falsy
item.
Install
npm install not-nullExample
var notnull = require('not-null');
var opts = { y : false, w : 4, z: null };
var x = notnull(opts.z, opts.x, opts.y, opts.w, 100);
console.log(x);
// -> falseThe return value is false because false is the first item that is
!= null.
API
var notnull = require('not-null')var x = notnull(a, b, c...)
Return the first item in the argument list a, b, c... that is != null.
If all the items are == null, return undefined.