electron/lib/browser/api/net.ts

20 lines
697 B
TypeScript
Raw Normal View History

2023-02-20 20:57:38 +00:00
import { IncomingMessage, session } from 'electron/main';
import type { ClientRequestConstructorOptions } from 'electron/main';
import { ClientRequest } from '@electron/internal/browser/api/net-client-request';
2023-02-20 20:57:38 +00:00
const { isOnline } = process._linkedBinding('electron_browser_net');
2016-09-21 15:35:03 +00:00
export function request (options: ClientRequestConstructorOptions | string, callback?: (message: IncomingMessage) => void) {
2020-03-20 20:28:31 +00:00
return new ClientRequest(options, callback);
}
2023-02-20 20:57:38 +00:00
export function fetch (input: RequestInfo, init?: RequestInit): Promise<Response> {
return session.defaultSession.fetch(input, init);
}
exports.isOnline = isOnline;
Object.defineProperty(exports, 'online', {
get: () => isOnline()
});