@newdash/newdash
Version:
javascript/typescript utility library
35 lines (34 loc) • 1.03 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.baseFill = void 0;
const toInteger_1 = require("../toInteger");
const toLength_1 = require("../toLength");
/**
* The base implementation of `_.fill` without an iteratee call guard.
*
* @ignore
* @internal
* @private
* @param array The array to fill.
* @param value The value to fill `array` with.
* @param start The start position.
* @param end The end position.
* @returns Returns `array`.
*/
function baseFill(array, value, start = 0, end = array?.length) {
var length = array.length;
start = (0, toInteger_1.toInteger)(start);
if (start < 0) {
start = -start > length ? 0 : (length + start);
}
end = (end === undefined || end > length) ? length : (0, toInteger_1.toInteger)(end);
if (end < 0) {
end += length;
}
end = start > end ? 0 : (0, toLength_1.toLength)(end);
while (start < end) {
array[start++] = value;
}
return array;
}
exports.baseFill = baseFill;