(asyncFunctions, sandbox, events, done, sandboxRoot)
| 315 | } |
| 316 | |
| 317 | function wrapAsyncFunctions(asyncFunctions, sandbox, events, done, sandboxRoot) { |
| 318 | if (!sandboxRoot) sandboxRoot = sandbox; |
| 319 | |
| 320 | if(!asyncFunctions) { |
| 321 | // stop if asyncFunctions does not exist |
| 322 | return; |
| 323 | } |
| 324 | |
| 325 | Object.keys(asyncFunctions).forEach(function(k) { |
| 326 | if (typeof asyncFunctions[k] === 'function') { |
| 327 | sandbox[k] = wrapAsyncFunction(asyncFunctions[k], sandbox, events, done, sandboxRoot); |
| 328 | |
| 329 | // we need to retain all the properties a function might have, think constructor with static functions |
| 330 | wrapAsyncFunctions(asyncFunctions[k], sandbox[k], events, done, sandboxRoot); |
| 331 | } else if (asyncFunctions[k] !== null && typeof asyncFunctions[k] === 'object' && !(asyncFunctions[k] instanceof Array)) { |
| 332 | sandbox[k] = sandbox[k] || {}; |
| 333 | wrapAsyncFunctions(asyncFunctions[k], sandbox[k], events, done, sandboxRoot); |
| 334 | } else { |
| 335 | sandbox[k] = asyncFunctions[k]; |
| 336 | } |
| 337 | }); |
| 338 | } |
| 339 | |
| 340 | module.exports = Script; |
no test coverage detected