Skip to content

Commit 29ac215

Browse files
committed
[Refactor] JSHint: Missing semicolons, spaces, unused variables, eqeqeq, indentation, etc.
1 parent dab083f commit 29ac215

File tree

4 files changed

+16
-17
lines changed

4 files changed

+16
-17
lines changed

lib/index.js

+5-6
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ var cluster = require('cluster')
99
// Starts either a server or client depending on whether this is a master or
1010
// worker cluster process
1111
exports = module.exports = function(options) {
12-
var _this = this;
1312
var port = options.port || process.env.PORT || 3000;
1413

1514
var server = require('./server');
@@ -19,7 +18,7 @@ exports = module.exports = function(options) {
1918

2019
if(cluster.isMaster) {
2120

22-
for (i = 0; i < (options.workers || os.cpus().length); i += 1) {
21+
for (var i = 0; i < (options.workers || os.cpus().length); i += 1) {
2322
console.log('starting worker thread #' + i);
2423
cluster.fork();
2524
}
@@ -43,8 +42,8 @@ exports = module.exports = function(options) {
4342
};
4443

4544
fs.readdirSync(__dirname + '/plugins').forEach(function(filename){
46-
if (!/\.js$/.test(filename)) return;
47-
var name = basename(filename, '.js');
48-
function load(){ return require('./plugins/' + name); }
49-
Object.defineProperty(exports, name, {value: load});
45+
if (!/\.js$/.test(filename)) return;
46+
var name = basename(filename, '.js');
47+
function load(){ return require('./plugins/' + name); }
48+
Object.defineProperty(exports, name, {value: load});
5049
});

lib/plugins/s3HtmlCache.js

+4-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@ var s3 = new (require('aws-sdk')).S3({params:{Bucket: process.env.S3_BUCKET_NAME
44
module.exports = {
55
init: function() {
66
this.cache = cache_manager.caching({
7-
store: s3_cache, ttl: 10/*seconds*/
7+
store: s3_cache,
8+
ttl: 10/*seconds*/
89
});
910
},
1011

@@ -27,7 +28,7 @@ module.exports = {
2728
this.cache.set(context.request.url, context.response.documentHTML);
2829
next();
2930
}
30-
}
31+
};
3132

3233

3334
var s3_cache = {
@@ -56,4 +57,4 @@ var s3_cache = {
5657
request.send();
5758
}
5859
}
59-
}
60+
};

lib/server.js

+6-7
Original file line numberDiff line numberDiff line change
@@ -50,28 +50,28 @@ server._pluginEvent = function(methodName, args, callback) {
5050
} else {
5151
next();
5252
}
53-
}
53+
};
5454

5555
args.push(next);
5656
next();
5757
};
5858

5959
server.createPhantom = function() {
6060
var _this = this;
61-
console.log('starting phantom')
61+
console.log('starting phantom');
6262

6363
phantom.create( "--load-images=false", "--ignore-ssl-errors=true", "--ssl-protocol=tlsv1", {
6464
binary: require('phantomjs').path,
6565
onExit: function() {
6666
_this.phantom = null;
67-
console.log('phantom crashed, restarting...')
67+
console.log('phantom crashed, restarting...');
6868
process.nextTick(_.bind(_this.createPhantom, _this));
6969
}
7070
}, _.bind(this.onPhantomCreate, this));
7171
};
7272

7373
server.onPhantomCreate = function(phantom) {
74-
console.log('started phantom')
74+
console.log('started phantom');
7575
this.phantom = phantom;
7676
this.phantom.id = Math.random().toString(36);
7777
};
@@ -161,7 +161,7 @@ server.onResourceRequestedCallback = function (req, res, requestData) {
161161
// Decrement the number of pending requests left to download after a resource
162162
// is downloaded
163163
server.onResourceReceived = function (req, res, response) {
164-
req.prerender.lastResourceReceived = new Date;
164+
req.prerender.lastResourceReceived = new Date();
165165

166166
//sometimes on redirects, phantomjs doesnt fire the 'end' stage of the original request, so we need to check it here
167167
if(util.normalizeUrl(req.prerender.url) === util.normalizeUrl(response.url) && response.status >= 300 && response.status <= 399) {
@@ -246,7 +246,7 @@ server.evaluateJavascriptOnPage = function(req, res) {
246246
req.prerender.page.evaluate(this.javascriptToExecuteOnPage, function(obj) {
247247
// Update the evaluated HTML
248248
req.prerender.documentHTML = obj.html;
249-
req.prerender.lastJavascriptExecution = new Date;
249+
req.prerender.lastJavascriptExecution = new Date();
250250

251251
if(!obj.shouldWaitForPrerenderReady || (obj.shouldWaitForPrerenderReady && obj.prerenderReady)) {
252252
clearInterval(req.prerender.timeoutChecker);
@@ -293,7 +293,6 @@ server.javascriptToExecuteOnPage = function() {
293293

294294
// Called when we're done evaluating the javascript on the page
295295
server.onPageEvaluate = function(req, res) {
296-
var _this = this;
297296

298297
if(req.prerender.stage >= 2) return;
299298

lib/util.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@ util.getUrl = function (req) {
2929
}
3030

3131
var newUrl = url.format(parts);
32-
if(newUrl[0] == '/') newUrl = newUrl.substr(1);
32+
if(newUrl[0] === '/') newUrl = newUrl.substr(1);
3333
return newUrl;
3434
};

0 commit comments

Comments
 (0)