diff --git a/nodes/core/core/80-function.js b/nodes/core/core/80-function.js index 14f125e23..62e905d04 100644 --- a/nodes/core/core/80-function.js +++ b/nodes/core/core/80-function.js @@ -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);