Permalink
Browse files

Go back to traditional coding style

Comma first doesn't seem light it has caught on, so this commit changes
the projects coding style back to the Google-ish standard formatting.
  • Loading branch information...
1 parent 0e54a07 commit ed4e2972cd5a80baa9c758b59800f5a912c04959 @felixge committed Oct 18, 2010
View
@@ -34,9 +34,9 @@ Note: Formidable requires [gently](http://github.com/felixge/node-gently) to run
Parse an incoming file upload.
- var formidable = require('formidable')
- , http = require('http')
- , sys = require('sys');
+ var formidable = require('formidable'),
+ http = require('http')
@mscdex

mscdex Oct 20, 2010

Shouldn't there be a comma at the end here? :-)

@dvv

dvv Oct 20, 2010

This is just readme :)

+ sys = require('sys');
http.createServer(function(req, res) {
if (req.url == '/upload' && req.method.toLowerCase() == 'post') {
@@ -52,13 +52,13 @@ Parse an incoming file upload.
// show a file upload form
res.writeHead(200, {'content-type': 'text/html'});
- res.end
- ( '<form action="/upload" enctype="multipart/form-data" method="post">'
- + '<input type="text" name="title"><br>'
- + '<input type="file" name="upload" multiple="multiple"><br>'
- + '<input type="submit" value="Upload">'
- + '</form>'
- );
+ res.end(
+ '<form action="/upload" enctype="multipart/form-data" method="post">'+
+ '<input type="text" name="title"><br>'+
+ '<input type="file" name="upload" multiple="multiple"><br>'+
+ '<input type="submit" value="Upload">'+
+ '</form>'
+ );
});
## API
@@ -1,18 +1,18 @@
require('../test/common');
-var multipartParser = require('formidable/multipart_parser')
- , MultipartParser = multipartParser.MultipartParser
- , parser = new MultipartParser()
- , Buffer = require('buffer').Buffer
- , boundary = '-----------------------------168072824752491622650073'
- , mb = 100
- , buffer = createMultipartBuffer(boundary, mb * 1024 * 1024)
- , callbacks =
- { partBegin: -1
- , partEnd: -1
- , headerField: -1
- , headerValue: -1
- , partData: -1
- , end: -1
+var multipartParser = require('formidable/multipart_parser'),
+ MultipartParser = multipartParser.MultipartParser,
+ parser = new MultipartParser(),
+ Buffer = require('buffer').Buffer,
+ boundary = '-----------------------------168072824752491622650073',
+ mb = 100,
+ buffer = createMultipartBuffer(boundary, mb * 1024 * 1024),
+ callbacks =
+ { partBegin: -1,
+ partEnd: -1,
+ headerField: -1,
+ headerValue: -1,
+ partData: -1,
+ end: -1,
};
@@ -41,10 +41,10 @@ parser.onEnd = function() {
callbacks.end++;
};
-var start = +new Date()
- , nparsed = parser.write(buffer)
- , duration = +new Date - start
- , mbPerSec = (mb / (duration / 1000)).toFixed(2);
+var start = +new Date(),
+ nparsed = parser.write(buffer),
+ duration = +new Date - start,
+ mbPerSec = (mb / (duration / 1000)).toFixed(2);
p(mbPerSec+' mb/sec');
@@ -63,4 +63,8 @@ function createMultipartBuffer(boundary, size) {
return buffer;
}
-assert.callbacks(callbacks);
+process.on('exit', function() {
+ for (var k in callbacks) {
+ assert.equal(0, callbacks[k], k+' count off by '+callbacks[k]);
+ }
+});
View
@@ -1,22 +1,22 @@
require('../test/common');
-var http = require('http')
- , util = require('util')
- , formidable = require('formidable')
- , server;
+var http = require('http'),
+ util = require('util'),
+ formidable = require('formidable'),
+ server;
server = http.createServer(function(req, res) {
if (req.url == '/') {
res.writeHead(200, {'content-type': 'text/html'});
- res.end
- ( '<form action="/post" method="post">'
- + '<input type="text" name="title"><br>'
- + '<input type="text" name="data[foo][]"><br>'
- + '<input type="submit" value="Submit">'
- + '</form>'
- )
+ res.end(
+ '<form action="/post" method="post">'+
+ '<input type="text" name="title"><br>'+
+ '<input type="text" name="data[foo][]"><br>'+
+ '<input type="submit" value="Submit">'+
+ '</form>'
+ );
} else if (req.url == '/post') {
- var form = new formidable.IncomingForm()
- , fields = [];
+ var form = new formidable.IncomingForm(),
+ fields = [];
form
.on('error', function(err) {
View
@@ -1,23 +1,23 @@
require('../test/common');
-var http = require('http')
- , util = require('util')
- , formidable = require('formidable')
- , server;
+var http = require('http'),
+ util = require('util'),
+ formidable = require('formidable'),
+ server;
server = http.createServer(function(req, res) {
if (req.url == '/') {
res.writeHead(200, {'content-type': 'text/html'});
- res.end
- ( '<form action="/upload" enctype="multipart/form-data" method="post">'
- + '<input type="text" name="title"><br>'
- + '<input type="file" name="upload" multiple="multiple"><br>'
- + '<input type="submit" value="Upload">'
- + '</form>'
- )
+ res.end(
+ '<form action="/upload" enctype="multipart/form-data" method="post">'+
+ '<input type="text" name="title"><br>'+
+ '<input type="file" name="upload" multiple="multiple"><br>'+
+ '<input type="submit" value="Upload">'+
+ '</form>'
+ );
} else if (req.url == '/upload') {
- var form = new formidable.IncomingForm()
- , files = []
- , fields = [];
+ var form = new formidable.IncomingForm(),
+ files = [],
+ fields = [];
form.uploadDir = TEST_TMP;
@@ -1,12 +1,12 @@
if (global.GENTLY) require = GENTLY.hijack(require);
var util = require('./util')
@dvv

dvv Oct 19, 2010

Please, append comma here

--Vladimir

- , path = require('path')
- , File = require('./file')
- , MultipartParser = require('./multipart_parser').MultipartParser
- , QuerystringParser = require('./querystring_parser').QuerystringParser
- , StringDecoder = require('string_decoder').StringDecoder
- , EventEmitter = require('events').EventEmitter;
+ path = require('path'),
+ File = require('./file'),
+ MultipartParser = require('./multipart_parser').MultipartParser,
+ QuerystringParser = require('./querystring_parser').QuerystringParser,
+ StringDecoder = require('string_decoder').StringDecoder,
+ EventEmitter = require('events').EventEmitter;
function IncomingForm() {
if (!(this instanceof IncomingForm)) return new IncomingForm;
@@ -185,11 +185,7 @@ IncomingForm.prototype.handlePart = function(part) {
part.on('end', function() {
file.end(function() {
self._flushing--;
- self.emit
- ( 'file'
- , part.name
- , file
- );
+ self.emit('file', part.name, file);
self._maybeEnd();
});
});
@@ -243,11 +239,11 @@ IncomingForm.prototype._newParser = function() {
IncomingForm.prototype._initMultipart = function(boundary) {
this.type = 'multipart';
- var parser = new MultipartParser()
- , self = this
- , headerField
- , headerValue
- , part;
+ var parser = new MultipartParser(),
+ self = this,
+ headerField,
+ headerValue,
+ part;
parser.initWithBoundary(boundary);
@@ -1,36 +1,36 @@
var Buffer = require('buffer').Buffer
- , s = 0
- , S =
- { PARSER_UNINITIALIZED: s++
- , START: s++
- , START_BOUNDARY: s++
- , HEADER_FIELD_START: s++
- , HEADER_FIELD: s++
- , HEADER_VALUE_START: s++
- , HEADER_VALUE: s++
- , HEADER_VALUE_ALMOST_DONE: s++
- , HEADERS_ALMOST_DONE: s++
- , PART_DATA_START: s++
- , PART_DATA: s++
- , PART_END: s++
- , END: s++
- }
+ s = 0,
+ S =
+ { PARSER_UNINITIALIZED: s++,
+ START: s++,
+ START_BOUNDARY: s++,
+ HEADER_FIELD_START: s++,
+ HEADER_FIELD: s++,
+ HEADER_VALUE_START: s++,
+ HEADER_VALUE: s++,
+ HEADER_VALUE_ALMOST_DONE: s++,
+ HEADERS_ALMOST_DONE: s++,
+ PART_DATA_START: s++,
+ PART_DATA: s++,
+ PART_END: s++,
+ END: s++,
+ },
- , f = 1
- , F =
- { PART_BOUNDARY: f
- , LAST_BOUNDARY: f *= 2
- }
+ f = 1,
+ F =
+ { PART_BOUNDARY: f,
+ LAST_BOUNDARY: f *= 2,
+ },
- , LF = 10
- , CR = 13
- , SPACE = 32
- , HYPHEN = 45
- , COLON = 58
- , A = 97
- , Z = 122
+ LF = 10,
+ CR = 13,
+ SPACE = 32,
+ HYPHEN = 45,
+ COLON = 58,
+ A = 97,
+ Z = 122,
- , lower = function(c) {
+ lower = function(c) {
return c | 0x20;
};
@@ -63,29 +63,29 @@ MultipartParser.prototype.initWithBoundary = function(str) {
};
MultipartParser.prototype.write = function(buffer) {
- var self = this
- , i = 0
- , len = buffer.length
- , prevIndex = this.index
- , index = this.index
- , state = this.state
- , flags = this.flags
- , lookbehind = this.lookbehind
- , boundary = this.boundary
- , boundaryChars = this.boundaryChars
- , boundaryLength = this.boundary.length
- , boundaryEnd = boundaryLength - 1
- , bufferLength = buffer.length
- , c
- , cl
+ var self = this,
+ i = 0,
+ len = buffer.length,
+ prevIndex = this.index,
+ index = this.index,
+ state = this.state,
+ flags = this.flags,
+ lookbehind = this.lookbehind,
+ boundary = this.boundary,
+ boundaryChars = this.boundaryChars,
+ boundaryLength = this.boundary.length,
+ boundaryEnd = boundaryLength - 1,
+ bufferLength = buffer.length,
+ c,
+ cl,
- , mark = function(name) {
+ mark = function(name) {
self[name+'Mark'] = i;
- }
- , clear = function(name) {
+ },
+ clear = function(name) {
delete self[name+'Mark'];
- }
- , callback = function(name, buffer, start, end) {
+ },
+ callback = function(name, buffer, start, end) {
if (start !== undefined && start === end) {
return;
}
@@ -94,8 +94,8 @@ MultipartParser.prototype.write = function(buffer) {
if (callbackSymbol in self) {
self[callbackSymbol](buffer, start, end);
}
- }
- , dataCallback = function(name, clear) {
+ },
+ dataCallback = function(name, clear) {
var markSymbol = name+'Mark';
if (!(markSymbol in self)) {
return;
@@ -288,7 +288,7 @@ MultipartParser.prototype.write = function(buffer) {
// it could be the beginning of a new sequence
i--;
}
-
+
break;
default:
return i;
@@ -310,4 +310,4 @@ MultipartParser.prototype.end = function() {
if (this.state != S.END) {
return new Error('MultipartParser.end(): stream ended unexpectedly');
}
-};
+};
View
@@ -1,6 +1,6 @@
-{ "name" : "formidable"
-, "version": "0.9.8"
-, "dependencies": {"gently": ">=0.7.0"}
-, "directories" : { "lib" : "./lib/formidable" }
-, "main" : "./lib/formidable/index"
+{ "name" : "formidable",
+ "version": "0.9.8",
+ "dependencies": {"gently": ">=0.7.0"},
+ "directories" : { "lib" : "./lib/formidable" },
+ "main" : "./lib/formidable/index",
@dvv

dvv Oct 19, 2010

Please, remove the trailing comma here -- json doesn't allow pending commas. W/o this the package cannot be require()d by nodules

TIA,
--Vladimir

}
Oops, something went wrong.

0 comments on commit ed4e297

Please sign in to comment.