Skip to content

[refactor] use async/await syntax? #1867

Open

Description

@samuela

As I dig through the source, I'm noticing that there's a lot of messy manual Promise chaining, eg. https://github.com/nodegit/nodegit/blob/master/generate/scripts/generateNativeCode.js#L121-L171. Is there a reason not to use async/await syntax? I'd be happy to submit some PRs if maintainers would be interested.

Activity

  1. samuela commented on Oct 17, 2021

    @samuela
    ContributorAuthor

    For some context async/await syntax has been supported in node.js since v7.6.0 which is from 2017, so we wouldn't be dropping support for barely anyone AFAICT.

  2. samuela commented on Oct 18, 2021

    @samuela
    ContributorAuthor

    I have completed a translation from .then-ing to async/await for the entire lib/ and lifecycleScripts/ directories. Commits are linked above. There are only a handful of .thens left in places where they actually appear to be the cleanest solution. Otherwise everything has been refactored to use async/await for clarity.

    Everything builds and passes the entire test suite. Throughout the process I also upgraded the test runner from istanbul to nyc. It turns out that istanbul has been deprecated, and nyc is the recommended solution now. See samuela@63c801c for more info.

    Using async/await syntax also required upgrading jshint, and updating the configuration to use the "esversion": 9 config option instead of esnext which has been deprecated. See samuela@e099639 for more info.

    I'd be happy to contribute all these changes upstream if they are of interest to maintainers. Let me know! (cc @implausible @ianhattendorf others?)

  3. Vadorequest commented on Jun 12, 2022

    @Vadorequest

    Could this be considered?

  4. jeremyj563 commented on Dec 13, 2023

    @jeremyj563

    Why is this being ignored? Is there some good reason to avoid migrating the project to the modern async/await syntax?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions