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

@clasp-to/core

v3.3.2

Published

CLASP protocol client for JavaScript/TypeScript - Creative Low-Latency Application Streaming Protocol

Readme

@clasp-to/core

JavaScript/TypeScript client for CLASP - Creative Low-Latency Application Streaming Protocol.

npm License

Installation

npm install @clasp-to/core

Quick Start

import { Clasp, ClaspBuilder } from '@clasp-to/core';

// Connect to a CLASP server
const client = await new ClaspBuilder('ws://localhost:7330')
  .withName('My App')
  .connect();

// Subscribe to parameter changes
client.on('/lumen/layer/*/opacity', (value, address) => {
  console.log(`${address} = ${value}`);
});

// Set a parameter
await client.set('/lumen/layer/0/opacity', 0.75);

// Get a parameter
const opacity = await client.get('/lumen/layer/0/opacity');

// Emit an event
await client.emit('/cue/fire', { id: 'intro' });

// Stream high-rate data
client.stream('/fader/1', 0.5);

// Close when done
await client.close();

API

ClaspBuilder

const client = await new ClaspBuilder(url)
  .withName('Client Name')        // Set client name
  .withFeatures(['param', 'event']) // Specify features
  .withReconnect(true, 5000)      // Auto-reconnect with interval
  .connect();

Clasp Client

Reading

  • get(address) - Get parameter value
  • on(pattern, callback) - Subscribe to address pattern
  • cached(address) - Get cached value (sync)

Writing

  • set(address, value) - Set parameter (stateful)
  • emit(address, payload?) - Emit event (ephemeral)
  • stream(address, value) - Stream sample (high-rate)

Bundles

// Atomic bundle
client.bundle([
  { set: ['/light/1', 1.0] },
  { set: ['/light/2', 0.0] }
]);

// Scheduled bundle
client.bundle([...], { at: client.time() + 100000 }); // 100ms later

Utilities

  • time() - Get server-synced time (microseconds)
  • connected - Check connection status
  • sessionId - Get session ID
  • close() - Close connection

Address Patterns

CLASP supports wildcards in subscriptions:

| Pattern | Matches | |---------|---------| | /lights/front | Exact match | | /lights/* | Single segment wildcard | | /lights/** | Multi-segment wildcard |

Browser Compatibility

@clasp-to/core works in both Node.js and browser environments.

Browser Support

| Browser | Version | Notes | |---------|---------|-------| | Chrome | 68+ | Full support | | Firefox | 63+ | Full support | | Safari | 12+ | Full support | | Edge | 79+ | Full support (Chromium) | | IE | Not supported | Use Edge or polyfills |

Bundle Size

  • ESM: ~15KB minified
  • ESM + gzip: ~5KB

Browser Usage

<script type="module">
import { Clasp } from 'https://unpkg.com/@clasp-to/core/dist/index.mjs';

const clasp = new Clasp('wss://your-server.com:7330');
await clasp.connect();

// Use normally
clasp.on('/sensor/*', (value, addr) => {
  document.getElementById('display').textContent = `${addr}: ${value}`;
});
</script>

Build Tool Integration

Works with all modern bundlers:

// Vite, Rollup, esbuild, webpack 5+
import { Clasp } from '@clasp-to/core';

React Example

import { useEffect, useState, useRef } from 'react';
import { Clasp } from '@clasp-to/core';

function useClasp(url) {
  const clientRef = useRef(null);
  const [connected, setConnected] = useState(false);

  useEffect(() => {
    const client = new Clasp(url);
    clientRef.current = client;

    client.connect().then(() => setConnected(true));
    client.onDisconnect(() => setConnected(false));

    return () => client.close();
  }, [url]);

  return { client: clientRef.current, connected };
}

function Fader({ address }) {
  const { client, connected } = useClasp('wss://localhost:7330');
  const [value, setValue] = useState(0);

  useEffect(() => {
    if (!client || !connected) return;

    const unsub = client.on(address, (v) => setValue(v));
    return unsub;
  }, [client, connected, address]);

  const handleChange = (e) => {
    const v = parseFloat(e.target.value);
    setValue(v);
    client?.set(address, v);
  };

  return (
    <input
      type="range"
      min="0"
      max="1"
      step="0.01"
      value={value}
      onChange={handleChange}
      disabled={!connected}
    />
  );
}

Known Limitations

  • No mDNS discovery: Browsers cannot perform mDNS lookups. Provide explicit server URLs.
  • No raw UDP/TCP: Only WebSocket transport is available in browsers.
  • CORS: Server must allow cross-origin connections if client is served from different domain.

Documentation

Visit clasp.to for full documentation.

License

MIT


Maintained by LumenCanvas | 2026