Skip to content

Alex/Bessie/David Pull Request - #4

Open
bishang wants to merge 43 commits into
codefellows-seattle-javascript-401d22:masterfrom
bishang:bitmap-lab
Open

bishang wants to merge 43 commits into
codefellows-seattle-javascript-401d22:masterfrom
bishang:bitmap-lab

Conversation

@bishang

@bishang bishang commented Feb 19, 2018

Copy link
Copy Markdown

No description provided.

bishang and others added 30 commits February 15, 2018 13:02
finished reader.test.js, broke writer.test.js
});
describe('#blackout', () => {
it('should return a blackout bitmap buffer', (done) => {
fs.readFile(`${__dirname}/test-data/palette-bitmap.bmp`, function(err, data){

@gagregrog gagregrog Mar 6, 2018

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Testing this lab is hard, and this "double read" technique is definitely a clever approach.

@@ -0,0 +1,22 @@
'use strict';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since this file doesn't actually do anything, it should be removed. Or...better yet, test that your writer works by writing the file, and then using fs to ensure that the written file is actually there.


// node index.js './data/palette-bitmap.bmp' './data/newpalettebitmap.bmp' 'blackout'
reader(process.argv[2], function (err, data) {
let buff = transformer(data, process.argv[4]);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider that your transform function could potentially throw, so it might be worth wrapping the call in a try/catch and handling the errors more elegantly, rather than just blasting the console with the error and letting the app crash.

"author": "",
"license": "ISC",
"dependencies": {
"jest": "^22.3.0"

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't forget to add eslint as a dependency to every project!

if(!transformTypes.includes(transformType)) throw new Error('transform type not supported');

switch(transformType){
case 'blackout':

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

case switches definitely have their place at times, but don't want to be too default in your toolbox -- they are associated with junior devs. Great job getting the transforms to work, though, this is one of the most infamous labs of 401

var transformTypes = ['blackout', 'invert', 'grayscale', 'invcolors'];
if(!transformTypes.includes(transformType)) throw new Error('transform type not supported');

switch(transformType){

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have a lot of repeated actions in this switch statement. For example, finding the start and offset. It would be much cleaner if you had a function that would do that for you and return the values that you need. Even nicer, if each transform were its own function, your switch case would be lean and clean. User wants this transform, switch case jumps there and calls that function.

@@ -0,0 +1,79 @@
'use strict';

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lots of magic numbers in here. They obviously have some significance with respect to the buffer, but that significance is unknown when looking at the code. You should store those in descriptive variable names so someone looking at your code can look and understand what they stand for.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants