Permalink
Browse files

code style

  • Loading branch information...
1 parent 68b0331 commit 941b05e74f71d82b8f63b97bf4e5651f5ab78b71 @brycekahle brycekahle committed Oct 20, 2014
View
@@ -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": ", "
+}
@@ -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
View
@@ -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();
};
@@ -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;
}
View
@@ -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();
};
View
@@ -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();
}
@@ -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);
View
@@ -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;
View
@@ -1,4 +1,5 @@
/* eslint-disable */
+/* jscs: disable */
'use strict';
// pulled specific shims from https://github.com/es-shims/es5-shim
@@ -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;
@@ -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);
});
@@ -13,7 +13,7 @@ function EventSourceTransport(transUrl) {
util.inherits(EventSourceTransport, AjaxBasedTransport);
-EventSourceTransport.enabled = function () {
+EventSourceTransport.enabled = function() {
return !!EventSourceDriver;
};
@@ -12,7 +12,7 @@ function HtmlFileTransport(transUrl) {
util.inherits(HtmlFileTransport, AjaxBasedTransport);
-HtmlFileTransport.enabled = function (info) {
+HtmlFileTransport.enabled = function(info) {
return HtmlfileReceiver.enabled && info.sameOrigin;
};
@@ -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);
};
@@ -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');
}
@@ -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();
};
Oops, something went wrong.

0 comments on commit 941b05e

Please sign in to comment.