@fastify/send
Version:
Better streaming static file server with Range and conditional-GET support
29 lines (25 loc) • 636 B
JavaScript
/**
* Normalize the index option into an array.
*
* @param {boolean|string|array} val
* @param {string} name
* @private
*/
function normalizeList (val, name) {
if (typeof val === 'string') {
return [val]
} else if (val === false) {
return []
} else if (Array.isArray(val)) {
for (let i = 0, il = val.length; i < il; ++i) {
if (typeof val[i] !== 'string') {
throw new TypeError(name + ' must be array of strings or false')
}
}
return val
} else {
throw new TypeError(name + ' must be array of strings or false')
}
}
module.exports.normalizeList = normalizeList