not-null
Return the first argument that is `!= null`
Last updated 5 years ago by parshap .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install not-null 
SYNC missed versions from official npm registry.

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.

Current Tags

  • 1.0.1                                ...           latest (5 years ago)

2 Versions

  • 1.0.1                                ...           5 years ago
  • 1.0.0                                ...           5 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (0)
None
Dev Dependencies (1)

Copyright 2014 - 2017 © taobao.org |