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

async ctor #693

Merged
merged 8 commits into from
Dec 13, 2023
Merged

async ctor #693

merged 8 commits into from
Dec 13, 2023

Conversation

goastler
Copy link
Member

No description provided.

@pr-explainer-bot
Copy link

Pull Request Report

Greetings! 👋

Here's a report for the pull request:

Changes:

  1. Added a new file asyncConstructor.ts in the util package.
  2. Added a new test file asyncConstructor.test.ts in the util/tests directory.

Suggestions to improve code:

  1. In the asyncConstructor.ts file, consider adding comments to explain the purpose of the anew function and the Constructor type.
  2. In the asyncConstructor.test.ts file, consider adding comments to explain the purpose of the tests and the Abc class.

Bugs:

No bugs found.

Improvements:

No improvements found.

Code Refactoring:

In the asyncConstructor.ts file, the anew function can be refactored for better readability. Here's an improved version:

export async function anew<T extends {
    ctor(...args: ConstructorParameters<Constructor<T>>): Promise<void>
}>(Clas: Constructor<T>, ...args: ConstructorParameters<Constructor<T>>) {
    const inst = new Clas(...args)
    await inst.ctor(...args)
    return inst
}

Rating:

I would rate the code as follows:

  • Readability: 8/10
  • Performance: 9/10
  • Security: 10/10

That's all for the report! Let me know if you need any further assistance. 😄

@goastler goastler changed the title WIP async ctor async ctor Dec 13, 2023
@goastler goastler merged commit 9cec717 into main Dec 13, 2023
3 checks passed
@goastler goastler deleted the async-ctor branch December 13, 2023 14:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants