Skip to main content

Cast the given value to an array.

/**
 * Cast the given value to an array.
 *
 * Source: https://github.com/jonschlinkert/class-utils/blob/master/index.js
 *
 * ```js
 * arrayify('foo');
 * //=> ['foo']
 *
 * arrayify(['foo']);
 * //=> ['foo']
 * ```
 *
 * @param {String|Array} `val`
 * @return {Array}
 */
function arrayify(val) {
    return val ? (Array.isArray(val) ? val : [val]) : [];
}