Skip to content

Commit

Permalink
[autofix.ci] apply automated fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
autofix-ci[bot] authored Jul 7, 2023
1 parent 7abe54e commit 7699a76
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 11 deletions.
2 changes: 1 addition & 1 deletion src/runtime/_internal/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ export function notImplementedClass(name: string) {
constructor() {
throw new Error(`[unenv] ${name} is not implemented yet!`);
}
}
};
}
22 changes: 14 additions & 8 deletions src/runtime/node/net/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,25 +11,31 @@ export const createServer = notImplemented(

export const Server = notImplementedClass("net.Server") as typeof net.Server;

export const BlockList = notImplementedClass("net.BlockList") as typeof net.BlockList;
export const BlockList = notImplementedClass(
"net.BlockList",
) as typeof net.BlockList;

export const connect = notImplemented("net.connect") as typeof net.connect;

export const createConnection = notImplemented(
"net.createConnection",
) as typeof net.createConnection;

const IPV4Regex = /^(?:[0-9]{1,3}\.){3}[0-9]{1,3}$/;
export const isIPv4: typeof net.isIPv4 = ((host: string) => IPV4Regex.test(host));
const IPV4Regex = /^(?:\d{1,3}\.){3}\d{1,3}$/;
export const isIPv4: typeof net.isIPv4 = (host: string) => IPV4Regex.test(host);

const IPV6Regex = /^([0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}$/;
export const isIPv6: typeof net.isIPv6 = ((host: string) => IPV6Regex.test(host));
const IPV6Regex = /^([\dA-Fa-f]{1,4}:){7}[\dA-Fa-f]{1,4}$/;
export const isIPv6: typeof net.isIPv6 = (host: string) => IPV6Regex.test(host);

export const isIP: typeof net.isIP = (host: string) => {
if (isIPv4(host)) return 4;
if (isIPv6(host)) return 6;
if (isIPv4(host)) {
return 4;
}
if (isIPv6(host)) {
return 6;
}
return 0;
}
};

export const exports: typeof net = {
Socket: Socket as any, // TODO
Expand Down
4 changes: 2 additions & 2 deletions src/runtime/node/net/socket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,12 @@ export class Socket extends Duplex implements net.Socket {

export class SocketAddress implements net.SocketAddress {
address: string;
family: 'ipv4' | 'ipv6';
family: "ipv4" | "ipv6";
port: number;
flowlabel: number;
constructor(options: net.SocketAddress) {
this.address = options.address;
this.family = options.family ;
this.family = options.family;
this.port = options.port;
this.flowlabel = options.flowlabel;
}
Expand Down

0 comments on commit 7699a76

Please sign in to comment.