-
-
Notifications
You must be signed in to change notification settings - Fork 10
fix: perform format operation in chunks #115
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
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
7f1dfdd
feat: perform format operation in chunks
cellison-figma 1e711f9
move mapSettledWithConcurrency to utils.ts
cellison-figma 1c031c8
swap concurrency calc method
cellison-figma ebcbb0e
add back missing config check
cellison-figma d9fbd2e
Update src/index.ts
cellison-figma 83c4a2c
Remove useless calculations
cellison-figma 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import { expect, test } from "@jest/globals"; | ||
| import { mapSettledWithConcurrency } from "../../dist/utils.js"; | ||
|
|
||
| test("bounds concurrency and preserves settled-result order", async () => { | ||
| let active = 0; | ||
| let maxActive = 0; | ||
|
|
||
| const results = await mapSettledWithConcurrency([0, 1, 2, 3, 4, 5], 3, async (value) => { | ||
| active += 1; | ||
| maxActive = Math.max(maxActive, active); | ||
| await new Promise((resolve) => setImmediate(resolve)); | ||
| active -= 1; | ||
| if (value === 2) throw new Error("expected failure"); | ||
| return value * 2; | ||
| }); | ||
|
|
||
| expect(maxActive).toBe(3); | ||
| expect(results.map((result) => result.status)).toEqual(["fulfilled", "fulfilled", "rejected", "fulfilled", "fulfilled", "fulfilled"]); | ||
| expect(results[0]).toEqual({ status: "fulfilled", value: 0 }); | ||
| expect(results[2]).toMatchObject({ status: "rejected", reason: new Error("expected failure") }); | ||
| expect(results[5]).toEqual({ status: "fulfilled", value: 10 }); | ||
| }); |
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@43081j Did you review the implementation of this function? It doesn't feel correct to me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
its a shame we need it but thats more a fault of Node not having any built-in capability for it.
the implementation seems fine to me 👍
basically kicks off
runnersCountfunctions which iterate until the queue is drained.