Files
lodash/internal/toIterable.js
John-David Dalton fec213a98c Bump to v3.7.0.
2015-12-16 17:49:35 -08:00

22 lines
562 B
JavaScript

define(['./getLength', './isLength', '../lang/isObject', '../object/values'], function(getLength, isLength, isObject, values) {
/**
* Converts `value` to an array-like object if it is not one.
*
* @private
* @param {*} value The value to process.
* @returns {Array|Object} Returns the array-like object.
*/
function toIterable(value) {
if (value == null) {
return [];
}
if (!isLength(getLength(value))) {
return values(value);
}
return isObject(value) ? value : Object(value);
}
return toIterable;
});