Skip to content

Simple function that return the first non null or undefined argument

License

Notifications You must be signed in to change notification settings

royriojas/coalescy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

NPM Version Build Status

coalescy

Simple function that return the first non null or undefined argument passed to it

Install

npm i --save coalescy

Usage

coalescy simply return the first non nully of the passed elements. Null if all the values are null

it works the same as

a || b

but it works on falsie values too

Example

var clsc = require('coalescy');
var obj = clsc(null, []); // obj = [];
obj = clsc(null, {}); // obj = {};
obj = clsc(null, [], {}); // obj = []; // the first non null
obj = clsc(null, undefined, 0, []) // 0

About

Simple function that return the first non null or undefined argument

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published