Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update @sindresorhus/is to v7 #2363

Merged
merged 1 commit into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
"ky"
],
"dependencies": {
"@sindresorhus/is": "^6.3.1",
"@sindresorhus/is": "^7.0.0",
"@szmarczak/http-timer": "^5.0.1",
"cacheable-lookup": "^7.0.0",
"cacheable-request": "^12.0.1",
Expand Down
2 changes: 1 addition & 1 deletion source/core/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1075,7 +1075,7 @@ export default class Request extends Duplex implements RequestEvents<Request> {
if (is.undefined(headers[key])) {
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
delete headers[key];
} else if (is.null_(headers[key])) {
} else if (is.null(headers[key])) {
throw new TypeError(`Use \`undefined\` instead of \`null\` to delete the \`${key}\` header`);
}
}
Expand Down
24 changes: 12 additions & 12 deletions source/core/options.ts
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ function validateSearchParameters(searchParameters: Record<string, unknown>): as
for (const key in searchParameters) {
const value = searchParameters[key];

assert.any([is.string, is.number, is.boolean, is.null_, is.undefined], value);
assert.any([is.string, is.number, is.boolean, is.null, is.undefined], value);
}
}

Expand Down Expand Up @@ -1102,7 +1102,7 @@ export default class Options {
}

set request(value: RequestFunction | undefined) {
assert.any([is.function_, is.undefined], value);
assert.any([is.function, is.undefined], value);

this._internals.request = value;
}
Expand Down Expand Up @@ -1474,8 +1474,8 @@ export default class Options {

let {setCookie, getCookieString} = value;

assert.function_(setCookie);
assert.function_(getCookieString);
assert.function(setCookie);
assert.function(getCookieString);

/* istanbul ignore next: Horrible `tough-cookie` v3 check */
if (setCookie.length === 4 && getCookieString.length === 0) {
Expand Down Expand Up @@ -1635,7 +1635,7 @@ export default class Options {
}

set dnsLookup(value: CacheableLookup['lookup'] | undefined) {
assert.any([is.function_, is.undefined], value);
assert.any([is.function, is.undefined], value);

this._internals.dnsLookup = value;
}
Expand Down Expand Up @@ -1735,7 +1735,7 @@ export default class Options {

if (hooks) {
for (const hook of hooks) {
assert.function_(hook);
assert.function(hook);
}
}

Expand Down Expand Up @@ -1770,7 +1770,7 @@ export default class Options {
}

set followRedirect(value: boolean | ((response: PlainResponse) => boolean)) {
assert.any([is.boolean, is.function_], value);
assert.any([is.boolean, is.function], value);

this._internals.followRedirect = value;
}
Expand Down Expand Up @@ -2013,7 +2013,7 @@ export default class Options {
}

set parseJson(value: ParseJsonFunction) {
assert.function_(value);
assert.function(value);

this._internals.parseJson = value;
}
Expand Down Expand Up @@ -2064,7 +2064,7 @@ export default class Options {
}

set stringifyJson(value: StringifyJsonFunction) {
assert.function_(value);
assert.function(value);

this._internals.stringifyJson = value;
}
Expand Down Expand Up @@ -2098,7 +2098,7 @@ export default class Options {
set retry(value: Partial<RetryOptions>) {
assert.plainObject(value);

assert.any([is.function_, is.undefined], value.calculateDelay);
assert.any([is.function, is.undefined], value.calculateDelay);
assert.any([is.number, is.undefined], value.maxRetryAfter);
assert.any([is.number, is.undefined], value.limit);
assert.any([is.array, is.undefined], value.methods);
Expand Down Expand Up @@ -2164,7 +2164,7 @@ export default class Options {
}

set createConnection(value: CreateConnectionFunction | undefined) {
assert.any([is.function_, is.undefined], value);
assert.any([is.function, is.undefined], value);

this._internals.createConnection = value;
}
Expand Down Expand Up @@ -2210,7 +2210,7 @@ export default class Options {
assert.plainObject(value);

assert.any([is.boolean, is.undefined], value.rejectUnauthorized);
assert.any([is.function_, is.undefined], value.checkServerIdentity);
assert.any([is.function, is.undefined], value.checkServerIdentity);
assert.any([is.string, is.object, is.array, is.undefined], value.certificateAuthority);
assert.any([is.string, is.object, is.array, is.undefined], value.key);
assert.any([is.string, is.object, is.array, is.undefined], value.certificate);
Expand Down
2 changes: 1 addition & 1 deletion source/core/utils/is-form-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,5 +7,5 @@ type FormData = {
} & Readable;

export default function isFormData(body: unknown): body is FormData {
return is.nodeStream(body) && is.function_((body as FormData).getBoundary);
return is.nodeStream(body) && is.function((body as FormData).getBoundary);
}
10 changes: 5 additions & 5 deletions source/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ const delay = async (ms: number) => new Promise(resolve => {
setTimeout(resolve, ms);
});

const isGotInstance = (value: Got | ExtendOptions): value is Got => is.function_(value);
const isGotInstance = (value: Got | ExtendOptions): value is Got => is.function(value);

const aliases: readonly HTTPAlias[] = [
'get',
Expand Down Expand Up @@ -134,10 +134,10 @@ const create = (defaults: InstanceDefaults): Got => {

const {pagination} = normalizedOptions;

assert.function_(pagination.transform);
assert.function_(pagination.shouldContinue);
assert.function_(pagination.filter);
assert.function_(pagination.paginate);
assert.function(pagination.transform);
assert.function(pagination.shouldContinue);
assert.function(pagination.filter);
assert.function(pagination.paginate);
assert.number(pagination.countLimit);
assert.number(pagination.requestLimit);
assert.number(pagination.backoff);
Expand Down
2 changes: 1 addition & 1 deletion test/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,7 @@ test('async handlers', withServer, async (t, server, got) => {
});

const promise = instance('');
t.true(is.function_(promise.cancel));
t.true(is.function(promise.cancel));
// @ts-expect-error Manual tests
t.true((await promise).modified);
});
Expand Down
4 changes: 2 additions & 2 deletions test/stream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ test('check for pipe method', withServer, (t, server, got) => {
server.get('/', defaultHandler);

const stream = got.stream('');
t.true(is.function_(stream.pipe));
t.true(is.function_(stream.on('foobar', () => {}).pipe));
t.true(is.function(stream.pipe));
t.true(is.function(stream.on('foobar', () => {}).pipe));

stream.destroy();
});
Expand Down