mirror of
https://github.com/wavetermdev/xterm.js.git
synced 2026-08-05 13:43:48 -07:00
Improve handling of default values
This commit is contained in:
@@ -12,7 +12,7 @@ type TypedArray = Uint8Array | Uint16Array | Uint32Array | Uint8ClampedArray
|
||||
| Int8Array | Int16Array | Int32Array
|
||||
| Float32Array | Float64Array;
|
||||
|
||||
export function fill<T extends TypedArray>(array: T, value: number, start: number = 0, end?: number | undefined): T {
|
||||
export function fill<T extends TypedArray>(array: T, value: number, start?: number, end?: number): T {
|
||||
// all modern engines that support .fill
|
||||
if (array.fill) {
|
||||
return array.fill(value, start, end) as T;
|
||||
@@ -20,7 +20,7 @@ export function fill<T extends TypedArray>(array: T, value: number, start: numbe
|
||||
return fillFallback(array, value, start, end);
|
||||
}
|
||||
|
||||
export function fillFallback<T extends TypedArray>(array: T, value: number, start: number = 0, end?: number | undefined): T {
|
||||
export function fillFallback<T extends TypedArray>(array: T, value: number, start: number = 0, end: number = array.length): T {
|
||||
// safari and IE 11
|
||||
// since IE 11 does not support Array.prototype.fill either
|
||||
// we cannot use the suggested polyfill from MDN
|
||||
@@ -29,9 +29,6 @@ export function fillFallback<T extends TypedArray>(array: T, value: number, star
|
||||
return array;
|
||||
}
|
||||
start = (array.length + start) % array.length;
|
||||
if (end === undefined) {
|
||||
end = array.length;
|
||||
}
|
||||
if (end >= array.length) {
|
||||
end = array.length;
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user