Files
vanillajs-seed/node_modules/ensure-array/ensure-array.js
2020-05-26 10:37:57 +02:00

9 lines
447 B
JavaScript

module.exports = function ensureArray(a, b, n) {
if (arguments.length === 0) return []; // no args, ret []
if (arguments.length === 1) { // single argument
if (a === undefined || a === null) return []; // undefined or null, ret []
if (Array.isArray(a)) return a; // isArray, return it
}
return Array.prototype.slice.call(arguments); // return array with copy of all arguments
}