const fs = require('fs').promises;

/// Promise method
const displayMessage = () => {
    return new Promise((resolve, reject) => {
        setTimeout(() => {
            resolve("Hello, this is a Promise message!");
        }, 1000);
    });
};

// Calling the promise
displayMessage().then(console.log).catch(console.error);

// Creating a file using fs module
const writeFile = async () => {
    try {
        await fs.writeFile("message.txt", "This file was created using fs module!");
        console.log("File created successfully!");
    } catch (error) {
        console.error("Error creating file:", error);
    }
};

// Calling the write file function
writeFile();