Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[minor] Minor `jshint`ing

  • Loading branch information...
commit 0a824aa6cd7943192b1da2dc4947b4ca048e74f7 1 parent 1c9907d
@mmalecki mmalecki authored
View
4 examples/http.js
@@ -20,12 +20,12 @@ var server = http.createServer(function (req, res) {
});
router.get(/foo/, function () {
- this.res.writeHead(200, { 'Content-Type': 'text/plain' })
+ this.res.writeHead(200, { 'Content-Type': 'text/plain' });
this.res.end('hello world\n');
});
router.post(/foo/, function () {
- this.res.writeHead(200, { 'Content-Type': 'application/json' })
+ this.res.writeHead(200, { 'Content-Type': 'application/json' });
this.res.end(JSON.stringify(this.req.body));
});
View
10 lib/director/http/index.js
@@ -10,7 +10,7 @@ var events = require('events'),
exports.methods = require('./methods');
Object.keys(responses).forEach(function (name) {
exports[name] = responses[name];
-})
+});
//
// ### function Router (routes)
@@ -52,7 +52,7 @@ Router.prototype.configure = function (options) {
this.stream = options.stream || false;
return director.Router.prototype.configure.call(this, options);
-}
+};
//
// ### function on (method, path, route)
@@ -112,7 +112,7 @@ Router.prototype.dispatch = function (req, res, callback) {
}
if (!fns || fns.length === 0) {
- error = new exports.NotFound('Could not find path: ' + req.url)
+ error = new exports.NotFound('Could not find path: ' + req.url);
if (typeof this.notfound === 'function') {
this.notfound.call(thisArg, callback);
}
@@ -127,7 +127,7 @@ Router.prototype.dispatch = function (req, res, callback) {
}
runlist = this.runlist(fns);
- stream = this.stream || runlist.some(function (fn) { return fn.stream === true });
+ stream = this.stream || runlist.some(function (fn) { return fn.stream === true; });
function parseAndInvoke() {
error = self.parse(req);
@@ -152,7 +152,7 @@ Router.prototype.dispatch = function (req, res, callback) {
// If the `http.ServerRequest` is still readable, then await
// the end event and then continue
//
- req.once('end', parseAndInvoke)
+ req.once('end', parseAndInvoke);
}
else {
//
View
40 lib/director/router.js
@@ -29,7 +29,7 @@ function _every (arr, iterator) {
return;
}
}
-};
+}
//
// Helper function for performing an asynchronous every
@@ -58,7 +58,7 @@ function _asyncEverySeries (arr, iterator, callback) {
}
});
})();
-};
+}
//
// Helper function for expanding "named" matches
@@ -77,7 +77,7 @@ function paramifyString(str, params, mod) {
for (var param in params) {
if (params.hasOwnProperty(param)) {
mod = params[param](str);
- if (mod !== str) { break }
+ if (mod !== str) { break; }
}
}
@@ -369,7 +369,7 @@ Router.prototype.invoke = function (fns, thisArg, callback) {
return fn.apply(thisArg, fns.captures || null);
}
else if (typeof fn === 'string' && self.resource) {
- self.resource[fn].apply(thisArg, fns.captures || null)
+ self.resource[fn].apply(thisArg, fns.captures || null);
}
});
}
@@ -457,8 +457,8 @@ Router.prototype.traverse = function (method, path, routes, regexp) {
next.captures = match.slice(1);
if (this.recurse && routes === this.routes) {
- next.push([routes['before'], routes['on']].filter(Boolean));
- next.after = next.after.concat([routes['after']].filter(Boolean))
+ next.push([routes.before, routes.on].filter(Boolean));
+ next.after = next.after.concat([routes.after].filter(Boolean));
}
return next;
@@ -491,7 +491,7 @@ Router.prototype.traverse = function (method, path, routes, regexp) {
if (routes === this.routes) {
fns.push([routes['before'], routes['on']].filter(Boolean));
- next.after = next.after.concat([routes['after']].filter(Boolean))
+ next.after = next.after.concat([routes['after']].filter(Boolean));
}
}
@@ -563,7 +563,7 @@ Router.prototype.insert = function (method, path, route, parent) {
parent[method] = [parent[method], route];
return;
case 'object':
- parent[method].push(route)
+ parent[method].push(route);
return;
case 'undefined':
parent[method] = route;
@@ -589,7 +589,7 @@ Router.prototype.insert = function (method, path, route, parent) {
parent[part][method] = [parent[part][method], route];
return;
case 'object':
- parent[part][method].push(route)
+ parent[part][method].push(route);
return;
case 'undefined':
parent[part][method] = route;
@@ -618,17 +618,19 @@ Router.prototype.extend = function(methods) {
len = methods.length,
i;
+ function extend(method) {
+ self._methods[method] = true;
+ self[method] = function () {
+ var extra = arguments.length === 1
+ ? [method, '']
+ : [method];
+
+ self.on.apply(self, extra.concat(Array.prototype.slice.call(arguments)));
+ };
+ }
+
for (i = 0; i < len; i++) {
- (function(method) {
- self._methods[method] = true;
- self[method] = function () {
- var extra = arguments.length === 1
- ? [method, '']
- : [method];
-
- self.on.apply(self, extra.concat(Array.prototype.slice.call(arguments)));
- };
- })(methods[i]);
+ extend(methods[i]);
}
};
Please sign in to comment.
Something went wrong with that request. Please try again.