-
Notifications
You must be signed in to change notification settings - Fork 12
Lab-James #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
Jamesbillard12
wants to merge
18
commits into
codefellows-javascript-401d17:master
Choose a base branch
from
Jamesbillard12:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Lab-James #13
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
e4afab9
added basic structure to folder
Jamesbillard12 45690ab
test is working for stand alone map
Jamesbillard12 0a167f4
filter is testing and working
Jamesbillard12 b6eb341
test work and validats concat
Jamesbillard12 8ff41ea
reduce works and tests well
Jamesbillard12 84f1bd2
finished basic lab
Jamesbillard12 9a34b28
toCaps work
Jamesbillard12 c3cabf5
got caps to work and a way to test it. time to write test
Jamesbillard12 c436276
could not get the test to work
Jamesbillard12 f8241ea
finished whole assignment including stretch
Jamesbillard12 831bafb
fixed small issues still need to fix naming conventions
Jamesbillard12 f26cb7d
edited readme
Jamesbillard12 7d28d68
Merge pull request #1 from Jamesbillard12/standalone
Jamesbillard12 0a7b881
fixed indentation in fp.js
Jamesbillard12 184179c
Merge pull request #2 from Jamesbillard12/standalone
Jamesbillard12 924fdba
made requested revisions
Jamesbillard12 ed043c2
fixed semicolon issue
Jamesbillard12 df479a2
Merge pull request #3 from Jamesbillard12/revisions
Jamesbillard12 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| **/node_modules/* | ||
| **/vendor/* | ||
| **/*.min.js | ||
| **/coverage/* | ||
| **/build/* |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,31 +1,7 @@ | ||
|  02: Tools and Context | ||
| ====== | ||
|
|
||
| ## To Submit this Assignment | ||
| * fork this repository & create a new branch for your work | ||
| * write all of your code in a directory named `lab-` + `<your name>` **e.g.** `lab-susan` | ||
| * push to your repository | ||
| * submit a pull request to this repository | ||
| * submit a link to your PR in canvas | ||
| * write a question and observation on canvas | ||
|
|
||
| ## Directions | ||
| * create a `/lib` and `/test` directory | ||
| * add a robust `.gitignore` file | ||
| * include a `package.json` | ||
| * include the provided `.eslintrc` file | ||
| * create a `lint` script for running eslint | ||
| * create a `test` script for running mocha | ||
| * create a `lib/fp.js` file for holding the following: | ||
| * create stand alone `map`, `filter`, `reduce`, `concat`, and `splice` functions using the `call`, and `apply` methods we discussed today | ||
| * you are welcome to use/experiment with `bind` too! | ||
| * *note:* - all functions should be created using the es6 lexical arrow function syntax | ||
|
|
||
| # Tests | ||
| * create a test for each of your custom functions in `lib/fp.js` | ||
| * note - feel free to create additional tests, if you choose! | ||
|
|
||
| ## Bonus 2pts | ||
| * create a CLI (`index.js`) that will use your new `map` function to uppercase all command line arguments and print them to the screen: 1pt | ||
| * **hint:** - you'll want to check out the `process` object (and it's methods) to get an array of provided command line arguments | ||
| * test your CLI: 1pt | ||
| ## Lab-James Lab-02 Documentation | ||
| * index.js calls function 'main' function which returns CLI parameters as uppercase words using the fp.splice method from ./lib/fp.js. | ||
| * ./lib/fp.js defines the map, filter, reduce, concat, and splice methods using both call and apply. | ||
| * Tests | ||
| * ./test/fp-test.js tests the above methods | ||
| * **Stretch Goal:** ./test/index-test.js tests the index.js CLI functionality. | ||
| * Project passes Mocha (chai) tests and esLint. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| 'use strict'; | ||
|
|
||
| const fp = require('./lib/fp.js'); | ||
|
|
||
| let main = module.exports = () => { | ||
| let list = fp.splice(process.argv, 2); | ||
| list = fp.map(list, (word) => word.toUpperCase()); | ||
| let result = list.join(' '); | ||
| console.log(result); | ||
| return result; | ||
| }; | ||
|
|
||
| main(); | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| 'use strict'; | ||
|
|
||
| module.exports = exports = {}; | ||
|
|
||
| exports.map = (list, ...args) => { | ||
| if (!list) throw new Error('array not provided'); | ||
| return Array.prototype.map.call(list, ...args); | ||
| }; | ||
|
|
||
|
|
||
| exports.filter = (arr, callback) => { | ||
| if (!arr) throw new Error('array not provided'); | ||
| return Array.prototype.filter.call(arr, callback); | ||
| }; | ||
|
|
||
| exports.concat = (arr1, arr2) => { | ||
| if (!arr1) throw new Error('initial array not provided'); | ||
| return Array.prototype.concat.apply(arr1, arr2); | ||
| }; | ||
|
|
||
| exports.reduce = (arr, idx, callback) => { | ||
| if (!arr) throw new Error('array not provided'); | ||
| return Array.prototype.reduce.call(arr, idx, callback); | ||
| }; | ||
|
|
||
| exports.splice = (list, ...args) => { | ||
| if (!list) throw new Error('array not provided'); | ||
| return Array.prototype.splice.call(list, ...args); | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| { | ||
| "name": "02-tools_and_context", | ||
| "version": "1.0.0", | ||
| "description": " 02: Tools and Context ======", | ||
| "main": "index.js", | ||
| "directories": { | ||
| "test": "test" | ||
| }, | ||
| "scripts": { | ||
| "start": "node index.js", | ||
| "test": "mocha", | ||
| "lint": "eslint" | ||
| }, | ||
| "repository": { | ||
| "type": "git", | ||
| "url": "git+https://github.com/codefellows-javascript-401d17/02-tools_and_context.git" | ||
| }, | ||
| "keywords": [], | ||
| "author": "", | ||
| "license": "ISC", | ||
| "bugs": { | ||
| "url": "https://github.com/codefellows-javascript-401d17/02-tools_and_context/issues" | ||
| }, | ||
| "homepage": "https://github.com/codefellows-javascript-401d17/02-tools_and_context#readme", | ||
| "devDependencies": { | ||
| "chai": "^4.1.0", | ||
| "expect": "^1.20.2", | ||
| "mocha": "^3.4.2" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,70 @@ | ||
| 'use strict'; | ||
|
|
||
| const fp = require('../lib/fp.js'); | ||
| const expect = require('chai').expect; | ||
|
|
||
| describe('fp', () => { | ||
| describe('#map', () => { | ||
| it('should throw array not provided error', () => { | ||
| let mapArrErr = fp.map; | ||
| expect(mapArrErr).to.throw(Error); | ||
| }); | ||
| it('should return an array with doubled numbers', () => { | ||
| let validMap = fp.map([1,2,3,4], (n) => { return n * 2; }); | ||
| expect(validMap).to.be.an('array').that.includes.members([2,4,6,8]); | ||
| }); | ||
| }); | ||
| describe('#filter', () =>{ | ||
| it('should throw array not provided error', () => { | ||
| let filterArrErr = fp.filter; | ||
| expect(filterArrErr).to.throw(Error); | ||
| }); | ||
| it('should return an array that is missing the number 2', () => { | ||
| let validFilter = fp.filter([1, 2, 3, 4], (n) => { return n !== 2; }); | ||
| expect(validFilter).to.be.an('array').to.not.have.members([2]); | ||
| }); | ||
| }); | ||
| describe('#concat', () => { | ||
| it('should throw an intial array not provided error', () => { | ||
| let concatArrErr = fp.concat; | ||
| expect(concatArrErr).to.throw(Error); | ||
| }); | ||
| it('should be an array the is a combination of two arrays', () => { | ||
| let validConcat = fp.concat([1,2,3], [4,5,6]); | ||
| expect(validConcat).to.be.an('array').to.include.members([1,2,3,4,5,6]); | ||
| }); | ||
| }); | ||
| describe('#reduce', () =>{ | ||
| it('should throw an intial array not provided error', () => { | ||
| let reduceArrErr = fp.concat; | ||
| expect(reduceArrErr).to.throw(Error); | ||
| }); | ||
| it('should reduce an array down to a single value', () => { | ||
| let validReduce = fp.reduce([0, 1, 2, 3], (acc, n) => {return acc + n; }, 0); | ||
| expect(validReduce).to.equal(6); | ||
| }); | ||
| it('should count amount of each name in an array and return it in an object', () => { | ||
| var names = ['Alice', 'Bob', 'Tiff', 'Bruce', 'Alice']; | ||
| var validNameReduce = fp.reduce(names, (allNames, name) => { | ||
| if (name in allNames) { | ||
| allNames[name]++; | ||
| } | ||
| else { | ||
| allNames[name] = 1; | ||
| } | ||
| return allNames; | ||
| }, {}); | ||
| expect(validNameReduce).to.be.an('object'); | ||
| }); | ||
| }); | ||
| describe('#splice', () => { | ||
| it('should throw an intial array not provided error', () =>{ | ||
| let spliceArrErr = fp.concat; | ||
| expect(spliceArrErr).to.throw(Error); | ||
| }); | ||
| it('should return [6,7,8]', () => { | ||
| let result = fp.splice([1,2,3,4,5,6,7,8], 5); | ||
| expect(result).to.be.an('array').to.include.members([6,7,8]); | ||
| }); | ||
| }); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,24 @@ | ||
| 'use strict'; | ||
|
|
||
| const expect = require('chai').expect; | ||
| const main = require('../index.js'); | ||
|
|
||
| describe('main', () => {var oldArgv = process.argv; | ||
| before(() => { | ||
| process.argv = [ | ||
| 'node path', | ||
| 'file path', | ||
| 'cat', | ||
| 'dog', | ||
| ]; | ||
| }); | ||
|
|
||
| after(() => { | ||
| process.argv = oldArgv; | ||
| }); | ||
|
|
||
| it('should return \'CAT DOG\'', () => { | ||
| let result = main(); | ||
| expect(result).to.be.a('string').to.have.string('CAT DOG'); | ||
| }); | ||
| }); |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't forget to at some point print them out to the screen in their capital form.