npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

@gurezo/web-serial-rxjs

v2.3.1

Published

RxJS-based utilities for the Web Serial API, usable from Angular, React, Svelte, and Vanilla JavaScript/TypeScript.

Readme

@gurezo/web-serial-rxjs

A TypeScript library that wraps the Web Serial API with a minimal, session-oriented RxJS surface. The v2 API exposes a single SerialSession so applications can drive their UI from state$ + isConnected$ + receive$ + lines$ + errors$, without rebuilding read loops or send queues themselves.

Browser support

The Web Serial API is only available in Chromium-based browsers: Chrome 89+, Edge 89+, Opera 75+.

SerialSession.isBrowserSupported() returns a synchronous boolean for feature detection before connect$.

Port info (device identification)

After a successful connect$, use getPortInfo() or subscribe to portInfo$ for the SerialPort.getInfo() snapshot (e.g. USB vendor/product IDs when the device exposes them). Both yield null when disconnected. getCurrentPort() returns the underlying SerialPort while connected; do not call close() on it—use disconnect$ for lifecycle.

Receive replay (receive$ vs receiveReplay$)

receive$ is non-replay: late subscribers only see chunks emitted after they subscribe. To retain the last N decoded text chunks per open connection (same bytes as receive$, e.g. for boot logs), pass receiveReplay: { enabled: true, bufferSize: 512 } to createSerialSession and subscribe to receiveReplay$. Larger bufferSize uses more memory. When receive replay is off (default), receiveReplay$ is the same hot stream as receive$. This option does not add replay to lines$—only raw decoder chunks on receiveReplay$.

receive$ vs lines$

Pick the stream that matches your use case. Using lines$ for a terminal mirror drops \r and redraw behaviour, which breaks shells and tools that rely on carriage-return updates (overview).

receive$ (raw stream)

  • UTF-8 decoder chunks as they arrive—not line-aligned.
  • Preserves \r, partial lines, and other control characters.
  • Use for: terminal display, prompt detection, buffering / scrollback you control, and other raw-stream handling.

lines$ (line-delimited events)

  • Emits complete lines (\n, \r\n, interior \r per implementation).
  • Use for logs, structured parsing, and protocols framed on newlines.
  • Not suitable for mirroring interactive CLI output when peers use \r for in-place redraws—you lose those semantics.

Avoid / Prefer

Avoid—appending lines$ strings for a terminal-style view hides redraws and corrupts layouts.

session.lines$.subscribe((line) => {
  output += line + '\n';
});

Prefer—concatenate chunks from receive$ for mirrors and shell-style buffers.

session.receive$.subscribe((chunk) => {
  output += chunk;
});

Installation

npm install @gurezo/web-serial-rxjs
# or
pnpm add @gurezo/web-serial-rxjs

Peer dependency

This library requires RxJS ^7.8.0 as a peer dependency:

npm install rxjs
# or
pnpm add rxjs

Where to go next

Documentation

| Doc | Use it for | | --- | --- | | Overview | Features and the v2 SerialSession / SerialSessionState map | | Quick Start | Open a port and wire subscriptions end-to-end | | Advanced Usage | Line framing, request/response-style flows, recovery | | API Reference | SerialSessionOptions, SerialError, and formal details | | v1 → v2 migration | Replacing the removed v1 SerialClient / ShellClient API | | Repository README | Monorepo layout, examples under apps/, contributing, MCP, and project icon |

License

MIT — see the LICENSE file in the repository.

Links