writes the copy of a plain object missing every default, its only changes, once
(js: NodeCompiler)
| 1271 | |
| 1272 | /** writes the copy of a plain object missing every default, its only changes, once */ |
| 1273 | private jsCopyOnce(js: NodeCompiler): NodeCompiler { |
| 1274 | if (this.hasMorph || this.undeclared === "delete" || js.inPlace) return js |
| 1275 | const keys = this.defaultable.map(prop => prop.key) |
| 1276 | return js.if( |
| 1277 | `${keys.map(k => `!(${js.serialize(k)} in data) && `).join("")}${this.jsShapeCheck(js)}Object.getPrototypeOf(data) === Object.prototype`, |
| 1278 | () => { |
| 1279 | js.const("out", "{ ...data }") |
| 1280 | for (const prop of this.defaultable) |
| 1281 | compileDefault(js, prop, "out", true) |
| 1282 | return this.jsDeclaredCopy(js, keys).return("out") |
| 1283 | } |
| 1284 | ) |
| 1285 | } |
| 1286 | |
| 1287 | /** writes the defaults of its missing keys */ |
| 1288 | private jsDefaults(js: NodeCompiler, options?: CopyOptions): NodeCompiler { |
no test coverage detected