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

Add a settleObject util #32

Merged
merged 2 commits into from
Sep 13, 2023
Merged

Add a settleObject util #32

merged 2 commits into from
Sep 13, 2023

Conversation

GRA0007
Copy link
Collaborator

@GRA0007 GRA0007 commented Sep 12, 2023

Add a settleObject util that behaves like Promise.allSettled for objects.

Use like so:

await settleObject({
  a: Promise.resolve('a'),
  b: Promise.reject('b'),
}) === {
  a: { status: 'fulfilled', value: 'a' },
  b: { status: 'rejected', reason: 'b' },
}

Also allows the resolveObject util to accept a number or symbol as a key.

@GRA0007 GRA0007 added the enhancement New feature or request label Sep 12, 2023
@GRA0007 GRA0007 requested a review from giraugh September 12, 2023 10:25
@GRA0007 GRA0007 self-assigned this Sep 12, 2023
@changeset-bot
Copy link

changeset-bot bot commented Sep 12, 2023

🦋 Changeset detected

Latest commit: 7c19f22

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@giraugh/tools Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Copy link
Owner

@giraugh giraugh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good!

@GRA0007 GRA0007 merged commit 1f6e4b2 into main Sep 13, 2023
2 checks passed
@GRA0007 GRA0007 deleted the feat/resolve-object-settled branch September 13, 2023 01:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants