88// lost with it. Every other value passes through unchanged.
99
1010const { unwrap, wrap } = binding ;
11+ const { ObjectDefineProperty, TypeError } = primordials ;
1112const {
1213 FinalizationRegistry : NativeFinalizationRegistry ,
1314 WeakMap : NativeWeakMap ,
@@ -38,7 +39,7 @@ class WeakMap extends NativeWeakMap {
3839
3940// V8 ships the upsert proposal; inherited, these would key on the wrapper.
4041if ( typeof NativeWeakMap . prototype . getOrInsert === "function" ) {
41- Object . defineProperty ( WeakMap . prototype , "getOrInsert" , {
42+ ObjectDefineProperty ( WeakMap . prototype , "getOrInsert" , {
4243 value : function getOrInsert ( key , value ) {
4344 return NativeWeakMap . prototype . getOrInsert . call ( this , unwrap ( key , true ) , value ) ;
4445 } ,
@@ -47,7 +48,7 @@ if (typeof NativeWeakMap.prototype.getOrInsert === "function") {
4748 } ) ;
4849}
4950if ( typeof NativeWeakMap . prototype . getOrInsertComputed === "function" ) {
50- Object . defineProperty ( WeakMap . prototype , "getOrInsertComputed" , {
51+ ObjectDefineProperty ( WeakMap . prototype , "getOrInsertComputed" , {
5152 value : function getOrInsertComputed ( key , callbackfn ) {
5253 if ( typeof callbackfn !== "function" ) {
5354 throw new TypeError ( "WeakMap.prototype.getOrInsertComputed: callback is not a function" ) ;
@@ -102,7 +103,7 @@ class WeakRef extends NativeWeakRef {
102103
103104// weak-ref.js gave the native prototype a `get` alias of `deref`; inherited
104105// as is, it would hand out the lifetime key.
105- Object . defineProperty ( WeakRef . prototype , "get" , {
106+ ObjectDefineProperty ( WeakRef . prototype , "get" , {
106107 value : WeakRef . prototype . deref ,
107108 writable : true ,
108109 configurable : true ,
@@ -136,7 +137,7 @@ for (const [name, value] of [
136137 [ "WeakRef" , WeakRef ] ,
137138 [ "FinalizationRegistry" , FinalizationRegistry ] ,
138139] ) {
139- Object . defineProperty ( globalThis , name , {
140+ ObjectDefineProperty ( globalThis , name , {
140141 value,
141142 writable : true ,
142143 configurable : true ,
0 commit comments