Skip to content
This repository
Browse code

[minor] Minor `jshint`ing

  • Loading branch information...
commit 0a824aa6cd7943192b1da2dc4947b4ca048e74f7 1 parent 1c9907d
authored
4  examples/http.js
@@ -20,12 +20,12 @@ var server = http.createServer(function (req, res) {
20 20
 });
21 21
 
22 22
 router.get(/foo/, function () {
23  
-  this.res.writeHead(200, { 'Content-Type': 'text/plain' })
  23
+  this.res.writeHead(200, { 'Content-Type': 'text/plain' });
24 24
   this.res.end('hello world\n');
25 25
 });
26 26
 
27 27
 router.post(/foo/, function () {
28  
-  this.res.writeHead(200, { 'Content-Type': 'application/json' })
  28
+  this.res.writeHead(200, { 'Content-Type': 'application/json' });
29 29
   this.res.end(JSON.stringify(this.req.body));
30 30
 });
31 31
 
10  lib/director/http/index.js
@@ -10,7 +10,7 @@ var events = require('events'),
10 10
 exports.methods   = require('./methods');
11 11
 Object.keys(responses).forEach(function (name) {
12 12
   exports[name] = responses[name];
13  
-})
  13
+});
14 14
 
15 15
 //
16 16
 // ### function Router (routes)
@@ -52,7 +52,7 @@ Router.prototype.configure = function (options) {
52 52
   this.stream = options.stream || false;
53 53
 
54 54
   return director.Router.prototype.configure.call(this, options);
55  
-}
  55
+};
56 56
 
57 57
 //
58 58
 // ### function on (method, path, route)
@@ -112,7 +112,7 @@ Router.prototype.dispatch = function (req, res, callback) {
112 112
   }
113 113
 
114 114
   if (!fns || fns.length === 0) {
115  
-    error = new exports.NotFound('Could not find path: ' + req.url)
  115
+    error = new exports.NotFound('Could not find path: ' + req.url);
116 116
     if (typeof this.notfound === 'function') {
117 117
       this.notfound.call(thisArg, callback);
118 118
     }
@@ -127,7 +127,7 @@ Router.prototype.dispatch = function (req, res, callback) {
127 127
   }
128 128
 
129 129
   runlist = this.runlist(fns);
130  
-  stream  = this.stream || runlist.some(function (fn) { return fn.stream === true });
  130
+  stream  = this.stream || runlist.some(function (fn) { return fn.stream === true; });
131 131
 
132 132
   function parseAndInvoke() {
133 133
     error = self.parse(req);
@@ -152,7 +152,7 @@ Router.prototype.dispatch = function (req, res, callback) {
152 152
       // If the `http.ServerRequest` is still readable, then await
153 153
       // the end event and then continue
154 154
       //
155  
-      req.once('end', parseAndInvoke)
  155
+      req.once('end', parseAndInvoke);
156 156
     }
157 157
     else {
158 158
       //
40  lib/director/router.js
@@ -29,7 +29,7 @@ function _every (arr, iterator) {
29 29
       return;
30 30
     }
31 31
   }
32  
-};
  32
+}
33 33
 
34 34
 //
35 35
 // Helper function for performing an asynchronous every
@@ -58,7 +58,7 @@ function _asyncEverySeries (arr, iterator, callback) {
58 58
       }
59 59
     });
60 60
   })();
61  
-};
  61
+}
62 62
 
63 63
 //
64 64
 // Helper function for expanding "named" matches
@@ -77,7 +77,7 @@ function paramifyString(str, params, mod) {
77 77
   for (var param in params) {
78 78
     if (params.hasOwnProperty(param)) {
79 79
       mod = params[param](str);
80  
-      if (mod !== str) { break }
  80
+      if (mod !== str) { break; }
81 81
     }
82 82
   }
83 83
 
@@ -369,7 +369,7 @@ Router.prototype.invoke = function (fns, thisArg, callback) {
369 369
         return fn.apply(thisArg, fns.captures || null);
370 370
       }
371 371
       else if (typeof fn === 'string' && self.resource) {
372  
-        self.resource[fn].apply(thisArg, fns.captures || null)
  372
+        self.resource[fn].apply(thisArg, fns.captures || null);
373 373
       }
374 374
     });
375 375
   }
@@ -457,8 +457,8 @@ Router.prototype.traverse = function (method, path, routes, regexp) {
457 457
         next.captures = match.slice(1);
458 458
 
459 459
         if (this.recurse && routes === this.routes) {
460  
-          next.push([routes['before'], routes['on']].filter(Boolean));
461  
-          next.after = next.after.concat([routes['after']].filter(Boolean))
  460
+          next.push([routes.before, routes.on].filter(Boolean));
  461
+          next.after = next.after.concat([routes.after].filter(Boolean));
462 462
         }
463 463
 
464 464
         return next;
@@ -491,7 +491,7 @@ Router.prototype.traverse = function (method, path, routes, regexp) {
491 491
 
492 492
           if (routes === this.routes) {
493 493
             fns.push([routes['before'], routes['on']].filter(Boolean));
494  
-            next.after = next.after.concat([routes['after']].filter(Boolean))
  494
+            next.after = next.after.concat([routes['after']].filter(Boolean));
495 495
           }
496 496
         }
497 497
 
@@ -563,7 +563,7 @@ Router.prototype.insert = function (method, path, route, parent) {
563 563
         parent[method] = [parent[method], route];
564 564
         return;
565 565
       case 'object':
566  
-        parent[method].push(route)
  566
+        parent[method].push(route);
567 567
         return;
568 568
       case 'undefined':
569 569
         parent[method] = route;
@@ -589,7 +589,7 @@ Router.prototype.insert = function (method, path, route, parent) {
589 589
         parent[part][method] = [parent[part][method], route];
590 590
         return;
591 591
       case 'object':
592  
-        parent[part][method].push(route)
  592
+        parent[part][method].push(route);
593 593
         return;
594 594
       case 'undefined':
595 595
         parent[part][method] = route;
@@ -618,17 +618,19 @@ Router.prototype.extend = function(methods) {
618 618
       len = methods.length,
619 619
       i;
620 620
 
  621
+  function extend(method) {
  622
+    self._methods[method] = true;
  623
+    self[method] = function () {
  624
+      var extra = arguments.length === 1
  625
+        ? [method, '']
  626
+        : [method];
  627
+
  628
+      self.on.apply(self, extra.concat(Array.prototype.slice.call(arguments)));
  629
+    };
  630
+  }
  631
+
621 632
   for (i = 0; i < len; i++) {
622  
-    (function(method) {
623  
-      self._methods[method] = true;
624  
-      self[method] = function () {
625  
-        var extra = arguments.length === 1
626  
-          ? [method, '']
627  
-          : [method];
628  
-
629  
-        self.on.apply(self, extra.concat(Array.prototype.slice.call(arguments)));
630  
-      };
631  
-    })(methods[i]);
  633
+    extend(methods[i]);
632 634
   }
633 635
 };
634 636
 

0 notes on commit 0a824aa

Please sign in to comment.
Something went wrong with that request. Please try again.