writes the defaults of its missing keys
(js: NodeCompiler, options?: CopyOptions)
| 1286 | |
| 1287 | /** writes the defaults of its missing keys */ |
| 1288 | private jsDefaults(js: NodeCompiler, options?: CopyOptions): NodeCompiler { |
| 1289 | // a default can fail, but where none is written, the check before stands |
| 1290 | if (!this.defaultable.length && !this.sequence?.defaultables) return js |
| 1291 | let first = options?.first === true |
| 1292 | for (const node of this.defaultable) { |
| 1293 | js.if(`!(${node.jsHoldsValue(js, "data")})`, () => |
| 1294 | compileDefault( |
| 1295 | this.jsCopy(js, { first }), |
| 1296 | node, |
| 1297 | "out", |
| 1298 | !node.defaultsUndefined |
| 1299 | ) |
| 1300 | ) |
| 1301 | first = false |
| 1302 | } |
| 1303 | this.jsSequenceDefaults(js) |
| 1304 | return js.retIfFailed() |
| 1305 | } |
| 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 { |
no test coverage detected