Skip to content

Instantly share code, notes, and snippets.

import { z } from "zod";
type StateType = "STATE_A" | "STATE_B" | "STATE_C";
const StateTypeSchema = z.enum([
"STATE_A",
"STATE_B",
"STATE_C",
]);
const collection = {
items: [],
*[Symbol.iterator]() {
for (const item of this.items) {
yield item;
}
},
};
collection.items.push("a", "b", "c");
@jakubprill
jakubprill / proxy-without-traps.ts
Created March 7, 2025 11:43
Proxy without traps
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";