(structure: StructureNode)
| 81 | } |
| 82 | |
| 83 | const writesOf = (structure: StructureNode): Writes => { |
| 84 | const writes: Writes = { |
| 85 | values: keys(), |
| 86 | added: keys(), |
| 87 | addsOnlyDefaults: true |
| 88 | } |
| 89 | const sequence = structure.sequence |
| 90 | if (sequence?.children.some(element => !returnsInput(element))) |
| 91 | writes.values.indices = true |
| 92 | if (structure.undeclared === "delete") return writes |
| 93 | for (const prop of structure.props) { |
| 94 | if (!returnsInput(prop.value)) writes.values.named.add(prop.key) |
| 95 | if (prop.hasDef()) { |
| 96 | writes.added.named.add(prop.key) |
| 97 | if (prop.value.tfs || typeof prop.default === "function") |
| 98 | writes.addsOnlyDefaults = false |
| 99 | } |
| 100 | } |
| 101 | if (structure.index?.some(index => !returnsInput(index.value))) |
| 102 | writes.values.every = true |
| 103 | if (sequence?.defaultables) { |
| 104 | writes.added.indices = true |
| 105 | if ( |
| 106 | sequence.defaultables.some( |
| 107 | ([node, value]) => node.tfs || typeof value === "function" |
| 108 | ) |
| 109 | ) |
| 110 | writes.addsOnlyDefaults = false |
| 111 | } |
| 112 | return writes |
| 113 | } |
| 114 | |
| 115 | const readsOf = (node: BaseRoot): Reads | undefined => { |
| 116 | // a function can read any key of what it receives |
no test coverage detected