epiphany/node_modules/arrify/index.js
2023-12-09 22:19:03 -08:00

23 lines
333 B
JavaScript

'use strict';
const arrify = value => {
if (value === null || value === undefined) {
return [];
}
if (Array.isArray(value)) {
return value;
}
if (typeof value === 'string') {
return [value];
}
if (typeof value[Symbol.iterator] === 'function') {
return [...value];
}
return [value];
};
module.exports = arrify;