Octane/Promise

Replace "new Function()"

Closed this issue · 2 comments

I think you can replace this line to

var global = this;

because context of AFE is global.

this ≡ global is just the top level scope inside a Node module, local to that module.
Function('return this')() returns the general global scope, where the method setImmediate is defined.

// inside a module:
typeof global.setImmediate // → 'undefined'
// but
typeof Function('return this')().setImmediate // → 'function'

I can rewrite the code like this:

var setImmediate = this.setImmediate || require('timers').setImmediate;

Thanks!