*Update dist

This commit is contained in:
Derrick Hammer 2023-04-09 12:15:38 -04:00
parent 5c666d38c0
commit 6099a6c4f6
Signed by: pcfreak30
GPG Key ID: C997C339BE476FF2
1 changed files with 17 additions and 2 deletions

19
dist/peer.js vendored
View File

@ -39,9 +39,10 @@ class Peer {
async init() {
const self = this;
let pipe;
const raw = await maybeGetAsyncProperty(self._peer.rawStream);
this._socket = new socket_js_1.default({
remoteAddress: self._peer.rawStream.remoteHost,
remotePort: self._peer.rawStream.remotePort,
remoteAddress: raw.remoteHost,
remotePort: raw.remotePort,
remotePublicKey: self._peer.remotePublicKey,
async write(data, cb) {
if (pipe) {
@ -90,3 +91,17 @@ class Peer {
}
}
exports.default = Peer;
async function maybeGetAsyncProperty(object) {
if (typeof object === "function") {
object = object();
}
if (isPromise(object)) {
object = await object;
}
return object;
}
function isPromise(obj) {
return (!!obj &&
(typeof obj === "object" || typeof obj === "function") &&
typeof obj.then === "function");
}