Skip to content

Commit 696c8c7

Browse files
committed
fix: format
1 parent 9fc3cc8 commit 696c8c7

File tree

15 files changed

+118
-119
lines changed

15 files changed

+118
-119
lines changed

src/download/download-engine/download-file/download-engine-file.ts

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
import { DownloadFlags, DownloadStatus, ProgressStatus } from "./progress-status-file.js";
2-
import { ChunkStatus, DownloadFile, SaveProgressInfo } from "../types.js";
1+
import {DownloadFlags, DownloadStatus, ProgressStatus} from "./progress-status-file.js";
2+
import {ChunkStatus, DownloadFile, SaveProgressInfo} from "../types.js";
33
import BaseDownloadEngineFetchStream from "../streams/download-engine-fetch-stream/base-download-engine-fetch-stream.js";
44
import BaseDownloadEngineWriteStream from "../streams/download-engine-write-stream/base-download-engine-write-stream.js";
55
import retry from "async-retry";
6-
import { EventEmitter } from "eventemitter3";
7-
import switchProgram, { AvailablePrograms } from "./download-programs/switch-program.js";
6+
import {EventEmitter} from "eventemitter3";
7+
import switchProgram, {AvailablePrograms} from "./download-programs/switch-program.js";
88
import BaseDownloadProgram from "./download-programs/base-download-program.js";
9-
import { pushComment } from "./utils/push-comment.js";
10-
import { uid } from "uid";
11-
import { DownloaderProgramManager } from "./downloaderProgramManager.js";
9+
import {pushComment} from "./utils/push-comment.js";
10+
import {uid} from "uid";
11+
import {DownloaderProgramManager} from "./downloaderProgramManager.js";
1212

