Skip to content

Commit

Permalink
cleanup and revert unrelated changes
Browse files Browse the repository at this point in the history
  • Loading branch information
delilahw committed Jul 26, 2020
1 parent 214b02f commit bc8bfcd
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions source/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,12 @@ const create = (defaults: InstanceDefaults): Got => {
};

// Pagination
const paginateEach = async function * <T, R>(url: string | URL, options?: OptionsWithPagination<T, R>) {
const paginateEach = (async function * <T, R>(url: string | URL, options?: OptionsWithPagination<T, R>) {
// TODO: Remove this `@ts-expect-error` when upgrading to TypeScript 4.
// Error: Argument of type 'Merge<Options, PaginationOptions<T, R>> | undefined' is not assignable to parameter of type 'Options | undefined'.
// @ts-expect-error
const normalizedOptions = normalizeArguments(url, options, defaults.options);
const optionsHooks = options?.hooks;
options = {...options, resolveBodyOnly: false};

const pagination = normalizedOptions.pagination!;
Expand Down Expand Up @@ -264,13 +265,13 @@ const create = (defaults: InstanceDefaults): Got => {
}

if (nextOptions) {
nextOptions.hooks = options?.hooks;
nextOptions.hooks = optionsHooks;
nextOptions.resolveBodyOnly = false;
}

numberOfRequests++;
}
};
});

got.paginate = (<T, R>(url: string | URL, options?: OptionsWithPagination<T, R>) => {
return paginateEach(url, options);
Expand All @@ -294,10 +295,7 @@ const create = (defaults: InstanceDefaults): Got => {

// Shortcuts
for (const method of aliases) {
got[method] = ((url: string | URL, options?: Options): GotReturn => got(url, {
...options,
method
})) as GotRequestFunction;
got[method] = ((url: string | URL, options?: Options): GotReturn => got(url, {...options, method})) as GotRequestFunction;

got.stream[method] = ((url: string | URL, options?: StreamOptions) => {
return got(url, {...options, method, isStream: true});
Expand Down

0 comments on commit bc8bfcd

Please sign in to comment.