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-greg/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
**/node_modules/*
**/vendor/*
**/*.min.js
**/coverage/*
**/build/*
27 changes: 27 additions & 0 deletions lab-greg/.eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
{
"env": {
"browser": true,
"node": true,
"commonjs": true,
"jest": true,
"es6": true
},
"globals": {
"err": true,
"req": true,
"res": true,
"next": true
},
"extends": "eslint:recommended",
"parserOptions": {
"sourceType": "module"
},
"rules": {
"no-console": "off",
"indent": [ "error", 2 ],
"quotes": ["error", "single", { "allowTemplateLiterals": true }],
"comma-dangle": ["error", "always-multiline"],
"semi": [ "error", "always" ],
"linebreak-style": ["error", "unix"]
}
}
145 changes: 145 additions & 0 deletions lab-greg/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,145 @@
# 401 JS
db
**.env
temp
build

# Created by https://www.gitignore.io/api/vim,osx,node,linux,windows
### Linux ###
*~

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*

# .nfs files are created when an open file is removed but is still being accessed
.nfs*

### 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 ###
*.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

### 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/vim,osx,node,linux,windows
7 changes: 7 additions & 0 deletions lab-greg/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
##
In your README.md file, describe the exported values of each module defined in your lib directory. Every function description should include it's airty (expected number of parameters), the expected data for each parameter (data-type and limitations), and the expected output behavior (for both valid and invalid use). Feel free to include any additional information that you would like.

In my greet.js module, the exported value will be one string that reads 'hello (argument passed into the function). For example, if 'world' is passed in, the export will be 'hello world'.

In my arithmetic.js module, there will be two exported values. One will be from the exports.add function, which will require two integer arguments. The expected return will be a sum of these two numbers.
The other exported value will be the exports.sub function. This will also require two integers as arguments and will return the difference of these two integers.
8 changes: 8 additions & 0 deletions lab-greg/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
'use strict';

const greet = require('./lib/greet.js');
const arithmetic = require('./lib/arithmetic.js');

greet.sayHello('world');
arithmetic.sum(2, 3);
arithmetic.sub(4, 2);
26 changes: 26 additions & 0 deletions lab-greg/lib/arithmetic.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
'use strict';

module.exports = exports = {};

exports.add = function(numOne, numTwo) {
var sum;

if(!numOne || !numTwo) throw new Error('Numbers not Provided')
sum = (numOne + numTwo);
if(typeof numOne !== 'number' || typeof numTwo !== 'number') return null;

console.log(sum);
return sum;

};

exports.sub = function(numOne, numTwo) {
var diff;
if(!numOne || !numTwo) throw new Error('Numbers not Provided')
diff = (numOne - numTwo);
if(typeof numOne !== 'number' || typeof numTwo !== 'number') return null;

console.log(diff);
return diff;

};
12 changes: 12 additions & 0 deletions lab-greg/lib/greet.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
'use strict';

module.exports = exports = {};

exports.sayHello = function(name) {
if(!name)
throw new Error('name not provided');
if(typeof name !== 'string') return null;

return `hello ${name}`;

};
29 changes: 29 additions & 0 deletions lab-greg/test/arithmetic-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
'use strict';

const arithmetic = require('../lib/arithmetic.js');
const assert = require('assert');

describe('arithmetic module', function() {
describe('#sum', function() {
it('should return the sum of two numbers', function() {
var result = arithmetic.add(1, 3);
assert.ok(result === 4, 'not equal to 4');
});
it('should throw a missing number error', function() {
assert.throws(function() {
arithmetic.sum();
}, 'error not thrown');
});
});
describe('#sub', function() {
it('should return the difference of two numbers', function() {
var result = arithmetic.sub(4, 2);
assert.ok(result === 2, 'not equal to 2');
});
it('should throw a missing number error', function() {
assert.throws(function() {
arithmetic.sub();
}, 'error not thrown');
});
});
});
21 changes: 21 additions & 0 deletions lab-greg/test/greet-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
'use strict';

const greet = require('../lib/greet.js');
const assert = require('assert');

describe('Greet Module', function() {
describe('#sayHello', function() {
it('should return hello world', function() {
var result = greet.sayHello('world');
assert.ok(result === 'hello world', 'not equal to hello world');
});
it('should throw a missing name error', function() {
assert.throws(function() {
greet.sayHello();
}, 'error not thrown');
});
});
});