Initial commit
[yaffs-website] / node_modules / grunt-contrib-watch / node_modules / lodash / array / fill.js
1 var baseFill = require('../internal/baseFill'),
2     isIterateeCall = require('../internal/isIterateeCall');
3
4 /**
5  * Fills elements of `array` with `value` from `start` up to, but not
6  * including, `end`.
7  *
8  * **Note:** This method mutates `array`.
9  *
10  * @static
11  * @memberOf _
12  * @category Array
13  * @param {Array} array The array to fill.
14  * @param {*} value The value to fill `array` with.
15  * @param {number} [start=0] The start position.
16  * @param {number} [end=array.length] The end position.
17  * @returns {Array} Returns `array`.
18  * @example
19  *
20  * var array = [1, 2, 3];
21  *
22  * _.fill(array, 'a');
23  * console.log(array);
24  * // => ['a', 'a', 'a']
25  *
26  * _.fill(Array(3), 2);
27  * // => [2, 2, 2]
28  *
29  * _.fill([4, 6, 8], '*', 1, 2);
30  * // => [4, '*', 8]
31  */
32 function fill(array, value, start, end) {
33   var length = array ? array.length : 0;
34   if (!length) {
35     return [];
36   }
37   if (start && typeof start != 'number' && isIterateeCall(array, value, start)) {
38     start = 0;
39     end = length;
40   }
41   return baseFill(array, value, start, end);
42 }
43
44 module.exports = fill;