Closed wayx closed 11 years ago
@webstalk3r thanks for good work!
@webstalk3r more about code style issues:
var
statement;var
, return
and large blocks of the logic;in
operator, use dot or array notation or Object#hasOwnProperty
instead;bad:
var headers = [],
isObject = typeof body[name] === 'object',
isFile = isObject && 'data' in body[name] && Buffer.isBuffer(body[name].data),
isBuffer = isObject && Buffer.isBuffer(body[name]);
headers.push('--' + BOUNDARY);
var disposition = 'content-disposition: form-data; name="' + name + '"';
if (isFile || isBuffer) {
disposition += '; filename="' + ( ! isBuffer && 'filename' in body[name] ?
body[name].filename :
name) + '"';
}
headers.push(disposition);
good:
var headers = [],
attach = body[name],
isFile = attach && Buffer.isBuffer(attach.data),
isBuffer = attach && Buffer.isBuffer(attach),
disposition = [
'content-disposition: form-data; name="', name, '"'
];
headers.push('--' + BOUNDARY);
if (isFile || isBuffer) {
disposition.push('; filename="');
if (isFile && attach.filename) {
disposition.push(body[name].filename);
} else {
disposition.push(name);
}
disposition.push('"');
}
headers.push(disposition.join(''));
It's great. Codestyle issues are really could be done by maintainer ;) Good work, guys. One question, any becnhmarks due to the recent changes? :)
I'll add benchmarks for transition from 0.1 to 1.0.
0.2 will be released ASAP due to @webstalk3r needs.
Added bodyEncoders (text, urlencoded, multipart, stringify default)
9