Hacker Newsnew | past | comments | ask | show | jobs | submit | _vkas's commentslogin

Not working for me.


I think HN users are outraged at everything.


And they only need 100k. For a multibillion dollar company, that's pennies.


Notejs should get promise versions of its current callback-based APIs:

    const fs = require("fs");
    fs.writeFile("Hello, World", "helloworld.txt", (error)=>{
        if(error) throw error;
        console.log("done!");
    });
Should be:

    const fs = require("fs");
    fs.writeFilePromise("Hello, World", "helloworld.txt").then(()=>console.log("done!"),error=>console.error(error));


It really should be:

   try{
        x = await fs.writeFilePromise("Hello, World", "helloworld.txt")
        console.log("done!")
   }
   catch(error)
   {
        console.error(error) // or console.log
   }
This takes advantage of promises fully.



This was tried many years ago. At that time, Promises/A+ was not finalized, and the community could not agree on which Promise specification was best, or even if one was needed at all.

Callbacks are lightest-weight re: CPU & memory overhead, so it was decided that core APIs should implement that, and developers can override using promisify (via e.g. Bluebird or the new `util.promisify()`) as they need. But putting that kind of assumption in core could lead to significant pain.


Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: