WBE_Praktikum_5/code/async/naive_async.js

16 lines
336 B
JavaScript
Raw Permalink Normal View History

2022-10-27 08:21:03 +02:00
//
// Naive asynchronous code. This doesnt work!
//
let fs = require('fs')
let timestamp = new Date().toString()
let contents
fs.writeFile('date.txt', timestamp, () => {})
fs.readFile('date.txt', (err, data) => {
if (err) throw err
contents = data
})
console.log('Comparing the contents')
console.assert(timestamp == contents)