Allow setTimeout in Function node to be promisified in node 8

This commit is contained in:
Nick O'Leary 2017-09-12 15:13:13 +01:00
parent 29cae9975e
commit 85392496e7
No known key found for this signature in database
GPG Key ID: 4F2157149161A6C9
1 changed files with 7 additions and 0 deletions

View File

@ -187,6 +187,13 @@ module.exports = function(RED) {
}
}
};
if (util.hasOwnProperty('promisify')) {
sandbox.setTimeout[util.promisify.custom] = function(after, value) {
return new Promise(function(resolve, reject) {
sandbox.setTimeout(function(){ resolve(value) }, after);
});
}
}
var context = vm.createContext(sandbox);
try {
this.script = vm.createScript(functionText);