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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,4 @@
* 2pts configuration
* 3pts feature tasks
* 3pts tests
* 2pts documentation
* 2pts documentation
5 changes: 5 additions & 0 deletions lab-nathan/.eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
**/node_modules/*
**/vendor/*
**/*.min.js
**/coverage/*
**/build/*
21 changes: 21 additions & 0 deletions lab-nathan/.eslintrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
{
"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-nathan/.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
7 changes: 7 additions & 0 deletions lab-nathan/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# Greet and Arithmetic

This project contains two node modules, greet and arithmetic.

The Greet module is a function which accepts a name parameter and returns "hello [name]!".

The Arithmetic module is an object containing two methods, add and subtract. They both accept two parameters and return the result.
Empty file added lab-nathan/index.js
Empty file.
20 changes: 20 additions & 0 deletions lab-nathan/lib/arithmetic.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'use strict';

let arithmetic = {};
module.exports = arithmetic;

arithmetic.add = function(a, b) {
if (typeof a !== 'number' || typeof b !== 'number') {
throw new Error('Cannot add non-numbers.');
}

return a + b;
};

arithmetic.subtract = function(a, b) {
if (typeof a !== 'number' || typeof b !== 'number') {
throw new Error('Cannot subract non-numbers.');
}

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

module.exports = function(name) {
return typeof name === 'string'? `hello ${name}!` : null;
};
33 changes: 33 additions & 0 deletions lab-nathan/test/arithmetic-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
'use strict';

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

describe('Arithmetic Module', function() {
describe('#add', function() {
it('should return 10', function() {
let result = arithmetic.add(3, 7);
assert.ok(result === 10);
});

it('should throw error with non-number inputs.', function() {
assert.throws(function() {
arithmetic.add('a', 4);
});
});
});

describe('#subtract', function() {
it('should return 10', function() {
let result = arithmetic.subtract(30, 20);
assert.ok(result === 10);
});

it('should throw error with non-number inputs.', function() {
assert.throws(function() {
arithmetic.subtract('a', 20);
});
});
});
});

18 changes: 18 additions & 0 deletions lab-nathan/test/greet-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
'use strict';

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

describe('Greet Module', function() {
describe('#', function() {
it('should return hello world!', function() {
let result = greet('world');
assert.ok(result === 'hello world!');
});

it('should return null with a non-string input', function() {
let result = greet(0);
assert.ok(result === null);
});
});
});