Skip to content

Instantly share code, notes, and snippets.

@Jabher
Created November 10, 2017 13:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jabher/3994844ad6f2bc13689b7057b61c710e to your computer and use it in GitHub Desktop.
Save Jabher/3994844ad6f2bc13689b7057b61c710e to your computer and use it in GitHub Desktop.
require('./magic');
function a() {
console.log(global.env.test)
}
Promise.resolve()
.then(async function () {
global.env.test = 'baz';
console.log('in async 1', global.env.test);
await new Promise(res => process.nextTick(res));
// console.log('in async 2', global.env.test);
await new Promise(res => process.nextTick(res));
// console.log('in async 3', global.env.test);
await new Promise(res => process.nextTick(res));
a();
});
Promise.resolve()
.then(() => {
process.nextTick(() => {
global.env.test = 'foo';
console.log('in nextTick 1', global.env.test);
process.nextTick(() => {
global.env.test = 'bar';
// Reflect.getPrototypeOf(global.env.test).test2 = 'baz';
console.log('in nextTick 1-1', global.env.test);
});
process.nextTick(() => {
console.log('in nextTick 1-2', global.env.test);
});
});
process.nextTick(() => {
console.log('in nextTick 2', global.env.test);
process.nextTick(() => {
console.log('in nextTick 2-2', global.env.test);
})
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment