Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions lab-allan/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
**/node_modules/*
**/vendor/*
**/*.min.js
**/coverage/*
**/build/*
33 changes: 33 additions & 0 deletions lab-allan/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"rules": {
"no-console": "off",
"indent": [
"error",
2
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"always"
],
"linebreak-style": [
"error",
"unix"
]
},
"env": {
"es6": true,
"node": true,
"mocha": true,
"jasmine": true
},
"ecmaFeatures": {
"modules": true,
"experimentalObjectRestSpread": true,
"impliedStrict": true
},
"extends": "eslint:recommended"
}
136 changes: 136 additions & 0 deletions lab-allan/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,136 @@
# Created by https://www.gitignore.io/api/osx,vim,node,macos,windows

### macOS ###
*.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon

# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### Node ###
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*

# Runtime data
pids
*.pid
*.seed
*.pid.lock

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# Bower dependency directory (https://bower.io/)
bower_components

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules/
jspm_packages/

# Typescript v1 declaration files
typings/

# Optional npm cache directory
.npm

# Optional eslint cache
.eslintcache

# Optional REPL history
.node_repl_history

# Output of 'npm pack'
*.tgz

# Yarn Integrity file
.yarn-integrity

# dotenv environment variables file
.env


### OSX ###

# Icon must end with two \r

# Thumbnails

# Files that might appear in the root of a volume

# Directories potentially created on remote AFP share

### Vim ###
# swap
[._]*.s[a-v][a-z]
[._]*.sw[a-p]
[._]s[a-v][a-z]
[._]sw[a-p]
# session
Session.vim
# temporary
.netrwhist
*~
# auto-generated tag files
tags

### Windows ###
# Windows thumbnail cache files
Thumbs.db
ehthumbs.db
ehthumbs_vista.db

# Folder config file
Desktop.ini

# Recycle Bin used on file shares
$RECYCLE.BIN/

# Windows Installer files
*.cab
*.msi
*.msm
*.msp

# Windows shortcuts
*.lnk

# End of https://www.gitignore.io/api/osx,vim,node,macos,windows
9 changes: 9 additions & 0 deletions lab-allan/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
### file-reader.js
- reads a specified text file and, if no errors are returned, uses buffer to return the first 8 bytes of the file's data as hex string.

### index.js
- calls the fileReader method on each text document in the assets folder and logs the results.

### file-reader-test.js
- tests that an improper file path returns an error
- tests that each of the text documents in the assets folder, when passed into the fileReader method, return a string of the correct length.
1 change: 1 addition & 0 deletions lab-allan/assets/one.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
The first text file for the lab assignment
1 change: 1 addition & 0 deletions lab-allan/assets/three.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Last one. Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.
1 change: 1 addition & 0 deletions lab-allan/assets/two.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Here's a bunch of text Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
16 changes: 16 additions & 0 deletions lab-allan/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
'use strict';

const fileReader = require(`${__dirname}/lib/file-reader.js`);

fileReader(`${__dirname}/assets/one.txt`, function(err, asset) {
if(err) throw err;
console.log('one.txt:', asset);
fileReader(`${__dirname}/assets/two.txt`, function(err, asset) {
if(err) throw err;
console.log('two.txt:', asset);
fileReader(`${__dirname}/assets/three.txt`, function(err, asset) {
if(err) throw err;
console.log('three.txt:', asset);
});
});
});
10 changes: 10 additions & 0 deletions lab-allan/lib/file-reader.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
'use strict';

const fs = require('fs');

const fileReader = module.exports = function(file, callback) {
fs.readFile(file, (err, asset) => {
if(err) return callback(err);
return callback(null, asset.toString('hex', 0, 8));
});
};
Loading