Initial commit
[yaffs-website] / node_modules / grunt-contrib-watch / node_modules / globule / node_modules / lodash / castArray.js
1 var isArray = require('./isArray');
2
3 /**
4  * Casts `value` as an array if it's not one.
5  *
6  * @static
7  * @memberOf _
8  * @since 4.4.0
9  * @category Lang
10  * @param {*} value The value to inspect.
11  * @returns {Array} Returns the cast array.
12  * @example
13  *
14  * _.castArray(1);
15  * // => [1]
16  *
17  * _.castArray({ 'a': 1 });
18  * // => [{ 'a': 1 }]
19  *
20  * _.castArray('abc');
21  * // => ['abc']
22  *
23  * _.castArray(null);
24  * // => [null]
25  *
26  * _.castArray(undefined);
27  * // => [undefined]
28  *
29  * _.castArray();
30  * // => []
31  *
32  * var array = [1, 2, 3];
33  * console.log(_.castArray(array) === array);
34  * // => true
35  */
36 function castArray() {
37   if (!arguments.length) {
38     return [];
39   }
40   var value = arguments[0];
41   return isArray(value) ? value : [value];
42 }
43
44 module.exports = castArray;