mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-06 17:47:49 +00:00
Bump to v3.0.0.
This commit is contained in:
21
internal/toIterable.js
Normal file
21
internal/toIterable.js
Normal file
@@ -0,0 +1,21 @@
|
||||
define(['./isLength', '../lang/isObject', '../object/values'], function(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(value.length)) {
|
||||
return values(value);
|
||||
}
|
||||
return isObject(value) ? value : Object(value);
|
||||
}
|
||||
|
||||
return toIterable;
|
||||
});
|
||||
Reference in New Issue
Block a user