Use r2pipe-promise for asynchronous radare2 scripting
masterThe r2pipe-promise module is a frontend for r2pipe that provides a promisified API. It allows you to interact with radare2 using modern asynchronous patterns instead of callbacks, making scripts cleaner and more readable. It supports standard JavaScript .then()/.catch() chains, the co module, bluebird, and native async/await (Node.js 7.6+).
const r2promise = require('r2pipe-promise');
const radare2FTW = async () => {
try {
const r2 = await r2promise.open('/bin/ls');
const msg = await r2.cmd('?E hello world');
console.log(msg);
return r2.quit();
} catch (err) {
console.error(err);
}
}
radare2FTW();