UNPKG

first-none-falsy-value-or-last

Version:

a function which returns the first none falsy value or the last value, if alle values are falsy

20 lines (15 loc) 346 B
'use strict'; /** * * @param {*} args * @return {*} */ function takeFirstNoneFalsyValueOrLast() { const args = Array.prototype.slice.call(arguments); const result = args.find((value) => !!value); if (result === undefined) { return args.pop(); } return result; } module.exports = takeFirstNoneFalsyValueOrLast;