Skip to content

Conversation

@MasterOdin
Copy link
Contributor

Closes #166

PR makes it so that calling the getPort or getPorts method without providing a callback will have them return a promise instead. This makes the library more similar to others that support both a callback and a promise interface, without needing extra functions.

The getPortPromise and getPortsPromise methods are retained for backwards compatibility, but may wish to mark them as deprecated via jsdoc so that people move to using getPort and getPorts.

.catch(function (err) {
done(err);
});
});
Copy link
Member

Choose a reason for hiding this comment

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

TY

}
resolve(port);

if (!callback) {
Copy link
Member

Choose a reason for hiding this comment

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

very good call btw

@eriktrom
Copy link
Member

One of my favorite PRs ever. So clean. One API. Thank you!

The getPortPromise and getPortsPromise methods are retained for backwards compatibility, but may wish to mark them as deprecated via jsdoc so that people move to using getPort and getPorts

Yeah - I mean - we just don't ever need to remove the aliases, given the code to keep them is a one liner and not subject to maintenance issues - and yeah the same idea applies to getSocket per #169 (see comment there)

@eriktrom
Copy link
Member

closes #166

@eriktrom eriktrom merged commit 724a0e1 into http-party:master Mar 12, 2025
19 checks passed
@MasterOdin MasterOdin deleted the feat-promise-return branch March 12, 2025 21:55
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.

Combine callback and promise functions into one

2 participants