Skip to content
This repository has been archived by the owner on Jun 1, 2021. It is now read-only.

Commit

Permalink
best practes codacy to code with quality
Browse files Browse the repository at this point in the history
  • Loading branch information
renanbastos93 committed Mar 21, 2018
1 parent 569302a commit 667206b
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 12 deletions.
2 changes: 1 addition & 1 deletion image-to-base64.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ const image2base64 = (url, param) => {
)
.then(
(buffer) => {
return "data:image/jpeg;base64," + window.btoa(
return window.btoa(
[].slice.call(
new Uint8Array(buffer)
).map(
Expand Down
12 changes: 3 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,8 @@ const image2base64 = (param) => {
let validTypeImage = new RegExp("(\.(jpg)|\.(png)|\.(jpeg))", "gi");
if(validTypeImage.test(param)){

if(fs.statSync(param).isFile()){
resolve(
fs.readFileSync(
path.resolve(param)
).toString("base64")
);
if(fs.statSync(param).isFile() === true){
resolve(fs.readFileSync(path.resolve(param)).toString("base64"));
}else{
reject(null);
}
Expand All @@ -40,9 +36,7 @@ const image2base64 = (param) => {
)
.then(
(body) => {
resolve(
body.toString("base64")
);
resolve(body.toString("base64"));
}
);

Expand Down
4 changes: 2 additions & 2 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ describe("must to be resolved the promise", function(){
assert(validBase64.test(data), true);
}
)
.catch((err)=>assert(err, true));
.catch((err) => assert(err, true));
});

it("get image of the path and convert to base64", function(){
Expand All @@ -25,7 +25,7 @@ describe("must to be resolved the promise", function(){
assert(validBase64.test(data).test(data), true);
}
)
.catch((err)=>assert(err, true));
.catch((err) => assert(err, true));
});

});

0 comments on commit 667206b

Please sign in to comment.