Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TypeError when using -n CLI flag #17

Closed
azaxarov opened this issue Apr 12, 2024 · 2 comments · Fixed by #18
Closed

TypeError when using -n CLI flag #17

azaxarov opened this issue Apr 12, 2024 · 2 comments · Fixed by #18
Assignees
Labels

Comments

@azaxarov
Copy link

azaxarov commented Apr 12, 2024

When using -n CLI flag, the following error is thrown: TypeError: ndjson is not a function

This regression likely happened after upgrading ndjson package from version 1.x.x to version 2.x.x, where the API of the package changed. The error takes place in the following two places:

const dataset = new S2A(process.stdin.pipe(ndjson()))

if (result.getType() == 'array') {

In order to fix this issue, update inputNDJSON and outputNDJSON functions. Consider using the following implementations:

function inputNDJSON() {
  const dataset = new S2A(process.stdin.pipe(ndjson.parse()))
  return {dataset}
}
async function* outputNDJSON(result) {
  const value = await result.get()

  if (Array.isArray(value)) {
    for await (const row of value) {
      yield JSON.stringify(row)
      yield '\n'
    }
  } else {
    yield JSON.stringify(value)
    yield '\n'
  }
}
@azaxarov azaxarov changed the title TypeError when using -n CLI flag TypeError when using -n CLI flag Apr 12, 2024
@tabuchid
Copy link

+1 We are experiencing this issue.

@linear linear bot added the SDX label Apr 16, 2024
rexxars added a commit that referenced this issue May 13, 2024
rexxars added a commit that referenced this issue May 13, 2024
@linear linear bot assigned rexxars May 13, 2024
sgulseth pushed a commit that referenced this issue May 14, 2024
@sgulseth
Copy link
Member

Thanks for reporting! Just published [email protected] which should handle ndjson correctly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants