diff --git a/02_advanced/agenda.md b/02_advanced/agenda.md index fd6671c..77419cf 100644 --- a/02_advanced/agenda.md +++ b/02_advanced/agenda.md @@ -221,7 +221,7 @@ Abschlussquiz - JS Grundlagen **Übungen:** -Übung 09 - 10 +Übung 09 - 11 --- @@ -230,8 +230,6 @@ Abschlussquiz - JS Grundlagen **Inhalt:** - Wiederholung der Inhalte -- commonjs vs esm -- async await - Promise.all() - **Exkurs: Switch Case Abfragen** - **Exkurs: Statische Webseite mit Sass und HTML** diff --git a/02_advanced/faq/interval-funktionreferenz.js b/02_advanced/faq/interval-funktionreferenz.js new file mode 100644 index 0000000..3769d79 --- /dev/null +++ b/02_advanced/faq/interval-funktionreferenz.js @@ -0,0 +1,11 @@ +const sayHello = () => { + console.log('Say hello'); +}; + +const iv = setInterval(sayHello, 500); + +const double = (n, i) => { + return n * 2 + i; +}; + +const numbers = [1, '2', 3].map(double); diff --git a/02_advanced/unterricht/tag14/01_promise-and-readfile/index.js b/02_advanced/unterricht/tag14/01_promise-and-readfile/index.js index 36a2c7e..7781cde 100644 --- a/02_advanced/unterricht/tag14/01_promise-and-readfile/index.js +++ b/02_advanced/unterricht/tag14/01_promise-and-readfile/index.js @@ -1,5 +1,8 @@ // fs = FileSystem Modul aus der Node Standardbib -const fs = require('fs'); // commonjs - Node Schreibweise +// const fs = require('fs'); // commonjs - Node Schreibweise +// const chalk = require('chalk'); +import fs from 'fs'; // module - ESM Schreibweise +import chalk from 'chalk'; // Funktion mir einem asynchronen Prozess const getContentBy = (path) => { @@ -16,13 +19,13 @@ const getContentBy = (path) => { }); }; -// Funktionsaufruf einer Funktion mit asynchronem Prozess -getContentBy('data/productss.csv') +// Funktionsaufruf einer Funktion mit asynchronen Prozess +getContentBy('data/products.csv') .then((data) => { - console.log(data); + console.log(chalk.yellow(data)); }) .catch((err) => { - console.error(err); + console.error(chalk.red(err)); }); console.log('weiter im code...'); diff --git a/02_advanced/unterricht/tag14/01_promise-and-readfile/package-lock.json b/02_advanced/unterricht/tag14/01_promise-and-readfile/package-lock.json new file mode 100644 index 0000000..8ae141d --- /dev/null +++ b/02_advanced/unterricht/tag14/01_promise-and-readfile/package-lock.json @@ -0,0 +1,28 @@ +{ + "name": "01_promise-and-readfile", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "01_promise-and-readfile", + "version": "1.0.0", + "license": "ISC", + "dependencies": { + "chalk": "^5.6.2" + } + }, + "node_modules/chalk": { + "version": "5.6.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.6.2.tgz", + "integrity": "sha512-7NzBL0rN6fMUW+f7A6Io4h40qQlG+xGmtMxfbnH/K7TAtt8JQWVQK+6g0UXKMeVJoyV5EkkNsErQ8pVD3bLHbA==", + "license": "MIT", + "engines": { + "node": "^12.17.0 || ^14.13 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + } + } +} diff --git a/02_advanced/unterricht/tag14/01_promise-and-readfile/package.json b/02_advanced/unterricht/tag14/01_promise-and-readfile/package.json index 5ad39c2..43aa1ff 100644 --- a/02_advanced/unterricht/tag14/01_promise-and-readfile/package.json +++ b/02_advanced/unterricht/tag14/01_promise-and-readfile/package.json @@ -4,10 +4,13 @@ "description": "", "license": "ISC", "author": "", - "type": "commonjs", + "type": "module", "main": "index.js", "scripts": { "test": "echo \"Error: no test specified\" && exit 1" }, - "keywords": [] + "keywords": [], + "dependencies": { + "chalk": "^5.6.2" + } } diff --git a/02_advanced/unterricht/tag14/02_commonjs-vs-esm/commonjs/index.js b/02_advanced/unterricht/tag14/02_commonjs-vs-esm/commonjs/index.js new file mode 100644 index 0000000..78a1ca0 --- /dev/null +++ b/02_advanced/unterricht/tag14/02_commonjs-vs-esm/commonjs/index.js @@ -0,0 +1,27 @@ +// commonjs - Schreibweise mit "require" +const fs = require('node:fs'); // "fs" ist ein Modul aus der Node Standardbib und kann mit Prefix "node:" hervorgehoben werden +const chalk = require('chalk'); + +const getFileBy = (path, encoding = 'utf-8') => { + return new Promise((resolve, reject) => { + // async process + fs.readFile(path, encoding, (err, data) => { + if (err) { + // console.error(err); + reject(err); + } + + // console.log(data); + resolve(data); + }); + }); +}; + +// Funktionsaufruf von Funktion mit async process +getFileBy('package.json') + .then((data) => { + console.log(chalk.yellow(data)); + }) + .catch((err) => { + console.log(chalk.red(err)); + }); diff --git a/02_advanced/unterricht/tag14/02_commonjs-vs-esm/commonjs/package-lock.json b/02_advanced/unterricht/tag14/02_commonjs-vs-esm/commonjs/package-lock.json new file mode 100644 index 0000000..abd9845 --- /dev/null +++ b/02_advanced/unterricht/tag14/02_commonjs-vs-esm/commonjs/package-lock.json @@ -0,0 +1,86 @@ +{ + "name": "commonjs", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "commonjs", + "version": "1.0.0", + "license": "ISC", + "dependencies": { + "chalk": "^4.1.2" + } + }, + "node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "license": "MIT", + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "license": "MIT", + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "license": "MIT", + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "license": "MIT" + }, + "node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "license": "MIT", + "engines": { + "node": ">=8" + } + }, + "node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "license": "MIT", + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + } + } +} diff --git a/02_advanced/unterricht/tag14/02_commonjs-vs-esm/commonjs/package.json b/02_advanced/unterricht/tag14/02_commonjs-vs-esm/commonjs/package.json new file mode 100644 index 0000000..ec0af72 --- /dev/null +++ b/02_advanced/unterricht/tag14/02_commonjs-vs-esm/commonjs/package.json @@ -0,0 +1,16 @@ +{ + "name": "commonjs", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "", + "license": "ISC", + "type": "commonjs", + "dependencies": { + "chalk": "^4.1.2" + } +} diff --git a/02_advanced/unterricht/tag14/02_commonjs-vs-esm/module/index.js b/02_advanced/unterricht/tag14/02_commonjs-vs-esm/module/index.js new file mode 100644 index 0000000..05c38c6 --- /dev/null +++ b/02_advanced/unterricht/tag14/02_commonjs-vs-esm/module/index.js @@ -0,0 +1,27 @@ +// esm - Schreibweise mit "import" +import fs from 'node:fs'; // "fs" ist ein Modul aus der Node Standardbib und kann mit Prefix "node:" hervorgehoben werden +import chalk from 'chalk'; + +const getFileBy = (path, encoding = 'utf-8') => { + return new Promise((resolve, reject) => { + // async process + fs.readFile(path, encoding, (err, data) => { + if (err) { + // console.error(err); + reject(err); + } + + // console.log(data); + resolve(data); + }); + }); +}; + +// Funktionsaufruf von Funktion mit async process +getFileBy('package.json') + .then((data) => { + console.log(chalk.yellow(data)); + }) + .catch((err) => { + console.log(chalk.red(err)); + }); diff --git a/02_advanced/unterricht/tag14/02_commonjs-vs-esm/module/package-lock.json b/02_advanced/unterricht/tag14/02_commonjs-vs-esm/module/package-lock.json new file mode 100644 index 0000000..c961078 --- /dev/null +++ b/02_advanced/unterricht/tag14/02_commonjs-vs-esm/module/package-lock.json @@ -0,0 +1,28 @@ +{ + "name": "module", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "module", + "version": "1.0.0", + "license": "ISC", + "dependencies": { + "chalk": "^5.6.2" + } + }, + "node_modules/chalk": { + "version": "5.6.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.6.2.tgz", + "integrity": "sha512-7NzBL0rN6fMUW+f7A6Io4h40qQlG+xGmtMxfbnH/K7TAtt8JQWVQK+6g0UXKMeVJoyV5EkkNsErQ8pVD3bLHbA==", + "license": "MIT", + "engines": { + "node": "^12.17.0 || ^14.13 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + } + } +} diff --git a/02_advanced/unterricht/tag14/02_commonjs-vs-esm/module/package.json b/02_advanced/unterricht/tag14/02_commonjs-vs-esm/module/package.json new file mode 100644 index 0000000..8fe75f7 --- /dev/null +++ b/02_advanced/unterricht/tag14/02_commonjs-vs-esm/module/package.json @@ -0,0 +1,16 @@ +{ + "name": "module", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "", + "license": "ISC", + "type": "module", + "dependencies": { + "chalk": "^5.6.2" + } +} diff --git a/02_advanced/unterricht/tag14/03_fs-promises/index.js b/02_advanced/unterricht/tag14/03_fs-promises/index.js new file mode 100644 index 0000000..5071e5f --- /dev/null +++ b/02_advanced/unterricht/tag14/03_fs-promises/index.js @@ -0,0 +1,40 @@ +// esm - Schreibweise mit "import" +import fs from 'node:fs'; // "fs" ist ein Modul aus der Node Standardbib und kann mit Prefix "node:" hervorgehoben werden +import color from 'chalk'; + +const getFileBy = (path, encoding = 'utf-8') => { + return new Promise((resolve, reject) => { + // async process + fs.readFile(path, encoding, (err, data) => { + if (err) { + // console.error(err); + reject(err); + } + + // console.log(data); + resolve(data); + }); + }); +}; + +const getPromisesFileBy = (path, encoding = 'utf-8') => { + // Unterobjekt "promises" von fs besitzt Ummantelung von Promise-Objekt und Verarbeitung der Callback-Funktion + return fs.promises.readFile(path, encoding); +}; + +// Funktionsaufruf von Funktion mit async process +getFileBy('package.json') + .then((data) => { + console.log(color.yellow(data)); + }) + .catch((err) => { + console.log(color.red(err)); + }); + +getPromisesFileBy('package.json') + .then((data) => { + console.log(color.green(data)); + }) + .catch((err) => { + console.log(color.magenta(err)); + }); diff --git a/02_advanced/unterricht/tag14/03_fs-promises/package-lock.json b/02_advanced/unterricht/tag14/03_fs-promises/package-lock.json new file mode 100644 index 0000000..c961078 --- /dev/null +++ b/02_advanced/unterricht/tag14/03_fs-promises/package-lock.json @@ -0,0 +1,28 @@ +{ + "name": "module", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "module", + "version": "1.0.0", + "license": "ISC", + "dependencies": { + "chalk": "^5.6.2" + } + }, + "node_modules/chalk": { + "version": "5.6.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.6.2.tgz", + "integrity": "sha512-7NzBL0rN6fMUW+f7A6Io4h40qQlG+xGmtMxfbnH/K7TAtt8JQWVQK+6g0UXKMeVJoyV5EkkNsErQ8pVD3bLHbA==", + "license": "MIT", + "engines": { + "node": "^12.17.0 || ^14.13 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + } + } +} diff --git a/02_advanced/unterricht/tag14/03_fs-promises/package.json b/02_advanced/unterricht/tag14/03_fs-promises/package.json new file mode 100644 index 0000000..3eb6d46 --- /dev/null +++ b/02_advanced/unterricht/tag14/03_fs-promises/package.json @@ -0,0 +1,16 @@ +{ + "name": "03_fs-promises", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "", + "license": "ISC", + "type": "module", + "dependencies": { + "chalk": "^5.6.2" + } +} diff --git a/02_advanced/unterricht/tag14/04_async-await/index.js b/02_advanced/unterricht/tag14/04_async-await/index.js new file mode 100644 index 0000000..2f5174c --- /dev/null +++ b/02_advanced/unterricht/tag14/04_async-await/index.js @@ -0,0 +1,35 @@ +// esm - Schreibweise mit "import" +import fs from 'node:fs'; // "fs" ist ein Modul aus der Node Standardbib und kann mit Prefix "node:" hervorgehoben werden +import color from 'chalk'; + +// async ... await +const getFileBy = async (path, encoding = 'utf-8') => { + try { + const result = await fs.promises.readFile(path, encoding); + return result; + } catch (error) { + throw new Error(error); + } +}; + +const getPromiseFileBy = (path, encoding = 'utf-8') => { + return new Promise((resolve, reject) => { + fs.readFile(path, encoding, (err, data) => { + if (err) { + reject(err); + } + resolve(data); + }); + }); +}; + +getFileBy('package.json') + .then((data) => { + console.log(color.green(data)); + }) + .catch((err) => { + console.log(color.magenta(err)); + }) + .finally(() => { + console.log(color.yellow('process finished')); + }); diff --git a/02_advanced/unterricht/tag14/04_async-await/package-lock.json b/02_advanced/unterricht/tag14/04_async-await/package-lock.json new file mode 100644 index 0000000..c961078 --- /dev/null +++ b/02_advanced/unterricht/tag14/04_async-await/package-lock.json @@ -0,0 +1,28 @@ +{ + "name": "module", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "module", + "version": "1.0.0", + "license": "ISC", + "dependencies": { + "chalk": "^5.6.2" + } + }, + "node_modules/chalk": { + "version": "5.6.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.6.2.tgz", + "integrity": "sha512-7NzBL0rN6fMUW+f7A6Io4h40qQlG+xGmtMxfbnH/K7TAtt8JQWVQK+6g0UXKMeVJoyV5EkkNsErQ8pVD3bLHbA==", + "license": "MIT", + "engines": { + "node": "^12.17.0 || ^14.13 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + } + } +} diff --git a/02_advanced/unterricht/tag14/04_async-await/package.json b/02_advanced/unterricht/tag14/04_async-await/package.json new file mode 100644 index 0000000..f5025c6 --- /dev/null +++ b/02_advanced/unterricht/tag14/04_async-await/package.json @@ -0,0 +1,16 @@ +{ + "name": "04_async-await", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "", + "license": "ISC", + "type": "module", + "dependencies": { + "chalk": "^5.6.2" + } +} diff --git a/02_advanced/unterricht/tag14/05_promise-all/data/file01.txt b/02_advanced/unterricht/tag14/05_promise-all/data/file01.txt new file mode 100644 index 0000000..002ff75 --- /dev/null +++ b/02_advanced/unterricht/tag14/05_promise-all/data/file01.txt @@ -0,0 +1 @@ +Ich bin file01 \ No newline at end of file diff --git a/02_advanced/unterricht/tag14/05_promise-all/data/file02.txt b/02_advanced/unterricht/tag14/05_promise-all/data/file02.txt new file mode 100644 index 0000000..be27611 --- /dev/null +++ b/02_advanced/unterricht/tag14/05_promise-all/data/file02.txt @@ -0,0 +1 @@ +Ich bin file02 \ No newline at end of file diff --git a/02_advanced/unterricht/tag14/05_promise-all/data/file03.txt b/02_advanced/unterricht/tag14/05_promise-all/data/file03.txt new file mode 100644 index 0000000..175a629 --- /dev/null +++ b/02_advanced/unterricht/tag14/05_promise-all/data/file03.txt @@ -0,0 +1 @@ +Ich bin file03 \ No newline at end of file diff --git a/02_advanced/unterricht/tag14/05_promise-all/data/file04.txt b/02_advanced/unterricht/tag14/05_promise-all/data/file04.txt new file mode 100644 index 0000000..56c5513 --- /dev/null +++ b/02_advanced/unterricht/tag14/05_promise-all/data/file04.txt @@ -0,0 +1 @@ +Ich bin file04 \ No newline at end of file diff --git a/02_advanced/unterricht/tag14/05_promise-all/index.js b/02_advanced/unterricht/tag14/05_promise-all/index.js new file mode 100644 index 0000000..cf0b718 --- /dev/null +++ b/02_advanced/unterricht/tag14/05_promise-all/index.js @@ -0,0 +1,28 @@ +import fs from 'node:fs'; +import color from 'chalk'; + +const getFileBy = (path, encoding = 'utf-8') => { + return fs.promises.readFile(path, encoding); +}; + +// getFileBy('data/file01.txt') +// .then((data) => { +// console.log(color.green(data)); +// }) +// .catch((err) => { +// console.log(color.red(err)); +// }); + +Promise.all([ + getFileBy('data/file01.txt'), + getFileBy('data/file02.txt'), + // getFileBy('data/404'), + getFileBy('data/file03.txt'), + getFileBy('data/file04.txt'), +]) + .then((data) => { + console.log(data); + }) + .catch((err) => { + console.log(err); + }); diff --git a/02_advanced/unterricht/tag14/05_promise-all/package-lock.json b/02_advanced/unterricht/tag14/05_promise-all/package-lock.json new file mode 100644 index 0000000..41b7e29 --- /dev/null +++ b/02_advanced/unterricht/tag14/05_promise-all/package-lock.json @@ -0,0 +1,28 @@ +{ + "name": "05_promise-all", + "version": "1.0.0", + "lockfileVersion": 3, + "requires": true, + "packages": { + "": { + "name": "05_promise-all", + "version": "1.0.0", + "license": "ISC", + "dependencies": { + "chalk": "^5.6.2" + } + }, + "node_modules/chalk": { + "version": "5.6.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-5.6.2.tgz", + "integrity": "sha512-7NzBL0rN6fMUW+f7A6Io4h40qQlG+xGmtMxfbnH/K7TAtt8JQWVQK+6g0UXKMeVJoyV5EkkNsErQ8pVD3bLHbA==", + "license": "MIT", + "engines": { + "node": "^12.17.0 || ^14.13 || >=16.0.0" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + } + } +} diff --git a/02_advanced/unterricht/tag14/05_promise-all/package.json b/02_advanced/unterricht/tag14/05_promise-all/package.json new file mode 100644 index 0000000..8cddb19 --- /dev/null +++ b/02_advanced/unterricht/tag14/05_promise-all/package.json @@ -0,0 +1,16 @@ +{ + "name": "05_promise-all", + "version": "1.0.0", + "description": "", + "keywords": [], + "license": "ISC", + "author": "", + "type": "module", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "dependencies": { + "chalk": "^5.6.2" + } +} diff --git a/02_advanced/unterricht/tag15/01_util-promisify/data/file.txt b/02_advanced/unterricht/tag15/01_util-promisify/data/file.txt new file mode 100644 index 0000000..df8d891 --- /dev/null +++ b/02_advanced/unterricht/tag15/01_util-promisify/data/file.txt @@ -0,0 +1 @@ +Ich bin eine Datei! \ No newline at end of file diff --git a/02_advanced/unterricht/tag15/01_util-promisify/index.js b/02_advanced/unterricht/tag15/01_util-promisify/index.js new file mode 100644 index 0000000..a6cb679 --- /dev/null +++ b/02_advanced/unterricht/tag15/01_util-promisify/index.js @@ -0,0 +1,16 @@ +// const fs = require('fs'); +// const util = require('util'); +import fs from 'node:fs'; +import util from 'node:util'; + +// util.promisify fängt das letzte Argument als Callback-Funktion ab und ummantel die Funktion mit einem Promise-Objekt. +// Das ummantelte Promise-Objekt wird zusätzlich von einer weiteren Funktion mit den Argumenten ummantelt. + +// https://javascript.info/promisify +// https://medium.com/trabe/understanding-nodes-promisify-and-callbackify-d2b04efde0e0 + +const getFileContent = util.promisify(fs.readFile); + +getFileContent('data/file.txt', 'utf8') + .then((data) => console.log(data)) + .catch((err) => console.error(`Something went wrong: ${err}`)); diff --git a/02_advanced/unterricht/tag15/01_util-promisify/package.json b/02_advanced/unterricht/tag15/01_util-promisify/package.json new file mode 100644 index 0000000..88a38aa --- /dev/null +++ b/02_advanced/unterricht/tag15/01_util-promisify/package.json @@ -0,0 +1,13 @@ +{ + "name": "01_util-promisify", + "version": "1.0.0", + "description": "", + "main": "index.js", + "scripts": { + "test": "echo \"Error: no test specified\" && exit 1" + }, + "keywords": [], + "author": "", + "license": "ISC", + "type": "module" +}