1313
export type DownloadEngineFileOptions = {
1414
chunkSize?: number;
@@ -86,12 +86,12 @@ export default class DownloadEngineFile extends EventEmitter<DownloadEngineFileE
8686
public constructor(file: DownloadFile, options: DownloadEngineFileOptions) {
8787
super();
8888
this.file = file;
89-
this.options = { ...DEFAULT_OPTIONS, ...options };
89+
this.options = {...DEFAULT_OPTIONS, ...options};
9090
this._progressStatus = {
9191
totalDownloadParts: file.parts.length,
9292
fileName: file.localFileName,
9393
transferAction: options.fetchStream.transferAction,
94-
downloadFlags: this._createProgressFlags(),
94+
downloadFlags: this._createProgressFlags()
9595
};
9696
this._setDefaultByOptions();
9797
this._initProgress();
@@ -288,7 +288,7 @@ export default class DownloadEngineFile extends EventEmitter<DownloadEngineFileE
288288
}
289289

290290
protected async _downloadSlice(startChunk: number, endChunk: number) {
291-
const getContext = () => this._activeStreamContext[startChunk] ??= { streamBytes: 0, retryingAttempts: 0 };
291+
const getContext = () => this._activeStreamContext[startChunk] ??= {streamBytes: 0, retryingAttempts: 0};
292292

293293
const fetchState = this.options.fetchStream.withSubState({
294294
chunkSize: this._progress.chunkSize,

src/download/download-engine/download-file/progress-status-file.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,4 +48,4 @@ export const EMPTY_PROGRESS_STATUS: ProgressStatus = {
4848
transferredBytes: 0,
4949
startTime: 0,
5050
endTime: 0
51-
};
51+
};

src/download/download-engine/streams/download-engine-fetch-stream/download-engine-fetch-stream-xhr.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import retry from "async-retry";
22
import prettyMillisecondsCompact from "../../../transfer-visualize/utils/prettyMSFast.js";
3-
import { AvailablePrograms } from "../../download-file/download-programs/switch-program.js";
3+
import {AvailablePrograms} from "../../download-file/download-programs/switch-program.js";
44
import BaseDownloadEngineFetchStream, {
55
DownloadInfoResponse,
66
FetchSubState,
@@ -9,12 +9,12 @@ import BaseDownloadEngineFetchStream, {
99
WriteCallback
1010
} from "./base-download-engine-fetch-stream.js";
1111
import EmptyResponseError from "./errors/empty-response-error.js";
12-
import { EmptyStreamTimeoutError } from "./errors/EmptyStreamTimeoutError.js";
12+
import {EmptyStreamTimeoutError} from "./errors/EmptyStreamTimeoutError.js";
1313
import InvalidContentLengthError from "./errors/invalid-content-length-error.js";
1414
import StatusCodeError from "./errors/status-code-error.js";
1515
import XhrError from "./errors/xhr-error.js";
16-
import { parseContentDisposition } from "./utils/content-disposition.js";
17-
import { parseHttpContentRange } from "./utils/httpRange.js";
16+
import {parseContentDisposition} from "./utils/content-disposition.js";
17+
import {parseHttpContentRange} from "./utils/httpRange.js";
1818

1919

2020
export default class DownloadEngineFetchStreamXhr extends BaseDownloadEngineFetchStream {

src/download/download-engine/streams/download-engine-write-stream/download-engine-write-stream-nodejs.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import retry from "async-retry";
22
import fsExtra from "fs-extra";
3-
import fs, { FileHandle } from "fs/promises";
4-
import { withLock } from "lifecycle-utils";
3+
import fs, {FileHandle} from "fs/promises";
4+
import {withLock} from "lifecycle-utils";
55
import BaseDownloadEngineWriteStream from "./base-download-engine-write-stream.js";
66
import WriteQueue from "./utils/WriteQueue.js";
77

src/download/download-engine/streams/download-engine-write-stream/utils/WriteQueue.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { FileHandle } from "fs/promises";
1+
import {FileHandle} from "fs/promises";
22
import WriterIsClosedError from "../errors/writer-is-closed-error.js";
33

44
const MIN_BUFFER_SIZE = 2 * 1024 * 1024; // 2 MB
@@ -66,7 +66,7 @@ export default class WriteQueue {
6666

6767
const merged = this._tryMerge(cursor, buffers, length);
6868
if (!merged) {
69-
this._regions.push({ cursor, buffers, length });
69+
this._regions.push({cursor, buffers, length});
7070
}
7171

7272
this._totalBuffered += length;

src/download/transfer-visualize/format-transfer-status.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
import { DownloadStatus, ProgressStatus } from "../download-engine/download-file/progress-status-file.js";
2-
import { TransferProgressInfo } from "./transfer-statistics.js";
3-
import prettyBytes, { PrettyBytesOptions, formatTrunc } from "./utils/prettyBytesFast.js";
1+
import {DownloadStatus, ProgressStatus} from "../download-engine/download-file/progress-status-file.js";
2+
import {TransferProgressInfo} from "./transfer-statistics.js";
3+
import prettyBytes, {PrettyBytesOptions, formatTrunc} from "./utils/prettyBytesFast.js";
44
import prettyMillisecondsCompact from "./utils/prettyMSFast.js";
55

66
const DEFAULT_LOCALIZATION: Intl.LocalesArgument = "en-US";
@@ -28,7 +28,7 @@ const NUMBER_FORMAT_OPTIONS: Intl.NumberFormatOptions = {
2828

2929
const PERCENTAGE_FRACTION_DIGITS = 4;
3030

31-
const PRETTY_BYTES_OPTIONS: PrettyBytesOptions = {...NUMBER_FORMAT_OPTIONS, space: false };
31+
const PRETTY_BYTES_OPTIONS: PrettyBytesOptions = {...NUMBER_FORMAT_OPTIONS, space: false};
3232

3333
const DEFAULT_CLI_INFO_STATUS: CliInfoStatus = {
3434
speed: 0,

src/download/transfer-visualize/progress-statistics-builder.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
import BaseDownloadEngine from "../download-engine/engine/base-download-engine.js";
2-
import { EventEmitter } from "eventemitter3";
2+
import {EventEmitter} from "eventemitter3";
33
import TransferStatistics from "./transfer-statistics.js";
4-
import { createFormattedStatus, FormattedStatus } from "./format-transfer-status.js";
4+
import {createFormattedStatus, FormattedStatus} from "./format-transfer-status.js";
55
import DownloadEngineFile from "../download-engine/download-file/download-engine-file.js";
6-
import { DownloadStatus, EMPTY_PROGRESS_STATUS, ProgressStatus } from "../download-engine/download-file/progress-status-file.js";
6+
import {DownloadStatus, EMPTY_PROGRESS_STATUS, ProgressStatus} from "../download-engine/download-file/progress-status-file.js";
77
import DownloadEngineMultiDownload from "../download-engine/engine/download-engine-multi-download.js";
8-
import { DownloadEngineRemote } from "../download-engine/engine/DownloadEngineRemote.js";
8+
import {DownloadEngineRemote} from "../download-engine/engine/DownloadEngineRemote.js";
99

1010
export type ProgressStatusWithIndex = FormattedStatus & {
1111
index: number,
@@ -85,10 +85,10 @@ export default class ProgressStatisticsBuilder extends EventEmitter<CliProgressB
8585

8686
const latestStatus = engine.status;
8787
const addFileNameFunc = () => {
88-
if(addFileName){
88+
if (addFileName){
8989
this._allFileNames += this._allFileNames ? ", " + latestStatus.fileName : latestStatus.fileName;
9090
}
91-
}
91+
};
9292

9393
if (engine instanceof DownloadEngineMultiDownload) {
9494
addFileNameFunc();
@@ -147,7 +147,7 @@ export default class ProgressStatisticsBuilder extends EventEmitter<CliProgressB
147147
}
148148

149149
private _calcCommonTransferAction() {
150-
this._commonTransferAction = Object.entries(this._commonTransferActionMap).reduce((a, b) => a[1] >= b[1] ? a : b)[0];
150+
this._commonTransferAction = Object.entries(this._commonTransferActionMap).reduce((a, b) => (a[1] >= b[1] ? a : b))[0];
151151
}
152152

153153
/**

src/download/transfer-visualize/transfer-cli/GlobalCLI.ts

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
import DownloadEngineMultiDownload, { DownloadEngineMultiAllowedEngines } from "../../download-engine/engine/download-engine-multi-download.js";
2-
import TransferCli, { TransferCliOptions } from "./transfer-cli.js";
3-
import { BaseMultiProgressBar } from "./multiProgressBars/BaseMultiProgressBar.js";
4-
import switchCliProgressStyle, { AvailableCLIProgressStyle } from "./progress-bars/switch-cli-progress-style.js";
5-
import { CliFormattedStatus } from "./progress-bars/base-transfer-cli-progress-bar.js";
1+
import DownloadEngineMultiDownload, {DownloadEngineMultiAllowedEngines} from "../../download-engine/engine/download-engine-multi-download.js";
2+
import TransferCli, {TransferCliOptions} from "./transfer-cli.js";
3+
import {BaseMultiProgressBar} from "./multiProgressBars/BaseMultiProgressBar.js";
4+
import switchCliProgressStyle, {AvailableCLIProgressStyle} from "./progress-bars/switch-cli-progress-style.js";
5+
import {CliFormattedStatus} from "./progress-bars/base-transfer-cli-progress-bar.js";
66
import cliSpinners from "cli-spinners";
7-
import { DownloadStatus } from "../../download-engine/download-file/progress-status-file.js";
7+
import {DownloadStatus} from "../../download-engine/download-file/progress-status-file.js";
88
import BaseDownloadEngine from "../../download-engine/engine/base-download-engine.js";
9-
import { DownloadEngineRemote } from "../../download-engine/engine/DownloadEngineRemote.js";
10-
import { FormattedStatus } from "../format-transfer-status.js";
9+
import {DownloadEngineRemote} from "../../download-engine/engine/DownloadEngineRemote.js";
10+
import {FormattedStatus} from "../format-transfer-status.js";
1111

1212
type AllowedDownloadEngine = DownloadEngineMultiDownload | BaseDownloadEngine | DownloadEngineRemote;
1313

@@ -189,7 +189,7 @@ class GlobalCLI {
189189
}
190190

191191
private static _createOptions(options: CliProgressDownloadEngineOptions) {
192-
const cliOptions: Partial<TransferCliOptions> = { ...options };
192+
const cliOptions: Partial<TransferCliOptions> = {...options};
193193
cliOptions.createProgressBar ??= typeof options.cliStyle === "function" ?
194194
{
195195
createStatusLine: options.cliStyle,

src/download/transfer-visualize/transfer-cli/progress-bars/fancy-transfer-cli-progress-bar.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import chalk from "chalk";
22
import sliceAnsi from "slice-ansi";
33
import stripAnsi from "strip-ansi";
4-
import { DownloadStatus } from "../../../download-engine/download-file/progress-status-file.js";
5-
import { DataLine, renderDataLine } from "../../utils/data-line.js";
4+
import {DownloadStatus} from "../../../download-engine/download-file/progress-status-file.js";
5+
import {DataLine, renderDataLine} from "../../utils/data-line.js";
66
import prettyMillisecondsCompact from "../../utils/prettyMSFast.js";
7-
import { STATUS_ICONS } from "../../utils/progressBarIcons.js";
7+
import {STATUS_ICONS} from "../../utils/progressBarIcons.js";
88
import BaseTransferCliProgressBar from "./base-transfer-cli-progress-bar.js";
99

1010
/**

src/download/transfer-visualize/transfer-cli/transfer-cli.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
import UpdateManager from "stdout-update";
2-
import { TransferCliProgressBar } from "./progress-bars/base-transfer-cli-progress-bar.js";
2+
import {TransferCliProgressBar} from "./progress-bars/base-transfer-cli-progress-bar.js";
33
import cliSpinners from "cli-spinners";
4-
import { FormattedStatus } from "../format-transfer-status.js";
4+
import {FormattedStatus} from "../format-transfer-status.js";
55
import switchCliProgressStyle from "./progress-bars/switch-cli-progress-style.js";
6-
import { BaseMultiProgressBar } from "./multiProgressBars/BaseMultiProgressBar.js";
6+
import {BaseMultiProgressBar} from "./multiProgressBars/BaseMultiProgressBar.js";
77

88
export type TransferCliOptions = {
99
name?: string,
@@ -34,10 +34,10 @@ export default class TransferCli {
3434
private _lastProgressLong = "";
3535
private _lastUpdateTime = 0;
3636
private _shouldExitOnSIGINT = false;
37-
private _debounceWait: number
37+
private _debounceWait: number;
3838

3939
public constructor(options: Partial<TransferCliOptions>) {
40-
this.options = { ...DEFAULT_TRANSFER_CLI_OPTIONS, ...options };
40+
this.options = {...DEFAULT_TRANSFER_CLI_OPTIONS, ...options};
4141
this._multiProgressBar = new this.options.createProgressBar.multiProgressBar(this.options);
4242
this._debounceWait = this._multiProgressBar.updateIntervalMs || this.options.debounceWait;
4343

@@ -76,7 +76,7 @@ export default class TransferCli {
7676
updateStatues(getLatestProgress: () => [FormattedStatus[], FormattedStatus, number], debounce = true) {
7777
this.latestProgressGetter = getLatestProgress;
7878

79-
if(debounce && Date.now() - this._lastUpdateTime < this._debounceWait) {
79+
if (debounce && Date.now() - this._lastUpdateTime < this._debounceWait) {
8080
return;
8181
}
8282

0 commit comments

Comments
 (0)