Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
hexc11266y@Stocken honestly I just wanted to see how awkward it would be to use non blocking fs calls to read in the full file structure starting from a specified "root". I wanted to do everything in one shot, and I'll probably refactor it later so it's possible, but yeah, kinda cool to asynchronously/recursivly traverse a file system.
-
Stocken4336y@hexc Understandable, been working with a similar type of code before, but if it works, don't change it!
-
Ever heard of if/else?
Also wth is that semicolon at the beginning of the line? Put it on the end or just dont put it anywhere -
hexc11266y@norman70688 I was going to use promisify to wrap the fs functions so it wont be so ugly, but basically that will do the same thing as what's seen here. As far as the promises, being necessary, I need a way to "wait" for all the files to be found and stat'ed, but I want all the files to be found asynchronously, so by using promises recursivly than waiting for all active promises to be fulfilled, I achieve what I was trying to. That said maybe there are other nicer ways, which I'll explore but I was crazy tired when I wrote that, and this was posted as a joke(though it's functional).
-
@hexc Oh I see the () now...
I usualy use semicolons so I dont rly have to worry about that...
But still. That justs looks dumb -
hexc11266y@code-freak problem is you can't async/await callback code unless you wrap it in a promise. You might notice I am using async await at the top level because that returns a promise. Also ide argue that most "noobs" wouldn't know what half this code does and why it works. As I've said before, it needs to be refactored/cleaned up, but the concept behind it(non blocking asyc recursion) is also something a noob would most likely not understand.
-
navitas29316yTo be honest, there are better ways to do this, and I remember nodejs having promises support for the fs methods. I also don't see the point of having an async function without any awaits.
-
hexc11266y@MonkeyParade this is old and it's been cleaned up since than, had written it when I was tired af...
Related Rants
Lol is this even JavaScript anymore?!?
joke/meme
js
lol im tired
meh i'll comment it later