diff --git a/package.json b/package.json index fc258cc..130bb03 100644 --- a/package.json +++ b/package.json @@ -16,7 +16,9 @@ "node": ">=18" }, "scripts": { - "test": "echo '[{\"foo\": 1}]' | ./bin/groq.js --pretty '*[]{ foo }'", + "test": "npm run test:json && npm run test:ndjson", + "test:json": "echo '[{\"foo\": 1}]' | ./bin/groq.js --pretty '*[]{ foo }'", + "test:ndjson": "echo '{\"foo\": [1,2,3,4]}\n{\"bar\": [2]}' | ./bin/groq.js -n --pretty '*[].foo'", "lint": "eslint . && prettier --check ./src ./bin" }, "files": [ diff --git a/src/cli.js b/src/cli.js index 7f03f76..cf1afd8 100644 --- a/src/cli.js +++ b/src/cli.js @@ -105,7 +105,7 @@ async function* outputPrettyJSON(result) { } async function* outputNDJSON(result) { - if (result.getType() == 'array') { + if (result.type == 'stream') { for await (const value of result) { yield JSON.stringify(await value.get()) yield '\n' @@ -129,7 +129,7 @@ async function inputJSON() { } function inputNDJSON() { - const dataset = new S2A(process.stdin.pipe(ndjson())) + const dataset = new S2A(process.stdin.pipe(ndjson.parse())) return {dataset} }