1-liners
Version:
Useful oneliners and shorthand functions
25 lines (21 loc) • 432 B
JavaScript
/**
* @module 1-liners/compact
*
* @description
*
* A pure function to make a list compact and remove falsey values
* @example
*
* const compact = require('1-liners/compact');
*
* compact([1, 2, false, 45]); // => [1, 2, 45]
*
*/
;
exports.__esModule = true;
exports["default"] = function (arr) {
return arr.filter(function (a) {
return a === 0 || !!a;
});
};
module.exports = exports["default"];