Skip to content

Commit

Permalink
2.1.8
Browse files Browse the repository at this point in the history
  • Loading branch information
pubkey committed Nov 12, 2018
1 parent f695a50 commit a3151d2
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 39 deletions.
51 changes: 32 additions & 19 deletions dist/es/methods/node.js
Expand Up @@ -464,15 +464,16 @@ function _openClientConnection() {
case 0:
pathToSocket = socketPath(channelName, readerUuid);
client = new net.Socket();
_context12.next = 4;
return new Promise(function (res) {
client.connect(pathToSocket, res);
});

case 4:
return _context12.abrupt("return", client);
return _context12.abrupt("return", new Promise(function (res, rej) {
client.connect(pathToSocket, function () {
return res(client);
});
client.on('error', function (err) {
return rej(err);
});
}));

case 5:
case 3:
case "end":
return _context12.stop();
}
Expand Down Expand Up @@ -937,25 +938,34 @@ function refreshReaderClients(channelState) {
return _context2.abrupt("return");

case 3:
_context2.next = 5;
_context2.prev = 3;
_context2.next = 6;
return openClientConnection(channelState.channelName, readerUuid);

case 5:
case 6:
client = _context2.sent;
channelState.otherReaderClients[readerUuid] = client;
_context2.next = 11;
_context2.next = 12;
break;

case 10:
_context2.prev = 10;
_context2.t0 = _context2["catch"](3);

case 12:
_context2.next = 16;
break;

case 9:
_context2.prev = 9;
_context2.t0 = _context2["catch"](0);
case 14:
_context2.prev = 14;
_context2.t1 = _context2["catch"](0);

case 11:
case 16:
case "end":
return _context2.stop();
}
}
}, _callee2, this, [[0, 9]]);
}, _callee2, this, [[0, 14], [3, 10]]);
}));

return function (_x23) {
Expand Down Expand Up @@ -1086,9 +1096,12 @@ function close(channelState) {
Object.values(channelState.otherReaderClients).forEach(function (client) {
return client.destroy();
});
if (channelState.infoFilePath) unlink(channelState.infoFilePath)["catch"](function () {
return null;
});

if (channelState.infoFilePath) {
try {
fs.unlinkSync(channelState.infoFilePath);
} catch (err) {}
}
}

function canBeUsed() {
Expand Down
51 changes: 32 additions & 19 deletions dist/lib/methods/node.js
Expand Up @@ -469,15 +469,16 @@ function _openClientConnection() {
case 0:
pathToSocket = socketPath(channelName, readerUuid);
client = new net.Socket();
_context12.next = 4;
return new Promise(function (res) {
client.connect(pathToSocket, res);
});

case 4:
return _context12.abrupt("return", client);
return _context12.abrupt("return", new Promise(function (res, rej) {
client.connect(pathToSocket, function () {
return res(client);
});
client.on('error', function (err) {
return rej(err);
});
}));

case 5:
case 3:
case "end":
return _context12.stop();
}
Expand Down Expand Up @@ -942,25 +943,34 @@ function refreshReaderClients(channelState) {
return _context2.abrupt("return");

case 3:
_context2.next = 5;
_context2.prev = 3;
_context2.next = 6;
return openClientConnection(channelState.channelName, readerUuid);

case 5:
case 6:
client = _context2.sent;
channelState.otherReaderClients[readerUuid] = client;
_context2.next = 11;
_context2.next = 12;
break;

case 10:
_context2.prev = 10;
_context2.t0 = _context2["catch"](3);

case 12:
_context2.next = 16;
break;

case 9:
_context2.prev = 9;
_context2.t0 = _context2["catch"](0);
case 14:
_context2.prev = 14;
_context2.t1 = _context2["catch"](0);

case 11:
case 16:
case "end":
return _context2.stop();
}
}
}, _callee2, this, [[0, 9]]);
}, _callee2, this, [[0, 14], [3, 10]]);
}));

return function (_x23) {
Expand Down Expand Up @@ -1091,9 +1101,12 @@ function close(channelState) {
Object.values(channelState.otherReaderClients).forEach(function (client) {
return client.destroy();
});
if (channelState.infoFilePath) unlink(channelState.infoFilePath)["catch"](function () {
return null;
});

if (channelState.infoFilePath) {
try {
fs.unlinkSync(channelState.infoFilePath);
} catch (err) {}
}
}

function canBeUsed() {
Expand Down
2 changes: 1 addition & 1 deletion package.json
@@ -1,6 +1,6 @@
{
"name": "broadcast-channel",
"version": "2.1.7",
"version": "2.1.8",
"description": "A BroadcastChannel implementation that works with new browsers, older browsers and Node.js",
"homepage": "https://github.com/pubkey/broadcast-channel#readme",
"keywords": [
Expand Down

0 comments on commit a3151d2

Please sign in to comment.