I am new to Node.js programming. I came to know about promise object. But one of my colleagues faced an interview question.
-
Without using any third party promise libraries which are available in npm(example Promise, bluebird), I need to implement a promise function which returns then() and catch() function like below.
asyncPromise().then().catch()
For example:
function asyncFunction(cb){
//-----------
cb(err,data);
}
function asyncPromise(){
}
We need to Wrap a function around that function that it will make it behave as a promise. How can we achieve this with both of above functions, without using the third party libraries?
via Mohan Raja
No comments:
Post a Comment