Skip to content

Commit

Permalink
Move the declaration of the result array closer to its usage within…
Browse files Browse the repository at this point in the history
… the `range` function.
  • Loading branch information
junhaoliao committed Oct 1, 2024
1 parent bfe6c0e commit fae7441
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions new-log-viewer/src/utils/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,6 @@ const getMapValueWithNearestLessThanOrEqualKey = <T>(
* @throws {Error} if `step` is 0.
*/
const range = (start: number, stop: Nullable<number> = null, step: number = 1): number[] => {
const result: number[] = [];

if (0 === step) {
throw new Error("Step cannot be zero.");
}
Expand All @@ -62,6 +60,7 @@ const range = (start: number, stop: Nullable<number> = null, step: number = 1):
start = 0;
}

const result: number[] = [];
if (0 < step) {
for (let i = start; i < stop; i += step) {
result.push(i);
Expand Down

0 comments on commit fae7441

Please sign in to comment.