Skip to content

Commit

Permalink
fix: add codecov
Browse files Browse the repository at this point in the history
  • Loading branch information
claudiorodriguez committed Dec 5, 2017
1 parent 884fcc6 commit cf53a5c
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 27 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
{
"extends": "fbjs-extended"
"extends": "mailonline"
}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,3 +27,4 @@ build/Release
node_modules

dist
package-lock.json
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ script:
- "npm test"

after_success:
- "./node_modules/.bin/jest --coverage && cat ./coverage/lcov.info | ./node_modules/.bin/coveralls"
- "./node_modules/.bin/jest --coverage && ./node_modules/.bin/codecov"
- npm run semantic-release

notifications:
Expand Down
24 changes: 14 additions & 10 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ import Datauri from 'datauri';
const datauri = new Datauri();

export const convert = (rgbaInput, width, height) => {
// (performance)
// eslint-disable-next-line no-var
var idx = 0;

// TODO: validate input
// TODO: add promises, don't do this all on sync
const SIZE = width * height * 4;
Expand All @@ -17,20 +21,22 @@ export const convert = (rgbaInput, width, height) => {
data = rgbaInput;
} else {
// input is array of quadruplets
if (rgbaInput.length !== (width * height)) {
throw new Error('Invalid length of quadruplet array input, must be ' + (width * height));
if (rgbaInput.length !== width * height) {
throw new Error('Invalid length of quadruplet array input, must be ' + width * height);
}
data = Buffer(SIZE);
data = Buffer.alloc(SIZE);

// (performance)
// eslint-disable-next-line no-var
var idx = 0;
// eslint-disable-next-line curly
while ((idx = data.writeUInt8(rgbaInput[Math.floor(idx / 4)][idx % 4], idx)) < SIZE);
while (idx < SIZE) {
idx = data.writeUInt8(
rgbaInput[Math.floor(idx / 4)][idx % 4],
idx
);
}
}

// Create png instance with metadata
const png = new PNG();

png.width = width;
png.height = height;
png.data = data;
Expand All @@ -41,5 +47,3 @@ export const convert = (rgbaInput, width, height) => {

return uri.content;
};

export default {convert};
20 changes: 9 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,20 @@
},
"homepage": "https://github.com/claudiorodriguez/rgba-to-datauri#readme",
"dependencies": {
"chai": "^3.5.0",
"datauri": "^1.0.4",
"mocha": "^2.4.5",
"pngjs": "^2.2.0"
},
"devDependencies": {
"babel-cli": "^6.24.1",
"babel-core": "^6.24.1",
"babel-cli": "^6.26.0",
"babel-core": "^6.26.0",
"babel-preset-es2015": "^6.24.1",
"coveralls": "^2.13.1",
"eslint": "^3.19.0",
"eslint-config-fbjs-extended": "^1.0.0",
"husky": "^0.13.3",
"jest": "^20.0.0",
"rimraf": "^2.6.1",
"semantic-release": "^6.3.6"
"codecov": "^3.0.0",
"eslint": "^4.12.1",
"eslint-config-mailonline": "^9.0.0",
"husky": "^0.14.3",
"jest": "^21.2.1",
"rimraf": "^2.6.2",
"semantic-release": "^8.2.0"
},
"jest": {
"testMatch": [
Expand Down
3 changes: 3 additions & 0 deletions test/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"extends": "mailonline/jest"
}
12 changes: 8 additions & 4 deletions test/convert.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,18 @@ const testFlatArray = [
[0, 255, 0, 255], [0, 255, 0, 255], [0, 255, 0, 255], [0, 255, 0, 255], [255, 0, 0, 255], [0, 0, 0, 255],
[0, 0, 0, 255], [255, 0, 0, 255], [255, 0, 0, 255], [255, 0, 0, 255], [255, 0, 0, 255], [255, 0, 0, 255],
[255, 0, 0, 255], [0, 0, 0, 255], [0, 0, 0, 255], [0, 0, 0, 255], [0, 0, 0, 255], [0, 0, 0, 255],
[0, 0, 0, 255], [0, 0, 0, 255], [0, 0, 0, 255], [0, 0, 0, 255],
[0, 0, 0, 255], [0, 0, 0, 255], [0, 0, 0, 255], [0, 0, 0, 255]
];

const testFlatBuffer = Buffer(8 * 8 * 4);
const testFlatBuffer = Buffer.alloc(8 * 8 * 4);
let idx = 0;

// eslint-disable-next-line curly
while ((idx = testFlatBuffer.writeUInt8(testFlatArray[Math.floor(idx / 4)][idx % 4], idx)) < (8 * 8 * 4));
while (idx < 8 * 8 * 4) {
idx = testFlatBuffer.writeUInt8(
testFlatArray[Math.floor(idx / 4)][idx % 4],
idx
);
}

const expectedUri = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAgAAAAICAYAAADED76LAAAAO0lEQVR4AYXB0Q0A' +
'EBBEwbdyHem/BDUtER9HhBkB5iEYzJ2AYJHZWEyFTK7IlaTwEWRW4xAsFlcCzEMHq+YKSPX/JJQAAAAASUVORK5CYII=';
Expand Down

0 comments on commit cf53a5c

Please sign in to comment.