mirror of
https://github.com/musix-org/musix-oss
synced 2024-11-10 11:20:19 +00:00
24 lines
333 B
JavaScript
24 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;
|