@signalbox/commons
v0.3.1
Published
signalbox commons: reusable polling and dedupe workflow building blocks
Readme
@signalbox/commons
Reusable workflow building blocks for signalbox: polling, de-duplication, and public-IP discovery.
Part of signalbox — see the full documentation.
Install
npm install @signalbox/commonsUsage
import { dedupeBy, poll, publicIPv4 } from "@signalbox/commons"
// A Flow that probes on startup and every interval, with optional retry triggers.
poll({
ctx,
every: 15 * 60 * 1000,
probe: () => publicIPv4(),
})
.filter(dedupeBy(({ value }) => value)) // drop repeats
.effect(({ value, phase }) => {
ctx.log(`ip ${value} (${phase})`)
})poll(options)— aFlow<{ value, phase }>that emits on startup, on an interval, and on anyretryOntrigger.dedupeBy(keyFn)— a stateful filter predicate that suppresses consecutive values with the same key.publicIPv4()— resolve the current public IPv4 over HTTP;isIPv4(value)validates a string.
License
MIT
