(ast: AST, encoding: Encoding)
| 4853 | export const toEncoded = (ast: AST): AST => toType(flip(ast)) |
| 4854 | |
| 4855 | function flipEncoding(ast: AST, encoding: Encoding): AST { |
| 4856 | let from = replaceEncoding(ast, undefined) |
| 4857 | const reversed = encoding.map((link) => { |
| 4858 | const out = new Link(flip(from), link.transformation.flip()) |
| 4859 | from = link.to |
| 4860 | return out |
| 4861 | }).reverse() as Arr.NonEmptyArray<Link> |
| 4862 | const to = flip(from) |
| 4863 | return replaceEncoding(to, to.encoding ? [...to.encoding, ...reversed] : reversed) |
| 4864 | } |
| 4865 | |
| 4866 | /** |
| 4867 | * Swaps the decode and encode directions of an AST's {@link Encoding} chain. |
no test coverage detected