es-toolkit
Version:
A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.
18 lines (15 loc) • 389 B
JavaScript
import { isArrayLike } from '../predicate/isArrayLike.mjs';
import { isMap } from '../predicate/isMap.mjs';
function toArray(value) {
if (value == null) {
return [];
}
if (isArrayLike(value) || isMap(value)) {
return Array.from(value);
}
if (typeof value === 'object') {
return Object.values(value);
}
return [];
}
export { toArray };