Skip to content

Commit

Permalink
Export constructor options from node/browser files
Browse files Browse the repository at this point in the history
  • Loading branch information
blakeembrey committed May 19, 2019
1 parent 4a3617c commit cfc17c8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
8 changes: 5 additions & 3 deletions src/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,16 @@ import {
CommonBody,
useRawBody,
EmptyBody,
RequestOptions,
ResponseOptions,
CommonRequestOptions,
CommonResponseOptions,
CommonResponse,
CommonRequest
} from "./common";

export type RawBody = ReadableStream | ArrayBuffer | string;
export type CreateBody = RawBody | EmptyBody;
export type RequestOptions = CommonRequestOptions<CreateBody>;
export type ResponseOptions = CommonResponseOptions;

export * from "./headers";
export * from "./signal";
Expand Down Expand Up @@ -188,7 +190,7 @@ export class Request extends Body implements CommonRequest<RawBody> {
signal: Signal;
trailer: Promise<Headers>;

constructor(input: string | Request, init: RequestOptions<CreateBody> = {}) {
constructor(input: string | Request, init: RequestOptions = {}) {
// Clone request or use passed options object.
const opts = typeof input === "string" ? init : input.clone();
const headers = new Headers(init.headers || opts.headers);
Expand Down
6 changes: 3 additions & 3 deletions src/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export type EmptyBody = null | undefined;
/**
* Body constructor shape.
*/
export type BodyConstructor<T, U extends T> = {
export type CommonBodyConstructor<T, U extends T> = {
new (body: T | EmptyBody, headers: Headers): CommonBody<U>;
};

Expand All @@ -40,7 +40,7 @@ export interface CommonBody<T> {
/**
* Request configuration.
*/
export interface RequestOptions<T> {
export interface CommonRequestOptions<T> {
method?: string;
body?: T;
signal?: Signal;
Expand All @@ -61,7 +61,7 @@ export interface CommonRequest<T> extends CommonBody<T> {
/**
* Response configuration.
*/
export interface ResponseOptions {
export interface CommonResponseOptions {
status?: number;
statusText?: string;
headers?: HeadersInit;
Expand Down
8 changes: 5 additions & 3 deletions src/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,15 @@ import {
CommonBody,
useRawBody,
EmptyBody,
RequestOptions,
ResponseOptions,
CommonRequestOptions,
CommonResponseOptions,
CommonRequest
} from "./common";

export type RawBody = Readable | Buffer | string;
export type CreateBody = RawBody | ArrayBuffer | EmptyBody;
export type RequestOptions = CommonRequestOptions<CreateBody>;
export type ResponseOptions = CommonResponseOptions;

export * from "./headers";
export * from "./signal";
Expand Down Expand Up @@ -182,7 +184,7 @@ export class Request extends Body implements CommonRequest<RawBody> {
signal: Signal;
trailer: Promise<Headers>;

constructor(input: string | Request, init: RequestOptions<CreateBody> = {}) {
constructor(input: string | Request, init: RequestOptions = {}) {
// Clone request or use passed options object.
const opts = typeof input === "string" ? init : input.clone();
const headers = new Headers(init.headers || opts.headers);
Expand Down

0 comments on commit cfc17c8

Please sign in to comment.