mirror of https://github.com/lukechilds/node.git
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
22 lines
527 B
22 lines
527 B
var isArrayLike = require('./isArrayLike'),
|
|
isObject = require('../lang/isObject'),
|
|
values = require('../object/values');
|
|
|
|
/**
|
|
* Converts `value` to an array-like object if it's 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 (!isArrayLike(value)) {
|
|
return values(value);
|
|
}
|
|
return isObject(value) ? value : Object(value);
|
|
}
|
|
|
|
module.exports = toIterable;
|
|
|