es-toolkit
Version:
A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.
22 lines (17 loc) • 503 B
JavaScript
;
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
const isArrayLike = require('../predicate/isArrayLike.js');
const isMap = require('../predicate/isMap.js');
function toArray(value) {
if (value == null) {
return [];
}
if (isArrayLike.isArrayLike(value) || isMap.isMap(value)) {
return Array.from(value);
}
if (typeof value === 'object') {
return Object.values(value);
}
return [];
}
exports.toArray = toArray;