Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
Download
80742 views
1
/**
2
* The base implementation of `_.fill` without an iteratee call guard.
3
*
4
* @private
5
* @param {Array} array The array to fill.
6
* @param {*} value The value to fill `array` with.
7
* @param {number} [start=0] The start position.
8
* @param {number} [end=array.length] The end position.
9
* @returns {Array} Returns `array`.
10
*/
11
function baseFill(array, value, start, end) {
12
var length = array.length;
13
14
start = start == null ? 0 : (+start || 0);
15
if (start < 0) {
16
start = -start > length ? 0 : (length + start);
17
}
18
end = (end === undefined || end > length) ? length : (+end || 0);
19
if (end < 0) {
20
end += length;
21
}
22
length = start > end ? 0 : (end >>> 0);
23
start >>>= 0;
24
25
while (start < length) {
26
array[start++] = value;
27
}
28
return array;
29
}
30
31
module.exports = baseFill;
32
33