| 1 | /** @internal */ |
| 2 | export function assignProperty(self: object, key: PropertyKey, value: unknown): void { |
| 3 | if (key === "__proto__") { |
| 4 | Object.defineProperty(self, key, { |
| 5 | value, |
| 6 | writable: true, |
| 7 | enumerable: true, |
| 8 | configurable: true |
| 9 | }) |
| 10 | } else { |
| 11 | ;(self as any)[key] = value |
| 12 | } |
| 13 | } |
| 14 | |
| 15 | /** @internal */ |
| 16 | export function assignProperties(self: object, source: object): void { |
| 17 | for (const key of Reflect.ownKeys(source)) { |
| 18 | if (Object.prototype.propertyIsEnumerable.call(source, key)) { |
| 19 | assignProperty(self, key, (source as any)[key]) |
| 20 | } |
| 21 | } |
| 22 | } |