Skip to content

Commit 6cae0b8

Browse files
Merge pull request #785 from fintura/master
Add "use strict", semicolons, whitespace & code cleanup, remove util.print.
2 parents b53ebb2 + 01a3773 commit 6cae0b8

39 files changed

+130
-62
lines changed

benches/buffer_bench.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1+
'use strict';
2+
13
var source = new Buffer(100),
24
dest = new Buffer(100), i, j, k, tmp, count = 1000000, bytes = 100;
3-
5+
46
for (i = 99 ; i >= 0 ; i--) {
57
source[i] = 120;
68
}

benches/hiredis_parser.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
var Parser = require('../lib/parser/hiredis').Parser;
24
var assert = require('assert');
35

benches/re_sub_test.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
var client = require('../index').createClient()
24
, client2 = require('../index').createClient()
35
, assert = require('assert');

benches/reconnect_test.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
var redis = require("../index").createClient(null, null, {
24
// max_attempts: 4
35
});

benches/stress/codec.js

+2-10
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,8 @@
1+
'use strict';
2+
13
var json = {
24
encode: JSON.stringify,
35
decode: JSON.parse
46
};
57

6-
var MsgPack = require('node-msgpack');
7-
msgpack = {
8-
encode: MsgPack.pack,
9-
decode: function(str) { return MsgPack.unpack(new Buffer(str)); }
10-
};
11-
12-
bison = require('bison');
13-
148
module.exports = json;
15-
//module.exports = msgpack;
16-
//module.exports = bison;

