MCPcopy
hub / github.com/brimdata/zui / createInterface

Function createInterface

packages/zed-wasm/src/interface.js:3–24  ·  view source on GitHub ↗
(go, deps)

Source from the content-addressed store, hash-verified

1import { decode, ndjson } from '@brimdata/zed-js';
2
3export 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}

Callers 2

initZedWasmFunction · 0.90
initZedWasmFunction · 0.90

Calls 3

decodeFunction · 0.90
parseMethod · 0.80
toJSMethod · 0.65

Tested by

no test coverage detected