{"id":49733,"library":"websocket-pull-stream","title":"WebSocket Pull Stream","description":"WebSocket Pull Stream (v2.0.12) wraps WebSocket connections with pull-stream semantics for lightweight, efficient real-time communication. Unlike websocket-stream, it is much leaner (browserified+uglified size ~8KB vs ~79KB) and adds object mode streams, duplex (two-way) communication, and a multiplexer API for multiple streams over one WebSocket. It is isomorphic (same API for browser and Node.js) and supports both pull and flow modes. The package is in maintenance mode as of 2025, with no recent updates since 2019, but remains a minimalist alternative for pull-stream ecosystems.","status":"maintenance","version":"2.0.12","language":"javascript","source_language":"en","source_url":"https://github.com/davidmarkclements/websocket-pull-stream","tags":["javascript","websocket","websockets","stream","streams","realtime","pull-stream","pull-core","pull"],"install":[{"cmd":"npm install websocket-pull-stream","lang":"bash","label":"npm"},{"cmd":"yarn add websocket-pull-stream","lang":"bash","label":"yarn"},{"cmd":"pnpm add websocket-pull-stream","lang":"bash","label":"pnpm"}],"dependencies":[{"reason":"Required for pull-stream duplex, source, sink, and through stream primitives used by this package.","package":"pull-stream","optional":false}],"imports":[{"note":"ESM-only since v2.  CommonJS require is not supported; use ES modules.","wrong":"const wsps = require('websocket-pull-stream')","symbol":"wsps","correct":"import wsps from 'websocket-pull-stream'"},{"note":"wsps returns a factory function that must be called (with optional object constructor) to get a duplex pull-stream.","wrong":"const stream = wsps(websocket)","symbol":"duplex","correct":"const stream = wsps(websocket)()"},{"note":"pull-stream uses a single default export 'pull' which contains source, sink, through, etc.","wrong":"import { Source } from 'pull-stream'","symbol":"Source","correct":"import pull from 'pull-stream'"}],"quickstart":{"code":"import WebSocket from 'ws';\nimport wsps from 'websocket-pull-stream';\nimport pull from 'pull-stream';\n\nconst ws = new WebSocket('ws://localhost:8081');\nws.on('open', () => {\n  // Create duplex stream\n  const duplex = wsps(ws)();\n  \n  // Source: push some data\n  const source = pull.values(['hello', 'world']);\n  \n  // Sink: log received data\n  const sink = pull.collect((err, results) => {\n    console.log(results);\n  });\n  \n  // Connect\n  pull(\n    source,\n    duplex,\n    sink\n  );\n});","lang":"typescript","description":"Shows how to create a duplex pull-stream from a WebSocket using websocket-pull-stream, and pipe data through it."},"warnings":[{"fix":"Call the returned function: const duplex = wsps(websocket)()","message":"Version 2 rewrote the API: wsps now returns a factory function instead of a stream directly.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Consider alternatives like ws or uWebSockets.js for active support.","message":"The package appears unmaintained; last release was 2019. No security patches are expected.","severity":"deprecated","affected_versions":"*"},{"fix":"Use import or dynamic import() instead of require().","message":"ESM-only export in v2. CommonJS require will throw at runtime.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Use pull-stream's pull() function to connect streams.","message":"The duplex stream is not a Node stream; it's a pull-stream. Piping with .pipe() will not work.","severity":"gotcha","affected_versions":"*"},{"fix":"const duplex = wsps(websocket, { mode: 'flow' })()","message":"Options like 'mode' and 'View' must be passed as second argument to wsps, not to the factory call.","severity":"gotcha","affected_versions":"*"},{"fix":"const duplex = wsps(websocket)(Object)","message":"Object mode is enabled by passing a constructor function (e.g., Object) to the factory call, not as an option.","severity":"gotcha","affected_versions":"*"}],"env_vars":null,"search_vec":"'2019':87 '2025':81 '79kb':36 '8kb':34 'add':38 'altern':92 'api':50,61 'browser':63 'browserifi':31 'communic':22,46 'connect':10 'core':109 'duplex':42 'ecosystem':97 'effici':18 'flow':71 'isomorph':59 'javascript':98 'leaner':30 'lightweight':17 'mainten':77 'minimalist':91 'mode':40,72,78 'much':29 'multipl':52 'multiplex':49 'node.js':65 'object':39 'one':55 'packag':74 'pull':2,5,13,69,95,105,108,110 'pull-cor':107 'pull-stream':12,94,104 'real':20 'real-tim':19 'realtim':103 'recent':84 'remain':89 'semant':15 'sinc':86 'size':33 'stream':3,6,14,26,41,53,96,101,102,106 'support':67 'time':21 'two':44 'two-way':43 'uglifi':32 'unlik':23 'updat':85 'v2.0.12':7 'vs':35 'way':45 'websocket':1,4,9,25,56,99,100 'websocket-stream':24 'wrap':8","created_at":"2026-06-07T17:03:19.801171+00:00","updated_at":"2026-06-07T17:03:19.801171+00:00","problems":[{"fix":"Use 'import wsps from 'websocket-pull-stream'' instead of require.","cause":"Using require() instead of import, or importing default incorrectly.","error":"TypeError: wsps is not a function"},{"fix":"Use pull(source, duplex, sink) from pull-stream package.","cause":"Trying to call .pipe() on a pull-stream duplex, which is not a Node stream.","error":"Uncaught TypeError: Cannot read properties of undefined (reading 'pipe')"},{"fix":"const stream = wsps(websocket)()","cause":"Calling wsps without invoking the returned factory.","error":"Error: stream is not a function"}],"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/davidmarkclements/websocket-pull-stream","github":"https://github.com/davidmarkclements/websocket-pull-stream","docs":null,"changelog":null,"pypi":null,"npm":"websocket-pull-stream","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}}