( name: string, input: string[] | string, output: string[] | string, lines: ArrayJoinInput<string> )
| 76 | } |
| 77 | |
| 78 | export const buildFunctionBlock = ( |
| 79 | name: string, |
| 80 | input: string[] | string, |
| 81 | output: string[] | string, |
| 82 | lines: ArrayJoinInput<string> |
| 83 | ) => { |
| 84 | const withInputs = arrayifyFields( |
| 85 | `function ${name}(`, |
| 86 | input, |
| 87 | `) internal pure` |
| 88 | ); |
| 89 | let outputs: ArrayJoinInput<string>[] = [] |
| 90 | if (output.length) { |
| 91 | suffixLastString(withInputs, ' returns ('); |
| 92 | outputs = arrayifyFields( |
| 93 | withInputs[withInputs.length - 1] as string, |
| 94 | output, |
| 95 | `) {` |
| 96 | ); |
| 97 | } else { |
| 98 | suffixLastString(withInputs, ' {') |
| 99 | outputs = arrayifyFields( |
| 100 | withInputs[withInputs.length - 1] as string, |
| 101 | '', |
| 102 | `` |
| 103 | ); |
| 104 | } |
| 105 | const allButLastInput = withInputs.slice(0, withInputs.length - 1); |
| 106 | return [...allButLastInput, ...outputs, lines, "}"]; |
| 107 | }; |
| 108 | |
| 109 | export function buildImportStatement(file: string, imports: string[]) { |
| 110 | if (imports.length == 0) return [`import "./${file}";`]; |
no test coverage detected