| 232 | } |
| 233 | |
| 234 | const pipeEncoder = ( |
| 235 | encoder: BaseRoot, |
| 236 | next: BaseRoot, |
| 237 | encoderTfs: boolean, |
| 238 | nextTfs: boolean, |
| 239 | $: BaseScope |
| 240 | ): BaseRoot => { |
| 241 | if (encoder.isUnknown()) return next |
| 242 | if (next.isUnknown() || encoder === next) return encoder |
| 243 | // a node that only transforms through an alias has alters === false, |
| 244 | // so rawPipeOnce would intersect it (and any open synthetic alias) |
| 245 | if ((encoderTfs && !encoder.alters) || (nextTfs && !next.alters)) { |
| 246 | return encoder.is("morph") ? |
| 247 | $.node("morph", { |
| 248 | ...encoder.inner, |
| 249 | morphs: [...encoder.morphs, next] |
| 250 | }) |
| 251 | : $.node("morph", { morphs: [encoder, next] }) |
| 252 | } |
| 253 | return encoder.rawPipeOnce(next) |
| 254 | } |
| 255 | |
| 256 | // a defaulted key or element is always present in what was decoded |
| 257 | const requireDefaulted = (inner: Structure.Inner): Structure.Inner => { |