writes `out`, which a transform writes into: data at the first site and where it writes in place
(js: NodeCompiler, options?: CopyOptions)
| 1306 | |
| 1307 | /** writes `out`, which a transform writes into: data at the first site and where it writes in place */ |
| 1308 | private jsCopy(js: NodeCompiler, options?: CopyOptions): NodeCompiler { |
| 1309 | if (this.writesInto(js)) return js |
| 1310 | const copy = () => |
| 1311 | this.sequence ? |
| 1312 | this.jsCopyProps( |
| 1313 | js.set("out", `${js.ref(copyOf)}(data)`), |
| 1314 | "data", |
| 1315 | "out" |
| 1316 | ) |
| 1317 | : js.set( |
| 1318 | "out", |
| 1319 | `${this.jsShapeCheck(js)}Object.getPrototypeOf(data) === Object.prototype ? { ...data } : ${js.ref(copyOf)}(data)` |
| 1320 | ) |
| 1321 | return options?.first ? copy() : js.if("out === data", copy) |
| 1322 | } |
| 1323 | |
| 1324 | /** writes the check of data's shape, reading a required key first; copyOf handles data without it */ |
| 1325 | jsShapeCheck(js: NodeCompiler): string { |
no test coverage detected