113 |
114 |
${movieDetail.Title}
119 |${movieDetail.Genre}
120 |${movieDetail.Plot}
121 |├── diagrams ├── 20 │ └── .gitkeep ├── 21 │ ├── .gitkeep │ └── diagrams.xml ├── 22 │ └── .gitkeep ├── 23 │ └── .gitkeep ├── 01 │ ├── .gitkeep │ └── diagrams.xml ├── 02 │ └── .gitkeep ├── 03 │ └── .gitkeep ├── 04 │ └── .gitkeep ├── 05 │ └── .gitkeep ├── async │ └── .gitkeep ├── ecomm │ └── .gitkeep ├── maze │ └── .gitkeep ├── node │ ├── .gitkeep │ └── async.xml ├── timer │ └── .gitkeep ├── message │ └── .gitkeep ├── movies │ ├── .gitkeep │ └── part2.xml ├── promises │ └── .gitkeep ├── requests │ └── .gitkeep └── testing │ └── .gitkeep ├── .gitignore ├── list ├── test.js ├── package.json ├── index.js └── package-lock.json ├── watchit ├── test.js ├── package.json ├── index.js └── package-lock.json ├── ecomm ├── public │ ├── images │ │ └── banner.jpg │ └── css │ │ └── main.css ├── repositories │ ├── carts.js │ ├── products.js │ ├── users.js │ └── repository.js ├── views │ ├── helpers.js │ ├── admin │ │ ├── auth │ │ │ ├── signin.js │ │ │ └── signup.js │ │ ├── products │ │ │ ├── new.js │ │ │ ├── index.js │ │ │ └── edit.js │ │ └── layout.js │ ├── products │ │ └── index.js │ ├── carts │ │ └── show.js │ └── layout.js ├── carts.json ├── routes │ ├── products.js │ ├── admin │ │ ├── middlewares.js │ │ ├── auth.js │ │ ├── validators.js │ │ └── products.js │ └── carts.js ├── package.json ├── index.js └── users.json ├── tme ├── sampleproject │ ├── index.js │ └── test │ │ └── forEach.test.js ├── index.js ├── samplewebproject │ ├── index.html │ ├── index.js │ └── test │ │ └── app.test.js ├── package.json ├── render.js ├── runner.js └── package-lock.json ├── movies ├── utils.js ├── style.css ├── autocomplete.js ├── index.html └── index.js ├── movies-testing ├── utils.js ├── style.css ├── test │ ├── test.html │ └── autocomplete.test.js ├── autocomplete.js ├── index.html └── index.js ├── hidash ├── index.js └── index.test.js ├── timer ├── index.js ├── index.html ├── style.css └── timer.js ├── maze ├── index.html └── index.js └── message ├── index.js └── index.html /diagrams/01/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /diagrams/02/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /diagrams/03/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /diagrams/04/.gitkeep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /diagrams/05/.gitkeep: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /diagrams/20/.gitkeep: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /diagrams/21/.gitkeep: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /diagrams/22/.gitkeep: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /diagrams/23/.gitkeep: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /diagrams/async/.gitkeep: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /diagrams/ecomm/.gitkeep: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /diagrams/maze/.gitkeep: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /diagrams/node/.gitkeep: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /diagrams/timer/.gitkeep: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /diagrams/message/.gitkeep: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /diagrams/movies/.gitkeep: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /diagrams/promises/.gitkeep: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /diagrams/requests/.gitkeep: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /diagrams/testing/.gitkeep: -------------------------------------------------------------------------------- 1 | 2 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | .DS_Store -------------------------------------------------------------------------------- /list/test.js: -------------------------------------------------------------------------------- 1 | console.log('hi how are you?'); 2 | -------------------------------------------------------------------------------- /watchit/test.js: -------------------------------------------------------------------------------- 1 | setInterval(() => { 2 | console.log('bye there!'); 3 | }, 1000); 4 | -------------------------------------------------------------------------------- /ecomm/public/images/banner.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/StephenGrider/everything-js/master/ecomm/public/images/banner.jpg -------------------------------------------------------------------------------- /tme/sampleproject/index.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | forEach(arr, fn) { 3 | for (let element of arr) { 4 | fn(element); 5 | } 6 | } 7 | }; 8 | -------------------------------------------------------------------------------- /ecomm/repositories/carts.js: -------------------------------------------------------------------------------- 1 | const Repository = require('./repository'); 2 | 3 | class CartsRepository extends Repository {} 4 | 5 | module.exports = new CartsRepository('carts.json'); 6 | -------------------------------------------------------------------------------- /ecomm/repositories/products.js: -------------------------------------------------------------------------------- 1 | const Repository = require('./repository'); 2 | 3 | class ProductsRepository extends Repository {} 4 | 5 | module.exports = new ProductsRepository('products.json'); 6 | -------------------------------------------------------------------------------- /ecomm/views/helpers.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | getError(errors, prop) { 3 | try { 4 | return errors.mapped()[prop].msg; 5 | } catch (err) { 6 | return ''; 7 | } 8 | } 9 | }; 10 | -------------------------------------------------------------------------------- /tme/index.js: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env node 2 | 3 | const Runner = require('./runner'); 4 | const runner = new Runner(); 5 | 6 | const run = async () => { 7 | await runner.collectFiles(process.cwd()); 8 | runner.runTests(); 9 | }; 10 | 11 | run(); 12 | -------------------------------------------------------------------------------- /movies/utils.js: -------------------------------------------------------------------------------- 1 | const debounce = (func, delay = 1000) => { 2 | let timeoutId; 3 | return (...args) => { 4 | if (timeoutId) { 5 | clearTimeout(timeoutId); 6 | } 7 | timeoutId = setTimeout(() => { 8 | func.apply(null, args); 9 | }, delay); 10 | }; 11 | }; 12 | -------------------------------------------------------------------------------- /movies-testing/utils.js: -------------------------------------------------------------------------------- 1 | const debounce = (func, delay = 1000) => { 2 | let timeoutId; 3 | return (...args) => { 4 | if (timeoutId) { 5 | clearTimeout(timeoutId); 6 | } 7 | timeoutId = setTimeout(() => { 8 | func.apply(null, args); 9 | }, delay); 10 | }; 11 | }; 12 | -------------------------------------------------------------------------------- /tme/samplewebproject/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 | 5 | 10 | 11 | 12 | 13 | 14 | -------------------------------------------------------------------------------- /ecomm/carts.json: -------------------------------------------------------------------------------- 1 | [ 2 | { 3 | "items": [], 4 | "id": "cafda8fb" 5 | }, 6 | { 7 | "items": [ 8 | { 9 | "id": "f6b1fbbc", 10 | "quantity": 1 11 | }, 12 | { 13 | "id": "ed1a0390", 14 | "quantity": 1 15 | } 16 | ], 17 | "id": "fb1e6e85" 18 | } 19 | ] -------------------------------------------------------------------------------- /list/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "list", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "bin": { 13 | "nls": "index.js" 14 | }, 15 | "dependencies": { 16 | "chalk": "^2.4.2" 17 | } 18 | } 19 | -------------------------------------------------------------------------------- /tme/samplewebproject/index.js: -------------------------------------------------------------------------------- 1 | document.querySelector('form').addEventListener('submit', event => { 2 | event.preventDefault(); 3 | 4 | const { value } = document.querySelector('input'); 5 | 6 | const header = document.querySelector('h1'); 7 | if (value.includes('@')) { 8 | header.innerHTML = 'Looks good!'; 9 | } else { 10 | header.innerHTML = 'Invalid email'; 11 | } 12 | }); 13 | -------------------------------------------------------------------------------- /tme/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "tme", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "bin": { 13 | "tme": "index.js" 14 | }, 15 | "dependencies": { 16 | "chalk": "^3.0.0", 17 | "jsdom": "^15.2.1" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /ecomm/routes/products.js: -------------------------------------------------------------------------------- 1 | const express = require('express'); 2 | const productsRepo = require('../repositories/products'); 3 | const productsIndexTemplate = require('../views/products/index'); 4 | 5 | const router = express.Router(); 6 | 7 | router.get('/', async (req, res) => { 8 | const products = await productsRepo.getAll(); 9 | res.send(productsIndexTemplate({ products })); 10 | }); 11 | 12 | module.exports = router; 13 | -------------------------------------------------------------------------------- /ecomm/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "ecomm", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "dev": "nodemon index.js --ignore *.json" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "dependencies": { 13 | "cookie-session": "^1.3.3", 14 | "express": "^4.17.1", 15 | "express-validator": "^6.2.0", 16 | "multer": "^1.4.2", 17 | "nodemon": "^1.19.4" 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /hidash/index.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | forEach(arr, fn) { 3 | // for (let i = 0; i < arr.length; i++) { 4 | // const value = arr[i]; 5 | // fn(value, i); 6 | // } 7 | 8 | for (let index in arr) { 9 | fn(arr[index], index); 10 | } 11 | }, 12 | map(arr, fn) { 13 | const result = []; 14 | 15 | for (let i = 0; i < arr.length; i++) { 16 | result.push(fn(arr[i], i)); 17 | } 18 | 19 | return result; 20 | } 21 | }; 22 | -------------------------------------------------------------------------------- /watchit/package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "watchit", 3 | "version": "1.0.0", 4 | "description": "", 5 | "main": "index.js", 6 | "scripts": { 7 | "test": "echo \"Error: no test specified\" && exit 1" 8 | }, 9 | "keywords": [], 10 | "author": "", 11 | "license": "ISC", 12 | "bin": { 13 | "watchit": "index.js" 14 | }, 15 | "dependencies": { 16 | "caporal": "^1.3.0", 17 | "chalk": "^3.0.0", 18 | "chokidar": "^3.3.0", 19 | "lodash.debounce": "^4.0.8" 20 | } 21 | } 22 | -------------------------------------------------------------------------------- /hidash/index.test.js: -------------------------------------------------------------------------------- 1 | const assert = require('assert'); 2 | const { forEach, map } = require('./index'); 3 | 4 | it('The forEach function', () => { 5 | let sum = 0; 6 | forEach([1, 2, 3], value => { 7 | sum += value; 8 | }); 9 | 10 | assert.strictEqual(sum, 6, 'Expected forEach to sum the array'); 11 | }); 12 | 13 | it('The map function', () => { 14 | const result = map([1, 2, 3], value => { 15 | return value * 2; 16 | }); 17 | 18 | assert.deepStrictEqual(result, [2, 4, 6]); 19 | }); 20 | -------------------------------------------------------------------------------- /tme/render.js: -------------------------------------------------------------------------------- 1 | const path = require('path'); 2 | const jsdom = require('jsdom'); 3 | const { JSDOM } = jsdom; 4 | 5 | const render = async filename => { 6 | const filePath = path.join(process.cwd(), filename); 7 | 8 | const dom = await JSDOM.fromFile(filePath, { 9 | runScripts: 'dangerously', 10 | resources: 'usable' 11 | }); 12 | 13 | return new Promise((resolve, reject) => { 14 | dom.window.document.addEventListener('DOMContentLoaded', () => { 15 | resolve(dom); 16 | }); 17 | }); 18 | }; 19 | 20 | module.exports = render; 21 | -------------------------------------------------------------------------------- /tme/sampleproject/test/forEach.test.js: -------------------------------------------------------------------------------- 1 | const assert = require('assert'); 2 | const { forEach } = require('../index'); 3 | 4 | let numbers; 5 | beforeEach(() => { 6 | numbers = [1, 2, 3]; 7 | }); 8 | 9 | it('should sum an array', () => { 10 | let total = 0; 11 | forEach(numbers, value => { 12 | total += value; 13 | }); 14 | 15 | assert.strictEqual(total, 6); 16 | numbers.push(3); 17 | numbers.push(3); 18 | numbers.push(3); 19 | numbers.push(3); 20 | }); 21 | 22 | it('beforeEach is ran each time', () => { 23 | assert.strictEqual(numbers.length, 4); 24 | }); 25 | -------------------------------------------------------------------------------- /diagrams/01/diagrams.xml: -------------------------------------------------------------------------------- 1 || Title | 37 |Price | 38 |Edit | 39 |Delete | 40 |
|---|
We will tell you which is best!
45 |We will tell you which is best!
45 |
113 |
114 |
${movieDetail.Plot}
121 |${movieDetail.Awards}
127 |Awards
128 |${movieDetail.BoxOffice}
131 |Box Office
132 |${movieDetail.Metascore}
135 |Metascore
136 |${movieDetail.imdbRating}
139 |IMDB Rating
140 |${movieDetail.imdbVotes}
143 |IMDB Votes
144 |
113 |
114 |
${movieDetail.Plot}
121 |${movieDetail.Awards}
127 |Awards
128 |${movieDetail.BoxOffice}
131 |Box Office
132 |${movieDetail.Metascore}
135 |Metascore
136 |${movieDetail.imdbRating}
139 |IMDB Rating
140 |${movieDetail.imdbVotes}
143 |IMDB Votes
144 |