···
const _getOwnPropertyDescriptor = Object.getOwnPropertyDescriptor;
const _defineProperty = Object.defineProperty;
const _create = Object.create;
28
+
const _slice = Array.prototype.slice;
type Object = Record<string | symbol, unknown>;
···
if (new.target === undefined) {
return target.apply(this, arguments);
78
-
return new (target.bind.apply(target, arguments));
79
+
const args = _slice.call(arguments);
81
+
return new (target.bind.apply(target, args));
···
standin.prototype = _create(null);
134
-
return freeze(standin);
137
+
return toplevel ? standin : freeze(standin);
let safeGlobal: Record<string | symbol, unknown> | void;
···
// Lastly, we also disallow certain property accesses on the safe global
// Wrap any given target with a Proxy preventing access to unscopables
211
-
return freeze(safeGlobal!);
214
+
if (typeof Proxy === 'function') {
215
+
// Wrap the target in a Proxy that disallows access to some keys
216
+
return (safeGlobal = new Proxy(safeGlobal!, {
217
+
// Return a value, if it's allowed to be returned and mask this value
218
+
get(target, _key) {
219
+
const key = safeKey(target, _key);
220
+
return !ignore[_key] && key !== undefined ? target[key] : undefined;
222
+
has(_target, _key) {
226
+
deleteProperty: noop,
227
+
defineProperty: noop,
228
+
getOwnPropertyDescriptor: noop,
231
+
// NOTE: Some property accesses may leak through here without the Proxy
232
+
return freeze(safeGlobal!);