WBE_Praktikum_5/code/async/naive_async.js

16 lines
336 B
JavaScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//
// 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)