diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..7a73a41 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,2 @@ +{ +} \ No newline at end of file diff --git a/chapter1/bank-account.js b/chapter1/bank-account.js index 6d49677..aa2ad4e 100644 --- a/chapter1/bank-account.js +++ b/chapter1/bank-account.js @@ -4,18 +4,34 @@ var BankSecurity = { var BankAccount = { balance: 0, +<<<<<<< HEAD + + deposit: function (money) { + this.balance = this.balance + money; + return this.balance; + }, + +======= deposit: function (money) { this.balance = this.balance + money; }, +>>>>>>> 4f8b4060407687a11e26eb422cb4e79289fe505c widthraw: function (cash) { this.balance = this.balance - cash; return this.balance; } +<<<<<<< HEAD +} +======= }; +>>>>>>> 4f8b4060407687a11e26eb422cb4e79289fe505c module.exports = { BankAccount: BankAccount, BankSecurity: BankSecurity } +<<<<<<< HEAD +======= +>>>>>>> 4f8b4060407687a11e26eb422cb4e79289fe505c diff --git a/chapter1/index.js b/chapter1/index.js index 09d2b85..5026932 100644 --- a/chapter1/index.js +++ b/chapter1/index.js @@ -1,33 +1,88 @@ -(function(){ +let Formulas = {}; - console.log('Hello world'); +Formulas.add = function (a, b) { + return a + b; +} - let add = function(a, b){ - return a + b; +Formulas.divideMultiply = function (a, b) { + if (b == 0) { + return undefined; } + return a * a / b; +} - let o = { - key: { key: { key: 42 }} - }; +Formulas.roundNumbers = function (a) { + return Math.round(a); +} - let arr = [1,2,3,4,5]; - - console.log(arr[4]) +Formulas.sinTimesCos = function (a) { + return Math.sin(a) * Math.cos(a); +} + +Formulas.parseNumberFromString = function (a) { + return parseFloat(a); +} +Formulas.findObjectValueByKey = function (obj, key) { + let i; + let j; + let p; + + for (i = 0; i < Object.keys(obj).length; i++) { + if (Object.keys(obj)[i] === key) { + return Object.values(obj)[i]; + } + if (typeof Object.values(obj)[i] === "object" && (Object.values(obj)[i] !== null)) { + var newObject = Object.values(obj)[i]; + for (j = 0; j < Object.keys(newObject).length; j++) { + if (Object.keys(newObject)[j] === key) { + return Object.values(newObject)[j]; + } + if (typeof Object.values(newObject)[j] === "object" && (Object.values(newObject)[j] !== null)) { + var newObject2 = Object.values(newObject)[j]; + for (p = 0; p < Object.keys(newObject2).length; p++) { + if (Object.keys(newObject2)[p] === key) { + return Object.values(newObject2)[p]; + } + } + } + } + } + } +} +Formulas.parseJSON = function (a) { + return JSON.parse(a); +} +Formulas.pushToArray = function (a, b) { + return a.push(b); +} - let blablaFunction = function(phrase) { - return function(){ - console.log('Phrase ' + phrase); - } +Formulas.squareArrayValues = function (a) { + var newArr = a; + for (var i = 0; i < newArr.length; i++) { + newArr[i] = newArr[i] * newArr[i]; } + return a; +} - let composedBlablaFunction = function(blaFunction) { - console.log('Get some air in your lungs!'); - blaFunction(); - console.log('Now you can rest!') +Formulas.sortArray = function (a) { + return a.sort(Formulas.sortNumbers) +} + +Formulas.sortNumbers = function (a, b) { + return a - b; +} + +Formulas.reverseString = function (a) { + var newString = ""; + for (var i = a.length - 1; i >= 0; i--) { + newString += a[i]; } + return newString; +} + +module.exports = Formulas; + - composedBlablaFunction(blablaFunction('Hello world')) -}()); diff --git a/chapter1/package-lock.json b/chapter1/package-lock.json index 876b35a..59b1304 100644 --- a/chapter1/package-lock.json +++ b/chapter1/package-lock.json @@ -16,7 +16,7 @@ "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "requires": { - "balanced-match": "^1.0.0", + "balanced-match": "1.0.0", "concat-map": "0.0.1" } }, @@ -71,12 +71,12 @@ "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "dev": true, "requires": { - "fs.realpath": "^1.0.0", - "inflight": "^1.0.4", - "inherits": "2", - "minimatch": "^3.0.4", - "once": "^1.3.0", - "path-is-absolute": "^1.0.0" + "fs.realpath": "1.0.0", + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.4.0", + "path-is-absolute": "1.0.1" } }, "growl": { @@ -103,8 +103,8 @@ "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", "dev": true, "requires": { - "once": "^1.3.0", - "wrappy": "1" + "once": "1.4.0", + "wrappy": "1.0.2" } }, "inherits": { @@ -119,7 +119,7 @@ "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, "requires": { - "brace-expansion": "^1.1.7" + "brace-expansion": "1.1.11" } }, "minimist": { @@ -168,7 +168,7 @@ "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "dev": true, "requires": { - "wrappy": "1" + "wrappy": "1.0.2" } }, "path-is-absolute": { @@ -183,7 +183,7 @@ "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", "dev": true, "requires": { - "has-flag": "^3.0.0" + "has-flag": "3.0.0" } }, "wrappy": { diff --git a/chapter1/package.json b/chapter1/package.json index dae84d1..dfb046b 100644 --- a/chapter1/package.json +++ b/chapter1/package.json @@ -4,7 +4,7 @@ "description": "", "main": "index.js", "scripts": { - "test": "./node_modules/mocha/bin/mocha" + "test": "mocha" }, "author": "", "license": "MIT", diff --git a/chapter1/test/bank-account.test.js b/chapter1/test/bank-account.test.js index d48e11e..6c2f313 100644 --- a/chapter1/test/bank-account.test.js +++ b/chapter1/test/bank-account.test.js @@ -3,6 +3,17 @@ var BankAccount = require('../bank-account').BankAccount; describe('Bank account', () => { it('should have no money on deposit in the beginning', () => { +<<<<<<< HEAD + assert.equal(BankAccount.balance, 0); + }); + + it('should be able to withdraw money', () => { + assert.equal(BankAccount.widthraw(20), -20); + }); + + it('should be able to deposit money', () => { + assert.equal(BankAccount.deposit(30), 10); +======= var obj = { foo: "hello world", @@ -14,5 +25,6 @@ describe('Bank account', () => { obj.fn(1,2,3,4,45,6, "", {}, [], Infinity,1,23,1,12,12,3,12,3123,123,123,123,123,123,123); //assert.equal(BankAccount.balance, 0); +>>>>>>> 4f8b4060407687a11e26eb422cb4e79289fe505c }); }) \ No newline at end of file diff --git a/chapter1/test/index.test.js b/chapter1/test/index.test.js index 90bc885..56b114e 100644 --- a/chapter1/test/index.test.js +++ b/chapter1/test/index.test.js @@ -1,85 +1,108 @@ var assert = require('assert'); +var Formulas = require('../index.js'); + +describe('JS Basics', function () { + describe('Numbers', function () { + it('should be able to add numbers', function () { + var a = 45; + var b = 54; + assert.equal(Formulas.add(a, b), 99); + }); +<<<<<<< HEAD + it('should be able to divide and multiply number', function () { + var a = 4; + var b = 2; + assert.equal(Formulas.divideMultiply(a, b), 8); +======= xdescribe('JS Basics', function() { describe('Numbers', function() { it('should be able to add number', function() { var a = 42.9902822; var b = 43.2929112; assert.equal(a + b, 99); +>>>>>>> 4f8b4060407687a11e26eb422cb4e79289fe505c }); - it('should be able to divide and multiply number', function() { - var a = 42.94; + it('should return undefined if divided by 0', function () { + var a = 4; var b = 0; - - assert.equal(a * a / b, 42); + assert.equal(Formulas.divideMultiply(a, b), undefined); }); - it('should be able to round numbers', function() { - var a = 42.94; - assert.equal(a, 42); + it('should be able to round numbers', function () { + var a = 42.94; + assert.equal(Formulas.roundNumbers(a), 43); }); - it('should be able to find sin(x) * cos(x)', function() { - var a = 42; - assert.equal(a, 1); + it('should be able to find sin(x)*cos(x)', function () { + var a = 0; + assert.equal(Formulas.sinTimesCos(a), 0); }); - it('should be able to parse number form string', function() { + it('should be able to parse number form string', function () { var price = "9.99 $" - assert.equal(price, 9.99); + assert.equal(Formulas.parseNumberFromString(price), 9.99); }); }); - describe('Objects', function() { - it('should be find object value by key', function() { - var obj = { a: {b: { d: "foo" }}, c: 42 } - assert.equal(obj, "foo"); + describe('Objects', function () { + it('should be able to find object value by key', function () { + var obj = { a: { b: { d: "foo" } }, c: 42 }; + assert.equal(Formulas.findObjectValueByKey(obj, 'd'), "foo"); }); - it('should be find object value by dynamic key', function() { - var obj = { a: {b: { d: "foo" }}, c: 42 } - assert.equal(obj["hm"], 42); + it('should be able to find object value by dynamic key', function () { + var obj = { a: { b: { d: "foo" } }, c: 42 } + assert.equal(Formulas.findObjectValueByKey(obj, 'c'), 42);; }); - it('should be parse object from json', function() { + it('should be able to parse object from json', function () { var json = '{"ok":true,"user_lessons":[{"user_lesson_id":408097171313,"state":"completed","skip":false,"lesson_id":1,"date_start":1533108640,"tasks":[{"user_task_id":407936828624,"state":"skipped","current_step":"","task_id":1},{"user_task_id":408791535509,"state":"skipped","current_step":"","task_id":2},{"user_task_id":409970847238,"state":"skipped","current_step":"","task_id":3}]}]}' - var dateStart = 42; + var parsedJSON = Formulas.parseJSON(json); + var dateStart = parsedJSON.user_lessons[0].date_start; assert.equal(dateStart, 1533108640); }); - it('should be set objet key', function() { - var obj = { a: {b: { d: "foo" }}, c: 42 } + it('should be able to set object key', function () { + var obj = { a: { b: { d: "foo" } }, c: 42 } + obj.a.b = "Js Rocks!"; assert.equal(obj.a.b, "Js Rocks!") }); }); - describe('Arrays', function() { - it('should be access array by index', function() { - var arrray = [1,2,3,4,5,6,7,8,9] - assert.equal(arrray, 5); + describe('Arrays', function () { + it('should be able to access array by index', function () { + var arrray = [1, 2, 3, 4, 5, 6, 7, 8, 9]; + assert.equal(arrray[4], 5); }); - it('should to push and pop from array', function() { - var arrray = [1,2,3,4,5,6,7,8,9] - assert.equal(arrray.length, 10); + it('should to push and pop from array', function () { + var array = [1, 2, 3, 4, 5, 6, 7, 8, 9]; + Formulas.pushToArray(array, 10); + assert.equal(array.length, 10); }); - it('should be able to output square of array values', function() { - assert.equal() + it('should be able to output square of array values', function () { + var arr = [1, 2, 3, 4, 5]; + var expectedArr = [1, 4, 9, 16, 25]; + var newArr = Formulas.squareArrayValues(arr); + assert.deepEqual(newArr, expectedArr); }); - it('should be able to sort array', function() { - var arr = [23,23,4,5,123,7,32,13,13,9] - assert.equal(arr, []); + it('should be able to sort array', function () { + var arr = [23, 23, 4, 5, 123, 7, 32, 13, 13, 9]; + var expectedArr = [4, 5, 7, 9, 13, 13, 23, 23, 32, 123]; + var sortedArr = Formulas.sortArray(arr); + assert.deepEqual(sortedArr, expectedArr); }); - it('should be able to reverse string', function() { - - var string = "I love corgies!" - assert.equal(string, "!seigroc evol I") + it('should be able to reverse string', function () { + var string = "I love corgies!"; + var newString = Formulas.reverseString(string); + assert.equal(newString, "!seigroc evol I"); }); }); }); \ No newline at end of file diff --git a/chapter2/package-lock.json b/chapter2/package-lock.json index 86e82c1..70d5900 100644 --- a/chapter2/package-lock.json +++ b/chapter2/package-lock.json @@ -9,7 +9,11 @@ "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.5.tgz", "integrity": "sha1-63d99gEXI6OxTopywIBcjoZ0a9I=", "requires": { +<<<<<<< HEAD + "mime-types": "2.1.20", +======= "mime-types": "~2.1.18", +>>>>>>> 4f8b4060407687a11e26eb422cb4e79289fe505c "negotiator": "0.6.1" } }, @@ -25,6 +29,22 @@ "dev": true }, "body-parser": { +<<<<<<< HEAD + "version": "1.18.2", + "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.18.2.tgz", + "integrity": "sha1-h2eKGdhLR9hZuDGZvVm84iKxBFQ=", + "requires": { + "bytes": "3.0.0", + "content-type": "1.0.4", + "debug": "2.6.9", + "depd": "1.1.2", + "http-errors": "1.6.3", + "iconv-lite": "0.4.19", + "on-finished": "2.3.0", + "qs": "6.5.1", + "raw-body": "2.3.2", + "type-is": "1.6.16" +======= "version": "1.18.3", "resolved": "https://registry.npmjs.org/body-parser/-/body-parser-1.18.3.tgz", "integrity": "sha1-WykhmP/dVTs6DyDe0FkrlWlVyLQ=", @@ -46,6 +66,7 @@ "resolved": "https://registry.npmjs.org/qs/-/qs-6.5.2.tgz", "integrity": "sha512-N5ZAX4/LxJmF+7wN74pUD6qAh9/wnvdQcjq9TZjevvXzSUo7bfmw91saqMjzGS2xq91/odN2dW/WOl7qQHNDGA==" } +>>>>>>> 4f8b4060407687a11e26eb422cb4e79289fe505c } }, "brace-expansion": { @@ -54,7 +75,11 @@ "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", "dev": true, "requires": { +<<<<<<< HEAD + "balanced-match": "1.0.0", +======= "balanced-match": "^1.0.0", +>>>>>>> 4f8b4060407687a11e26eb422cb4e79289fe505c "concat-map": "0.0.1" } }, @@ -156,6 +181,30 @@ "resolved": "https://registry.npmjs.org/express/-/express-4.16.3.tgz", "integrity": "sha1-avilAjUNsyRuzEvs9rWjTSL37VM=", "requires": { +<<<<<<< HEAD + "accepts": "1.3.5", + "array-flatten": "1.1.1", + "body-parser": "1.18.2", + "content-disposition": "0.5.2", + "content-type": "1.0.4", + "cookie": "0.3.1", + "cookie-signature": "1.0.6", + "debug": "2.6.9", + "depd": "1.1.2", + "encodeurl": "1.0.2", + "escape-html": "1.0.3", + "etag": "1.8.1", + "finalhandler": "1.1.1", + "fresh": "0.5.2", + "merge-descriptors": "1.0.1", + "methods": "1.1.2", + "on-finished": "2.3.0", + "parseurl": "1.3.2", + "path-to-regexp": "0.1.7", + "proxy-addr": "2.0.4", + "qs": "6.5.1", + "range-parser": "1.2.0", +======= "accepts": "~1.3.5", "array-flatten": "1.1.1", "body-parser": "1.18.2", @@ -178,10 +227,17 @@ "proxy-addr": "~2.0.3", "qs": "6.5.1", "range-parser": "~1.2.0", +>>>>>>> 4f8b4060407687a11e26eb422cb4e79289fe505c "safe-buffer": "5.1.1", "send": "0.16.2", "serve-static": "1.13.2", "setprototypeof": "1.1.0", +<<<<<<< HEAD + "statuses": "1.4.0", + "type-is": "1.6.16", + "utils-merge": "1.0.1", + "vary": "1.1.2" +======= "statuses": "~1.4.0", "type-is": "~1.6.16", "utils-merge": "1.0.1", @@ -244,6 +300,7 @@ } } } +>>>>>>> 4f8b4060407687a11e26eb422cb4e79289fe505c } }, "finalhandler": { @@ -252,12 +309,21 @@ "integrity": "sha512-Y1GUDo39ez4aHAw7MysnUD5JzYX+WaIj8I57kO3aEPT1fFRL4sr7mjei97FgnwhAyyzRYmQZaTHb2+9uZ1dPtg==", "requires": { "debug": "2.6.9", +<<<<<<< HEAD + "encodeurl": "1.0.2", + "escape-html": "1.0.3", + "on-finished": "2.3.0", + "parseurl": "1.3.2", + "statuses": "1.4.0", + "unpipe": "1.0.0" +======= "encodeurl": "~1.0.2", "escape-html": "~1.0.3", "on-finished": "~2.3.0", "parseurl": "~1.3.2", "statuses": "~1.4.0", "unpipe": "~1.0.0" +>>>>>>> 4f8b4060407687a11e26eb422cb4e79289fe505c } }, "forwarded": { @@ -282,12 +348,21 @@ "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", "dev": true, "requires": { +<<<<<<< HEAD + "fs.realpath": "1.0.0", + "inflight": "1.0.6", + "inherits": "2.0.3", + "minimatch": "3.0.4", + "once": "1.4.0", + "path-is-absolute": "1.0.1" +======= "fs.realpath": "^1.0.0", "inflight": "^1.0.4", "inherits": "2", "minimatch": "^3.0.4", "once": "^1.3.0", "path-is-absolute": "^1.0.0" +>>>>>>> 4f8b4060407687a11e26eb422cb4e79289fe505c } }, "growl": { @@ -313,6 +388,18 @@ "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz", "integrity": "sha1-i1VoC7S+KDoLW/TqLjhYC+HZMg0=", "requires": { +<<<<<<< HEAD + "depd": "1.1.2", + "inherits": "2.0.3", + "setprototypeof": "1.1.0", + "statuses": "1.4.0" + } + }, + "iconv-lite": { + "version": "0.4.19", + "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.19.tgz", + "integrity": "sha512-oTZqweIP51xaGPI4uPa56/Pri/480R+mo7SeU+YETByQNhDG55ycFyNLIgta9vXhILrxXDmF7ZGhqZIcuN0gJQ==" +======= "depd": "~1.1.2", "inherits": "2.0.3", "setprototypeof": "1.1.0", @@ -326,6 +413,7 @@ "requires": { "safer-buffer": ">= 2.1.2 < 3" } +>>>>>>> 4f8b4060407687a11e26eb422cb4e79289fe505c }, "inflight": { "version": "1.0.6", @@ -333,8 +421,13 @@ "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", "dev": true, "requires": { +<<<<<<< HEAD + "once": "1.4.0", + "wrappy": "1.0.2" +======= "once": "^1.3.0", "wrappy": "1" +>>>>>>> 4f8b4060407687a11e26eb422cb4e79289fe505c } }, "inherits": { @@ -347,11 +440,14 @@ "resolved": "https://registry.npmjs.org/ipaddr.js/-/ipaddr.js-1.8.0.tgz", "integrity": "sha1-6qM9bd16zo9/b+DJygRA5wZzix4=" }, +<<<<<<< HEAD +======= "lodash": { "version": "4.17.10", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.10.tgz", "integrity": "sha512-UejweD1pDoXu+AD825lWwp4ZGtSwgnpZxb3JDViD7StjQz+Nb/6l093lx4OQ0foGWNRoc19mWy7BzL+UAK2iVg==" }, +>>>>>>> 4f8b4060407687a11e26eb422cb4e79289fe505c "media-typer": { "version": "0.3.0", "resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz", @@ -382,7 +478,11 @@ "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.20.tgz", "integrity": "sha512-HrkrPaP9vGuWbLK1B1FfgAkbqNjIuy4eHlIYnFi7kamZyLLrGlo2mpcx0bBmNpKqBtYtAfGbodDddIgddSJC2A==", "requires": { +<<<<<<< HEAD + "mime-db": "1.36.0" +======= "mime-db": "~1.36.0" +>>>>>>> 4f8b4060407687a11e26eb422cb4e79289fe505c } }, "minimatch": { @@ -391,7 +491,11 @@ "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", "dev": true, "requires": { +<<<<<<< HEAD + "brace-expansion": "1.1.11" +======= "brace-expansion": "^1.1.7" +>>>>>>> 4f8b4060407687a11e26eb422cb4e79289fe505c } }, "minimist": { @@ -463,7 +567,11 @@ "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", "dev": true, "requires": { +<<<<<<< HEAD + "wrappy": "1.0.2" +======= "wrappy": "1" +>>>>>>> 4f8b4060407687a11e26eb422cb4e79289fe505c } }, "parseurl": { @@ -487,7 +595,11 @@ "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.4.tgz", "integrity": "sha512-5erio2h9jp5CHGwcybmxmVqHmnCBZeewlfJ0pex+UW7Qny7OOZXTtH56TGNyBizkgiOwhJtMKrVzDTeKcySZwA==", "requires": { +<<<<<<< HEAD + "forwarded": "0.1.2", +======= "forwarded": "~0.1.2", +>>>>>>> 4f8b4060407687a11e26eb422cb4e79289fe505c "ipaddr.js": "1.8.0" } }, @@ -502,6 +614,39 @@ "integrity": "sha1-9JvmtIeJTdxA3MlKMi9hEJLgDV4=" }, "raw-body": { +<<<<<<< HEAD + "version": "2.3.2", + "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.3.2.tgz", + "integrity": "sha1-vNYMd9Prk83gBQKVw/N5OJvIj4k=", + "requires": { + "bytes": "3.0.0", + "http-errors": "1.6.2", + "iconv-lite": "0.4.19", + "unpipe": "1.0.0" + }, + "dependencies": { + "depd": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/depd/-/depd-1.1.1.tgz", + "integrity": "sha1-V4O04cRZ8G+lyif5kfPQbnoxA1k=" + }, + "http-errors": { + "version": "1.6.2", + "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-1.6.2.tgz", + "integrity": "sha1-CgAsyFcHGSp+eUbO7cERVfYOxzY=", + "requires": { + "depd": "1.1.1", + "inherits": "2.0.3", + "setprototypeof": "1.0.3", + "statuses": "1.4.0" + } + }, + "setprototypeof": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/setprototypeof/-/setprototypeof-1.0.3.tgz", + "integrity": "sha1-ZlZ+NwQ+608E2RvWWMDL77VbjgQ=" + } +======= "version": "2.3.3", "resolved": "https://registry.npmjs.org/raw-body/-/raw-body-2.3.3.tgz", "integrity": "sha512-9esiElv1BrZoI3rCDuOuKCBRbuApGGaDPQfjSflGxdy4oyzqghxu6klEkkVIvBje+FF0BX9coEv8KqW6X/7njw==", @@ -510,6 +655,7 @@ "http-errors": "1.6.3", "iconv-lite": "0.4.23", "unpipe": "1.0.0" +>>>>>>> 4f8b4060407687a11e26eb422cb4e79289fe505c } }, "safe-buffer": { @@ -517,17 +663,34 @@ "resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.1.1.tgz", "integrity": "sha512-kKvNJn6Mm93gAczWVJg7wH+wGYWNrDHdWvpUmHyEsgCtIwwo3bqPtV4tR5tuPaUhTOo/kvhVwd8XwwOllGYkbg==" }, +<<<<<<< HEAD +======= "safer-buffer": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/safer-buffer/-/safer-buffer-2.1.2.tgz", "integrity": "sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==" }, +>>>>>>> 4f8b4060407687a11e26eb422cb4e79289fe505c "send": { "version": "0.16.2", "resolved": "https://registry.npmjs.org/send/-/send-0.16.2.tgz", "integrity": "sha512-E64YFPUssFHEFBvpbbjr44NCLtI1AohxQ8ZSiJjQLskAdKuriYEP6VyGEsRDH8ScozGpkaX1BGvhanqCwkcEZw==", "requires": { "debug": "2.6.9", +<<<<<<< HEAD + "depd": "1.1.2", + "destroy": "1.0.4", + "encodeurl": "1.0.2", + "escape-html": "1.0.3", + "etag": "1.8.1", + "fresh": "0.5.2", + "http-errors": "1.6.3", + "mime": "1.4.1", + "ms": "2.0.0", + "on-finished": "2.3.0", + "range-parser": "1.2.0", + "statuses": "1.4.0" +======= "depd": "~1.1.2", "destroy": "~1.0.4", "encodeurl": "~1.0.2", @@ -540,6 +703,7 @@ "on-finished": "~2.3.0", "range-parser": "~1.2.0", "statuses": "~1.4.0" +>>>>>>> 4f8b4060407687a11e26eb422cb4e79289fe505c } }, "serve-static": { @@ -547,9 +711,15 @@ "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.13.2.tgz", "integrity": "sha512-p/tdJrO4U387R9oMjb1oj7qSMaMfmOyd4j9hOFoxZe2baQszgHcSWjuya/CiT5kgZZKRudHNOA0pYXOl8rQ5nw==", "requires": { +<<<<<<< HEAD + "encodeurl": "1.0.2", + "escape-html": "1.0.3", + "parseurl": "1.3.2", +======= "encodeurl": "~1.0.2", "escape-html": "~1.0.3", "parseurl": "~1.3.2", +>>>>>>> 4f8b4060407687a11e26eb422cb4e79289fe505c "send": "0.16.2" } }, @@ -569,7 +739,11 @@ "integrity": "sha512-zjaXglF5nnWpsq470jSv6P9DwPvgLkuapYmfDm3JWOm0vkNTVF2tI4UrN2r6jH1qM/uc/WtxYY1hYoA2dOKj5w==", "dev": true, "requires": { +<<<<<<< HEAD + "has-flag": "3.0.0" +======= "has-flag": "^3.0.0" +>>>>>>> 4f8b4060407687a11e26eb422cb4e79289fe505c } }, "type-is": { @@ -578,7 +752,11 @@ "integrity": "sha512-HRkVv/5qY2G6I8iab9cI7v1bOIdhm94dVjQCPFElW9W+3GeDOSHmy2EBYe4VTApuzolPcmgFTN3ftVJRKR2J9Q==", "requires": { "media-typer": "0.3.0", +<<<<<<< HEAD + "mime-types": "2.1.20" +======= "mime-types": "~2.1.18" +>>>>>>> 4f8b4060407687a11e26eb422cb4e79289fe505c } }, "unpipe": { diff --git a/chapter2/package.json b/chapter2/package.json index 7bee432..0faa71c 100644 --- a/chapter2/package.json +++ b/chapter2/package.json @@ -9,9 +9,13 @@ "author": "", "license": "ISC", "dependencies": { +<<<<<<< HEAD + "express": "^4.16.3" +======= "body-parser": "^1.18.3", "express": "^4.16.3", "lodash": "^4.17.10" +>>>>>>> 4f8b4060407687a11e26eb422cb4e79289fe505c }, "devDependencies": { "mocha": "^5.2.0" diff --git a/chapter2/scripts.js b/chapter2/scripts.js new file mode 100644 index 0000000..31aa746 --- /dev/null +++ b/chapter2/scripts.js @@ -0,0 +1,11 @@ +const express = require('express'); + +const app = express(); + +app.get('/', function (req, res) { + res.send("Hello world") +}) + +app.listen(8000, function () { + console.log("It's live"); +}) \ No newline at end of file diff --git a/chapter4-homework/app.js b/chapter4-homework/app.js index 81e3f67..1126a5b 100644 --- a/chapter4-homework/app.js +++ b/chapter4-homework/app.js @@ -1,6 +1,6 @@ var express = require('express'); var app = express(); -app.use(express.static('public')) +app.use(express.static('public')); app.listen(3000); \ No newline at end of file diff --git a/chapter4-homework/package-lock.json b/chapter4-homework/package-lock.json index 99ea8e8..fd1d272 100644 --- a/chapter4-homework/package-lock.json +++ b/chapter4-homework/package-lock.json @@ -9,7 +9,7 @@ "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.5.tgz", "integrity": "sha1-63d99gEXI6OxTopywIBcjoZ0a9I=", "requires": { - "mime-types": "~2.1.18", + "mime-types": "2.1.20", "negotiator": "0.6.1" } }, @@ -24,15 +24,15 @@ "integrity": "sha1-h2eKGdhLR9hZuDGZvVm84iKxBFQ=", "requires": { "bytes": "3.0.0", - "content-type": "~1.0.4", + "content-type": "1.0.4", "debug": "2.6.9", - "depd": "~1.1.1", - "http-errors": "~1.6.2", + "depd": "1.1.2", + "http-errors": "1.6.3", "iconv-lite": "0.4.19", - "on-finished": "~2.3.0", + "on-finished": "2.3.0", "qs": "6.5.1", "raw-body": "2.3.2", - "type-is": "~1.6.15" + "type-is": "1.6.16" }, "dependencies": { "debug": { @@ -105,36 +105,36 @@ "resolved": "http://registry.npmjs.org/express/-/express-4.16.3.tgz", "integrity": "sha1-avilAjUNsyRuzEvs9rWjTSL37VM=", "requires": { - "accepts": "~1.3.5", + "accepts": "1.3.5", "array-flatten": "1.1.1", "body-parser": "1.18.2", "content-disposition": "0.5.2", - "content-type": "~1.0.4", + "content-type": "1.0.4", "cookie": "0.3.1", "cookie-signature": "1.0.6", "debug": "2.6.9", - "depd": "~1.1.2", - "encodeurl": "~1.0.2", - "escape-html": "~1.0.3", - "etag": "~1.8.1", + "depd": "1.1.2", + "encodeurl": "1.0.2", + "escape-html": "1.0.3", + "etag": "1.8.1", "finalhandler": "1.1.1", "fresh": "0.5.2", "merge-descriptors": "1.0.1", - "methods": "~1.1.2", - "on-finished": "~2.3.0", - "parseurl": "~1.3.2", + "methods": "1.1.2", + "on-finished": "2.3.0", + "parseurl": "1.3.2", "path-to-regexp": "0.1.7", - "proxy-addr": "~2.0.3", + "proxy-addr": "2.0.4", "qs": "6.5.1", - "range-parser": "~1.2.0", + "range-parser": "1.2.0", "safe-buffer": "5.1.1", "send": "0.16.2", "serve-static": "1.13.2", "setprototypeof": "1.1.0", - "statuses": "~1.4.0", - "type-is": "~1.6.16", + "statuses": "1.4.0", + "type-is": "1.6.16", "utils-merge": "1.0.1", - "vary": "~1.1.2" + "vary": "1.1.2" }, "dependencies": { "debug": { @@ -153,12 +153,12 @@ "integrity": "sha512-Y1GUDo39ez4aHAw7MysnUD5JzYX+WaIj8I57kO3aEPT1fFRL4sr7mjei97FgnwhAyyzRYmQZaTHb2+9uZ1dPtg==", "requires": { "debug": "2.6.9", - "encodeurl": "~1.0.2", - "escape-html": "~1.0.3", - "on-finished": "~2.3.0", - "parseurl": "~1.3.2", - "statuses": "~1.4.0", - "unpipe": "~1.0.0" + "encodeurl": "1.0.2", + "escape-html": "1.0.3", + "on-finished": "2.3.0", + "parseurl": "1.3.2", + "statuses": "1.4.0", + "unpipe": "1.0.0" }, "dependencies": { "debug": { @@ -186,10 +186,10 @@ "resolved": "http://registry.npmjs.org/http-errors/-/http-errors-1.6.3.tgz", "integrity": "sha1-i1VoC7S+KDoLW/TqLjhYC+HZMg0=", "requires": { - "depd": "~1.1.2", + "depd": "1.1.2", "inherits": "2.0.3", "setprototypeof": "1.1.0", - "statuses": ">= 1.4.0 < 2" + "statuses": "1.4.0" } }, "iconv-lite": { @@ -237,7 +237,7 @@ "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.20.tgz", "integrity": "sha512-HrkrPaP9vGuWbLK1B1FfgAkbqNjIuy4eHlIYnFi7kamZyLLrGlo2mpcx0bBmNpKqBtYtAfGbodDddIgddSJC2A==", "requires": { - "mime-db": "~1.36.0" + "mime-db": "1.36.0" } }, "ms": { @@ -273,7 +273,7 @@ "resolved": "https://registry.npmjs.org/proxy-addr/-/proxy-addr-2.0.4.tgz", "integrity": "sha512-5erio2h9jp5CHGwcybmxmVqHmnCBZeewlfJ0pex+UW7Qny7OOZXTtH56TGNyBizkgiOwhJtMKrVzDTeKcySZwA==", "requires": { - "forwarded": "~0.1.2", + "forwarded": "0.1.2", "ipaddr.js": "1.8.0" } }, @@ -311,7 +311,7 @@ "depd": "1.1.1", "inherits": "2.0.3", "setprototypeof": "1.0.3", - "statuses": ">= 1.3.1 < 2" + "statuses": "1.4.0" } }, "setprototypeof": { @@ -332,18 +332,18 @@ "integrity": "sha512-E64YFPUssFHEFBvpbbjr44NCLtI1AohxQ8ZSiJjQLskAdKuriYEP6VyGEsRDH8ScozGpkaX1BGvhanqCwkcEZw==", "requires": { "debug": "2.6.9", - "depd": "~1.1.2", - "destroy": "~1.0.4", - "encodeurl": "~1.0.2", - "escape-html": "~1.0.3", - "etag": "~1.8.1", + "depd": "1.1.2", + "destroy": "1.0.4", + "encodeurl": "1.0.2", + "escape-html": "1.0.3", + "etag": "1.8.1", "fresh": "0.5.2", - "http-errors": "~1.6.2", + "http-errors": "1.6.3", "mime": "1.4.1", "ms": "2.0.0", - "on-finished": "~2.3.0", - "range-parser": "~1.2.0", - "statuses": "~1.4.0" + "on-finished": "2.3.0", + "range-parser": "1.2.0", + "statuses": "1.4.0" }, "dependencies": { "debug": { @@ -361,9 +361,9 @@ "resolved": "https://registry.npmjs.org/serve-static/-/serve-static-1.13.2.tgz", "integrity": "sha512-p/tdJrO4U387R9oMjb1oj7qSMaMfmOyd4j9hOFoxZe2baQszgHcSWjuya/CiT5kgZZKRudHNOA0pYXOl8rQ5nw==", "requires": { - "encodeurl": "~1.0.2", - "escape-html": "~1.0.3", - "parseurl": "~1.3.2", + "encodeurl": "1.0.2", + "escape-html": "1.0.3", + "parseurl": "1.3.2", "send": "0.16.2" } }, @@ -383,7 +383,7 @@ "integrity": "sha512-HRkVv/5qY2G6I8iab9cI7v1bOIdhm94dVjQCPFElW9W+3GeDOSHmy2EBYe4VTApuzolPcmgFTN3ftVJRKR2J9Q==", "requires": { "media-typer": "0.3.0", - "mime-types": "~2.1.18" + "mime-types": "2.1.20" } }, "unpipe": { diff --git a/chapter4-homework/public/MIB.jpg b/chapter4-homework/public/MIB.jpg new file mode 100644 index 0000000..653a7d3 Binary files /dev/null and b/chapter4-homework/public/MIB.jpg differ diff --git a/chapter4-homework/public/index.html b/chapter4-homework/public/index.html index 7a81da6..cf4648c 100644 --- a/chapter4-homework/public/index.html +++ b/chapter4-homework/public/index.html @@ -1,21 +1,54 @@ +