Created
November 29, 2025 05:52
-
-
Save aquapi/4af7e99cc23ffe6626587c1eb6093e91 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| declare const _: unique symbol; | |
| export interface Redacted<out T> extends Symbol { | |
| [_]: T | |
| } | |
| const redactMap = new WeakMap(); | |
| export const init = <const T>(val: T): Redacted<T> => { | |
| const sym = Symbol('<redacted>'); | |
| redactMap.set(sym, val); | |
| return sym as any as Redacted<T>; | |
| } | |
| export const value = <const T>(redacted: Redacted<T>): T => redactMap.get(redacted); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment