Skip to content

Commit

Permalink
chore: add isOnline and online to utility net module
Browse files Browse the repository at this point in the history
  • Loading branch information
devm33 committed Sep 29, 2023
1 parent 9b6fc23 commit b8652aa
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/utility/api/net.ts
Expand Up @@ -3,10 +3,18 @@ import type { ClientRequestConstructorOptions } from 'electron/main';
import { ClientRequest } from '@electron/internal/common/api/net-client-request';
import { fetchWithSession } from '@electron/internal/browser/api/net-fetch';

const { isOnline } = 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.isOnline = isOnline;

Object.defineProperty(exports, 'online', {
get: () => isOnline()
});

0 comments on commit b8652aa

Please sign in to comment.