diff options
Diffstat (limited to 'tools/eslint/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/lang/toArray.js')
-rw-r--r-- | tools/eslint/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/lang/toArray.js | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/tools/eslint/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/lang/toArray.js b/tools/eslint/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/lang/toArray.js new file mode 100644 index 0000000000..72b0b46e18 --- /dev/null +++ b/tools/eslint/node_modules/js-yaml/node_modules/argparse/node_modules/lodash/lang/toArray.js @@ -0,0 +1,32 @@ +var arrayCopy = require('../internal/arrayCopy'), + getLength = require('../internal/getLength'), + isLength = require('../internal/isLength'), + values = require('../object/values'); + +/** + * Converts `value` to an array. + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to convert. + * @returns {Array} Returns the converted array. + * @example + * + * (function() { + * return _.toArray(arguments).slice(1); + * }(1, 2, 3)); + * // => [2, 3] + */ +function toArray(value) { + var length = value ? getLength(value) : 0; + if (!isLength(length)) { + return values(value); + } + if (!length) { + return []; + } + return arrayCopy(value); +} + +module.exports = toArray; |