From 84893cd10c9b4b0aff9b3162eb7f9525f198e3a6 Mon Sep 17 00:00:00 2001 From: Johann Date: Fri, 10 Nov 2017 07:39:06 -0800 Subject: [PATCH 1/4] practice tests completed --- .gitignore | 3 +++ index.js | 12 +++++++++ package-lock.json | 62 +++++++++++++++++++++++++++++++++++++++++++++++ package.json | 23 ++++++++++++++++++ 4 files changed, 100 insertions(+) create mode 100644 .gitignore create mode 100644 index.js create mode 100644 package-lock.json create mode 100644 package.json diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..09ede39 --- /dev/null +++ b/.gitignore @@ -0,0 +1,3 @@ + + +node_modules/ diff --git a/index.js b/index.js new file mode 100644 index 0000000..60c7be4 --- /dev/null +++ b/index.js @@ -0,0 +1,12 @@ +let _ = require('lodash'); +let chalk = require('chalk'); + +console.log(chalk.blue('Hello') + 'World' + chalk.red('!')); + +_.each([1,2,3], function(el, idx) { + console.log(el); +}); + +console.log("hello world"); + + diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..aa20a71 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,62 @@ +{ + "name": "assignment_node_hello_world", + "version": "1.0.0", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "ansi-styles": { + "version": "3.2.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-3.2.0.tgz", + "integrity": "sha512-NnSOmMEYtVR2JVMIGTzynRkkaxtiq1xnFBcdQD/DnNCYPoEPsVJhM98BDyaoNOQIi7p4okdi3E27eN7GQbsUug==", + "requires": { + "color-convert": "1.9.1" + } + }, + "chalk": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.3.0.tgz", + "integrity": "sha512-Az5zJR2CBujap2rqXGaJKaPHyJ0IrUimvYNX+ncCy8PJP4ltOGTrHUIo097ZaL2zMeKYpiCdqDvS6zdrTFok3Q==", + "requires": { + "ansi-styles": "3.2.0", + "escape-string-regexp": "1.0.5", + "supports-color": "4.5.0" + } + }, + "color-convert": { + "version": "1.9.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-1.9.1.tgz", + "integrity": "sha512-mjGanIiwQJskCC18rPR6OmrZ6fm2Lc7PeGFYwCmy5J34wC6F1PzdGL6xeMfmgicfYcNLGuVFA3WzXtIDCQSZxQ==", + "requires": { + "color-name": "1.1.3" + } + }, + "color-name": { + "version": "1.1.3", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.3.tgz", + "integrity": "sha1-p9BVi9icQveV3UIyj3QIMcpTvCU=" + }, + "escape-string-regexp": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", + "integrity": "sha1-G2HAViGQqN/2rjuyzwIAyhMLhtQ=" + }, + "has-flag": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-2.0.0.tgz", + "integrity": "sha1-6CB68cx7MNRGzHC3NLXovhj4jVE=" + }, + "lodash": { + "version": "4.17.4", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.4.tgz", + "integrity": "sha1-eCA6TRwyiuHYbcpkYONptX9AVa4=" + }, + "supports-color": { + "version": "4.5.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-4.5.0.tgz", + "integrity": "sha1-vnoN5ITexcXN34s9WRJQRJEvY1s=", + "requires": { + "has-flag": "2.0.0" + } + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..daddc36 --- /dev/null +++ b/package.json @@ -0,0 +1,23 @@ +{ + "name": "assignment_node_hello_world", + "version": "1.0.0", + "description": "assignment_node_hello_world ===========================", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "repository": { + "type": "git", + "url": "git+https://github.com/JohnRPB/assignment_node_hello_world.git" + }, + "author": "", + "license": "ISC", + "bugs": { + "url": "https://github.com/JohnRPB/assignment_node_hello_world/issues" + }, + "homepage": "https://github.com/JohnRPB/assignment_node_hello_world#readme", + "dependencies": { + "chalk": "^2.3.0", + "lodash": "^4.17.4" + } +} From 264bfc194167baa8902a1818bb32e5bb012d0928 Mon Sep 17 00:00:00 2001 From: Johann Date: Fri, 10 Nov 2017 08:31:39 -0800 Subject: [PATCH 2/4] logger working --- index.js | 6 ++++++ lib/logger.js | 27 +++++++++++++++++++++++++++ 2 files changed, 33 insertions(+) create mode 100644 lib/logger.js diff --git a/index.js b/index.js index 60c7be4..b17e872 100644 --- a/index.js +++ b/index.js @@ -1,5 +1,8 @@ let _ = require('lodash'); let chalk = require('chalk'); +let Logger = require('./lib/logger'); + +let logger = new Logger(); console.log(chalk.blue('Hello') + 'World' + chalk.red('!')); @@ -9,4 +12,7 @@ _.each([1,2,3], function(el, idx) { console.log("hello world"); +console.log(logger.log("This should be blue", "INFO")); +console.log(logger.log("This should be yellow", "WARNING")); +console.log(logger.log("This should be red", "ERROR")); diff --git a/lib/logger.js b/lib/logger.js new file mode 100644 index 0000000..a56d8df --- /dev/null +++ b/lib/logger.js @@ -0,0 +1,27 @@ +let chalk = require('chalk'); + +class Logger { + constructor() {} + + info(message) { + return chalk.blue(message); + } + warning(message) { + return chalk.yellow(message); + } + error(message) { + return chalk.red(message); + } + log(message, level) { + switch(level) { + case "INFO": + return this.info(message); + case "WARNING": + return this.warning(message); + case "ERROR": + return this.error(message); + } + } +} + +module.exports = Logger; From 7d6164d8c50bc8b5966d31ff8518cdcc04628a94 Mon Sep 17 00:00:00 2001 From: Johann Date: Fri, 10 Nov 2017 11:23:19 -0800 Subject: [PATCH 3/4] made logger use console.log --- index.js | 6 +++--- lib/logger.js | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index b17e872..98b6f09 100644 --- a/index.js +++ b/index.js @@ -12,7 +12,7 @@ _.each([1,2,3], function(el, idx) { console.log("hello world"); -console.log(logger.log("This should be blue", "INFO")); -console.log(logger.log("This should be yellow", "WARNING")); -console.log(logger.log("This should be red", "ERROR")); +logger.log("This should be blue", "INFO"); +logger.log("This should be yellow", "WARNING"); +logger.log("This should be red", "ERROR"); diff --git a/lib/logger.js b/lib/logger.js index a56d8df..f85dfac 100644 --- a/lib/logger.js +++ b/lib/logger.js @@ -15,11 +15,11 @@ class Logger { log(message, level) { switch(level) { case "INFO": - return this.info(message); + return console.log(this.info(message)); case "WARNING": - return this.warning(message); + return console.log(this.warning(message)); case "ERROR": - return this.error(message); + return console.log(this.error(message)); } } } From fa3045ec8fba6271d6a9688cf6d0d76e831e32ac Mon Sep 17 00:00:00 2001 From: Johann Date: Fri, 10 Nov 2017 11:34:04 -0800 Subject: [PATCH 4/4] added json iteration --- data/.logs.json.swp | Bin 0 -> 12288 bytes index.js | 4 ++++ lib/logger.js | 8 ++++---- 3 files changed, 8 insertions(+), 4 deletions(-) create mode 100644 data/.logs.json.swp diff --git a/data/.logs.json.swp b/data/.logs.json.swp new file mode 100644 index 0000000000000000000000000000000000000000..b81864901d314bce8c91efadff96070b5ddcd59e GIT binary patch literal 12288 zcmeI&&r1|x9LMpmfzS`FaD{>j9w)klxmy}pbdiMcAQ`qxKhR~|eH=$;pJ#YxRui%A z1zq;gr9*cQb%+jK>X3n#`U|qM4TI<(2oXO+1|_Vs11*$%7hbH+&OCgd_vk^Ku}p4Y zP@L=PA-oO}-Cu0JIh1N6r=7_5Y!w}jdtECVS2?G$*Sj-kvwgMCz7s8&?$?EKNvbeN z59{%8#x_#)%W3IpKRTMuxl>r|k}k^O!i3gd+BeeA`$kX7066;R-UgdsQvhoK$T_7g3^Yj_0< zFbC6MU<6LW3Fv?pSZyU*fn|6D6?g#mAcQ`+2)!WSdkfK5sKPsV1P`GCbC83pFbKWS z3~BE_=c9N@CB;y z8CKvEe1s1W^?nch;sRWN3vdB0zy-KKLkf(L5c42}RgytqJJPx!tUk{Zv$|}=m>ozF zJ%>4lr!bWxLM_UH_49l$dNeaS+g0P*>cqi0n2)~rbG6G_7lo2Dfxs1JRx8=DbqQ&V zHruT+AnX!`P(^7vh40B|E>{K8gu-zRj&5BsZm7Sz#l+*`;Z}u*S-0DAvI%1g)^Qi= z7%K5b