Meteor/V3/Fibers To Async Promises

/icons/calendar.svg

Last update

Sep 7, 2024

This codemod assists in removing the use of Fibers from your Meteor codebase, refactoring your code to utilize the modern async/await pattern introduced in Meteor v3.

You can find the implementation of this codemod in the Studio here

Fibers Removal

With the release of Meteor v3, Fibers are no longer necessary. The async/await syntax provides a cleaner and more modern approach to handling asynchronous operations in your code. This codemod will automatically refactor your code to replace Fibers with async/await.

Example Transformation

Future to Promise with async/await

Before:

const Future = Npm.require('fibers/future');
function someFunction() {
const future = new Future();
someAsyncFunction((error, result) => {
if (error) {
future.throw(error);
} else {
future.return(result);
}
});
return future.wait();
}

After:

async function someFunction() {
return new Promise((resolve, reject) => {
someAsyncFunction((error, result) => {
if (error) {
reject(error);
} else {
resolve(result);
}
});
});
}

Build custom codemods

Use AI-powered codemod studio and automate undifferentiated tasks for yourself, colleagues or the community

background illustrationGet Started Now