roc
Version:
Build modern web applications easily
28 lines (25 loc) • 561 B
JavaScript
;
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = toArray;
/**
* Given an input the function will return an array.
*
* @param {object} input - The input to be converted.
*
* @returns {object[]} - The converted result.
*/
function toArray(input) {
let parsed;
try {
parsed = JSON.parse(input);
} catch (err) {
// Ignore this case
}
if (Array.isArray(parsed)) {
return parsed;
}
return input.toString().split(',');
}
//# sourceMappingURL=to-array.js.map