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
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
The diff you're trying to view is too large. We only load the first 3000 changed files.
54 changes: 5 additions & 49 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,52 +1,8 @@
![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
## Greet
Greet contains a function that accepts the user's name(for example, Brandon) as its only airity and returns the greeting "hello Brandon". The function will return "null" if the airity is empty or a number.

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

## 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 (invoded with number arguments)
* Test each method for inproper use (invoded 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.
## Arithmetic
Arithmetic has 2 functions that individually adds and subtracts 2 airities. If neither input has a number in its airity, then the function will return null. The tests check for numbers, and for nothing or a letter/word being inputed. Both of which will return back "null".
32 changes: 32 additions & 0 deletions lab-brandon/__test__/arithmetic.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
'use strict'
const arithmetic = require('../lib/arithmetic');

test('add() should return null', () => {
let result = arithmetic.add()
expect(result).toEqual(null)
})

test('sub() should return null', () => {
let result = arithmetic.sub()
expect(result).toEqual(null)
})

test('add(\"aayy\") should return null', () => {
let result = arithmetic.add("aayy")
expect(result).toEqual(null)
})

test('sub(\"aayy\") should return null', () => {
let result = arithmetic.sub("aayy")
expect(result).toEqual(null)
})

test('add(5,5) should return 10', () => {
let result = arithmetic.add(5,5)
expect(result).toEqual(10)
})

test('sub(5,1) should return 4', () => {
let result = arithmetic.sub(5,1)
expect(result).toEqual(4)
})
16 changes: 16 additions & 0 deletions lab-brandon/__test__/greet.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
const greet = require('../lib/greet');

test('greet() should return null', () => {
let result = greet()
expect(result).toEqual(null)
})

test('greet(\"world\") should return “hello world”', () => {
let result = greet('world')
expect(result).toEqual('hello world')
})

test('greet(5) should return “hello world”', () => {
let result = greet(5)
expect(result).toEqual(null)
})
14 changes: 14 additions & 0 deletions lab-brandon/lib/arithmetic.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
'use strict'

module.exports.add = function(a,b){
if(typeof a !== "number" || typeof b !== "number")
return null
return a + b
}


module.exports.sub = function(a,b){
if(typeof a !== "number" || typeof b !== "number")
return null
return a - b
}
7 changes: 7 additions & 0 deletions lab-brandon/lib/greet.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
'use strict'

module.exports = function(name){
if(typeof name !== "string")
return null
return `hello ${name}`
}
1 change: 1 addition & 0 deletions node_modules/.bin/acorn

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/babylon

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/errno

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/escodegen

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/esgenerate

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/esparse

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/esvalidate

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/handlebars

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/jest

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/jest-runtime

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/js-yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/jsesc

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/json5

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/loose-envify

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/mkdirp

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/rimraf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/sane

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/semver

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/sshpk-conv

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/sshpk-sign

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/sshpk-verify

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/uglifyjs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/uuid

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions node_modules/.bin/which

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

11 changes: 11 additions & 0 deletions node_modules/abab/CHANGELOG.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

52 changes: 52 additions & 0 deletions node_modules/abab/README.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 9 additions & 0 deletions node_modules/abab/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

109 changes: 109 additions & 0 deletions node_modules/abab/lib/atob.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading