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

@nvdigitalsolutions/nvoos-dom-batcher

v0.1.0-alpha.3

Published

requestAnimationFrame DOM update batcher, scroll batcher, and UI utilities for high-frequency streaming UIs - Extracted from NV Open Operator System

Readme

@nvdigitalsolutions/nvoos-dom-batcher

requestAnimationFrame-based DOM update batcher, scroll batcher, and a suite of UI utilities for high-frequency streaming UIs — extracted from the NV Open Operator System WordPress plugin.

Zero external dependencies. Uses only standard browser APIs.

Why this package?

When an AI assistant streams tokens over SSE or WebSocket, a naïve implementation calls element.textContent += token on every chunk — causing a forced reflow on every message and making the UI janky under load. This package solves that by coalescing DOM writes and scroll operations into a single requestAnimationFrame callback per frame.

It also ships formatting helpers, status management, and a lightweight attachment library that are commonly needed alongside a streaming chat UI.

Installation

npm install @nvdigitalsolutions/nvoos-dom-batcher

Quick Start

import { domUpdateBatcher, scrollBatcher } from '@nvdigitalsolutions/nvoos-dom-batcher';

const output = document.getElementById('output');
const container = document.getElementById('scroll-container');

// Stream tokens from an SSE endpoint
eventSource.addEventListener('token', (e) => {
  // Batched: all token appends within one animation frame are coalesced
  domUpdateBatcher.schedule(() => {
    output.textContent += e.data;
  });

  // Batched: only the last scroll-to-bottom per frame is executed
  scrollBatcher.scrollToBottom(container);
});

API

configure(options)

Enable/disable batching globally. Call once at startup.

import { configure } from '@nvdigitalsolutions/nvoos-dom-batcher';

configure({ debug: true });   // disables RAF — runs synchronously (useful for testing)
configure({ optimizations: false }); // same effect
configure({ optimizations: true });  // re-enable (default)

domUpdateBatcher

domUpdateBatcher.schedule(updateFn: () => void): void

Queues updateFn to run in the next animation frame. Multiple calls within one frame are merged. Falls back to immediate execution when debug mode is on or requestAnimationFrame is unavailable.

scrollBatcher

scrollBatcher.scrollToBottom(element: HTMLElement): void

Queues a scroll-to-bottom operation. Deduplicated per element per frame — so calling it 100 times in one tick is equivalent to calling it once.

Formatting utilities

import { escapeHtml, formatBytes, formatDuration, formatElapsedTime } from '@nvdigitalsolutions/nvoos-dom-batcher';

escapeHtml('<script>alert(1)</script>');  // '&lt;script&gt;alert(1)&lt;/script&gt;'
formatBytes(1536);                         // '1.5 KB'
formatDuration(95);                        // '1:35'
formatElapsedTime(75);                     // '1m 15s'

Status management

import { setStatus, clearStatus } from '@nvdigitalsolutions/nvoos-dom-batcher';

setStatus(containerEl, 'Thinking…', 'loading');
clearStatus(containerEl);

Button utilities

import { toggleButtonClass, setButtonState, setButtonIcon, updateButtonLabel } from '@nvdigitalsolutions/nvoos-dom-batcher';

setButtonState(btn, 'loading');           // sets data-state="loading"
toggleButtonClass(btn, 'active', true);   // adds class
setButtonIcon(btn, svgString, '.icon');   // XSS-safe SVG injection
updateButtonLabel(btn, 'Submit');         // sets aria-label + title

Cross-instance communication

import { broadcastMessage, listenToChatEvents } from '@nvdigitalsolutions/nvoos-dom-batcher';

// Send an event to all other chat instances on the same page
broadcastMessage('chat:scroll', { target: 'bottom' });

// Listen for events from other instances
const unsubscribe = listenToChatEvents('chat:scroll', (data) => {
  console.log(data);
});
unsubscribe(); // cleanup

Attachment library

import { validateAttachment, addToAttachmentLibrary, getFromAttachmentLibrary, removeFromAttachmentLibrary } from '@nvdigitalsolutions/nvoos-dom-batcher';

const result = validateAttachment(file, { maxBytes: 10 * 1024 * 1024, allowedTypes: ['image/png'] });
if (result.valid) {
  addToAttachmentLibrary('att-1', file);
}

const stored = getFromAttachmentLibrary('att-1');
removeFromAttachmentLibrary('att-1');

Recording timer

import { displayRecordingTimer } from '@nvdigitalsolutions/nvoos-dom-batcher';

const stopTimer = displayRecordingTimer(container, Date.now());
// Later:
stopTimer();

TypeScript

Full TypeScript definitions included:

import type { DomBatcherConfig } from '@nvdigitalsolutions/nvoos-dom-batcher';

License

MIT — NV Digital Solutions