diff options
Diffstat (limited to 'src/bun.js/api/sockets.classes.ts')
-rw-r--r-- | src/bun.js/api/sockets.classes.ts | 130 |
1 files changed, 130 insertions, 0 deletions
diff --git a/src/bun.js/api/sockets.classes.ts b/src/bun.js/api/sockets.classes.ts new file mode 100644 index 000000000..0c72d1d8d --- /dev/null +++ b/src/bun.js/api/sockets.classes.ts @@ -0,0 +1,130 @@ +import { define } from "../scripts/class-definitions"; + +function generate(ssl) { + return define({ + name: ssl ? "TCPSocket" : "TLSSocket", + JSType: "0b11101110", + proto: { + write: { + fn: "write", + length: 3, + }, + end: { + fn: "end", + length: 3, + }, + + // }, + listener: { + getter: "getListener", + }, + + timeout: { + fn: "timeout", + length: 1, + }, + + flush: { + fn: "flush", + length: 0, + }, + + shutdown: { + fn: "shutdown", + length: 1, + }, + + ref: { + fn: "ref", + length: 0, + }, + unref: { + fn: "unref", + length: 0, + }, + + localPort: { + getter: "getLocalPort", + }, + // cork: { + // fn: "cork", + // length: 1, + // }, + data: { + getter: "getData", + cache: true, + setter: "setData", + }, + readyState: { + getter: "getReadyState", + }, + + // topics: { + // getter: "getTopics", + // }, + + remoteAddress: { + getter: "getRemoteAddress", + cache: true, + }, + + reload: { + fn: "reload", + length: 1, + }, + }, + finalize: true, + construct: true, + klass: {}, + }); +} +export default [ + generate(true), + generate(false), + define({ + name: "Listener", + JSType: "0b11101110", + proto: { + stop: { + fn: "stop", + length: 1, + }, + + ref: { + fn: "ref", + length: 0, + }, + unref: { + fn: "unref", + length: 0, + }, + + port: { + getter: "getPort", + }, + + unix: { + getter: "getUnix", + cache: true, + }, + + reload: { + fn: "reload", + length: 1, + }, + + hostname: { + getter: "getHostname", + cache: true, + }, + + data: { + getter: "getData", + setter: "setData", + }, + }, + finalize: true, + construct: true, + klass: {}, + }), +]; |