[Pkg-javascript-commits] [sockjs-client] 191/350: code style
tonnerre at ancient-solutions.com
tonnerre at ancient-solutions.com
Fri Aug 5 01:04:20 UTC 2016
This is an automated email from the git hooks/post-receive script.
tonnerre-guest pushed a commit to branch upstream
in repository sockjs-client.
commit 941b05e74f71d82b8f63b97bf4e5651f5ab78b71
Author: Bryce Kahle <bkahle at gmail.com>
Date: Mon Oct 20 12:39:36 2014 -0400
code style
---
.jscsrc | 20 +++++++++++++++++
lib/event/eventtarget.js | 6 ++---
lib/facade.js | 8 +++----
lib/iframe-bootstrap.js | 4 ++--
lib/info-ajax.js | 2 +-
lib/info-iframe.js | 8 +++----
lib/info-receiver.js | 6 ++---
lib/main.js | 12 +++++-----
lib/shims.js | 1 +
lib/transport/browser/abstract-xhr.js | 21 +++++++++---------
lib/transport/driver/xhr.js | 10 ++++-----
lib/transport/eventsource.js | 2 +-
lib/transport/htmlfile.js | 2 +-
lib/transport/iframe.js | 8 ++++---
lib/transport/lib/ajax-based.js | 2 +-
lib/transport/lib/buffered-sender.js | 4 ++--
lib/transport/lib/iframe-wrap.js | 4 ++--
lib/transport/lib/polling.js | 2 +-
lib/transport/lib/sender-receiver.js | 6 ++---
lib/transport/receiver/eventsource.js | 8 +++----
lib/transport/receiver/htmlfile.js | 16 ++++++-------
lib/transport/receiver/jsonp.js | 18 +++++++--------
lib/transport/receiver/xhr.js | 6 ++---
lib/transport/sender/jsonp.js | 16 ++++++-------
lib/transport/sender/xdr.js | 12 +++++-----
lib/transport/sender/xhr-cors.js | 2 +-
lib/transport/sender/xhr-fake.js | 2 +-
lib/transport/sender/xhr-local.js | 2 +-
lib/transport/websocket.js | 6 ++---
lib/utils/browser-crypto.js | 4 ++--
lib/utils/browser.js | 4 ++--
lib/utils/escape.js | 8 +++----
lib/utils/iframe.js | 42 ++++++++++++++++++-----------------
lib/utils/object.js | 2 +-
lib/utils/transport.js | 8 +++----
lib/utils/url.js | 4 ++--
36 files changed, 157 insertions(+), 131 deletions(-)
diff --git a/.jscsrc b/.jscsrc
new file mode 100644
index 0000000..b0df4d5
--- /dev/null
+++ b/.jscsrc
@@ -0,0 +1,20 @@
+{
+ "requireCurlyBraces": ["if", "else", "for", "while", "do", "try", "catch"],
+ "requireSpaceAfterKeywords": ["do", "for", "if", "else", "switch", "case", "try", "catch", "void", "while", "with", "return", "typeof"],
+ "requireSpaceBeforeBlockStatements": true,
+ "requireParenthesesAroundIIFE": true,
+ "requireSpacesInConditionalExpression": true,
+ "requireSpacesInFunction": {
+ "beforeOpeningCurlyBrace": true
+ },
+ "disallowSpacesInFunction": {
+ "beforeOpeningRoundBrace": true
+ },
+ "disallowSpacesInCallExpression": true,
+ "requireBlocksOnNewline": true,
+ "disallowCommaBeforeLineBreak": true,
+ "requireCapitalizedConstructors": true,
+ "validateQuoteMarks": { "escape": true, "mark": "'" },
+ "validateIndentation": 2,
+ "validateParameterSeparator": ", "
+}
\ No newline at end of file
diff --git a/lib/event/eventtarget.js b/lib/event/eventtarget.js
index a09ce92..aa4adff 100644
--- a/lib/event/eventtarget.js
+++ b/lib/event/eventtarget.js
@@ -8,7 +8,7 @@ function EventTarget() {
this._listeners = {};
}
-EventTarget.prototype.addEventListener = function (eventType, listener) {
+EventTarget.prototype.addEventListener = function(eventType, listener) {
if (!(eventType in this._listeners)) {
this._listeners[eventType] = [];
}
@@ -22,7 +22,7 @@ EventTarget.prototype.addEventListener = function (eventType, listener) {
return;
};
-EventTarget.prototype.removeEventListener = function (eventType, listener) {
+EventTarget.prototype.removeEventListener = function(eventType, listener) {
if (!(eventType in this._listeners)) {
return;
}
@@ -40,7 +40,7 @@ EventTarget.prototype.removeEventListener = function (eventType, listener) {
return;
};
-EventTarget.prototype.dispatchEvent = function (event) {
+EventTarget.prototype.dispatchEvent = function(event) {
var t = event.type;
var args = Array.prototype.slice.call(arguments, 0);
// TODO: This doesn't match the real behavior; per spec, onfoo get
diff --git a/lib/facade.js b/lib/facade.js
index e4599cd..320891e 100644
--- a/lib/facade.js
+++ b/lib/facade.js
@@ -10,16 +10,16 @@ function FacadeJS(transport) {
transport.on('close', this._transportClose.bind(this));
}
-FacadeJS.prototype._transportClose = function (code, reason) {
+FacadeJS.prototype._transportClose = function(code, reason) {
iframeUtils.postMessage('c', JSON3.stringify([code, reason]));
};
-FacadeJS.prototype._transportMessage = function (frame) {
+FacadeJS.prototype._transportMessage = function(frame) {
iframeUtils.postMessage('t', frame);
};
-FacadeJS.prototype._send = function (data) {
+FacadeJS.prototype._send = function(data) {
this._transport.send(data);
};
-FacadeJS.prototype._close = function () {
+FacadeJS.prototype._close = function() {
this._transport.close();
this._transport.removeAllListeners();
};
diff --git a/lib/iframe-bootstrap.js b/lib/iframe-bootstrap.js
index 0bdeb7d..97337b7 100644
--- a/lib/iframe-bootstrap.js
+++ b/lib/iframe-bootstrap.js
@@ -9,9 +9,9 @@ var urlUtils = require('./utils/url')
, loc = require('./location')
;
-module.exports = function (SockJS, availableTransports) {
+module.exports = function(SockJS, availableTransports) {
var transportMap = {};
- availableTransports.forEach(function (at) {
+ availableTransports.forEach(function(at) {
if (at.facadeTransport) {
transportMap[at.facadeTransport.transportName] = at.facadeTransport;
}
diff --git a/lib/info-ajax.js b/lib/info-ajax.js
index 2248972..e41d0c0 100644
--- a/lib/info-ajax.js
+++ b/lib/info-ajax.js
@@ -35,7 +35,7 @@ function InfoAjax(url, AjaxObject) {
util.inherits(InfoAjax, EventEmitter);
-InfoAjax.prototype.close = function () {
+InfoAjax.prototype.close = function() {
this.removeAllListeners();
this.xo.close();
};
diff --git a/lib/info-iframe.js b/lib/info-iframe.js
index 77c8952..b09ddcc 100644
--- a/lib/info-iframe.js
+++ b/lib/info-iframe.js
@@ -15,7 +15,7 @@ function InfoIframe(url) {
var go = function() {
var ifr = self.ifr = new IframeTransport(InfoReceiverIframe.transportName, url, url);
- ifr.once('message', function (msg) {
+ ifr.once('message', function(msg) {
if (msg) {
var d = JSON3.parse(msg);
var info = d[0], rtt = d[1];
@@ -24,7 +24,7 @@ function InfoIframe(url) {
self.close();
});
- ifr.once('close', function () {
+ ifr.once('close', function() {
self.emit('finish');
self.close();
});
@@ -40,11 +40,11 @@ function InfoIframe(url) {
util.inherits(InfoIframe, EventEmitter);
-InfoIframe.enabled = function () {
+InfoIframe.enabled = function() {
return IframeTransport.enabled();
};
-InfoIframe.prototype.close = function () {
+InfoIframe.prototype.close = function() {
if (this.ifr) {
this.ifr.close();
}
diff --git a/lib/info-receiver.js b/lib/info-receiver.js
index ca9a18a..23590e0 100644
--- a/lib/info-receiver.js
+++ b/lib/info-receiver.js
@@ -10,7 +10,7 @@ var EventEmitter = require('events').EventEmitter
, InfoAjax = require('./info-ajax')
;
-var debug = function () {};
+var debug = function() {};
if (process.env.NODE_ENV !== 'production') {
debug = require('debug')('sockjs-client:info-receiver');
}
@@ -20,7 +20,7 @@ function InfoReceiver(baseUrl, urlInfo) {
var self = this;
EventEmitter.call(this);
- process.nextTick(function(){
+ process.nextTick(function() {
self.doXhr(baseUrl, urlInfo);
});
}
@@ -29,7 +29,7 @@ util.inherits(InfoReceiver, EventEmitter);
// TODO this is currently ignoring the list of available transports and the whitelist
-InfoReceiver._getReceiver = function (url, urlInfo) {
+InfoReceiver._getReceiver = function(url, urlInfo) {
// determine method of CORS support (if needed)
if (urlInfo.sameOrigin) {
return new InfoAjax(url, XHRLocal);
diff --git a/lib/main.js b/lib/main.js
index cdd68e9..2dd66a6 100644
--- a/lib/main.js
+++ b/lib/main.js
@@ -22,7 +22,7 @@ var u = require('url')
, InfoReceiver = require('./info-receiver')
;
-var debug = function () {};
+var debug = function() {};
if (process.env.NODE_ENV !== 'production') {
// Make debug module available globally so you can enable via the console easily
global.dbg = require('debug');
@@ -77,7 +77,7 @@ function SockJS(url, protocols, transportsWhitelist) {
// Step 5 - check protocols argument
var sortedProtocols = protocols.sort();
- sortedProtocols.forEach(function (proto, i) {
+ sortedProtocols.forEach(function(proto, i) {
if (!proto) {
throw new SyntaxError("The protocols entry '" + proto + "' is invalid.");
}
@@ -238,7 +238,7 @@ SockJS.prototype._transportMessage = function(msg) {
break;
case 'a':
payload = JSON3.parse(msg.slice(1) || '[]');
- payload.forEach(function (p) {
+ payload.forEach(function(p) {
debug('message', self.transport, p);
self.dispatchEvent(new TransportMessageEvent(p));
});
@@ -314,7 +314,7 @@ SockJS.prototype._close = function(code, reason, wasClean) {
}
this.readyState = SockJS.CLOSING;
- process.nextTick(function () {
+ process.nextTick(function() {
this.readyState = SockJS.CLOSED;
if (forceFail) {
@@ -334,7 +334,7 @@ SockJS.prototype._close = function(code, reason, wasClean) {
// See: http://www.erg.abdn.ac.uk/~gerrit/dccp/notes/ccid2/rto_estimator/
// and RFC 2988.
-SockJS.prototype.countRTO = function (rtt) {
+SockJS.prototype.countRTO = function(rtt) {
// In a local environment, when using IE8/9 and the `jsonp-polling`
// transport the time needed to establish a connection (the time that pass
// from the opening of the transport to the call of `_dispatchOpen`) is
@@ -347,7 +347,7 @@ SockJS.prototype.countRTO = function (rtt) {
return 300 + rtt; // 300msec < rto <= 400msec
};
-module.exports = function (availableTransports) {
+module.exports = function(availableTransports) {
transports = transport(availableTransports);
require('./iframe-bootstrap')(SockJS, availableTransports);
return SockJS;
diff --git a/lib/shims.js b/lib/shims.js
index 3e67bf7..d9b81b5 100644
--- a/lib/shims.js
+++ b/lib/shims.js
@@ -1,4 +1,5 @@
/* eslint-disable */
+/* jscs: disable */
'use strict';
// pulled specific shims from https://github.com/es-shims/es5-shim
diff --git a/lib/transport/browser/abstract-xhr.js b/lib/transport/browser/abstract-xhr.js
index ba0f234..bb53625 100644
--- a/lib/transport/browser/abstract-xhr.js
+++ b/lib/transport/browser/abstract-xhr.js
@@ -6,7 +6,7 @@ var EventEmitter = require('events').EventEmitter
, XHR = global.XMLHttpRequest
;
-var debug = function () {};
+var debug = function() {};
if (process.env.NODE_ENV !== 'production') {
debug = require('debug')('sockjs-client:browser:xhr');
}
@@ -18,7 +18,7 @@ function AbstractXHRObject(method, url, payload, opts) {
try {
this.xhr = new XHR();
- } catch(x) {}
+ } catch (x) {}
if (!this.xhr) {
debug('no xhr');
@@ -35,13 +35,13 @@ function AbstractXHRObject(method, url, payload, opts) {
// Explorer tends to keep connection open, even after the
// tab gets closed: http://bugs.jquery.com/ticket/5280
- this.unloadRef = utils.unloadAdd(function(){
+ this.unloadRef = utils.unloadAdd(function() {
debug('unload cleanup');
self._cleanup(true);
});
try {
this.xhr.open(method, url, true);
- } catch(e) {
+ } catch (e) {
debug('exception', e);
// IE raises an exception on wrong port.
this.emit('finish', 0, '');
@@ -57,7 +57,7 @@ function AbstractXHRObject(method, url, payload, opts) {
this.xhr.withCredentials = 'true';
}
if (opts && opts.headers) {
- for(var key in opts.headers) {
+ for (var key in opts.headers) {
this.xhr.setRequestHeader(key, opts.headers[key]);
}
}
@@ -127,12 +127,12 @@ AbstractXHRObject.prototype._cleanup = function(abort) {
utils.unloadDel(this.unloadRef);
// IE needs this field to be a function
- this.xhr.onreadystatechange = function(){};
+ this.xhr.onreadystatechange = function() {};
if (abort) {
try {
this.xhr.abort();
- } catch(x) {}
+ } catch (x) {}
}
this.unloadRef = this.xhr = null;
};
@@ -146,7 +146,7 @@ AbstractXHRObject.enabled = !!XHR;
// override XMLHttpRequest for IE6/7
if (!AbstractXHRObject.enabled && global.ActiveXObject) {
debug('overriding xmlhttprequest');
- XHR = function () {
+ XHR = function() {
try {
return new global.ActiveXObject('Microsoft.XMLHTTP');
} catch (e) {
@@ -157,8 +157,9 @@ if (!AbstractXHRObject.enabled && global.ActiveXObject) {
}
var cors = false;
-try { cors = 'withCredentials' in new XHR(); }
-catch (ignored) {}
+try {
+ cors = 'withCredentials' in new XHR();
+} catch (ignored) {}
AbstractXHRObject.supportsCORS = cors;
diff --git a/lib/transport/driver/xhr.js b/lib/transport/driver/xhr.js
index 54a32cd..3a200f7 100644
--- a/lib/transport/driver/xhr.js
+++ b/lib/transport/driver/xhr.js
@@ -6,7 +6,7 @@ var EventEmitter = require('events').EventEmitter
, u = require('url')
;
-var debug = function () {};
+var debug = function() {};
if (process.env.NODE_ENV !== 'production') {
debug = require('debug')('sockjs-client:driver:xhr');
}
@@ -26,23 +26,23 @@ function XhrDriver(method, url, payload, opts) {
, agent: false
};
- this.req = http.request(options, function (res) {
+ this.req = http.request(options, function(res) {
res.setEncoding('utf8');
var responseText = '';
- res.on('data', function (chunk) {
+ res.on('data', function(chunk) {
debug('data', chunk);
responseText += chunk;
self.emit('chunk', 200, responseText);
});
- res.once('end', function () {
+ res.once('end', function() {
debug('end');
self.emit('finish', res.statusCode, responseText);
self.req = null;
});
});
- this.req.on('error', function (e) {
+ this.req.on('error', function(e) {
debug('error', e);
self.emit('finish', 0, e.message);
});
diff --git a/lib/transport/eventsource.js b/lib/transport/eventsource.js
index ba681a0..dd6b698 100644
--- a/lib/transport/eventsource.js
+++ b/lib/transport/eventsource.js
@@ -13,7 +13,7 @@ function EventSourceTransport(transUrl) {
util.inherits(EventSourceTransport, AjaxBasedTransport);
-EventSourceTransport.enabled = function () {
+EventSourceTransport.enabled = function() {
return !!EventSourceDriver;
};
diff --git a/lib/transport/htmlfile.js b/lib/transport/htmlfile.js
index add02d6..84f5bbc 100644
--- a/lib/transport/htmlfile.js
+++ b/lib/transport/htmlfile.js
@@ -12,7 +12,7 @@ function HtmlFileTransport(transUrl) {
util.inherits(HtmlFileTransport, AjaxBasedTransport);
-HtmlFileTransport.enabled = function (info) {
+HtmlFileTransport.enabled = function(info) {
return HtmlfileReceiver.enabled && info.sameOrigin;
};
diff --git a/lib/transport/iframe.js b/lib/transport/iframe.js
index 8847ce0..94d6dc4 100644
--- a/lib/transport/iframe.js
+++ b/lib/transport/iframe.js
@@ -18,7 +18,7 @@ var util = require('util')
, random = require('../utils/random')
;
-var debug = function () {};
+var debug = function() {};
if (process.env.NODE_ENV !== 'production') {
debug = require('debug')('sockjs-client:transport:iframe');
}
@@ -76,7 +76,9 @@ IframeTransport.prototype._message = function(e) {
{
iframeMessage = JSON3.parse(e.data);
}
- catch (ignored) { return; }
+ catch (ignored) {
+ return;
+ }
if (iframeMessage.windowId !== this.windowId) {
debug('mismatched window id', iframeMessage.windowId, this.windowId);
@@ -113,7 +115,7 @@ IframeTransport.prototype.postMessage = function(type, data) {
}), this.origin);
};
-IframeTransport.prototype.send = function (message) {
+IframeTransport.prototype.send = function(message) {
debug('send', message);
this.postMessage('m', message);
};
diff --git a/lib/transport/lib/ajax-based.js b/lib/transport/lib/ajax-based.js
index 1f514ac..f73ca5f 100644
--- a/lib/transport/lib/ajax-based.js
+++ b/lib/transport/lib/ajax-based.js
@@ -4,7 +4,7 @@ var util = require('util')
, SenderReceiver = require('./sender-receiver')
;
-var debug = function () {};
+var debug = function() {};
if (process.env.NODE_ENV !== 'production') {
debug = require('debug')('sockjs-client:ajax-based');
}
diff --git a/lib/transport/lib/buffered-sender.js b/lib/transport/lib/buffered-sender.js
index e7f1c4a..aa23272 100644
--- a/lib/transport/lib/buffered-sender.js
+++ b/lib/transport/lib/buffered-sender.js
@@ -4,7 +4,7 @@ var util = require('util')
, EventEmitter = require('events').EventEmitter
;
-var debug = function () {};
+var debug = function() {};
if (process.env.NODE_ENV !== 'production') {
debug = require('debug')('sockjs-client:buffered-sender');
}
@@ -70,7 +70,7 @@ BufferedSender.prototype.sendSchedule = function() {
}
};
-BufferedSender.prototype._cleanup = function () {
+BufferedSender.prototype._cleanup = function() {
debug('_cleanup');
this.removeAllListeners();
};
diff --git a/lib/transport/lib/iframe-wrap.js b/lib/transport/lib/iframe-wrap.js
index a9b4575..f46bf50 100644
--- a/lib/transport/lib/iframe-wrap.js
+++ b/lib/transport/lib/iframe-wrap.js
@@ -5,7 +5,7 @@ var util = require('util')
, objectUtils = require('../../utils/object')
;
-module.exports = function (transport) {
+module.exports = function(transport) {
function IframeWrapTransport(transUrl, baseUrl) {
IframeTransport.call(this, transport.transportName, transUrl, baseUrl);
@@ -13,7 +13,7 @@ module.exports = function (transport) {
util.inherits(IframeWrapTransport, IframeTransport);
- IframeWrapTransport.enabled = function (url, info) {
+ IframeWrapTransport.enabled = function(url, info) {
if (!global.document) {
return false;
}
diff --git a/lib/transport/lib/polling.js b/lib/transport/lib/polling.js
index a2595e7..dcc905e 100644
--- a/lib/transport/lib/polling.js
+++ b/lib/transport/lib/polling.js
@@ -4,7 +4,7 @@ var util = require('util')
, EventEmitter = require('events').EventEmitter
;
-var debug = function () {};
+var debug = function() {};
if (process.env.NODE_ENV !== 'production') {
debug = require('debug')('sockjs-client:polling');
}
diff --git a/lib/transport/lib/sender-receiver.js b/lib/transport/lib/sender-receiver.js
index 6cb07ff..8c5d249 100644
--- a/lib/transport/lib/sender-receiver.js
+++ b/lib/transport/lib/sender-receiver.js
@@ -5,7 +5,7 @@ var util = require('util')
, Polling = require('./polling')
;
-var debug = function () {};
+var debug = function() {};
if (process.env.NODE_ENV !== 'production') {
debug = require('debug')('sockjs-client:sender-receiver');
}
@@ -16,11 +16,11 @@ function SenderReceiver(transUrl, urlSuffix, senderFunc, Receiver, AjaxObject) {
BufferedSender.call(this, transUrl, senderFunc);
this.poll = new Polling(Receiver, transUrl + urlSuffix, AjaxObject);
- this.poll.on('message', function (msg) {
+ this.poll.on('message', function(msg) {
debug('poll message', msg);
self.emit('message', msg);
});
- this.poll.once('close', function (code, reason) {
+ this.poll.once('close', function(code, reason) {
debug('poll close', code, reason);
self.poll = null;
self.stop();
diff --git a/lib/transport/receiver/eventsource.js b/lib/transport/receiver/eventsource.js
index 0a4112e..7bc6c3c 100644
--- a/lib/transport/receiver/eventsource.js
+++ b/lib/transport/receiver/eventsource.js
@@ -5,7 +5,7 @@ var util = require('util')
, EventSourceDriver = require('eventsource')
;
-var debug = function () {};
+var debug = function() {};
if (process.env.NODE_ENV !== 'production') {
debug = require('debug')('sockjs-client:receiver:eventsource');
}
@@ -20,7 +20,7 @@ function EventSourceReceiver(url) {
debug('message', e.data);
self.emit('message', decodeURI(e.data));
};
- es.onerror = function (e) {
+ es.onerror = function(e) {
debug('error', es.readyState, e);
// ES on reconnection has readyState = 0 or 1.
// on network error it's CLOSED = 2
@@ -38,7 +38,7 @@ EventSourceReceiver.prototype.abort = function() {
this._close('user');
};
-EventSourceReceiver.prototype._cleanup = function () {
+EventSourceReceiver.prototype._cleanup = function() {
debug('cleanup');
var es = this.es;
if (es) {
@@ -48,7 +48,7 @@ EventSourceReceiver.prototype._cleanup = function () {
}
};
-EventSourceReceiver.prototype._close = function (reason) {
+EventSourceReceiver.prototype._close = function(reason) {
debug('close', reason);
var self = this;
setTimeout(function() {
diff --git a/lib/transport/receiver/htmlfile.js b/lib/transport/receiver/htmlfile.js
index bf173d7..884d8a0 100644
--- a/lib/transport/receiver/htmlfile.js
+++ b/lib/transport/receiver/htmlfile.js
@@ -6,7 +6,7 @@ var util = require('util')
, random = require('../../utils/random')
;
-var debug = function () {};
+var debug = function() {};
if (process.env.NODE_ENV !== 'production') {
debug = require('debug')('sockjs-client:receiver:htmlfile');
}
@@ -26,15 +26,15 @@ function HtmlfileReceiver(url) {
iframeUtils.createHtmlfile : iframeUtils.createIframe;
global[iframeUtils.WPrefix][this.id] = {
- start: function () {
+ start: function() {
debug('start');
self.iframeObj.loaded();
- },
- message: function (data) {
+ }
+ , message: function(data) {
debug('message', data);
self.emit('message', data);
- },
- stop: function () {
+ }
+ , stop: function() {
debug('stop');
self._cleanup();
self._close('network');
@@ -55,7 +55,7 @@ HtmlfileReceiver.prototype.abort = function() {
this._close('user');
};
-HtmlfileReceiver.prototype._cleanup = function () {
+HtmlfileReceiver.prototype._cleanup = function() {
debug('_cleanup');
if (this.iframeObj) {
this.iframeObj.cleanup();
@@ -64,7 +64,7 @@ HtmlfileReceiver.prototype._cleanup = function () {
delete global[iframeUtils.WPrefix][this.id];
};
-HtmlfileReceiver.prototype._close = function (reason) {
+HtmlfileReceiver.prototype._close = function(reason) {
debug('_close', reason);
this.emit('close', null, reason);
this.removeAllListeners();
diff --git a/lib/transport/receiver/jsonp.js b/lib/transport/receiver/jsonp.js
index d5cf1fd..4db9960 100644
--- a/lib/transport/receiver/jsonp.js
+++ b/lib/transport/receiver/jsonp.js
@@ -7,7 +7,7 @@ var utils = require('../../utils/iframe')
, EventEmitter = require('events').EventEmitter
;
-var debug = function () {};
+var debug = function() {};
if (process.env.NODE_ENV !== 'production') {
debug = require('debug')('sockjs-client:receiver:jsonp');
}
@@ -34,7 +34,7 @@ function JsonpReceiver(url) {
util.inherits(JsonpReceiver, EventEmitter);
-JsonpReceiver.prototype.abort = function () {
+JsonpReceiver.prototype.abort = function() {
debug('abort');
if (global[utils.WPrefix][this.id]) {
var err = new Error('JSONP user aborted read');
@@ -46,7 +46,7 @@ JsonpReceiver.prototype.abort = function () {
JsonpReceiver.timeout = 35000;
JsonpReceiver.scriptErrorTimeout = 1000;
-JsonpReceiver.prototype._callback = function (data) {
+JsonpReceiver.prototype._callback = function(data) {
debug('_callback', data);
this._cleanup();
@@ -62,7 +62,7 @@ JsonpReceiver.prototype._callback = function (data) {
this.removeAllListeners();
};
-JsonpReceiver.prototype._abort = function (err) {
+JsonpReceiver.prototype._abort = function(err) {
debug('_abort', err);
this._cleanup();
this.aborting = true;
@@ -70,7 +70,7 @@ JsonpReceiver.prototype._abort = function (err) {
this.removeAllListeners();
};
-JsonpReceiver.prototype._cleanup = function () {
+JsonpReceiver.prototype._cleanup = function() {
debug('_cleanup');
clearTimeout(this.timeoutId);
if (this.script2) {
@@ -89,7 +89,7 @@ JsonpReceiver.prototype._cleanup = function () {
delete global[utils.WPrefix][this.id];
};
-JsonpReceiver.prototype._scriptError = function () {
+JsonpReceiver.prototype._scriptError = function() {
debug('_scriptError');
var self = this;
if (this.errorTimer) {
@@ -103,7 +103,7 @@ JsonpReceiver.prototype._scriptError = function () {
}, JsonpReceiver.scriptErrorTimeout);
};
-JsonpReceiver.prototype._createScript = function (url) {
+JsonpReceiver.prototype._createScript = function(url) {
debug('_createScript', url);
var self = this;
var script = this.script = global.document.createElement('script');
@@ -153,8 +153,8 @@ JsonpReceiver.prototype._createScript = function (url) {
if (!browser.isOpera()) {
// Naively assume we're in IE
try {
- script.htmlFor = script.id;
- script.event = 'onclick';
+ script.htmlFor = script.id;
+ script.event = 'onclick';
} catch (x) {}
script.async = true;
} else {
diff --git a/lib/transport/receiver/xhr.js b/lib/transport/receiver/xhr.js
index da6984d..394d5f1 100644
--- a/lib/transport/receiver/xhr.js
+++ b/lib/transport/receiver/xhr.js
@@ -4,7 +4,7 @@ var util = require('util')
, EventEmitter = require('events').EventEmitter
;
-var debug = function () {};
+var debug = function() {};
if (process.env.NODE_ENV !== 'production') {
debug = require('debug')('sockjs-client:receiver:xhr');
}
@@ -31,7 +31,7 @@ function XhrReceiver(url, AjaxObject) {
util.inherits(XhrReceiver, EventEmitter);
-XhrReceiver.prototype._chunkHandler = function (status, text) {
+XhrReceiver.prototype._chunkHandler = function(status, text) {
debug('_chunkHandler', status);
if (status !== 200 || !text) {
return;
@@ -51,7 +51,7 @@ XhrReceiver.prototype._chunkHandler = function (status, text) {
}
};
-XhrReceiver.prototype._cleanup = function () {
+XhrReceiver.prototype._cleanup = function() {
debug('_cleanup');
this.removeAllListeners();
};
diff --git a/lib/transport/sender/jsonp.js b/lib/transport/sender/jsonp.js
index 631f1f4..d9d55b0 100644
--- a/lib/transport/sender/jsonp.js
+++ b/lib/transport/sender/jsonp.js
@@ -3,19 +3,19 @@
var random = require('../../utils/random')
;
-var debug = function () {};
+var debug = function() {};
if (process.env.NODE_ENV !== 'production') {
debug = require('debug')('sockjs-client:sender:jsonp');
}
var form, area;
-function createIframe (id) {
+function createIframe(id) {
debug('createIframe', id);
try {
// ie6 dynamic iframes with target="" support (thanks Chris Lambacher)
return global.document.createElement('<iframe name="' + id + '">');
- } catch(x) {
+ } catch (x) {
var iframe = global.document.createElement('iframe');
iframe.name = id;
return iframe;
@@ -38,7 +38,7 @@ function createForm() {
global.document.body.appendChild(form);
}
-module.exports = function (url, payload, callback) {
+module.exports = function(url, payload, callback) {
debug(url, payload);
if (!form) {
createForm();
@@ -54,7 +54,7 @@ module.exports = function (url, payload, callback) {
try {
area.value = payload;
- } catch(e) {
+ } catch (e) {
// seriously broken browsers get here
}
form.submit();
@@ -77,11 +77,11 @@ module.exports = function (url, payload, callback) {
// failed to submit our form.
callback(err);
};
- iframe.onerror = function () {
+ iframe.onerror = function() {
debug('onerror', id);
completed();
};
- iframe.onload = function () {
+ iframe.onload = function() {
debug('onload', id);
completed();
};
@@ -91,7 +91,7 @@ module.exports = function (url, payload, callback) {
completed();
}
};
- return function () {
+ return function() {
debug('aborted', id);
completed(new Error('Aborted'));
};
diff --git a/lib/transport/sender/xdr.js b/lib/transport/sender/xdr.js
index 6a59749..6025d5a 100644
--- a/lib/transport/sender/xdr.js
+++ b/lib/transport/sender/xdr.js
@@ -5,7 +5,7 @@ var EventEmitter = require('events').EventEmitter
, eventUtils = require('../../utils/event')
;
-var debug = function () {};
+var debug = function() {};
if (process.env.NODE_ENV !== 'production') {
debug = require('debug')('sockjs-client:sender:xdr');
}
@@ -19,7 +19,7 @@ function XDRObject(method, url, payload) {
var self = this;
EventEmitter.call(this);
- process.nextTick(function(){
+ process.nextTick(function() {
self._start(method, url, payload);
});
}
@@ -37,7 +37,7 @@ XDRObject.prototype._start = function(method, url, payload) {
debug('onerror');
self._error();
};
- xdr.ontimeout = function () {
+ xdr.ontimeout = function() {
debug('ontimeout');
self._error();
};
@@ -51,14 +51,14 @@ XDRObject.prototype._start = function(method, url, payload) {
self._cleanup(false);
};
this.xdr = xdr;
- this.unloadRef = eventUtils.unloadAdd(function(){
+ this.unloadRef = eventUtils.unloadAdd(function() {
self._cleanup(true);
});
try {
// Fails with AccessDenied if port number is bogus
this.xdr.open(method, url);
this.xdr.send(payload);
- } catch(x) {
+ } catch (x) {
this._error();
}
};
@@ -80,7 +80,7 @@ XDRObject.prototype._cleanup = function(abort) {
if (abort) {
try {
this.xdr.abort();
- } catch(x) {}
+ } catch (x) {}
}
this.unloadRef = this.xdr = null;
};
diff --git a/lib/transport/sender/xhr-cors.js b/lib/transport/sender/xhr-cors.js
index 0ab0ece..318f822 100644
--- a/lib/transport/sender/xhr-cors.js
+++ b/lib/transport/sender/xhr-cors.js
@@ -6,7 +6,7 @@ var util = require('util')
function XHRCorsObject(method, url, payload, opts) {
var self = this;
- process.nextTick(function(){
+ process.nextTick(function() {
XhrDriver.call(self, method, url, payload, opts);
});
}
diff --git a/lib/transport/sender/xhr-fake.js b/lib/transport/sender/xhr-fake.js
index af2996d..f5073ba 100644
--- a/lib/transport/sender/xhr-fake.js
+++ b/lib/transport/sender/xhr-fake.js
@@ -15,7 +15,7 @@ function XHRFake(/* method, url, payload, opts */) {
util.inherits(XHRFake, EventEmitter);
-XHRFake.prototype.close = function () {
+XHRFake.prototype.close = function() {
clearTimeout(this.to);
};
diff --git a/lib/transport/sender/xhr-local.js b/lib/transport/sender/xhr-local.js
index 9b841b7..8870634 100644
--- a/lib/transport/sender/xhr-local.js
+++ b/lib/transport/sender/xhr-local.js
@@ -6,7 +6,7 @@ var util = require('util')
function XHRLocalObject(method, url, payload /*, opts */) {
var self = this;
- process.nextTick(function(){
+ process.nextTick(function() {
XhrDriver.call(self, method, url, payload, {
noCredentials: true
});
diff --git a/lib/transport/websocket.js b/lib/transport/websocket.js
index 4e0cd2c..c1c5d3b 100644
--- a/lib/transport/websocket.js
+++ b/lib/transport/websocket.js
@@ -6,7 +6,7 @@ var utils = require('../utils/event')
, WebsocketDriver = require('./driver/websocket')
;
-var debug = function () {};
+var debug = function() {};
if (process.env.NODE_ENV !== 'production') {
debug = require('debug')('sockjs-client:websocket');
}
@@ -35,7 +35,7 @@ function WebSocketTransport(transUrl) {
// let's not open the ws connection at all. See:
// https://github.com/sockjs/sockjs-client/issues/28
// https://bugzilla.mozilla.org/show_bug.cgi?id=696085
- this.unloadRef = utils.unloadAdd(function(){
+ this.unloadRef = utils.unloadAdd(function() {
debug('unload');
self.ws.close();
});
@@ -67,7 +67,7 @@ WebSocketTransport.prototype.close = function() {
this._cleanup();
};
-WebSocketTransport.prototype._cleanup = function () {
+WebSocketTransport.prototype._cleanup = function() {
debug('_cleanup');
var ws = this.ws;
if (ws) {
diff --git a/lib/utils/browser-crypto.js b/lib/utils/browser-crypto.js
index a3fc797..8d7fe4a 100644
--- a/lib/utils/browser-crypto.js
+++ b/lib/utils/browser-crypto.js
@@ -1,13 +1,13 @@
'use strict';
if (global.crypto && global.crypto.getRandomValues) {
- module.exports.randomBytes = function (length) {
+ module.exports.randomBytes = function(length) {
var bytes = new Uint8Array(length);
global.crypto.getRandomValues(bytes);
return bytes;
};
} else {
- module.exports.randomBytes = function (length) {
+ module.exports.randomBytes = function(length) {
var bytes = new Array(length);
for (var i = 0; i < length; i++) {
bytes[i] = Math.floor(Math.random() * 256);
diff --git a/lib/utils/browser.js b/lib/utils/browser.js
index 82820b3..ccc30d8 100644
--- a/lib/utils/browser.js
+++ b/lib/utils/browser.js
@@ -1,12 +1,12 @@
'use strict';
module.exports = {
- isOpera: function () {
+ isOpera: function() {
return global.navigator &&
/opera/i.test(global.navigator.userAgent);
}
-, isKonqueror: function () {
+, isKonqueror: function() {
return global.navigator &&
/konqueror/i.test(global.navigator.userAgent);
}
diff --git a/lib/utils/escape.js b/lib/utils/escape.js
index 743b9c6..8f2e60c 100644
--- a/lib/utils/escape.js
+++ b/lib/utils/escape.js
@@ -4,8 +4,8 @@ var JSON3 = require('json3');
// Some extra characters that Chrome gets wrong, and substitutes with
// something else on the wire.
-var extraEscapable = /[\x00-\x1f\ud800-\udfff\ufffe\uffff\u0300-\u0333\u033d-\u0346\u034a-\u034c\u0350-\u0352\u0357-\u0358\u035c-\u0362\u0374\u037e\u0387\u0591-\u05af\u05c4\u0610-\u0617\u0653-\u0654\u0657-\u065b\u065d-\u065e\u06df-\u06e2\u06eb-\u06ec\u0730\u0732-\u0733\u0735-\u0736\u073a\u073d\u073f-\u0741\u0743\u0745\u0747\u07eb-\u07f1\u0951\u0958-\u095f\u09dc-\u09dd\u09df\u0a33\u0a36\u0a59-\u0a5b\u0a5e\u0b5c-\u0b5d\u0e38-\u0e39\u0f43\u0f4d\u0f52\u0f57\u0f5c\u0f69\u0f72-\u0f76\u0f78\u0f [...]
- extraLookup;
+var extraEscapable = /[\x00-\x1f\ud800-\udfff\ufffe\uffff\u0300-\u0333\u033d-\u0346\u034a-\u034c\u0350-\u0352\u0357-\u0358\u035c-\u0362\u0374\u037e\u0387\u0591-\u05af\u05c4\u0610-\u0617\u0653-\u0654\u0657-\u065b\u065d-\u065e\u06df-\u06e2\u06eb-\u06ec\u0730\u0732-\u0733\u0735-\u0736\u073a\u073d\u073f-\u0741\u0743\u0745\u0747\u07eb-\u07f1\u0951\u0958-\u095f\u09dc-\u09dd\u09df\u0a33\u0a36\u0a59-\u0a5b\u0a5e\u0b5c-\u0b5d\u0e38-\u0e39\u0f43\u0f4d\u0f52\u0f57\u0f5c\u0f69\u0f72-\u0f76\u0f78\u0f [...]
+ , extraLookup;
// This may be quite slow, so let's delay until user actually uses bad
// characters.
@@ -13,11 +13,11 @@ var unrollLookup = function(escapable) {
var i;
var unrolled = {};
var c = [];
- for(i = 0; i < 65536; i++) {
+ for (i = 0; i < 65536; i++) {
c.push( String.fromCharCode(i) );
}
escapable.lastIndex = 0;
- c.join('').replace(escapable, function (a) {
+ c.join('').replace(escapable, function(a) {
unrolled[ a ] = '\\u' + ('0000' + a.charCodeAt(0).toString(16)).slice(-4);
return '';
});
diff --git a/lib/utils/iframe.js b/lib/utils/iframe.js
index 16ccec6..2b1d084 100644
--- a/lib/utils/iframe.js
+++ b/lib/utils/iframe.js
@@ -5,7 +5,7 @@ var eventUtils = require('./event')
, browser = require('./browser')
;
-var debug = function () {};
+var debug = function() {};
if (process.env.NODE_ENV !== 'production') {
debug = require('debug')('sockjs-client:utils:iframe');
}
@@ -20,7 +20,7 @@ module.exports = {
}
}
-, postMessage: function (type, data) {
+, postMessage: function(type, data) {
if (global.parent !== global) {
global.parent.postMessage(JSON3.stringify({
windowId: module.exports.currentWindowId
@@ -32,14 +32,16 @@ module.exports = {
}
}
-, createIframe: function (iframeUrl, errorCallback) {
+, createIframe: function(iframeUrl, errorCallback) {
var iframe = global.document.createElement('iframe');
var tref, unloadRef;
var unattach = function() {
debug('unattach');
clearTimeout(tref);
// Explorer had problems with that.
- try {iframe.onload = null;} catch (x) {}
+ try {
+ iframe.onload = null;
+ } catch (x) {}
iframe.onerror = null;
};
var cleanup = function() {
@@ -50,8 +52,8 @@ module.exports = {
// within iframe. Without the timeout it goes straight to
// onunload.
setTimeout(function() {
- if(iframe) {
- iframe.parentNode.removeChild(iframe);
+ if (iframe) {
+ iframe.parentNode.removeChild(iframe);
}
iframe = null;
}, 0);
@@ -81,7 +83,7 @@ module.exports = {
iframe.src = iframeUrl;
iframe.style.display = 'none';
iframe.style.position = 'absolute';
- iframe.onerror = function(){
+ iframe.onerror = function() {
onerror('onerror');
};
iframe.onload = function() {
@@ -89,31 +91,31 @@ module.exports = {
// `onload` is triggered before scripts on the iframe are
// executed. Give it few seconds to actually load stuff.
clearTimeout(tref);
- tref = setTimeout(function () {
+ tref = setTimeout(function() {
onerror('onload timeout');
}, 2000);
};
global.document.body.appendChild(iframe);
- tref = setTimeout(function(){
+ tref = setTimeout(function() {
onerror('timeout');
}, 15000);
unloadRef = eventUtils.unloadAdd(cleanup);
return {
- post: post,
- cleanup: cleanup,
- loaded: unattach
+ post: post
+ , cleanup: cleanup
+ , loaded: unattach
};
}
/* jshint undef: false, newcap: false */
/* eslint no-undef: 0, new-cap: 0 */
-, createHtmlfile: function (iframeUrl, errorCallback) {
+, createHtmlfile: function(iframeUrl, errorCallback) {
var doc = new global.ActiveXObject('htmlfile');
var tref, unloadRef;
var iframe;
var unattach = function() {
- clearTimeout(tref);
- iframe.onerror = null;
+ clearTimeout(tref);
+ iframe.onerror = null;
};
var cleanup = function() {
if (doc) {
@@ -154,17 +156,17 @@ module.exports = {
iframe = doc.createElement('iframe');
c.appendChild(iframe);
iframe.src = iframeUrl;
- iframe.onerror = function () {
+ iframe.onerror = function() {
onerror('onerror');
};
- tref = setTimeout(function(){
+ tref = setTimeout(function() {
onerror('timeout');
}, 15000);
unloadRef = eventUtils.unloadAdd(cleanup);
return {
- post: post,
- cleanup: cleanup,
- loaded: unattach
+ post: post
+ , cleanup: cleanup
+ , loaded: unattach
};
}
};
diff --git a/lib/utils/object.js b/lib/utils/object.js
index 415e9f7..261adfe 100644
--- a/lib/utils/object.js
+++ b/lib/utils/object.js
@@ -15,7 +15,7 @@ module.exports = {
source = arguments[i];
for (prop in source) {
if (Object.prototype.hasOwnProperty.call(source, prop)) {
- obj[prop] = source[prop];
+ obj[prop] = source[prop];
}
}
}
diff --git a/lib/utils/transport.js b/lib/utils/transport.js
index c4f5ef4..eee70ed 100644
--- a/lib/utils/transport.js
+++ b/lib/utils/transport.js
@@ -1,13 +1,13 @@
'use strict';
-var debug = function () {};
+var debug = function() {};
if (process.env.NODE_ENV !== 'production') {
debug = require('debug')('sockjs-client:utils:transport');
}
-module.exports = function (availableTransports) {
+module.exports = function(availableTransports) {
return {
- filterToEnabled: function (transportsWhitelist, info) {
+ filterToEnabled: function(transportsWhitelist, info) {
var transports = {
main: []
, facade: []
@@ -18,7 +18,7 @@ module.exports = function (availableTransports) {
transportsWhitelist = [transportsWhitelist];
}
- availableTransports.forEach(function (trans) {
+ availableTransports.forEach(function(trans) {
if (!trans) {
return;
}
diff --git a/lib/utils/url.js b/lib/utils/url.js
index e7696d4..4744f5d 100644
--- a/lib/utils/url.js
+++ b/lib/utils/url.js
@@ -2,13 +2,13 @@
var u = require('url');
-var debug = function () {};
+var debug = function() {};
if (process.env.NODE_ENV !== 'production') {
debug = require('debug')('sockjs-client:utils:url');
}
module.exports = {
- getOrigin: function (url) {
+ getOrigin: function(url) {
if (!url) {
return null;
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/sockjs-client.git
More information about the Pkg-javascript-commits
mailing list