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 .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
**/node_modules/*
**/vendor/*
**/*.min.js
**/coverage/*
**/build/*
26 changes: 26 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
{
"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" ]
}
}
119 changes: 119 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,119 @@
# Created by https://www.gitignore.io/api/osx,vim,node,linux

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

# End of https://www.gitignore.io/api/osx,vim,node,linux
53 changes: 3 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,53 +1,6 @@
![CF](https://camo.githubusercontent.com/70edab54bba80edb7493cad3135e9606781cbb6b/687474703a2f2f692e696d6775722e636f6d2f377635415363382e706e67) 01: Node Ecosystem
===

## Submission Instructions
* Work in a fork of this repository.
* Work in a branch on your fork.
* Write all of your code in a directory named `lab-` + `<your name>` **e.g.** `lab-susan`.
* Open a pull request to this repository.
* Submit on canvas a question and observation, how long you spent, and a link to your pull request.
* Features without unit tests behind them will not be graded.

## Resources
* [Jest Getting Started](https://facebook.github.io/jest/docs/en/getting-started.html)
* [Jest Globals](https://facebook.github.io/jest/docs/en/api.html#content)
* [Jest Expect](https://facebook.github.io/jest/docs/en/expect.html#content)
## Lab 01 class 401d19 Documentation
#The# exported values in my greet.JS module is a single "string" unless a non string is input which will result in returning "null". This would be considered as having only ONE "arity". My expected data was "Hello, World!"

## Configuration
Configure the root of your repository with the following files and directories. Thoughfully name and organize any aditional configuration or module files.
* **README.md** - contains documentation
* **.gitignore** - contains a [robust](http://gitignore.io) `.gitignore` file
* **.eslintrc** - contains the course linter configuratoin
* **.eslintignore** - contains the course linter ignore configuration
* **lib/** - contains module definitions
* **__test__/** - contains unit tests

## Feature Tasks
#### Greet Module
Create a NodeJS module in the lib/ directory named `greet.js` that exports a single function.
* The `greet` function should have a single parameter (arity of one) that should expect a string as it's input
* The `greet` function should return the input name, concatenated with "hello ": eg. ("hello susan")
* The `greet` function should return `null` if the input is not a string

#### Arithmetic Module
Create a NodeJS module in the lib/ directory named `arithmetic.js` that exports an object. This module should have `add` and `sub` methods that implament addition and subtraction.
* The `add` method should have an arity of two (define two paramiters)
* If either parameter is a non-number the function should return null
* Else return the sum of the 2 numbers
* The `sub` method should have an arity of two (define two paramiters)
* If either parameter is a non-number the function should return null
* Else return the second paramiter subtracted from the first paramiter

## Testing
#### Greet Module Tests
* Write a test that expects the greet module to return `null` when you supply non string values
* Write a test the expects the greet module to return `'hello world'`
* This should happen when invoked with `'world'` as the first argument

#### Arithmetic Module Tests
* Test each method for proper use (invoked with number arguments)
* Test each method for inproper use (invoked with one or more non-numner arguments)

## Documentation
In your README.md describe the exported values of each module defined in your lib/ directory. Every function description should include it's airty (expected number of paramiters), the expected data for each paramiter (data-type and limitations), and it's behavior (for both valid and invalued use). Feel free to write any additional information in your README.md.
The exported values in my "arithmetic.JS" module is the sum and the difference between two numbers unless a NON Number(NaN) is input which will result in returning "null". This would be considered as having sn "arity" of TWO. My expected data from ADD was the SUM of 10 and 5 which is 15 and from SUBTRACT I expected the difference of two numbers 10 and 5 which is 5.
19 changes: 19 additions & 0 deletions __test__/arithmetic.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
'use strict';

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

describe('arithmetic.test.js', () => {
describe('math.add', () => {
test('math.add should return the sum of two numbers if there are no errors', () => {
expect(math.add(5, 10)).toEqual(15);
expect(math.add('foo')).toEqual(null);
});
});

describe('math.subtract', () => {
test('math.subtract should return the difference of two numbers if there are no errors', () => {
expect(math.subtract(10, 5)).toEqual(5);
expect(math.subtract('bar')).toEqual(null);
});
});
});
13 changes: 13 additions & 0 deletions __test__/greet.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'use strict';

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

describe('Testing greet.js for Hello, World!', () => {
test('should return "Hello, World!"', () => {
expect(greet.greeting('World!')).toEqual('Hello, World!');
});

test('this should return null for non string values', () => {
expect(greet.greeting(100)).toEqual(null);
});
});
15 changes: 15 additions & 0 deletions lib/arithmetic.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
'use strict';

const math = module.exports = {};

math.add = (a, b) => {
if(typeof a !== 'number' || typeof b !== 'number')
return null;
return a + b;
};

math.subtract = (a, b) => {
if(typeof a !== 'number' || typeof b !== 'number')
return null;
return a - b;
};
9 changes: 9 additions & 0 deletions lib/greet.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
'use strict';

const greet = module.exports = {};

greet.greeting = (name) => {
if (name === '' || typeof name !== 'string')
return null;
return `Hello, ${name}`;
};
Loading