benches/stress/speed/speed.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
var msgpack = require('node-msgpack');
24
var bison = require('bison');
35
var codec = {

benches/sub_quit_test.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
var client = require("redis").createClient(),
24
client2 = require("redis").createClient();
35

connection_breaker.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
var net = require('net');
24

35
var proxyPort = 6379;

diff_multi_bench_output.js

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
#!/usr/bin/env node
22

3+
'use strict';
4+
35
var colors = require('colors'),
46
fs = require('fs'),
57
_ = require('underscore'),
@@ -35,8 +37,8 @@ before_lines.forEach(function(b, i) {
3537
return;
3638
}
3739

38-
b_words = b.split(' ').filter(is_whitespace);
39-
a_words = a.split(' ').filter(is_whitespace);
40+
var b_words = b.split(' ').filter(is_whitespace);
41+
var a_words = a.split(' ').filter(is_whitespace);
4042

4143
var ops =
4244
[b_words, a_words]
@@ -47,7 +49,7 @@ before_lines.forEach(function(b, i) {
4749
var isNaN = !num && num !== 0;
4850
return !isNaN;
4951
});
50-
if (ops.length != 2) return
52+
if (ops.length !== 2) return;
5153

5254
var delta = ops[1] - ops[0];
5355
var pct = ((delta / ops[0]) * 100).toPrecision(3);
@@ -58,7 +60,7 @@ before_lines.forEach(function(b, i) {
5860
pct = humanize_diff(pct, '%');
5961
console.log(
6062
// name of test
61-
command_name(a_words) == command_name(b_words)
63+
command_name(a_words) === command_name(b_words)
6264
? command_name(a_words) + ':'
6365
: '404:',
6466
// results of test

examples/auth.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
var redis = require("redis"),
24
client = redis.createClient();
35

examples/backpressure_drain.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
var redis = require("../index"),
24
client = redis.createClient(null, null, {
35
command_queue_high_water: 5,

examples/eval.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
var redis = require("../index"),
24
client = redis.createClient();
35

examples/extend.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
var redis = require("redis"),
24
client = redis.createClient();
35

@@ -14,7 +16,7 @@ redis.RedisClient.prototype.parse_info = function (callback) {
1416
obj[parts[0]] = parts[1];
1517
}
1618
});
17-
callback(obj)
19+
callback(obj);
1820
});
1921
};
2022

examples/file.js

+5-3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
// Read a file from disk, store it in Redis, then read it back from Redis.
24

35
var redis = require("redis"),
@@ -11,17 +13,17 @@ var redis = require("redis"),
1113

1214
// Read a file from fs, store it in Redis, get it back from Redis, write it back to fs.
1315
fs.readFile(filename, function (err, data) {
14-
if (err) throw err
16+
if (err) throw err;
1517
console.log("Read " + data.length + " bytes from filesystem.");
16-
18+
1719
client.set(filename, data, redis.print); // set entire file
1820
client.get(filename, function (err, reply) { // get entire file
1921
if (err) {
2022
console.log("Get error: " + err);
2123
} else {
2224
fs.writeFile("duplicate_" + filename, reply, function (err) {
2325
if (err) {
24-
console.log("Error on write: " + err)
26+
console.log("Error on write: " + err);
2527
} else {
2628
console.log("File written.");
2729
}

examples/mget.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
var client = require("redis").createClient();
24

35
client.mget(["sessions started", "sessions started", "foo"], function (err, res) {

examples/monitor.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
var client = require("../index").createClient(),
24
util = require("util");
35

examples/multi.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
var redis = require("redis"),
24
client = redis.createClient(), set_size = 20;
35

examples/multi2.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
var redis = require("redis"),
24
client = redis.createClient(), multi;
35

examples/psubscribe.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
var redis = require("redis"),
24
client1 = redis.createClient(),
35
client2 = redis.createClient(),

examples/pub_sub.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
var redis = require("redis"),
24
client1 = redis.createClient(), msg_count = 0,
35
client2 = redis.createClient();

examples/scan.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
var redis = require("redis"),
24
client = redis.createClient();
35

examples/simple.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
var redis = require("redis"),
24
client = redis.createClient();
35

examples/sort.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
var redis = require("redis"),
24
client = redis.createClient();
35

examples/subqueries.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
// Sending commands in response to other commands.
24
// This example runs "type" against every key in the database
35
//

examples/subquery.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
var client = require("redis").createClient();
24

35
function print_results(obj) {
@@ -7,7 +9,7 @@ function print_results(obj) {
79
// build a map of all keys and their types
810
client.keys("*", function (err, all_keys) {
911
var key_types = {};
10-
12+
1113
all_keys.forEach(function (key, pos) { // use second arg of forEach to get pos
1214
client.type(key, function (err, type) {
1315
key_types[key] = type;

examples/unix_socket.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
'use strict';
2+
13
var redis = require("redis"),
24
client = redis.createClient("/tmp/redis.sock"),
35
profiler = require("v8-profiler");
46

57
client.on("connect", function () {
6-
console.log("Got Unix socket connection.")
8+
console.log("Got Unix socket connection.");
79
});
810

911
client.on("error", function (err) {

examples/web_server.js

+4-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
// A simple web server that generates dyanmic content based on responses from Redis
24

35
var http = require("http"), server,
@@ -7,9 +9,9 @@ server = http.createServer(function (request, response) {
79
response.writeHead(200, {
810
"Content-Type": "text/plain"
911
});
10-
12+
1113
var redis_info, total_requests;
12-
14+
1315
redis_client.info(function (err, reply) {
1416
redis_info = reply; // stash response in outer scope
1517
});

generate_commands.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
var http = require("http"),
24
fs = require("fs");
35

index.js

+7-5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
/*global Buffer require exports console setTimeout */
24

35
var net = require("net"),
@@ -15,10 +17,10 @@ var net = require("net"),
1517
// can set this to true to enable for all connections
1618
exports.debug_mode = false;
1719

18-
var arraySlice = Array.prototype.slice
20+
var arraySlice = Array.prototype.slice;
1921
function trace() {
2022
if (!exports.debug_mode) return;
21-
console.log.apply(null, arraySlice.call(arguments))
23+
console.log.apply(null, arraySlice.call(arguments));
2224
}
2325

2426
// hiredis might not be installed
@@ -139,7 +141,7 @@ RedisClient.prototype.unref = function () {
139141
trace("Not connected yet, will unref later");
140142
this.once("connect", function () {
141143
this.unref();
142-
})
144+
});
143145
}
144146
};
145147

@@ -217,7 +219,7 @@ RedisClient.prototype.do_auth = function () {
217219
}, 2000); // TODO - magic number alert
218220
return;
219221
} else if (err.toString().match("no password is set")) {
220-
console.log("Warning: Redis server does not require a password, but a password was supplied.")
222+
console.log("Warning: Redis server does not require a password, but a password was supplied.");
221223
err = null;
222224
res = "OK";
223225
} else {
@@ -1263,7 +1265,7 @@ var createClient_unix = function(path, options){
12631265
redis_client.address = path;
12641266

12651267
return redis_client;
1266-
}
1268+
};
12671269

12681270
var createClient_tcp = function (port_arg, host_arg, options) {
12691271
var cnxOptions = {

lib/commands.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
// This file was generated by ./generate_commands.js on Wed Apr 23 2014 14:51:21 GMT-0700 (PDT)
24
module.exports = [
35
"append",

lib/parser/hiredis.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
var events = require("events"),
24
util = require("../util"),
35
hiredis = require("hiredis");

lib/parser/javascript.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
var events = require("events"),
24
util = require("../util");
35

lib/queue.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
// Queue class adapted from Tim Caswell's pattern library
24
// http://github.com/creationix/pattern/blob/master/lib/pattern/queue.js
35

lib/to_array.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
function to_array(args) {
24
var len = args.length,
35
arr = new Array(len), i;

lib/util.js

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
'use strict';
2+
13
// Support for very old versions of node where the module was called "sys". At some point, we should abandon this.
24

35
var util;

0 commit comments

Comments
 (0)