Initial commit
[yaffs-website] / node_modules / grunt-contrib-watch / node_modules / lodash / lang / toArray.js
1 var arrayCopy = require('../internal/arrayCopy'),
2     getLength = require('../internal/getLength'),
3     isLength = require('../internal/isLength'),
4     values = require('../object/values');
5
6 /**
7  * Converts `value` to an array.
8  *
9  * @static
10  * @memberOf _
11  * @category Lang
12  * @param {*} value The value to convert.
13  * @returns {Array} Returns the converted array.
14  * @example
15  *
16  * (function() {
17  *   return _.toArray(arguments).slice(1);
18  * }(1, 2, 3));
19  * // => [2, 3]
20  */
21 function toArray(value) {
22   var length = value ? getLength(value) : 0;
23   if (!isLength(length)) {
24     return values(value);
25   }
26   if (!length) {
27     return [];
28   }
29   return arrayCopy(value);
30 }
31
32 module.exports = toArray;