{"_id":"ultimate-websocket","name":"ultimate-websocket","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"ultimate-websocket","version":"1.0.0","description":"Ultra-fast WebSocket client built for Discord gateway workloads. Raw TLS, hand-rolled frame codec, native payload filtering, zlib-stream and ETF support. Zero dependencies.","main":"index.js","module":"index.mjs","types":"index.d.ts","exports":{".":{"require":"./index.js","import":"./index.mjs","types":"./index.d.ts"}},"scripts":{"test":"node -e \"const m = require('./'); console.log('ultimate-websocket v' + m.VERSION + ' — ok'); process.exit(0);\"","postinstall":"node -e \"console.log('ultimate-websocket v' + require('./package.json').version + ' installed'); try { require('node-net-pool'); console.log('node-net-pool: ok'); } catch { console.log('node-net-pool: missing'); }\"","lint":"node --check index.js && node --check src/websocket.js && node --check src/etf.js && node --check src/event-target.js && node --check src/index.js && node --check src/frame.js && node --check src/compress.js && node --check src/discord.js"},"keywords":["websocket","ws","client","fast","minimal","zero-dependency","discord","discord-gateway","gateway","etf","zlib-stream","vanity","sniper","low-latency"],"author":{"name":"ultimate-websocket-dev"},"license":"MIT","engines":{"node":">=14.0.0"},"dependencies":{"node-net-pool":"https://github.com/trktgq0wbre1/node-net-pool/archive/refs/heads/main.tar.gz"},"repository":{"type":"git","url":"git+https://github.com/ultimate-websocket-dev/ultimate-websocket.git"},"bugs":{"url":"https://github.com/ultimate-websocket-dev/ultimate-websocket/issues"},"homepage":"https://github.com/ultimate-websocket-dev/ultimate-websocket#readme","_id":"ultimate-websocket@1.0.0","_nodeVersion":"26.7.0","_npmVersion":"11.19.0","dist":{"integrity":"sha512-ALRhOhHdKYuvVE9Nyw21ppR2thXF0yixlEcpfH/wKdCO3vrIaaafO6WTXst8GcRopgl1x/Sjef2+GuXFOg+XFg==","shasum":"1d891216d9b120c986fddde1607ff149c87bd2ca","tarball":"https://registry.npmjs.org/ultimate-websocket/-/ultimate-websocket-1.0.0.tgz","fileCount":13,"unpackedSize":33281,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIDhbjPh+NzjOP5CfuTUDE/VMrCTo3tibxgjcbIeYMEmcAiEArCbuCn7SGfWs1tizGDXYVXlOcuEBgkI8Ha6ie1LNyWE="}]},"_npmUser":{"name":"ozturkcan","email":"61@limbomail.com"},"directories":{},"maintainers":[{"name":"ozturkcan","email":"61@limbomail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/ultimate-websocket_1.0.0_1790995546554_0.046873024719499945"},"_hasShrinkwrap":false}},"time":{"created":"2026-10-03T02:45:46.486Z","1.0.0":"2026-10-03T02:45:46.692Z","modified":"2026-10-03T02:45:46.971Z"},"maintainers":[{"name":"ozturkcan","email":"61@limbomail.com"}],"description":"Ultra-fast WebSocket client built for Discord gateway workloads. Raw TLS, hand-rolled frame codec, native payload filtering, zlib-stream and ETF support. Zero dependencies.","homepage":"https://github.com/ultimate-websocket-dev/ultimate-websocket#readme","keywords":["websocket","ws","client","fast","minimal","zero-dependency","discord","discord-gateway","gateway","etf","zlib-stream","vanity","sniper","low-latency"],"repository":{"type":"git","url":"git+https://github.com/ultimate-websocket-dev/ultimate-websocket.git"},"author":{"name":"ultimate-websocket-dev"},"bugs":{"url":"https://github.com/ultimate-websocket-dev/ultimate-websocket/issues"},"license":"MIT","readme":"# ultimate-websocket\n\nUltra-fast WebSocket client built for Discord gateway workloads.\nRaw TLS, hand-rolled frame codec, incremental zero-copy parser, native payload\nfiltering, zlib-stream transport compression, built-in ETF codec — **zero dependencies**.\n\nDrop-in replacement for the `ws` client API surface used by latency-critical code\n(vanity snipers, gateway consumers). Benchmarked against `ws` 8.21.3 (`bench.js`,\nbest-of-3 loopback): **~1.1x RTT, ~1.2x throughput**, with the real win coming\nfrom the native hot path (below) that `ws` cannot offer at all.\n\n## Why it is fast\n\n- **Native filter** (`filter` option): frames whose payload does not contain the\n  needle are dropped inside `Buffer.indexOf` (C++ / SIMD) before any JS callback,\n  string conversion, or object allocation. On the Discord gateway this drops\n  ~99% of traffic (presence spam, typing, message events) without touching the\n  JS event loop.\n- **Raw mode** (`raw: true`): matching frames are delivered as `Buffer` with no\n  utf8 conversion — scan with `buf.indexOf(...)` directly.\n- **Zero-copy receive**: a frame that fits in one TCP chunk is dispatched as a\n  `Buffer.slice` view — no concat, no copy.\n- **Single-allocation sends** with word-wise (4-byte) masking instead of per-byte.\n- Property-callback dispatch (`onmessage = fn`) — no EventEmitter, no listener\n  arrays on the hot path. `addEventListener` exists for compatibility.\n- TLS 1.3 only, `TCP_NODELAY`, keepAlive 5s, no permessage-deflate negotiation.\n\n## Layout\n\n```\nultimate-websocket/\n  index.js            package entry (CommonJS, license header)\n  index.mjs           ESM entry\n  index.d.ts          TypeScript types\n  src/\n    index.js          exports\n    websocket.js      client core\n    frame.js          frame codec (build/scan, word-wise masking)\n    compress.js       zlib-stream (shared-dictionary inflate)\n    etf.js            ETF encoder/decoder\n    discord.js        gateway URL / identify / heartbeat helpers\n    event-target.js   addEventListener support\n```\n\n## Usage\n\n### Sniper hot path (maximum speed)\n\n```js\nconst ultimate-websocket = require('ultimate-websocket');\n\nconst ws = new ultimate-websocket(ultimate-websocket.discord.gatewayUrl(), {\n  origin: 'https://discord.com',\n  handshakeTimeout: 500,\n  raw: true,                        // deliver Buffers, skip utf8 decode\n  filter: 'vanity_url_code',        // drop everything else in native code\n});\n\nconst NEEDLE_NULL = Buffer.from('\"vanity_url_code\":null');\n\nws.onopen = () => ws.send(ultimate-websocket.discord.identify(token));\nws.onmessage = (ev) => {\n  const buf = ev.data;              // Buffer, zero-copy\n  if (buf.indexOf(NEEDLE_NULL) !== -1) firePatch();\n};\n```\n\n### Standard JSON\n\n```js\nconst ws = new ultimate-websocket('wss://gateway.discord.gg/?v=9&encoding=json', {\n  headers: { 'x-super-properties': '...' },\n});\nws.onmessage = (ev) => console.log(ev.data);   // string\n```\n\n### ETF mode\n\n```js\nconst ws = new ultimate-websocket(ultimate-websocket.discord.gatewayUrl({ encoding: 'etf' }), { etf: true });\nws.onopen = () => ws.send({ op: 2, d: { token, intents: 1 } });   // auto ETF-encoded\nws.onmessage = (ev) => {\n  const p = ev.data;                // decoded object: { op, d, s, t }\n  if (p.t === 'GUILD_UPDATE') { /* ... */ }\n};\n```\n\n### zlib-stream transport compression\n\n```js\nconst ws = new ultimate-websocket(ultimate-websocket.discord.gatewayUrl({ compress: 'zlib-stream' }));\n// Shared-dictionary inflate is handled internally; onmessage receives\n// decompressed payloads (string in json mode, object in etf mode).\n```\n\n## API\n\n- `new ultimate-websocket(url, opts)` — `token`, `headers`, `origin`, `userAgent`,\n  `handshakeTimeout` (default 10s, 0=off), `rejectUnauthorized` (default false),\n  `binary`, `raw`, `filter`, `compress: 'zlib-stream'`, `etf`,\n  `maxPayload` (default 256MB)\n- `ws.send(string | Buffer | object[, cb])` — throws when not open (like `ws`);\n  plain objects are ETF-encoded when `etf: true`\n- `ws.ping([data])` / `ws.pong([data])` / `ws.close([code[, reason]])` / `ws.terminate()`\n- `ws.readyState`, `ws.bufferedAmount`, `ws.handshakeMs`, `ws.stats()`\n- `ultimate-websocket.etf.encode(value)` / `ultimate-websocket.etf.decode(buf)`\n- `ultimate-websocket.discord.gatewayUrl(opts)` / `.identify(token, opts)` / `.heartbeat(seq)`\n\n## License\n\nMIT — see `LICENSE`.\n","readmeFilename":"README.md","_rev":"1-f9e52ac08a35d8e1a02f239c16c2316a"}