feat(lib/utils/proxy)!: return non-proxified value if passed to unproxify

This commit is contained in:
PalmDevs 2025-08-04 09:36:11 +07:00
parent 15ed4c551b
commit 0d1fcb5c2d
No known key found for this signature in database
GPG key ID: 6FAE8F8677ACA8BA

View file

@ -152,13 +152,12 @@ export function proxify<T>(signal: () => T, options?: ProxifyOptions): T {
/**
* Get the value of a proxified value at the current moment.
* Returns the same value if not a proxified value.
*
* @see {@link proxify} for more documentation.
*
* @param proxified The proxified value.
* @returns The unproxified value.
*
* @throws {TypeError} If the value is not a proxified value.
* @returns The unproxified value, or the value if it's not a proxified value.
*
* @example Without cache
* ```ts
@ -180,8 +179,7 @@ export function proxify<T>(signal: () => T, options?: ProxifyOptions): T {
*/
export function unproxify<T extends object>(proxified: T): T {
const hint = getProxyTarget(proxified)
if (!hint)
throw new TypeError(`${typeof proxified} is not a proxified value`)
if (!hint) return proxified
return unproxifyFromHint(hint)
}