| 1 | /**
|
|---|
| 2 | * Creates a new array filled with the specified value from the start position up to, but not including, the end position.
|
|---|
| 3 | * This function does not mutate the original array.
|
|---|
| 4 | *
|
|---|
| 5 | * @template T - The type of elements in the original array.
|
|---|
| 6 | * @template U - The type of the value to fill the new array with.
|
|---|
| 7 | * @param {Array<T>} arr - The array to base the new array on.
|
|---|
| 8 | * @param {U} value - The value to fill the new array with.
|
|---|
| 9 | * @returns {Array<T | U>} The new array with the filled values.
|
|---|
| 10 | *
|
|---|
| 11 | * @example
|
|---|
| 12 | * const array = [1, 2, 3, 4, 5];
|
|---|
| 13 | * let result = toFilled(array, '*', 2);
|
|---|
| 14 | * console.log(result); // [1, 2, '*', '*', '*']
|
|---|
| 15 | * console.log(array); // [1, 2, 3, 4, 5]
|
|---|
| 16 | *
|
|---|
| 17 | * result = toFilled(array, '*', 1, 4);
|
|---|
| 18 | * console.log(result); // [1, '*', '*', '*', 5]
|
|---|
| 19 | * console.log(array); // [1, 2, 3, 4, 5]
|
|---|
| 20 | *
|
|---|
| 21 | * result = toFilled(array, '*');
|
|---|
| 22 | * console.log(result); // ['*', '*', '*', '*', '*']
|
|---|
| 23 | * console.log(array); // [1, 2, 3, 4, 5]
|
|---|
| 24 | *
|
|---|
| 25 | * result = toFilled(array, '*', -4, -1);
|
|---|
| 26 | * console.log(result); // [1, '*', '*', '*', 5]
|
|---|
| 27 | * console.log(array); // [1, 2, 3, 4, 5]
|
|---|
| 28 | */
|
|---|
| 29 | declare function toFilled<T, U>(arr: readonly T[], value: U): Array<T | U>;
|
|---|
| 30 | /**
|
|---|
| 31 | * Creates a new array filled with the specified value from the start position up to, but not including, the end position.
|
|---|
| 32 | * This function does not mutate the original array.
|
|---|
| 33 | *
|
|---|
| 34 | * @template T - The type of elements in the original array.
|
|---|
| 35 | * @template U - The type of the value to fill the new array with.
|
|---|
| 36 | * @param {Array<T>} arr - The array to base the new array on.
|
|---|
| 37 | * @param {U} value - The value to fill the new array with.
|
|---|
| 38 | * @param {number} [start=0] - The start position. Defaults to 0.
|
|---|
| 39 | * @returns {Array<T | U>} The new array with the filled values.
|
|---|
| 40 | *
|
|---|
| 41 | * @example
|
|---|
| 42 | * const array = [1, 2, 3, 4, 5];
|
|---|
| 43 | * let result = toFilled(array, '*', 2);
|
|---|
| 44 | * console.log(result); // [1, 2, '*', '*', '*']
|
|---|
| 45 | * console.log(array); // [1, 2, 3, 4, 5]
|
|---|
| 46 | *
|
|---|
| 47 | * result = toFilled(array, '*', 1, 4);
|
|---|
| 48 | * console.log(result); // [1, '*', '*', '*', 5]
|
|---|
| 49 | * console.log(array); // [1, 2, 3, 4, 5]
|
|---|
| 50 | *
|
|---|
| 51 | * result = toFilled(array, '*');
|
|---|
| 52 | * console.log(result); // ['*', '*', '*', '*', '*']
|
|---|
| 53 | * console.log(array); // [1, 2, 3, 4, 5]
|
|---|
| 54 | *
|
|---|
| 55 | * result = toFilled(array, '*', -4, -1);
|
|---|
| 56 | * console.log(result); // [1, '*', '*', '*', 5]
|
|---|
| 57 | * console.log(array); // [1, 2, 3, 4, 5]
|
|---|
| 58 | */
|
|---|
| 59 | declare function toFilled<T, U>(arr: readonly T[], value: U, start: number): Array<T | U>;
|
|---|
| 60 | /**
|
|---|
| 61 | * Creates a new array filled with the specified value from the start position up to, but not including, the end position.
|
|---|
| 62 | * This function does not mutate the original array.
|
|---|
| 63 | *
|
|---|
| 64 | * @template T - The type of elements in the original array.
|
|---|
| 65 | * @template U - The type of the value to fill the new array with.
|
|---|
| 66 | * @param {Array<T>} arr - The array to base the new array on.
|
|---|
| 67 | * @param {U} value - The value to fill the new array with.
|
|---|
| 68 | * @param {number} [start=0] - The start position. Defaults to 0.
|
|---|
| 69 | * @param {number} [end=arr.length] - The end position. Defaults to the array's length.
|
|---|
| 70 | * @returns {Array<T | U>} The new array with the filled values.
|
|---|
| 71 | *
|
|---|
| 72 | * @example
|
|---|
| 73 | * const array = [1, 2, 3, 4, 5];
|
|---|
| 74 | * let result = toFilled(array, '*', 2);
|
|---|
| 75 | * console.log(result); // [1, 2, '*', '*', '*']
|
|---|
| 76 | * console.log(array); // [1, 2, 3, 4, 5]
|
|---|
| 77 | *
|
|---|
| 78 | * result = toFilled(array, '*', 1, 4);
|
|---|
| 79 | * console.log(result); // [1, '*', '*', '*', 5]
|
|---|
| 80 | * console.log(array); // [1, 2, 3, 4, 5]
|
|---|
| 81 | *
|
|---|
| 82 | * result = toFilled(array, '*');
|
|---|
| 83 | * console.log(result); // ['*', '*', '*', '*', '*']
|
|---|
| 84 | * console.log(array); // [1, 2, 3, 4, 5]
|
|---|
| 85 | *
|
|---|
| 86 | * result = toFilled(array, '*', -4, -1);
|
|---|
| 87 | * console.log(result); // [1, '*', '*', '*', 5]
|
|---|
| 88 | * console.log(array); // [1, 2, 3, 4, 5]
|
|---|
| 89 | */
|
|---|
| 90 | declare function toFilled<T, U>(arr: readonly T[], value: U, start: number, end: number): Array<T | U>;
|
|---|
| 91 |
|
|---|
| 92 | export { toFilled };
|
|---|