1.0.1 • Published 3 years ago

defined v1.0.1

Weekly downloads
3,211,223
License
MIT
Repository
github
Last release
3 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-1461tapeftapeotape-watch2tanngotapetang-union-findtape-deep-includetape-spawntape-libtdagtailwind-vector-effectsymlink-dependenciestailwind-templatesvg-linearizeteaching-express-todo-apiwikidbwebaudio-serial-txworldtime2024wsnct-rangetestimonyswarmlogswarmbottexelthreejs-camera-controller-first-person-desktopthreejs-createthree-path-geometryvisionjsuz-factor-bundleuxun-cssnanovas-httpvideo-multi-uploadervideomail-client@borealisswap/borealis-swap-lib@rstacruz/pnpm@rubenrodriguez/mixmapitaqueimpeditipfs-merkle-dag-nodeipfs-dagipfs-hyperlogkeyconfigkafirchain-tetriskeybootkeyboot-uiimmuniteidb-blob-storeidb-content-addressable-blob-storehyperbootimgur-blob-storeinform-2dhyperkvi18nifyhyperlog-sodiumhyperloggoogle-panorama-by-locationholodexhtmlbinhex-gridhello_world_founderinu-engineinput-integerbshybrid-rsa-streamlitepie-datepicker-gabelevel-option-wraplevel-simple-logmediaxmlkountexamplemendel-browserifymavectra@thismr/bitmindtest-core@tehshrike/faucet@the91end/react-auth@vasosolo/multiselectcombobox@xswap/v2-core@yak-spirit/yak-swap-ui@zdychacek/browserify-babylon@zdychacek/detective@zdychacek/module-depsamount-formataccountdown-commandaccountdown-partyaccountdownaccountdown-basicbabel-plugin-jsx-factorybabel-preset-unminifyaxis3daxis3d-inputsaxis3d-orbit-camera
1.0.1

3 years ago

1.0.0

11 years ago

0.0.0

13 years ago