Skip to content

[feature] Promise returning process.nextTick #19617

@jamiebuilds

Description

@jamiebuilds

Just a quick idea I had after talking to @sindresorhus.

When process.nextTick() is called without a function, return a Promise:

async function fn() {
  await process.nextTick();
}

in effect:

function nextTick(fn) {
  if (typeof fn === 'function') {
    process.nextTick(fn);
  } else {
    return new Promise(res => process.nextTick(res));
  }
}

As more of Node (possibly) moves to Promises/async-await for APIs (#15413) this makes sense I think

Metadata

Metadata

Assignees

No one assigned

    Labels

    feature requestIssues that request new features to be added to Node.js.processIssues and PRs related to the process subsystem.promisesIssues and PRs related to ECMAScript promises.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions