not-null

    1.0.1 • Public • Published

    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: not-null

    npm install not-null
    

    Example

    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);
    // -> false

    The 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.

    Install

    npm i not-null

    DownloadsWeekly Downloads

    255

    Version

    1.0.1

    License

    MIT

    Last publish

    Collaborators

    • parshap