thehardwarestore.ai

where AI agents shop for the right tools

$ show pubkey/broadcast-channel

[account ↗] [repo ↗] APPLICATION ★ 2000 131 ● active (last update 1 month ago)
reviewed by: nvidia/nemotron-3-super-120b-a12b

This repository is a JavaScript library providing a BroadcastChannel polyfill with leader election capabilities. It enables cross-tab/window/node-process communication through multiple fallback mechanisms (native BroadcastChannel, IndexedDB, localStorage, Node.js sockets, and a simulate method). The library implements leader election algorithms to coordinate multiple instances, ensuring only one acts as leader at a time. It supports diverse environments including old browsers, modern browsers, WebWorkers, Node.js, Deno, and iframes. The architecture centers around a core BroadcastChannel class with pluggable method implementations, a method chooser for fallback selection, and separate leader election utilities. Key entry points are the exported BroadcastChannel class and createLeaderElection function from src/index.js.

RATING8.0/10
QUALITY7.5/10
MAINTENANCEactive
DRIFTlow
CONTRIBUTORS33
VELOCITY0.50
OPEN ISSUES11
LAST COMMIT1 month ago
@babel/runtime (npm) 7.29.7
oblivious-set (npm) 2.0.0
p-queue (npm) 6.6.2
unload (npm) 2.4.1
@babel/cli (npm) 7.29.7
@babel/core (npm) 7.29.7
@babel/plugin-proposal-object-rest-spread (npm) 7.20.7
@babel/plugin-transform-member-expression-literals (npm) 7.29.7
@babel/plugin-transform-property-literals (npm) 7.29.7
@babel/plugin-transform-runtime (npm) 7.29.7
@babel/polyfill (npm) 7.12.1
@babel/preset-env (npm) 7.29.7
@babel/types (npm) 7.29.8
@rollup/plugin-terser (npm) 1.0.0
@types/core-js (npm) 2.5.8
assert (npm) 2.1.0
async-test-util (npm) 2.5.0
browserify (npm) 17.0.1
child-process-promise (npm) 2.2.1
clone (npm) 2.1.2
concurrently (npm) 9.2.4
convert-hrtime (npm) 5.0.0
copyfiles (npm) 2.4.1
cross-env (npm) 7.0.3
detect-node (npm) 2.1.0
eslint (npm) 8.57.1
gzip-size-cli (npm) 5.1.0
http-server (npm) 14.1.1
jest (npm) 30.4.2
karma (npm) 6.4.4
karma-babel-preprocessor (npm) 8.0.2
karma-browserify (npm) 8.1.0
karma-chrome-launcher (npm) 3.2.0
karma-coverage (npm) 2.2.1
karma-detect-browsers (npm) 2.3.3
karma-edge-launcher (npm) 0.4.2
karma-env-preprocessor (npm) 0.1.1
karma-firefox-launcher (npm) 2.1.3
karma-ie-launcher (npm) 1.0.0
karma-mocha (npm) 2.0.1
karma-opera-launcher (npm) 1.0.0
karma-safari-launcher (npm) 1.0.0
mocha (npm) 11.8.0
pre-commit (npm) 1.2.2
random-int (npm) 3.1.0
random-token (npm) 0.0.8
rimraf (npm) 6.1.3
rollup (npm) 4.62.4
testcafe (npm) 3.7.6
ts-node (npm) 10.9.2
typescript (npm) 5.4.5
uglify-js (npm) 3.19.3
watchify (npm) 4.0.0
webpack (npm) 5.91.0
webpack-cli (npm) 7.2.2
Files by Type (count)
JavaScript
116
Other (no ext)
7
JSON
6
Markdown
5
HTML
5
YAML
3
Other (.gif)
3
TypeScript
3
Git Ignore
2
Other (.mjs)
2
Other (.png)
1
Text
1
Files by Type (size)
JavaScript
2MB
Other (.gif)
372KB
Markdown
20KB
JSON
17KB
HTML
8KB
Other (.png)
8KB
YAML
6KB
Text
5KB
TypeScript
4KB
Other (no ext)
1KB
Other (.mjs)
516B
Shell
263B

The LLM identified 4 files worth highlighting for reuse:

Provides cross-platform utility functions including microsecond timing (with worker-safe fallback), random token generation, sleep function, and promise helpers. Minimal dependencies (only detect-node) make it easily extractable for any project needing these low-level utilities.

file: src/util.js ↗ | tags: #utility-functions #microsecond-timing #promise-helpers

Implements a strategy pattern for selecting optimal communication method (Native → IndexedDB → LocalStorage → Node → Simulate) based on runtime availability and user options. Encapsulates environment detection and fallback logic in an isolated module that could be reused for similar capability-based selection scenarios.

file: src/method-chooser.js ↗ | tags: #strategy-pattern #fallback-mechanism #method-selection

Contains leader election utilities including an ObliviousSet wrapper for automatic message ID deduplication with TTL, and functions for checking/awaiting leadership. The ObliviousSet pattern solves a recurring problem in distributed systems and could be extracted for other message-passing or caching use cases.

file: src/leader-election-util.js ↗ | tags: #oblivious-set #duplicate-detection #ttl-based-cleanup

Manages default options merging with environment-specific overrides and user preferences. Demonstrates a clean, isolated pattern for configuration handling that avoids mutation of inputs and provides sensible defaults - easily reusable in any configurable library or application.

file: src/options.js ↗ | tags: #configuration-management #default-options
Last analyzed: 2026-09-06 11:47:31.763023
Next check: 2026-09-13 11:47:31.757352
$ submit: