Skip to content

Promisify - add as a promise util #1549

@rubnogueira

Description

@rubnogueira

I'm dealing with an old codebase, and I already replaced many methods from lodash, underscore and bluebird with this library and it works amazingly well! Extra points for having great type inference and typescript support 🙌

But I still have a request that would be great if this library could support. We deal with many old libraries that only use callback methods. Currently we are using Bluebird promisify or even node:util with promisify.

http://bluebirdjs.com/docs/api/promise.promisify.html

https://nodejs.org/api/util.html#utilpromisifyoriginal

Bluebird doesn't play very well with TypeScript, and it is very outdated. Node is only available on the server, not in the client browser, so for frontend usage, it is not that direct. It would be wonderful if this library had this method.

Point of attention: sometimes we need to bind the context of the function to the promisify. I wonder if this could be done automatically somehow? Example from bluebird docs:

var redisGet = Promise.promisify(redisClient.get, {context: redisClient});
redisGet('foo').then(function() {
    //...
});

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions