1.0.1 • Published 2 years ago

defined v1.0.1

Weekly downloads
3,211,223
License
MIT
Repository
github
Last release
2 years ago

defined Version Badge

github actions coverage License Downloads

npm badge

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

example

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.

methods

var defined = require('defined')

var x = defined(a, b, c...)

Return the first item in the argument list a, b, c... that is !== undefined.

If all the items are === undefined, return undefined.

install

With npm do:

npm install defined

license

MIT

detectivebrowserifycloud-archive-s3@ihikmawan/tailwindcss-multi-theme-l2wenke-browserifywenke-node-watchifyblock-stream-file@olivervorasai/sliderencrypto-browserifycogoportutils@saaspe/components@everything-registry/sub-chunk-1461@emilbayes/css-pipeline@eliteswap/v2-corefs-remainder-chunk-storegit-syncglo-demo-primitiveglo-meshglo-textureglsl-proj4google-panorama-by-locationgps-beamglyphygantt-chartgarnish-uifwdbforkdbframe-loopfresh-tapefrida-device-watchergenerator-mnmenyo-devetherfseth-mine-when-needemr-tabulator-tableseelmailelectron-speecheserveeosmaioresexhibit-builder-browserifyexhibit-plugin-browserifyexpress-todo-apieasyplayer-myec0lint-style-config-postcssecstatic-lrfindup-package-jsonfleek-versioned-routerfiles-require-hookfenglin-uploaderfhir2extplug-meh-iconsfancy-selectfactor-bundlefactor-bundle-WA64faucetfaucet-babelfd-chunk-storehybrid-rsa-streamhyperkvhyperloghyperlog-sodiumhyperboothtmlbinholodexhello_world_founderhex-gridi18nifyidb-blob-storeidb-content-addressable-blob-storeimmunitelevel-option-wraplevel-simple-log@materia-dex/materia-contracts-proxy@mattdesl/fika@rubenrodriguez/mixmap@rstacruz/pnpm@sammacbeth/browserify@sammacbeth/webextify@novembrecom/zxcvbn@pirxpilot/module-deps@pirxpilot/browserify@prantlf/faucet@plotly/point-cluster@mizchi/watchify@ngxvoice/ngx-voicelistner@tehshrike/faucet@the91end/react-auth@sudophunk/fulido@suleyman2712/360-image-viewer@suleyman2712/custom-orbit-controls@talmobi/faucet@talmobi/watchify@soapdog/webextify@thismr/bitmindtest-corebleach-log-serverbowserifyappend-only-torrentapp-serverappfeedappxgen
1.0.1

2 years ago

1.0.0

9 years ago

0.0.0

11 years ago