electron/lib/utility/api/net.ts
Samuel Attard e9cb85bea6
build: add import/order eslint rule (#44106)
build: add import/order eslint rule (#44085)

* build: add import/order eslint rule

* chore: run lint:js --fix
2024-10-02 20:52:01 -07:00

23 lines
827 B
TypeScript

import { fetchWithSession } from '@electron/internal/browser/api/net-fetch';
import { ClientRequest } from '@electron/internal/common/api/net-client-request';
import { IncomingMessage } from 'electron/utility';
import type { ClientRequestConstructorOptions } from 'electron/utility';
const { isOnline, resolveHost } = process._linkedBinding('electron_common_net');
export function request (options: ClientRequestConstructorOptions | string, callback?: (message: IncomingMessage) => void) {
return new ClientRequest(options, callback);
}
export function fetch (input: RequestInfo, init?: RequestInit): Promise<Response> {
return fetchWithSession(input, init, undefined, request);
}
exports.resolveHost = resolveHost;
exports.isOnline = isOnline;
Object.defineProperty(exports, 'online', {
get: () => isOnline()
});