(go, deps)
| 1 | import { decode, ndjson } from '@brimdata/zed-js'; |
| 2 | |
| 3 | export function createInterface(go, deps) { |
| 4 | return { |
| 5 | // program?: string, |
| 6 | // input?: string | File | Blob | ReadableStream | any[], |
| 7 | // inputFormat?: LoadFormat, |
| 8 | // outputFormat?: 'js' | 'zed', |
| 9 | zq: async (opts) => { |
| 10 | const result = await go.zq({ |
| 11 | input: deps.getInput(opts.input), |
| 12 | inputFormat: opts.inputFormat, |
| 13 | program: opts.program, |
| 14 | outputFormat: 'zjson', |
| 15 | }); |
| 16 | |
| 17 | const zed = decode(ndjson.parseLines(result)); |
| 18 | if (opts.outputFormat === 'zed') return zed; |
| 19 | return zed.map((val) => val.toJS()); |
| 20 | }, |
| 21 | |
| 22 | parse: (string) => go.parse(string), |
| 23 | }; |
| 24 | } |
no test coverage detected