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

visa-ts

v1.0.0

Published

TypeScript VISA library for instrument communication

Readme

visa-ts

npm version Build Status Coverage License: MIT

TypeScript VISA (Virtual Instrument Software Architecture) library for instrument communication.

A PyVISA-inspired library for controlling test and measurement instruments from Node.js/TypeScript.

Features

  • PyVISA-compatible API — Familiar patterns for lab automation developers
  • Multiple transports — USB-TMC, Serial, TCP/IP (LXI)
  • Device simulation — Test without hardware using simulated PSU, Load, and DMM
  • Circuit simulation — Simulated devices interact with realistic physics
  • TypeScript-first — Full type safety and autocomplete
  • Result-based errors — No exceptions, explicit error handling
  • SCPI utilities — Parse responses, binary blocks, etc.

Installation

npm install visa-ts

This includes serialport and usb as dependencies for Serial and USB-TMC support.

Quick Start

import { createResourceManager } from 'visa-ts';

// Create resource manager
const rm = createResourceManager();

// List connected USB instruments
const resources = await rm.listResources('USB?*::INSTR');
console.log(resources);
// ['USB0::0x1AB1::0x04CE::DS1ZA123456789::INSTR']

// Open instrument
const result = await rm.openResource('USB0::0x1AB1::0x04CE::DS1ZA123456789::INSTR');
if (!result.ok) {
  console.error('Failed to open:', result.error);
  return;
}
const instr = result.value;

// Configure
instr.timeout = 5000;

// Query device identity
const idn = await instr.query('*IDN?');
if (idn.ok) {
  console.log(idn.value);  // 'RIGOL TECHNOLOGIES,DS1054Z,...'
}

// Close
await instr.close();
await rm.close();

Resource String Formats

| Type | Format | Example | |------|--------|---------| | USB-TMC | USB[board]::vendor::product::serial::INSTR | USB0::0x1AB1::0x04CE::DS1ZA123456789::INSTR | | Serial | ASRL[port]::INSTR | ASRL/dev/ttyUSB0::INSTR | | TCP/IP | TCPIP[board]::host::port::SOCKET | TCPIP0::192.168.1.100::5025::SOCKET |

Discovery

// USB - automatic enumeration
const usbDevices = await rm.listResources('USB?*::INSTR');

// Serial - lists available ports
const serialPorts = await rm.listResources('ASRL?*::INSTR');

// TCP/IP - manual (requires known IP)
const instr = await rm.openResource('TCPIP0::192.168.1.100::5025::SOCKET');

API Reference

ResourceManager

  • listResources(query?: string) — List available instruments
  • openResource(resourceString, options?) — Open connection to instrument
  • close() — Close all connections

MessageBasedResource

  • query(cmd) — Write command and read response
  • queryBinaryValues(cmd, datatype?) — Query binary data
  • write(cmd) — Write command (no response)
  • read() — Read response
  • clear() — Clear device buffers
  • close() — Close connection

Attributes

  • timeout — I/O timeout in milliseconds
  • readTermination — Read termination character
  • writeTermination — Write termination character

Simulation

Test your instrument control code without physical hardware:

import { createResourceManager, createSimulatedPsu } from 'visa-ts';

// Create resource manager and register a simulated PSU
const rm = createResourceManager();
rm.registerSimulatedDevice('PSU', createSimulatedPsu());

// Use it like real hardware
const result = await rm.openResource('SIM::PSU::INSTR');
if (result.ok) {
  const psu = result.value;
  await psu.write('VOLT 12.0');
  await psu.write('OUTP ON');
  const voltage = await psu.query('MEAS:VOLT?');
  console.log(voltage.value); // '12.000'
}

Available simulated devices: createSimulatedPsu(), createSimulatedLoad(), createSimulatedDmm()

When multiple simulated devices are connected, circuit simulation makes them interact realistically (e.g., PSU current limiting affects Load measurements).

Comparison to PyVISA

| PyVISA | visa-ts | |--------|---------| | rm = pyvisa.ResourceManager() | rm = createResourceManager() | | rm.list_resources() | await rm.listResources() | | instr = rm.open_resource(...) | result = await rm.openResource(...) | | instr.query('*IDN?') | await instr.query('*IDN?') | | instr.timeout = 5000 | instr.timeout = 5000 |

Key differences:

  • Factory functions instead of classes (createResourceManager() not new ResourceManager())
  • All I/O operations are async (return Promises)
  • Errors returned as Result<T, Error> instead of exceptions
  • TypeScript provides full type safety

License

MIT