function getGlobal ( ) { if ( typeof self !== "undefined" ) { return self ; } if ( typeof window !== "undefined" ) { return window ; } if ( typeof global !== "undefined" ) { return global ; } throw new Error ( "unable to locate global object" ) ; } /**
 * There are chances to construct a `Function` from a string, etc.
 * ```
 * ((a,b)=>a[b])(()=>1, 'constructor')('console.log(`yo`)')()
 * ```
 */ const reservedObjects = new WeakSet ( [ Function , Object , Function . prototype , Object . prototype , getGlobal ( ) , ] ) ; export function sanitize ( cooked ) { if ( reservedObjects . has ( cooked as object ) ) { throw new TypeError ( "Cannot access reserved objects such as `Function`." ) ; } } const allowedConstructors = new WeakSet ( [ Array , Date , Map , Set , URLSearchParams , WeakMap , WeakSet , ] ) ; export function isAllowedConstructor ( constructor ) { return allowedConstructors . has ( constructor as ArrayConstructor ) ; }