Skip to content

Commit

Permalink
refactor: rename RequestResult to RequestResponse
Browse files Browse the repository at this point in the history
  • Loading branch information
dsherret committed Jan 28, 2024
1 parent 558762e commit 9982f63
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion mod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ export type {
PromptOptions,
SelectOptions,
} from "./src/console/mod.ts";
export { RequestBuilder, RequestResult } from "./src/request.ts";
export { RequestBuilder, RequestResponse } from "./src/request.ts";
// these are used when registering commands
export type {
CdChange,
Expand Down
14 changes: 7 additions & 7 deletions src/request.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export const withProgressBarFactorySymbol: unique symbol = Symbol();
/**
* Builder API for downloading files.
*/
export class RequestBuilder implements PromiseLike<RequestResult> {
export class RequestBuilder implements PromiseLike<RequestResponse> {
#state: Readonly<RequestBuilderState> | undefined = undefined;

#getClonedState(): RequestBuilderState {
Expand Down Expand Up @@ -86,15 +86,15 @@ export class RequestBuilder implements PromiseLike<RequestResult> {
return builder;
}

then<TResult1 = RequestResult, TResult2 = never>(
onfulfilled?: ((value: RequestResult) => TResult1 | PromiseLike<TResult1>) | null | undefined,
then<TResult1 = RequestResponse, TResult2 = never>(
onfulfilled?: ((value: RequestResponse) => TResult1 | PromiseLike<TResult1>) | null | undefined,
onrejected?: ((reason: any) => TResult2 | PromiseLike<TResult2>) | null | undefined,
): PromiseLike<TResult1 | TResult2> {
return this.fetch().then(onfulfilled).catch(onrejected);
}

/** Fetches and gets the response. */
fetch(): Promise<RequestResult> {
fetch(): Promise<RequestResponse> {
return makeRequest(this.#getClonedState());
}

Expand Down Expand Up @@ -342,8 +342,8 @@ interface Timeout {
clear(): void;
}

/** Result of making a request. */
export class RequestResult {
/** Response of making a request where the body can be read. */
export class RequestResponse {
#response: Response;
#downloadResponse: Response;
#originalUrl: string;
Expand Down Expand Up @@ -647,7 +647,7 @@ export async function makeRequest(state: RequestBuilderState) {
referrerPolicy: state.referrerPolicy,
signal: timeout?.signal,
});
const result = new RequestResult({
const result = new RequestResponse({
response,
originalUrl: state.url.toString(),
progressBar: getProgressBar(),
Expand Down

0 comments on commit 9982f63

Please sign in to comment.