Skip to content

feat: migrate to typescript and expose a hook for parsing ndjson - #9

Merged
rolandjitsu merged 4 commits into
masterfrom
feat/typescript-ndjson
Aug 9, 2026
Merged

feat: migrate to typescript and expose a hook for parsing ndjson#9
rolandjitsu merged 4 commits into
masterfrom
feat/typescript-ndjson

Conversation

@rolandjitsu

Copy link
Copy Markdown
Owner

What kind of change does this PR introduce?

  • bugfix
  • feature
  • refactoring / style
  • build / chore
  • documentation

Did you add tests for your changes?

  • Yes, my code is well tested
  • Not relevant

If relevant, did you update the documentation?

  • Yes, I've updated the documentation
  • Not relevant

Summary

  1. Migrate source to TypeScript.
  2. Add useNdjsonStream() hook.

Does this PR introduce a breaking change?

No.

Other information

Rename src to .ts and type the hooks, so the public API types live in the
source and tsdown generates the .d.ts (dropping the hand-written typings that
could drift). Add tsconfig and a typecheck step; oxlint, Vitest, and the build
already handle TypeScript natively.

Assisted-by: Claude:claude-opus-4-8
Add BOM stripping, id-with-NUL rejection, non-numeric retry, and colon-less
field lines to raise branch coverage.

Assisted-by: Claude:claude-opus-4-8
useStream wraps each reader.read() chunk as-is without buffering or splitting,
so framing (e.g. NDJSON) is the caller's responsibility. Document the contract
in the README and in the source.

Assisted-by: Claude:claude-opus-4-8
Stream NDJSON with a streaming decoder and line buffer, calling onData with
each parsed line. Standalone rather than wrapping useStream, so multi-byte
characters split across chunk boundaries are not corrupted.

Assisted-by: Claude:claude-opus-4-8
@rolandjitsu
rolandjitsu enabled auto-merge (rebase) August 9, 2026 03:38
@rolandjitsu
rolandjitsu disabled auto-merge August 9, 2026 03:38
@rolandjitsu
rolandjitsu merged commit 820a825 into master Aug 9, 2026
3 checks passed
@github-actions

github-actions Bot commented Aug 9, 2026

Copy link
Copy Markdown

🎉 This PR is included in version 1.3.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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 this pull request may close these issues.

1 participant