| 1 | import { MutableList } from '../_internal/MutableList.d.mjs';
|
|---|
| 2 | import { RejectReadonly } from '../_internal/RejectReadonly.d.mjs';
|
|---|
| 3 |
|
|---|
| 4 | /**
|
|---|
| 5 | * Fills an array with a value.
|
|---|
| 6 | * @template T
|
|---|
| 7 | * @param {any[] | null | undefined} array - The array to fill
|
|---|
| 8 | * @param {T} value - The value to fill array with
|
|---|
| 9 | * @returns {T[]} Returns the filled array
|
|---|
| 10 | * @example
|
|---|
| 11 | * fill([1, 2, 3], 'a')
|
|---|
| 12 | * // => ['a', 'a', 'a']
|
|---|
| 13 | */
|
|---|
| 14 | declare function fill<T>(array: any[] | null | undefined, value: T): T[];
|
|---|
| 15 | /**
|
|---|
| 16 | * Fills an array-like object with a value.
|
|---|
| 17 | * @template T, AL
|
|---|
| 18 | * @param {RejectReadonly<AL> | null | undefined} array - The array-like object to fill
|
|---|
| 19 | * @param {T} value - The value to fill array with
|
|---|
| 20 | * @returns {ArrayLike<T>} Returns the filled array-like object
|
|---|
| 21 | * @example
|
|---|
| 22 | * fill({ length: 3 }, 2)
|
|---|
| 23 | * // => { 0: 2, 1: 2, 2: 2, length: 3 }
|
|---|
| 24 | */
|
|---|
| 25 | declare function fill<T, AL extends MutableList<any>>(array: RejectReadonly<AL> | null | undefined, value: T): ArrayLike<T>;
|
|---|
| 26 | /**
|
|---|
| 27 | * Fills an array with a value from start up to end.
|
|---|
| 28 | * @template T, U
|
|---|
| 29 | * @param {U[] | null | undefined} array - The array to fill
|
|---|
| 30 | * @param {T} value - The value to fill array with
|
|---|
| 31 | * @param {number} [start=0] - The start position
|
|---|
| 32 | * @param {number} [end=array.length] - The end position
|
|---|
| 33 | * @returns {Array<T | U>} Returns the filled array
|
|---|
| 34 | * @example
|
|---|
| 35 | * fill([1, 2, 3], 'a', 1, 2)
|
|---|
| 36 | * // => [1, 'a', 3]
|
|---|
| 37 | */
|
|---|
| 38 | declare function fill<T, U>(array: U[] | null | undefined, value: T, start?: number, end?: number): Array<T | U>;
|
|---|
| 39 | /**
|
|---|
| 40 | * Fills an array-like object with a value from start up to end.
|
|---|
| 41 | * @template T, U
|
|---|
| 42 | * @param {U extends readonly any[] ? never : U | null | undefined} array - The array-like object to fill
|
|---|
| 43 | * @param {T} value - The value to fill array with
|
|---|
| 44 | * @param {number} [start=0] - The start position
|
|---|
| 45 | * @param {number} [end=array.length] - The end position
|
|---|
| 46 | * @returns {ArrayLike<T | U[0]>} Returns the filled array-like object
|
|---|
| 47 | * @example
|
|---|
| 48 | * fill({ 0: 1, 1: 2, 2: 3, length: 3 }, 'a', 1, 2)
|
|---|
| 49 | * // => { 0: 1, 1: 'a', 2: 3, length: 3 }
|
|---|
| 50 | */
|
|---|
| 51 | declare function fill<T, U extends MutableList<any>>(array: RejectReadonly<U> | null | undefined, value: T, start?: number, end?: number): ArrayLike<T | U[0]>;
|
|---|
| 52 |
|
|---|
| 53 | export { fill };
|
|---|