Skip to content

Commit

Permalink
codestyle fixes, added test.jpg, fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
ivoba authored and riyadhalnur committed Sep 17, 2015
1 parent c9cd5df commit 2ab6af0
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,4 @@ node_modules
.lock-wscript

*.jpg
!test/test.jpg
15 changes: 4 additions & 11 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,18 +28,13 @@ var base64encoder = function (url, options, callback) {

if (options && options.localFile === true) {
fs.readFile(url, function (err, data) {
if (err) {
return callback(err);
}
if (err) { return callback(err); }

return encoder(data, options);
});
}
else {
} else {
request({url: url, encoding: null}, function (err, res, body) {
if (err) {
return callback(err);
}
if (err) { return callback(err); }

if (body && res.statusCode === 200) {
return encoder(body, options);
Expand All @@ -54,9 +49,7 @@ var base64decoder = function (imageBuffer, options, callback) {

if (options && options.filename) {
fs.writeFile(options.filename + '.jpg', imageBuffer, 'base64', function (err) {
if (err) {
return callback(err);
}
if (err) { return callback(err); }
return callback(null, 'Image saved successfully to disk!');
});
}
Expand Down
Binary file added test/test.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions test/tests.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 2ab6af0

Please sign in to comment.