Reverse argument order for sendTo

It makes more sense to put the address first then have the large
structure to send as the second argument to sendTo.  The opposite order
was originally chosen to be similar to that of sendto in BSD sockets.
This commit is contained in:
Hornwitser committed 2023-07-27 00:24:24 +02:00
1 parent 183d2921a8
commit 295cc7543a
24 files changed
+87 -74

No files matched your search

+3 -3
View File
@@ -374,19 +374,19 @@ class Link {
* undefined if it was an event.
*/
send(requestOrEvent) {
return this.sendTo(requestOrEvent, this.connector.dst);
return this.sendTo(this.connector.dst, requestOrEvent);
}
/**
* Send a request or event to the given address
*
* @param {*} requestOrEvent - Request or event to send
* @param {*|module:lib/data.Address} destination - Where to send it
* @param {*} requestOrEvent - Request or event to send
* @returns {Promise<*>|undefined}
* Promise that resolves to the response if a request was sent or
* undefined if it was an event.
*/
sendTo(requestOrEvent, destination) {
sendTo(destination, requestOrEvent) {
let dst = libData.Address.fromShorthand(destination);
if (requestOrEvent.constructor.type === "request") {