diff options
Diffstat (limited to 'deps/npm/node_modules/lodash/internal/toIterable.js')
-rw-r--r-- | deps/npm/node_modules/lodash/internal/toIterable.js | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/deps/npm/node_modules/lodash/internal/toIterable.js b/deps/npm/node_modules/lodash/internal/toIterable.js new file mode 100644 index 0000000000..c0a5b2885f --- /dev/null +++ b/deps/npm/node_modules/lodash/internal/toIterable.js @@ -0,0 +1,22 @@ +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; |