UNPKG

hd-utils

Version:

A handy utils for modern JS developers

10 lines (9 loc) 345 B
/** * @description If the source is null or undefined, return an empty array, otherwise return the source as an array. * @example toArray(null) // [] * @example toArray([21]) // [21] * @example toArray({}) // [{}] * @param {unknown} source - unknown * @returns An array. */ export default function toArray<T = any>(source: unknown): T[];