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
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"presets": ["@babel/preset-env", "@babel/preset-typescript"]
}
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
node_modules
.vscode
6 changes: 6 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"trailingComma": "all",
"tabWidth": 2,
"semi": true,
"singleQuote": false
}
3 changes: 3 additions & 0 deletions nodemon.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"ignore": ["*.json", "*.txt"]
}
2,816 changes: 2,663 additions & 153 deletions package-lock.json

Large diffs are not rendered by default.

20 changes: 18 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,27 @@
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
"test": "echo \"Error: no test specified\" && exit 1",
"task1": "nodemon --exec babel-node ./src/task1.ts --extensions .ts",
"task2": "nodemon --exec babel-node ./src/task2.ts --extensions .ts"
},
"author": "",
"license": "ISC",
"dependencies": {
"nodemon": "^2.0.12"
"@types/event-stream": "^3.3.34",
"@types/node": "^16.10.1",
"csvtojson": "^2.0.10",
"event-stream": "^4.0.1",
"tslint": "^6.1.3",
"typescript": "^4.4.3"
},
"devDependencies": {
"@babel/cli": "^7.15.7",
"@babel/core": "^7.15.5",
"@babel/node": "^7.15.4",
"@babel/preset-env": "^7.15.6",
"@babel/preset-typescript": "^7.15.0",
"nodemon": "^2.0.13",
"prettier": "2.4.1"
}
}
1 change: 1 addition & 0 deletions src/csv/nodejs-hw1-ex1.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Book,Author,Amount,PriceThe Compound Effect,Darren Hardy,5,9.48The 7 Habits of Highly Effective People,Stephen R. Covey,4,23.48The Miracle Morning,Hal Elrod,10,21.34Influence: The Psychology of Persuasion,Robert B. Cialdini,4,12.99The ONE Thing,Gary Keller,1,11.18
Expand Down
7 changes: 7 additions & 0 deletions src/task1.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import es from 'event-stream';

// TASK 1
process.stdin
.pipe(es.split())
.pipe(es.mapSync((data: string) => data.split('').reverse().join('').trim()))
.pipe(process.stdout);
20 changes: 20 additions & 0 deletions src/task2.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import csv from "csvtojson";
import fs from "fs";
import path from "path";
import { pipeline } from "stream";

const csvPath = path.join(__dirname, "./csv/nodejs-hw1-ex1.csv");
const jsonPath = path.join(__dirname, "./csv/result.txt");

pipeline(
fs.createReadStream(csvPath),
csv(),
fs.createWriteStream(jsonPath),
(err: any) => {
if (err) {
console.error("Pipeline failed.", err);
} else {
console.log("Pipeline succeeded.");
}
},
);