Skip to content

Instantly share code, notes, and snippets.

@devsnek
Created June 20, 2018 06:00
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 devsnek/3679af4029594f31a62b70e35ed035d9 to your computer and use it in GitHub Desktop.
Save devsnek/3679af4029594f31a62b70e35ed035d9 to your computer and use it in GitHub Desktop.
'use strict';
// v8 runs this file for each context created
(function(global, binding, v8) {
// https://github.com/nodejs/node/issues/14909
delete global.Intl.v8BreakIterator;
// https://github.com/nodejs/node/issues/21219
// Adds Atomics.notify and warns on first usage of Atomics.wake
const AtomicsWake = global.Atomics.wake;
const ReflectApply = global.Reflect.apply;
// wrap for function.name
function notify(...args) {
return ReflectApply(AtomicsWake, this, args);
}
const warning = 'Atomics.wake will be removed in a future version, ' +
'use Atomics.notify instead.';
let wakeWarned = false;
function wake(...args) {
if (!wakeWarned) {
wakeWarned = true;
if (global.process !== undefined) {
global.process.emitWarning(warning, 'Atomics');
} else {
global.console.error(`Atomics: ${warning}`);
}
}
return ReflectApply(AtomicsWake, this, args);
}
global.Object.defineProperties(global.Atomics, {
notify: {
value: notify,
enumerable: false,
configurable: true,
writable: true,
},
wake: {
value: wake,
enumerable: false,
configurable: true,
writable: true,
},
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment