
Security News
The Hidden Blast Radius of the Axios Compromise
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.
A tiny library for node that helps you use fibers with node-style callbacks and works similarly to suspend
Spawn a fiber task. From within your task, call your async functions with yield and pass them a resume function instead of a callback:
fibby.run(function (fib) {
console.log("Hello");
fib.yield(setInterval(fib.resume(), 1000))
console.log("World");
});
Handle errors with try/catch, or as return results via
resume.nothrow
fibby.run(function (fib) {
// Throwing resume
try { fib.yield(fs.readFile("test.js", fib.resume())); }
catch (e) { /* handle the error */ }
// Non-throwing resume always results with an array
var err_res = fib.yield(fs.readFile("test.js", fib.resume.nothrow()));
if (err_res[0]) { /* handle error */ }
});
Dont like nested parens? Want to keep things brief? Use resume.t
instead of resume() and resume.nt instead of resume.nothrow()
Want to catch all uncaught exceptions? You can pass a callback argument to
fibby.run:
fibby.run(function (fib) {
var data = fib.yield(fs.readFile("test.js", fib.resume.t));
}, function(err) {
// thrown error propagates here automagically
// because it was not caught.
});
You can also use fibby instead to create a function which
can accept multiple arguments and a callback. The arguments will be
passed to your fiber right after the first resume argument
var getLine = fibby.fn(function (fib, file, number) {
var data = fib.yield(fs.readFile(file, fib.resume.t));
return data.toString().split('\n')[number];
});
getLine('test.js', 2, function(err, lineContent) {
// thrown error propagates here automagically
// because it was not caught.
// If the file actually exists, lineContent
// will contain the second line
});
note: make sure that you pass the callback last.
Notice how if you return a value at the end of your fiber, it will be passed as a result to the callback. If you return undefined, the callback will not be called.
Your async functions call the callback with more than 2 arguments? Not a problem - the yield call from within your task will return an array instead.
function returnsmore(callback) {
callback(null, 'arg1', 'arg2');
}
fibby.run(function (fib) {
var res = fib.yield(returnsmore(fib.resume.t));
var arg1 = res[0];
var arg2 = res[1];
var nothrowres = fib.yield(returnsmore(fib.resume.nt);
var err = res[0];
var arg1 = res[1];
var arg2 = res[2];
});
Look in test/index.js for more examples and tests.
jmar777 for his awesome suspend library which served as the base for fibby
MIT
FAQs
Use fibers with functions that take callbacks.
We found that fibby 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
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.