1
0
mirror of https://github.com/node-red/node-red.git synced 2023-10-10 13:36:53 +02:00

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

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); var context = vm.createContext(sandbox);
try { try {
this.script = vm.createScript(functionText); this.script = vm.createScript(functionText);