Menu

1 / 2

util.promisify in Roo-Code codebase.

DEV Community·Ramu Narasinga·6 months ago
#TQpmdXZc
Reading 0:00
15s threshold

In this article, we review promisify method. You will learn:

What is util.promisify?

What is Roo-Code?

Usage example.

What is util.promisify?

Util is a NodeJS API . It has a lot of method defined. Check the util page. We are interested in promisify.

Promisify

Promisify takes a function following the common error-first callback style, i.e. taking an (err, value) => ... callback as the last argument, and returns a version that returns promises.

Below is an example picked from the docs:

import { promisify } from ' node:util ' ; import { stat } from ' node:fs ' ;

const promisifiedStat = promisify ( stat ); promisifiedStat ( ' . ' ). then (( stats ) => { // Do something with `stats` }). catch (( error ) => { // Handle the error.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.