Skip to content

log files hex data in order#4

Open
noahgribbin wants to merge 2 commits intocodefellows-javascript-401d13:masterfrom
noahgribbin:master
Open

log files hex data in order#4
noahgribbin wants to merge 2 commits intocodefellows-javascript-401d13:masterfrom
noahgribbin:master

Conversation

@noahgribbin
Copy link

No description provided.

@@ -0,0 +1 @@
askjdhsakjhdkajshdkjashdkajshdk file two

Choose a reason for hiding this comment

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

Nice keyboard faceroll. :)

'use strict';
var box = [];

exports.box = box;

Choose a reason for hiding this comment

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

Interesting idea to export the array after you've filled it up from your asynchronous calls.

var buff3 = Buffer.from(data).toString('hex').substring(0,8);
console.log(buff3, data);
box.push(buff3);
console.log(box );

Choose a reason for hiding this comment

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

When turning in assignments, try to remove console logs like these and the ones above before you turn it in. Get in the habit of not leaving them in when you turn stuff in.

const fileReader = module.exports = function(file, callback) {
fs.readFile(file, function(err, data){
if(err) return callback(err);
return callback(null, data.toString());

Choose a reason for hiding this comment

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

Great work returning the callback with null passed in for the error.

const fs = require('fs');
const fileReader = module.exports = function(file, callback) {
fs.readFile(file, function(err, data){
if(err) return callback(err);

Choose a reason for hiding this comment

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

Great work calling the callback with an error if one appears.


const expect = require('chai').expect;
const fileReader = require('../lib/file-reader.js');
const box = require('box');

Choose a reason for hiding this comment

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

There's your results array. Cool.

describe('File Reader Module', function(){
describe('with an impropper filepath', function(){
it('should return an error', function(done){
fileReader(`${__dirname}/not-a-file.txt`, function(err){

Choose a reason for hiding this comment

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

Good test. Nice work on this.

});
describe('with a propper file path', function(){
it('should return the contents of the file', function(done){
fileReader(`${__dirname}/../data/one.txt`, function(err, data){

Choose a reason for hiding this comment

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

Cool, so now we know that the function call on a single data file works.

});
});
it('should log the hex values in order', function(done){
// TODO: test for logs in correct order

Choose a reason for hiding this comment

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

Need a test here to take the information that you stored in box and ensure that it's in the correct order. You'll need to write a test to handle for that.

});
});
});
});

Choose a reason for hiding this comment

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

Where is your eslintrc file?

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.

2 participants