{"id":49725,"library":"websocket-lowfat-promise","title":"websock-lowfat-promise","description":"A zero-dependency promise wrapper for ws-compatible WebSocket objects. Version 1.1.12 provides a minimal, low-fat API that promisifies open, send, recv, ping, and close operations. Works in browser and Node.js environments that support promises. Unlike heavier alternatives like 'ws-wrapper' or 'reconnecting-websocket', this package is deliberately minimal (≈30 lines) with no dependencies, making it ideal for lightweight or embedded use cases. Its release cadence is low; last update was in 2021.","status":"active","version":"1.1.12","language":"javascript","source_language":"en","source_url":"git://github.com/BuGlessRB/websocket-lowfat-promise","tags":["javascript","ws","websocket","promise","promisified","zerodeps"],"install":[{"cmd":"npm install websocket-lowfat-promise","lang":"bash","label":"npm"},{"cmd":"yarn add websocket-lowfat-promise","lang":"bash","label":"yarn"},{"cmd":"pnpm add websocket-lowfat-promise","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"Package exports a default function/class. Named import will fail in ESM.","wrong":"const { wspromise } = require('websocket-lowfat-promise')","symbol":"default","correct":"import wspromise from 'websocket-lowfat-promise'"},{"note":"In CommonJS, require returns the full module.exports object directly.","wrong":"const { default: wspromise } = require('websocket-lowfat-promise')","symbol":"default (CJS)","correct":"const wspromise = require('websocket-lowfat-promise')"},{"note":"If using TS and only need types for the class, use type import to avoid runtime overhead.","wrong":"import WSPromise from 'websocket-lowfat-promise'","symbol":"TypeScript type","correct":"import type WSPromise from 'websocket-lowfat-promise'"}],"quickstart":{"code":"const WebSocket = require('ws');\nconst wspromise = require('websocket-lowfat-promise');\n\nasync function runme() {\n  const wsp = new wspromise(new WebSocket('wss://echo.websocket.org'));\n  await wsp.open();\n  await wsp.send('Hello!');\n  const response = await wsp.recv();\n  console.log(response);\n  await wsp.close();\n  console.log('Done');\n}\n\nrunme().catch(console.error);","lang":"javascript","description":"Shows how to create a promisified WebSocket, open, send, receive, and close."},"warnings":[{"fix":"Wrap recv() with a timeout or listen for 'close' event externally.","message":"wspromise.recv() will never resolve if no message arrives before the connection closes — it does not reject on close.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Ensure the underlying WebSocket is configured correctly before passing to wspromise.","message":"The passed WebSocket must be in 'open' state (or will be opened) — wspromise does not handle auto-reconnection or initial connection backoff.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"First create a WebSocket instance, then pass it to new wspromise(ws).","message":"Constructor expects an existing WebSocket instance; it does not accept a URL string.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Consider alternatives like 'ws' with manual Promise wrapping or 'async-ws' for actively maintained solutions.","message":"This package has not been updated since 2021. It may not support recent Node.js versions or security patches.","severity":"deprecated","affected_versions":"all"}],"env_vars":null,"search_vec":"'1.1.12':18 '2021':83 '30':60 'altern':46 'api':25 'browser':37 'cadenc':76 'case':73 'close':33 'compat':14 'deliber':58 'depend':8,64 'embed':71 'environ':40 'fat':24 'heavier':45 'ideal':67 'javascript':84 'last':79 'lightweight':69 'like':47 'line':61 'low':23,78 'low-fat':22 'lowfat':3 'make':65 'minim':21,59 'node.js':39 'object':16 'open':28 'oper':34 'packag':56 'ping':31 'promis':4,9,43,87 'promisifi':27,88 'provid':19 'reconnect':53 'reconnecting-websocket':52 'recv':30 'releas':75 'send':29 'support':42 'unlik':44 'updat':80 'use':72 'version':17 'websock':2 'websock-lowfat-promis':1 'websocket':15,54,86 'work':35 'wrapper':10,50 'ws':13,49,85 'ws-compat':12 'ws-wrapper':48 'zero':7 'zero-depend':6 'zerodep':89","created_at":"2026-06-07T17:03:17.445478+00:00","updated_at":"2026-06-07T17:03:17.445478+00:00","problems":[{"fix":"Always await wsp.open() before any other operations.","cause":"Calling send() or recv() before awaiting open().","error":"Error: WebSocket is not open: readyState 0 (CONNECTING)"},{"fix":"Use const wspromise = require('websocket-lowfat-promise'); (CJS) or import wspromise from 'websocket-lowfat-promise'; (ESM).","cause":"Using default import in CommonJS vs ESM incorrectly.","error":"TypeError: wspromise is not a constructor"},{"fix":"Ensure the argument is a ws-compatible WebSocket instance with standard event methods.","cause":"Passing an invalid WebSocket object (e.g., no 'on' or 'removeListener').","error":"TypeError: (intermediate value).recv is not a function"},{"fix":"Wrap calls in try/catch or use .catch() to handle promise rejections properly.","cause":"Attempting to send/recv before open completes or after close, and not catching the rejection.","error":"UnhandledPromiseRejectionWarning: Error: WebSocket is not open"}],"ecosystem":"npm","meta_description":null,"install_score":null,"quickstart_score":null,"quickstart_tag":null,"pypi_latest":null,"cli_name":null,"cli_version":null,"type":"library","homepage":"https://github.com/BuGlessRB/websocket-lowfat-promise#readme","github":"git://github.com/BuGlessRB/websocket-lowfat-promise","docs":null,"changelog":null,"pypi":null,"npm":"websocket-lowfat-promise","openapi_spec":null,"status_page":null,"smithery":null,"categories":["messaging"],"base_url":null,"auth_type":null,"provenance":{"verified_status":null,"verified_at":null,"last_verified":"2026-06-07","next_check":"2026-09-05","install_tag":null}}