Permalink
Browse files

clearing away JSHint warnings

  • Loading branch information...
1 parent 2c6e12c commit c1b4680fe4fa5007b45c1312914d1cbc498c0384 @mcandre mcandre committed May 10, 2013
@@ -44,7 +44,7 @@ parser.onEnd = function() {
var start = +new Date(),
nparsed = parser.write(buffer),
- duration = +new Date - start,
+ duration = +new Date() - start,
mbPerSec = (mb / (duration / 1000)).toFixed(2);
console.log(mbPerSec+' mb/sec');
View
@@ -8,8 +8,8 @@ var common = require('../test/common'),
server = http.createServer(function(req, res) {
if (req.method !== 'POST') {
- res.writeHead(200, {'content-type': 'text/plain'})
- res.end('Please POST a JSON payload to http://localhost:'+port+'/')
+ res.writeHead(200, {'content-type': 'text/plain'});
+ res.end('Please POST a JSON payload to http://localhost:'+port+'/');
return;
}
@@ -50,18 +50,18 @@ var request = http.request({
console.log('Status:', response.statusCode);
response.pipe(process.stdout);
response.on('end', function() {
- console.log('\n')
+ console.log('\n');
process.exit();
});
// response.on('data', function(chunk) {
// data += chunk.toString('utf8');
// });
// response.on('end', function() {
- // console.log('Response Data:')
+ // console.log('Response Data:');
// console.log(data);
// process.exit();
// });
-})
+});
request.write('{"numbers":[1,2,3,4,5],"nested":{"key":"value"}}');
request.end();
View
@@ -40,7 +40,7 @@ function IncomingForm(opts) {
this.openedFiles = [];
return this;
-};
+}
util.inherits(IncomingForm, EventEmitter);
exports.IncomingForm = IncomingForm;
@@ -245,8 +245,8 @@ IncomingForm.prototype._parseContentType = function() {
}
if (this.headers['content-type'].match(/multipart/i)) {
- var m;
- if (m = this.headers['content-type'].match(/boundary=(?:"([^"]+)"|([^;]+))/i)) {
+ var m = this.headers['content-type'].match(/boundary=(?:"([^"]+)"|([^;]+))/i);
+ if (m) {
this._initMultipart(m[1] || m[2]);
} else {
this._error(new Error('bad content-type header, no multipart boundary'));
@@ -334,9 +334,9 @@ IncomingForm.prototype._initMultipart = function(boundary) {
headerField = headerField.toLowerCase();
part.headers[headerField] = headerValue;
- var m;
+ var m = headerValue.match(/\bname="([^"]+)"/i);
if (headerField == 'content-disposition') {
- if (m = headerValue.match(/\bname="([^"]+)"/i)) {
+ if (m) {
part.name = m[1];
}
@@ -375,13 +375,13 @@ IncomingForm.prototype._initMultipart = function(boundary) {
can be divided by 4, it will result in a number of buytes that
can be divided vy 3.
*/
- var offset = parseInt(part.transferBuffer.length / 4) * 4;
- part.emit('data', new Buffer(part.transferBuffer.substring(0, offset), 'base64'))
+ var offset = parseInt(part.transferBuffer.length / 4, 10) * 4;
+ part.emit('data', new Buffer(part.transferBuffer.substring(0, offset), 'base64'));
part.transferBuffer = part.transferBuffer.substring(offset);
};
parser.onPartEnd = function() {
- part.emit('data', new Buffer(part.transferBuffer, 'base64'))
+ part.emit('data', new Buffer(part.transferBuffer, 'base64'));
part.emit('end');
};
break;
@@ -499,7 +499,7 @@ IncomingForm.prototype._initJSONencoded = function() {
parser.onField = function(key, val) {
self.emit('field', key, val);
- }
+ };
parser.onEnd = function() {
self.ended = true;
View
@@ -1,16 +1,16 @@
if (global.GENTLY) require = GENTLY.hijack(require);
-var Buffer = require('buffer').Buffer
+var Buffer = require('buffer').Buffer;
function JSONParser() {
this.data = new Buffer('');
this.bytesWritten = 0;
-};
+}
exports.JSONParser = JSONParser;
JSONParser.prototype.initWithLength = function(length) {
this.data = new Buffer(length);
-}
+};
JSONParser.prototype.write = function(buffer) {
if (this.data.length >= this.bytesWritten + buffer.length) {
@@ -20,16 +20,16 @@ JSONParser.prototype.write = function(buffer) {
}
this.bytesWritten += buffer.length;
return buffer.length;
-}
+};
JSONParser.prototype.end = function() {
try {
- var fields = JSON.parse(this.data.toString('utf8'))
+ var fields = JSON.parse(this.data.toString('utf8'));
for (var field in fields) {
this.onField(field, fields[field]);
}
} catch (e) {}
this.data = null;
this.onEnd();
-}
+};
@@ -46,7 +46,7 @@ function MultipartParser() {
this.index = null;
this.flags = 0;
-};
+}
exports.MultipartParser = MultipartParser;
MultipartParser.stateToString = function(stateNumber) {
@@ -214,7 +214,7 @@ MultipartParser.prototype.write = function(buffer) {
case S.PART_DATA:
prevIndex = index;
- if (index == 0) {
+ if (index === 0) {
// boyer-moore derrived algorithm to safely skip non-boundary data
i += boundaryEnd;
while (i < bufferLength && !(buffer[i] in boundaryChars)) {
@@ -226,7 +226,7 @@ MultipartParser.prototype.write = function(buffer) {
if (index < boundary.length) {
if (boundary[index] == c) {
- if (index == 0) {
+ if (index === 0) {
dataCallback('partData', true);
}
index++;
@@ -310,7 +310,7 @@ MultipartParser.prototype.end = function() {
self[callbackSymbol]();
}
};
- if ((this.state == S.HEADER_FIELD_START && this.index == 0) ||
+ if ((this.state == S.HEADER_FIELD_START && this.index === 0) ||
(this.state == S.PART_DATA && this.index == this.boundary.length)) {
callback(this, 'partEnd');
callback(this, 'end');
@@ -7,7 +7,7 @@ var querystring = require('querystring');
function QuerystringParser(maxKeys) {
this.maxKeys = maxKeys;
this.buffer = '';
-};
+}
exports.QuerystringParser = QuerystringParser;
QuerystringParser.prototype.write = function(buffer) {
@@ -5,7 +5,7 @@ function expect(filename) {
{type: 'field', name: 'title', value: 'Weird filename'},
{type: 'file', name: 'upload', filename: filename, fixture: properFilename},
];
-};
+}
var webkit = " ? % * | \" < > . ? ; ' @ # $ ^ & ( ) - _ = + { } [ ] ` ~.txt";
var ffOrIe = " ? % * | \" < > . ☃ ; ' @ # $ ^ & ( ) - _ = + { } [ ] ` ~.txt";
@@ -1,4 +1,4 @@
-exports['rfc1867'] =
+exports.rfc1867 =
{ boundary: 'AaB03x',
raw:
'--AaB03x\r\n'+
@@ -54,7 +54,7 @@ exports['noTrailing\r\n'] =
]
};
-exports['emptyHeader'] =
+exports.emptyHeader =
{ boundary: 'AaB03x',
raw:
'--AaB03x\r\n'+
@@ -36,7 +36,7 @@ function testNext(fixtures) {
if (!fixture) return server.close();
var name = fixture.name;
- var fixture = fixture.fixture;
+ fixture = fixture.fixture;
uploadFixture(name, function(err, parts) {
if (err) throw err;
@@ -55,7 +55,7 @@ function testNext(fixtures) {
testNext(fixtures);
});
-};
+}
function uploadFixture(name, cb) {
server.once('request', function(req, res) {
@@ -33,7 +33,7 @@ Object.keys(fixtures).forEach(function(name) {
parser.onHeaderValue = function(b, start, end) {
headerValue += b.toString('ascii', start, end);
- }
+ };
parser.onHeaderEnd = function() {
part.headers[headerField] = headerValue;
@@ -44,11 +44,11 @@ Object.keys(fixtures).forEach(function(name) {
parser.onPartData = function(b, start, end) {
var str = b.toString('ascii', start, end);
part.data += b.slice(start, end);
- }
+ };
parser.onEnd = function() {
endCalled = true;
- }
+ };
buffer.write(fixture.raw, 'binary', 0);
View
@@ -1 +1 @@
-require('urun')(__dirname)
+require('urun')(__dirname);
@@ -38,7 +38,7 @@ var server = http.createServer(function(req, res) {
var parts = [
{'Content-Disposition': 'form-data; name="foo"', 'body': 'bar'}
- ]
+ ];
var req = request({method: 'POST', url: url, multipart: parts}, function(e, res, body) {
var obj = JSON.parse(body);
@@ -4,7 +4,7 @@ var assert = common.assert;
var File = common.require('file');
var file;
-var now = new Date;
+var now = new Date();
test('IncomingForm', {
before: function() {
file = new File({
@@ -15,7 +15,7 @@ test('IncomingForm', {
lastModifiedDate: now,
filename: 'cat.png',
mime: 'image/png'
- })
+ });
},
'#toJSON()': function() {
@@ -30,4 +30,4 @@ test('IncomingForm', {
assert.equal(now, obj.mtime);
assert.equal(len, 8);
}
-});
+});
@@ -47,13 +47,13 @@ test('IncomingForm', {
var ext = path.extname(form._uploadPath('fine.jpg?foo=bar'));
assert.equal(ext, '.jpg');
- var ext = path.extname(form._uploadPath('fine?foo=bar'));
+ ext = path.extname(form._uploadPath('fine?foo=bar'));
assert.equal(ext, '');
- var ext = path.extname(form._uploadPath('super.cr2+dsad'));
+ ext = path.extname(form._uploadPath('super.cr2+dsad'));
assert.equal(ext, '.cr2');
- var ext = path.extname(form._uploadPath('super.bar'));
+ ext = path.extname(form._uploadPath('super.bar'));
assert.equal(ext, '.bar');
},
});

0 comments on commit c1b4680

Please sign in to comment.