Being asynchronous, there is no guarantee of knowing when the promise will be resolved. It may have to wait for a while (depending on what you are doing).
The typical way of continuing execution after a promise is by chaining execution or by using callback functions.
As a Callback
Your sample code (to me) suggests the use of a callback.
exports.myFunction = function(callback){
myPromise.doThis().then(ret => {
callback(ret);
});
}
Then using would look similar to:
var myFunction = require('pathToFile').myFunction;
myFunction(function(ret){
//Do what's required with ret here
});
Edit:
As @torazaburo mentioned, the function can be condensed into:
exports.myFunction = function(callback){
myPromise.doThis().then(callback);
}
As a Promise
exports.myFunction = function(){
//Returnes a promise
return myPromise.doThis();
}
Then using would look similar to:
var myFunction = require('pathToFile').myFunction;
myFunction().then(function(ret){
//Do what's required with ret here
});