X-Git-Url: http://www.aleph1.co.uk/gitweb/?p=yaffs-website;a=blobdiff_plain;f=node_modules%2Fgrunt-legacy-log-utils%2Fnode_modules%2Flodash%2FtoArray.js;fp=node_modules%2Fgrunt-legacy-log-utils%2Fnode_modules%2Flodash%2FtoArray.js;h=c342289194395affb12c6f3ad233e467eda018e5;hp=0000000000000000000000000000000000000000;hb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;hpb=57c063afa3f66b07c4bbddc2d6129a96d90f0aad diff --git a/node_modules/grunt-legacy-log-utils/node_modules/lodash/toArray.js b/node_modules/grunt-legacy-log-utils/node_modules/lodash/toArray.js new file mode 100644 index 000000000..c34228919 --- /dev/null +++ b/node_modules/grunt-legacy-log-utils/node_modules/lodash/toArray.js @@ -0,0 +1,57 @@ +var Symbol = require('./_Symbol'), + copyArray = require('./_copyArray'), + getTag = require('./_getTag'), + isArrayLike = require('./isArrayLike'), + isString = require('./isString'), + iteratorToArray = require('./_iteratorToArray'), + mapToArray = require('./_mapToArray'), + setToArray = require('./_setToArray'), + stringToArray = require('./_stringToArray'), + values = require('./values'); + +/** `Object#toString` result references. */ +var mapTag = '[object Map]', + setTag = '[object Set]'; + +/** Built-in value references. */ +var iteratorSymbol = typeof (iteratorSymbol = Symbol && Symbol.iterator) == 'symbol' ? iteratorSymbol : undefined; + +/** + * Converts `value` to an array. + * + * @static + * @memberOf _ + * @category Lang + * @param {*} value The value to convert. + * @returns {Array} Returns the converted array. + * @example + * + * _.toArray({ 'a': 1, 'b': 2 }); + * // => [1, 2] + * + * _.toArray('abc'); + * // => ['a', 'b', 'c'] + * + * _.toArray(1); + * // => [] + * + * _.toArray(null); + * // => [] + */ +function toArray(value) { + if (!value) { + return []; + } + if (isArrayLike(value)) { + return isString(value) ? stringToArray(value) : copyArray(value); + } + if (iteratorSymbol && value[iteratorSymbol]) { + return iteratorToArray(value[iteratorSymbol]()); + } + var tag = getTag(value), + func = tag == mapTag ? mapToArray : (tag == setTag ? setToArray : values); + + return func(value); +} + +module.exports = toArray;