pub const NODE_HTTPS_JS: &str = r#"
import EventEmitter from "node:events";
import * as http from "node:http";
export function request(input, optionsOrCallback, callback) {
let options;
if (typeof optionsOrCallback === 'function') {
callback = optionsOrCallback;
options = typeof input === 'string' || input instanceof URL
? { ...(typeof input === 'string' ? (() => { try { const u = new URL(input); return { protocol: u.protocol, hostname: u.hostname, port: u.port, path: u.pathname + u.search }; } catch(_) { return { path: input }; } })() : { protocol: input.protocol, hostname: input.hostname, port: input.port, path: input.pathname + input.search }) }
: (input || {});
} else {
options = typeof input === 'string' || input instanceof URL
? { ...(typeof input === 'string' ? (() => { try { const u = new URL(input); return { protocol: u.protocol, hostname: u.hostname, port: u.port, path: u.pathname + u.search }; } catch(_) { return { path: input }; } })() : { protocol: input.protocol, hostname: input.hostname, port: input.port, path: input.pathname + input.search }), ...(optionsOrCallback || {}) }
: { ...(input || {}), ...(optionsOrCallback || {}) };
}
if (!options.protocol) options.protocol = 'https:';
return http.request(options, callback);
}
export function get(input, optionsOrCallback, callback) {
const req = request(input, optionsOrCallback, callback);
req.end();
return req;
}
export function createServer() {
throw new Error('node:https.createServer is not available in PiJS');
}
export const globalAgent = {};
export default { request, get, createServer, globalAgent };
"#;Expand description
The JS source for the node:https virtual module.