log files hex data in order#4
log files hex data in order#4noahgribbin wants to merge 2 commits intocodefellows-javascript-401d13:masterfrom
Conversation
| @@ -0,0 +1 @@ | |||
| askjdhsakjhdkajshdkjashdkajshdk file two | |||
| 'use strict'; | ||
| var box = []; | ||
|
|
||
| exports.box = box; |
There was a problem hiding this comment.
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 ); |
There was a problem hiding this comment.
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()); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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'); |
| 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){ |
| }); | ||
| 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){ |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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.
| }); | ||
| }); | ||
| }); | ||
| }); |
No description provided.