UNPKG

305 BJavaScriptView Raw
1export default function arrify(value) {
2 if (value === null || value === undefined) {
3 return [];
4 }
5
6 if (Array.isArray(value)) {
7 return value;
8 }
9
10 if (typeof value === 'string') {
11 return [value];
12 }
13
14 if (typeof value[Symbol.iterator] === 'function') {
15 return [...value];
16 }
17
18 return [value];
19}