This commit is contained in:
Philippe Torrel
2026-07-06 09:11:46 +02:00
parent 1b7f884cc6
commit 3578c15a45
10 changed files with 101 additions and 4 deletions

View File

@@ -0,0 +1 @@
Ich bin file 01

View File

@@ -0,0 +1 @@
Ich bin file 02

View File

@@ -0,0 +1 @@
Ich bin file 03

View File

@@ -0,0 +1 @@
Ich bin file 04

View File

@@ -0,0 +1 @@
Ich bin file 05

View File

@@ -0,0 +1 @@
Ich bin file 06

View File

@@ -0,0 +1,29 @@
// const fs = require('node:fs'); // commonjs
import fs from 'node:fs'; // esm - module Schreibweise
const getFileBy = (path, encoding = 'utf-8') => {
return new Promise((resolve, reject) => {
// async process
fs.readFile(path, encoding, (error, data) => {
if (error) {
reject(error);
}
resolve(data);
});
});
};
Promise.all([
getFileBy('data/file01.txt'),
getFileBy('data/file02.txt'),
getFileBy('data/file03.txt'),
getFileBy('data/file04.txt'),
getFileBy('data/file05.txt'),
getFileBy('data/file06.txt'),
])
.then((data) => {
console.log(data);
})
.catch((err) => {
console.log(err);
});

View File

@@ -0,0 +1,13 @@
{
"name": "u12_mehrere-dateien-auslesen",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"keywords": [],
"author": "",
"license": "ISC",
"type": "module"
}