Skip to content

Add possibility to create promises and to complete them when we want.

License

Notifications You must be signed in to change notification settings

JulienTD/async-completer

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

async-completer

Add possibility to create promises and to complete them when we want.

Installation

$ npm install async-completer

Getting started

The usual use-case of completer is to transform a synchronous function with a callback into an async one.

In our example, we will create a synchronous function, and we'll add to it a complete object to transform it into an async one.

const foo = ...
const completer = new Completer();

foo.bar((text: String) => {
    if (text === "example") {
        completer.complete("something");
    }
});

return completer.promise;

As you can see in this example, we transformed a function with a callback into an async one. It means that it will be easier to access the data we want in our program.

About

Add possibility to create promises and to complete them when we want.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published