UNPKG

333 BJavaScriptView Raw
1'use strict';
2
3const arrify = value => {
4 if (value === null || value === undefined) {
5 return [];
6 }
7
8 if (Array.isArray(value)) {
9 return value;
10 }
11
12 if (typeof value === 'string') {
13 return [value];
14 }
15
16 if (typeof value[Symbol.iterator] === 'function') {
17 return [...value];
18 }
19
20 return [value];
21};
22
23module.exports = arrify;