forked from denoland/deno
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
1918739
commit 7d2fa40
Showing
7 changed files
with
160 additions
and
28 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
const primordials = globalThis.__bootstrap.primordials; | ||
const { | ||
SymbolToStringTag, | ||
ArrayPrototypeIncludes, | ||
Proxy, | ||
ReflectGet, | ||
ReflectGetOwnPropertyDescriptor, | ||
ReflectGetPrototypeOf, | ||
} = primordials; | ||
|
||
/** Creates a proxy that represents a subset of the properties | ||
* of the original object optionally without evaluating the properties | ||
* in order to get the values. */ | ||
function createFilteredInspectProxy({ object, keys, evaluate }) { | ||
return new Proxy({}, { | ||
get(_target, key) { | ||
if (key === SymbolToStringTag) { | ||
return object.constructor?.name; | ||
} else if (ArrayPrototypeIncludes(keys, key)) { | ||
return ReflectGet(object, key); | ||
} else { | ||
return undefined; | ||
} | ||
}, | ||
getOwnPropertyDescriptor(_target, key) { | ||
if (!ArrayPrototypeIncludes(keys, key)) { | ||
return undefined; | ||
} else if (evaluate) { | ||
return getEvaluatedDescriptor(object, key); | ||
} else { | ||
return getDescendantPropertyDescriptor(object, key) ?? | ||
getEvaluatedDescriptor(object, key); | ||
} | ||
}, | ||
has(_target, key) { | ||
return ArrayPrototypeIncludes(keys, key); | ||
}, | ||
ownKeys() { | ||
return keys; | ||
}, | ||
}); | ||
|
||
function getDescendantPropertyDescriptor(object, key) { | ||
let propertyDescriptor = ReflectGetOwnPropertyDescriptor(object, key); | ||
if (!propertyDescriptor) { | ||
const prototype = ReflectGetPrototypeOf(object); | ||
if (prototype) { | ||
propertyDescriptor = getDescendantPropertyDescriptor(prototype, key); | ||
} | ||
} | ||
return propertyDescriptor; | ||
} | ||
|
||
function getEvaluatedDescriptor(object, key) { | ||
return { | ||
configurable: true, | ||
enumerable: true, | ||
value: object[key], | ||
}; | ||
} | ||
} | ||
|
||
export { createFilteredInspectProxy }; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,2 @@ | ||
const DOMException = window.DOMException; | ||
export { DOMException }; | ||
export default DOMException; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters