Registry / storage / happenstance

happenstance

JSON →
library12.0.5jsnpmunverified

happenstance is a Node.js library for queuing timer events into an evented message queue. Current stable version is 12.0.5. It provides a simple, event-driven API for scheduling and handling timed events, with a focus on reliability and performance. Key differentiators include lightweight implementation, no external dependencies, and support for both one-shot and recurring timers. It is maintained by the bigeasy organization on GitHub and follows a regular release cadence.

npm install happenstance
INSTALL
IMPORT
SIG · HAPPENSTANCE
H
happenstance
storagejavascriptv12.0.5
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import happenstance from 'happenstance'
const happenstance = require('happenstance')
ESM-only since v12; CJS require will throw.
Timer
import { Timer } from 'happenstance'
Named export for Timer class.
Queue
import { Queue } from 'happenstance'
const { Queue } = require('happenstance')
Named export; CJS not supported in v12+.

Creates a queue, schedules one-shot and recurring timers, and processes events.

import happenstance from 'happenstance'; const queue = happenstance(); // Schedule a one-shot timer after 1000ms queue.timer(1000, () => { console.log('Timer fired'); }); // Schedule a recurring timer every 2000ms const recurring = queue.timer(2000, () => { console.log('Recurring timer'); }); // Cancel a timer recurring.cancel(); // Process events (in a real app, use event loop) queue.run();
Debug
Known issues
breakingESM-only since version 12; no CommonJS support.
fix
Use ES module imports (import happenstance from 'happenstance') or downgrade to version 11.x.
affects: >=12.0.0
deprecatedThe .on('timer') event listener pattern is deprecated; use callback parameter instead.
fix
Pass callback as second argument to timer() instead of listening on 'timer' event.
affects: >=10.0.0
gotchaTimer resolution is based on Node.js event loop; may not be exact on heavy load.
fix
Do not rely on sub-millisecond precision; use process.hrtime for high-resolution timing.
affects: *
Errors
Common errors & fixes
TypeError: happenstance is not a function
Using CommonJS require with ESM-only package (v12+).
fix
Change to ES module import: import happenstance from 'happenstance' or use dynamic import.
Error: Cannot find module 'happenstance'
Package not installed or incorrect path.
fix
Ensure happenstance is in package.json dependencies and installed via npm install happenstance.
Upgrade
Version history
12.0.5latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
13 hits · last 30 days
node
12
Amazon
1
Resources
happenstance — npm install happenstance · libregistry