(inst: T, def: D)
| 20 | params?: { Parent?: typeof Class } |
| 21 | ): $constructor<T, D> { |
| 22 | function init(inst: T, def: D) { |
| 23 | if (!inst._zod) { |
| 24 | Object.defineProperty(inst, class="st">"_zod", { |
| 25 | value: { |
| 26 | def, |
| 27 | constr: _, |
| 28 | traits: new Set(), |
| 29 | }, |
| 30 | enumerable: false, |
| 31 | }); |
| 32 | } |
| 33 | |
| 34 | if (inst._zod.traits.has(name)) { |
| 35 | return; |
| 36 | } |
| 37 | |
| 38 | inst._zod.traits.add(name); |
| 39 | |
| 40 | initializer(inst, def); |
| 41 | |
| 42 | class="cm">// support prototype modifications |
| 43 | const proto = _.prototype; |
| 44 | const keys = Object.keys(proto); |
| 45 | for (let i = 0; i < keys.length; i++) { |
| 46 | const k = keys[i]!; |
| 47 | if (!(k in inst)) { |
| 48 | (inst as any)[k] = proto[k].bind(inst); |
| 49 | } |
| 50 | } |
| 51 | } |
| 52 | |
| 53 | class="cm">// doesn't work if Parent has a constructor with arguments |
| 54 | const Parent = params?.Parent ?? Object; |
no test coverage detected