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
import { z } from "zod"; | |
type StateType = "STATE_A" | "STATE_B" | "STATE_C"; | |
const StateTypeSchema = z.enum([ | |
"STATE_A", | |
"STATE_B", | |
"STATE_C", | |
]); |
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
const collection = { | |
items: [], | |
*[Symbol.iterator]() { | |
for (const item of this.items) { | |
yield item; | |
} | |
}, | |
}; | |
collection.items.push("a", "b", "c"); |
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
const target = { name: "target" }; | |
const proxy = new Proxy(target, {}); | |
proxy.name = "proxy"; | |
console.log(proxy.name); // proxy | |
console.log(target.name); // proxy | |
target.name = "target"; |