Skip to content

Commit

Permalink
refactor: inline timeout var; saves 4 bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
lukeed committed Nov 13, 2018
1 parent 8d0bcd6 commit c8c8d91
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ export default function (url, opts) {
opts = opts || {};

var ws, num=0, $={};
var ms=opts.timeout || 1e3, max=opts.maxAttempts || Infinity;
var max = opts.maxAttempts || Infinity;

$.open = function () {
ws = new WebSocket(url, opts.protocols || []);
Expand All @@ -30,7 +30,7 @@ export default function (url, opts) {
(num++ < max) ? setTimeout(_ => {
(opts.onreconnect || noop)(e);
$.open();
}, ms) : (opts.onmaximum || noop)(e);
}, opts.timeout || 1e3) : (opts.onmaximum || noop)(e);
};

$.json = function (x) {
Expand Down

0 comments on commit c8c8d91

Please sign in to comment.