Repository navigation
Concatenate untyped Buffer lists as Node does #1272
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
Merged
+125
−6
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
5d7234a
Concatenate untyped Buffer lists as Node does
ctate 3da9d33
Merge main
ctate 57b6a44
Compare the zlib-shims npm case with Node
ctate 4e7f104
Merge main
ctate e9a90e0
Merge main
ctate ead270c
Merge main
ctate 05b63df
Check Buffer.concat's length before the elements of an untyped list
ctate File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
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
6 changes: 6 additions & 0 deletions
6
.../compiler/test/ts7/baselines/order-parity/tests/corpus/5973-buffer-concat-untyped.js.json
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,6 @@ | ||
| { | ||
| "order": [ | ||
| "<repo>/tests/corpus/5973-buffer-concat-untyped.js" | ||
| ], | ||
| "diags": [] | ||
| } |
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
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| // Buffer.concat over an untyped list (JavaScript's `const chunks = []`): | ||
| // Uint8Array elements concatenate, the length form pads or truncates, and | ||
| // a non-array list or a non-Uint8Array element throws Node's TypeError. The | ||
| // length form checks the length before the elements, and an empty list | ||
| // returns before either. | ||
| const chunks = []; | ||
| chunks.push(Buffer.from("ab")); | ||
| chunks.push(new Uint8Array([99, 100])); | ||
| console.log(Buffer.concat(chunks).toString()); | ||
| console.log(Buffer.concat(chunks, 6)); | ||
| console.log(Buffer.concat(chunks, 3).toString()); | ||
| console.log(Buffer.concat([]).length); | ||
|
|
||
| const lists = [[1], ["a"], [Buffer.from("x"), null], "x", 5, [new Uint16Array(1)]]; | ||
| for (const list of lists) { | ||
| try { | ||
| Buffer.concat(list); | ||
| console.log("no error"); | ||
| } catch (e) { | ||
| console.log(e.name, e.code, e.message); | ||
| } | ||
| } | ||
|
|
||
| const withLength = [ | ||
| [[1], -1], | ||
| [[Buffer.from("a"), "b"], NaN], | ||
| [[1], 2], | ||
| [[], -1], | ||
| [[Buffer.from("a")], 1.5], | ||
| [[Buffer.from("a"), Buffer.from("b")], 2], | ||
| ]; | ||
| for (const [list, length] of withLength) { | ||
| try { | ||
| console.log("length", Buffer.concat(list, length).length); | ||
| } catch (e) { | ||
| console.log(e.name, e.code, e.message); | ||
| } | ||
| } |
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.