Uh oh!
There was an error while loading. Please reload this page.
streaming-standardization: add ReadableStream + processFile path convenience - #3
Merged
Merged
Conversation
…enience - Add ReadableStream to ScaniiContent union type (Blob | ArrayBuffer | ArrayBufferView | ReadableStream) - Add processFile(path, metadata?, callback?) — Node-only path convenience using Readable.toWeb(createReadStream(path)) - Add processAsyncFile(path, metadata?, callback?) — same for async scanning - ReadableStream inputs are buffered to Blob via new Response(stream).blob() before FormData append (Node's FormData does not accept ReadableStream as a multipart part value directly) - buildMultipart becomes async; processFile/processAsyncFile pass basename(path) as filename - Add unit test for ReadableStream input - Add integration tests: processFile, processAsyncFile, ReadableStream input - Bump version 1.0.1 → 1.1.0 (additive new public API, per API_VERSIONING_POLICY.md) Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Uh oh!
There was an error while loading. Please reload this page.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ReadableStreamto theScaniiContentunion type accepted byprocess/processAsync— aligns with Node 22+ Web Streams APIprocessFile(path, metadata?, callback?)— Node-only path convenience; opens file viaReadable.toWeb(fs.createReadStream(path)), sets multipart filename tobasename(path)processAsyncFile(path, metadata?, callback?)— same for async scanningprocess(blob, ...)API is unchangedImplementation note on
ReadableStream: Node'sFormDatadoes not acceptReadableStreamas a multipart part value. When aReadableStreamis passed, it is buffered to aBlobvianew Response(stream).blob()before being appended toFormData. This is the only practical approach without building raw multipart bytes manually. Documented in the JSDoc and CHANGELOG.Node-only caveat:
processFileandprocessAsyncFileusenode:fsandnode:stream— they are not available in browsers. README documents this. Browsers continue to useprocess(blob, ...)orprocess(file, ...).Test plan
npm test— 36 tests (17 unit + 19 integration) all passnpm run typecheck— cleannpm run lint— cleanprocessFilewith UUID malware fixture,processAsyncFilewith clean content,ReadableStreaminput toprocess🤖 Generated with Claude Code