
Security News
Vite Releases Technical Preview of Rolldown-Vite, a Rust-Based Bundler
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
callbag-mock
Advanced tools
Callbag mock with manual emitting and signal tapping.
Useful for unit testing other callbag packages, or for triggering signals in callbag chains from non-callbag code.
npm install callbag-mock
(isSource?: boolean, reporter?: function) => mock
The isSource
boolean decides whether the mock will handshake back when initialised (meaning it is a source).
A reporter
, if provided, will be called each time the mock receives a signal:
(t: 0 | 1 | 2, d: any, in: 'body' | 'talkback') => void
The third in
parameter tells you whether the signal was received in the function body or the talkback.
The mock instance has an .emit(t,d)
method for manually triggering signals:
(t: 0 | 1 | 2, d: any)
There is a .getReceivedData()
method to get all received data so far.
Use .getMessages()
if you want all messages as [t, d]
tuples.
Get references to sent talkbacks through .getTalkback()
and received talkbacks through .getPartnerTalkback()
.
You can also .checkConnection()
to see whether or not the callbag has a live connection.
const mock = require('callbag-mock');
const reporter = (name, dir, t, d) => {
if (t !== 0) console.log(name, dir, t, d);
}
const source = mock('source', reporter, true);
const sink = mock('sink', reporter);
source.checkConnection(); // false
sink.checkConnection(); // false
source(0, sink);
source.getTalkback() === sink.getPartnerTalkback() // true
sink === source.getPartnerTalkback() // true
source.emit(1, 'foo'); // 'sink', 'body', 1, 'foo'
sink.emit(1, 'bar'); // 'source', 'talkback', 1, 'bar'
sink.getReceivedData(); // ['foo']
source.checkConnection(); // true
sink.checkConnection(); // true
FAQs
Callbag mock with manual emitting and signal tapping
The npm package callbag-mock receives a total of 1 weekly downloads. As such, callbag-mock popularity was classified as not popular.
We found that callbag-mock demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Vite releases Rolldown-Vite, a Rust-based bundler preview offering faster builds and lower memory usage as a drop-in replacement for Vite.
Research
Security News
A malicious npm typosquat uses remote commands to silently delete entire project directories after a single mistyped install.
Research
Security News
Malicious PyPI package semantic-types steals Solana private keys via transitive dependency installs using monkey patching and blockchain exfiltration.