I used 3 different File System APIs in Node.js

Поділитися
Вставка
  • Опубліковано 26 жов 2024

КОМЕНТАРІ • 120

  • @nagarajansubramani
    @nagarajansubramani 2 роки тому +13

    I love how in your videos you setup the code as a series of Undo operations so as you continually press Ctrl+Z the code lines magically appear pasted on screen as you speak along.

  • @Krikit1337
    @Krikit1337 2 роки тому +356

    Shouldn't that be await readdir for the promises API?

    • @beyondfireship
      @beyondfireship  2 роки тому +183

      ah yes, good call

    • @tacticalassaultanteater9678
      @tacticalassaultanteater9678 2 роки тому +42

      This is also by far the most common bug with promises, and one Typescript doesn't catch by default. There's an ESLint rule to ban unhandled promise rejections that also catches unawaited promises

    • @ivanfaye3041
      @ivanfaye3041 2 роки тому +6

      @@tacticalassaultanteater9678 ?? When I use typescript it does catches promises that have not been waited

    • @arthurcoser
      @arthurcoser 2 роки тому +3

      @@ivanfaye3041 only if you're using the result of the promise to do something, if you're just running them and doing something else it can't tell if it's intended or not

    • @poolkrooni
      @poolkrooni 2 роки тому +3

      @@tacticalassaultanteater9678 mate could you share the rule you're talking about?

  • @ewanmunro7580
    @ewanmunro7580 2 роки тому +151

    I think a more code focused channel makes a lot of sense. Combining your iconic voice and concise (and fun) writing with a traditional education kind of feel.

    • @parlor3115
      @parlor3115 2 роки тому +1

      Get the best of both worlds ayy?

  • @evols7028
    @evols7028 2 роки тому +10

    I had not used callbacks for a long time, this video revived my callback PTSD. Async/await truly is a marvelous thing

  • @blueguy5588
    @blueguy5588 2 роки тому +10

    This is a great channel idea. I agree with others; at a certain point, it becomes easiest to understand how a piece of software works simply by looking at the code, so it makes sense to have a channel where code is central.

  • @yungifez
    @yungifez 2 роки тому +2

    This channel feels premium

  • @abdullahsoomro6238
    @abdullahsoomro6238 2 роки тому +2

    Lovely videos. Keep uploading short and very informative videos. And thank you for creating such an amazing content.

  • @RaymondovanDijk
    @RaymondovanDijk 2 роки тому +16

    Going fast! 2 vids on the same day😱

  • @e-jarod4110
    @e-jarod4110 2 роки тому +8

    A tutorial about oauth in nestjs / node.js (without existing passport lib) will be awesome
    Some OAuth services have not their own passport plugin

  • @alloycipher4528
    @alloycipher4528 2 роки тому +4

    i respect your work ethic

  • @yairopro
    @yairopro 2 роки тому +2

    Graph-fs does a great job

  • @guilhermealveslopes
    @guilhermealveslopes 2 роки тому +2

    I love this channel Jeff, I subscribed with Bell icon, cause me, and buch of other people, highly want to see tons upon tons of very specific non-introductory pieces like this.
    And then maybe in the end we could build a guides website for all of javascript with just videos from this channel.

  • @CarlenWhite
    @CarlenWhite 2 роки тому +8

    It isn't running a separate thread when it comes to callbacks/promises, it's the event loop. AFAIK you're adding something to the event loop, your function yields, the loop polls for status, and runs the associated callback(s) if needed plus anything else.
    If you've worked with an async runtime in Rust, you might know what's going on here.

    • @SamualN
      @SamualN 2 роки тому +3

      he means the request to go get the directory and wait for the os to respond etc is off the main thread

    • @ed_iz_ed
      @ed_iz_ed 2 роки тому

      in a way is a separate thread, io can go on while the code executes, but callbacks will execute on the same single thread

    • @okie9025
      @okie9025 2 роки тому +3

      Actually Node _does_ launch a separate thread for IO operations, but this is the only case where that happens (except WebWorkers but that's browser-only)

  • @ritwan3952
    @ritwan3952 Рік тому

    THIS IS AMAZING

  • @salman0ansari
    @salman0ansari 2 роки тому

    we need more content like this

  • @lolidkstudio
    @lolidkstudio 2 роки тому +1

    fireship new channel moment

  • @Infinitay
    @Infinitay 2 роки тому

    I would love if this second channel hosts various comparisons and benchmarks between different libraries, and even libraries in other languages.

    • @allentom97
      @allentom97 2 роки тому

      Seems out of scope for this channel?
      Seeing as it is focusing on specific tutorials

  • @Mufti199
    @Mufti199 2 роки тому +2

    A server side app that deletes things from my "notporn" folder? Great product-market fit!

  • @re.liable
    @re.liable 2 роки тому +1

    I'd be interested in a video about js/mjs/cjs extensions, and the `node:` prefix for built-in modules

  • @erminpajazetovic9506
    @erminpajazetovic9506 2 роки тому +9

    The folder name💀💀

  • @zozodejante8350
    @zozodejante8350 2 роки тому +19

    Your upload schedule on this channel is blazingly fast bro

    • @alexradu1921
      @alexradu1921 2 роки тому +3

      sometimes I wonder when does he have time to go outside, eat, wash, clean, sleep... he's just making one high quality video after another which is like crazy

  • @sweatypotato248
    @sweatypotato248 2 роки тому

    what? this channel exist I didnt know until now

  • @thmsrttg
    @thmsrttg 2 роки тому

    love that directory name 😆

  • @neilvasu
    @neilvasu 2 роки тому

    yesss this is what we need, in the weeds snippets

  • @vicjajsalu2
    @vicjajsalu2 2 роки тому

    New firship channel!

  • @supercellodude
    @supercellodude 2 роки тому

    If I was a smug scheme or haskell weenie, I'd drone on about "oh javascript has finally caught on with continuation programming". However, waiting for standards bodies to try and "zip together" divergent implementations' feature sets is very familiar between ecmascript and the RnRS.

  • @shoucs2
    @shoucs2 2 роки тому

    Great Video, but to complete your UA-cam career you will now we need a "Afar Fireship" channel too.

  • @anthonybyansi4255
    @anthonybyansi4255 2 роки тому

    Even though you create 100 fireship channels, I will definitely npm sub fireship

  • @debjanisarkar9756
    @debjanisarkar9756 2 роки тому

    Thanks a lot!!

  • @丶-s3u
    @丶-s3u 2 роки тому

    Well done

  • @mehboobdev
    @mehboobdev 2 роки тому

    Folder name was awesome 😎, lol

  • @wlockuz4467
    @wlockuz4467 2 роки тому

    Should've mentioned, that to catch errors with fs/promises its as simple as wrapping all your calls inside a try/catch, much better than declaring 10 different .catch() callbacks then losing your mind.

  • @cauhxmilloy7670
    @cauhxmilloy7670 2 роки тому +8

    One topic that I wish I saw talked about more on some edu vids, nudge nudge, is that callback hell often gets blamed on the callback API. Instead, IMO, it should be blamed on the over abundant use of anonymous inline functions / lambdas.
    Using normal named functions as callbacks allows for callback APIs to be used with no risk of callback hell. You do miss out on variable captures, but that is something that is often relied on out of laziness and can cause it's own bugs. I like callback APIs as they are often much lighter weight and easier to debug than other OOP counterparts, like promises.

    • @LC-hd5dc
      @LC-hd5dc 2 роки тому +1

      then you're creating a new kind of code smell by splitting out one-off functions
      really the only viable option for async handling in js is promises

    • @pepkin88
      @pepkin88 2 роки тому +2

      Callback hell is not about indentations or anonymous functions. It's about ensuring that no callback will throw, because each uncaught exception will crash the app, and it's by design.
      The example in this video is unfortunate, because you cannot handle exceptions that way using Node's callback api.

  • @phatakom
    @phatakom 2 роки тому +2

    async-await syntax is just love

  • @pepkin88
    @pepkin88 2 роки тому +3

    0:53 Regarding callbacks, you do not want to throw errors like that. If you do that, there's no way to catch them, other that process.on('uncaughtException', ...), which is a catch-all for all exceptions and should be proceeded by exiting the process.
    Callback hell is not about indentations. It's about ensuring that there is no callback that will just crash the app because of an uncaught exception.
    But we live in the future now and promises are the way to go.
    P.S.: There is one more way to access the file system, and that is through streams, like fs.createReadStream(...).

  • @benelhadjdjellouloussama4286
    @benelhadjdjellouloussama4286 2 роки тому

    Yoo Bro, can you please show us ways how to handle images in DB in Nodejs

  • @upendranayak6344
    @upendranayak6344 2 роки тому

    Man the software scares it's terrifying

  • @JITSoftware
    @JITSoftware 2 роки тому

    Cool video, but I'm torn by that syntax error at 0:53

    • @pepkin88
      @pepkin88 2 роки тому +1

      I don't see any syntax errors there (maybe only misaligned indents). But I do see throwing exceptions from a callback, and that is a big no-no.

  • @tekno47
    @tekno47 2 роки тому

    fs-extra is the goat

  • @towatch
    @towatch 2 роки тому

    Hello, i love fireship.

  • @kartikchauhan2778
    @kartikchauhan2778 2 роки тому

    Please make a video on django backend development
    Thanks

  • @_vicary
    @_vicary 2 роки тому

    the callbacks totally reminded me when Isaacs pushed back fs/promises for so long, this guy should be the most hated dirtbag in the JavaScript history.

  • @cloud244
    @cloud244 2 роки тому

    Nice! I often use the first method which can get ugly quite quickly. I will give the fs/promises a try!

  • @seannewell397
    @seannewell397 2 роки тому

    I wish someone would just use separate functions for the callback api; it's my first thought when using them.

  • @shaftymaze
    @shaftymaze 2 роки тому

    Deno’s fresh lemon drop animation please 🎉❤

  • @fizipcfx
    @fizipcfx 2 роки тому

    this videos are awesome man

  • @cphoover11
    @cphoover11 2 роки тому

    Callbacks are just there to support legacy applications devs should favor promises IMO

  • @LetrixAR
    @LetrixAR 2 роки тому

    fs-extra is great

  • @thestreamer1481
    @thestreamer1481 2 роки тому

    You man, do a video of intro to the channel

  • @darkwoodmovies
    @darkwoodmovies 2 роки тому

    Adding more dependencies to a Node project? I would never...

  • @AbhishekKumar-qx9wq
    @AbhishekKumar-qx9wq 2 роки тому +5

    Directory name sus 🙂

  • @ayank007
    @ayank007 2 роки тому

    Is there any Noob Fireship channel I'm missing?

  • @Ai4698
    @Ai4698 2 роки тому +1

    Currently doing spring security and cors is beating me up so bad. I'm using react as my front end

  • @emmytobs
    @emmytobs 2 роки тому

    Doesn't using await before the Promise.all() pause the execution of the code until all the files have been removed?

    • @petrustefanescu5842
      @petrustefanescu5842 2 роки тому

      Yes, but file removals are done independent of each other. Awaiting Promise.all is like a barrier that only lets flow go further only if all operations are done

  • @pauljohnsonbringbackdislik1469
    @pauljohnsonbringbackdislik1469 2 роки тому

    I wish fs/promises include "exists()". It's a bummer to be forced to use "access(...).then(() => true, () => false)"

  • @SivicIsntFat
    @SivicIsntFat 2 роки тому

    Isn’t it running in the same thread but on the eventloop?

  • @cool_scatter
    @cool_scatter 2 роки тому +1

    Seems like promises are the clear winner here

  • @the-old-channel
    @the-old-channel 2 роки тому

    I miss the background music

  • @sintaulsiam
    @sintaulsiam 2 роки тому

    Just hoped in

  • @Username5H0
    @Username5H0 2 роки тому

    No one gonna mention that directory name though?

  • @turolretar
    @turolretar 2 роки тому

    Are u on tiktok?

  • @clockwise9179
    @clockwise9179 Рік тому

    Please enable save video :((

  • @magnusmarkling
    @magnusmarkling 2 роки тому +1

    "one of the most common operations in server-side code is to read and write from the filesystem"
    I honestly haven't done that in the last ten years or so.

  • @joostkoch7229
    @joostkoch7229 2 роки тому

    17k gang

  • @SpeckyYT
    @SpeckyYT 2 роки тому +3

    This was a poorly made video being honest.
    0:12 why did you name the folder like that
    0:46 how did you mess up the indentation?
    0:55 errors in callbacks aren't thrown like that, since there is no way to catch them except by listening to the process' uncaught exceptions event
    1:18 if you did "if (err) throw err" in the callbacks example, why aren't you try/catching it in the sync example?
    1:39 no "await"? did you even test your examples before showing them?
    1:54 no ".catch()"? what's the point of comparing different methods of doimg the same things while not managing everything the same way?
    Unsubscribed.

    • @bigmistqke
      @bigmistqke 2 роки тому

      Ye agree. the examples were poorly written

  • @elysiapog3402
    @elysiapog3402 2 роки тому

    yay

  • @EthioWonder
    @EthioWonder 2 роки тому

    What the hech is the directory name

  • @shepardpower
    @shepardpower 2 роки тому

    Bruh that thumbnail is cursed lol

  • @clashclan4739
    @clashclan4739 2 роки тому +1

    Need angular related stuffs

  • @akam9919
    @akam9919 2 роки тому +1

    There's definitely not porn in that folder...
    foo just has a list of sites...
    bar has ids...

  • @arjix8738
    @arjix8738 2 роки тому

    so the title is misleading and you used the same API in three different ways

  • @atesztoth
    @atesztoth 2 роки тому +1

    I like your videos very much, but I noticed you often confuse something about the Promise.all API. You usually say it’s running promises in parallel.
    But since the Node runtime is single threaded, it cannot do paralellism but runs your promises concurrently. There is a big difference.
    True paralellism is achievable using Node, but you must utilize worker threads or child processes to do so.
    Cheers!

    • @bigmistqke
      @bigmistqke 2 роки тому

      Could u elaborate what the difference is?

    • @atesztoth
      @atesztoth 2 роки тому

      ​@@bigmistqke The point is this: www.baeldung.com/wp-content/uploads/sites/4/2022/01/vs-1024x462-1.png
      The easiest to understand if you imagine you're carrying two bags from point A to B. In case of concurrency you are going to carry bag "a" a bit, then bag "b" a bit and you do it repeatedly until you're ready. Carrying concurrently means you're grab the two bags at the same time and bring them both to point B.

  • @baxiry.
    @baxiry. 2 роки тому

    All roads lead to golang

  • @AmodeusR
    @AmodeusR Рік тому

    To be honest, I rather learn python and do it with it than trying to tinker with this.

  • @Henry-mc5yq
    @Henry-mc5yq 2 роки тому +1

    No caffeine going good?

  • @ayecaptainjack6930
    @ayecaptainjack6930 2 роки тому

    why are you always talking about “main thread” or “thread-pool” when talking about asynchronous programming? JS is single threaded, it doesn’t make sense to talkt about anything thread related.
    (You did the same thing in your async-await video)

  • @bugdeveloper
    @bugdeveloper 2 роки тому

    O my callback hell

  • @Manish___Choudhary
    @Manish___Choudhary 2 роки тому +2

    Is there any js package that can get the logo of the inserted website URL?

    • @SamualN
      @SamualN 2 роки тому +1

      do you mean the favicon? if so you don't need a package to do that
      just request and download the favicon

    • @ericktorres9791
      @ericktorres9791 2 роки тому +1

      You don't need to do that. Just use the fetch API to request the HTML of the website and search for the favicon which is the tag. Something like this
      await fetch('www.youtube.com').then(response => response.text()).match(//g)
      will get you all of the different favicons. Best of luck!

    • @gangatharan-r
      @gangatharan-r 2 роки тому

      Some favicons are directly hardcoded in base64 format. You might have to factor that too

  • @tjgdddfcn
    @tjgdddfcn 2 роки тому

    just delete the directory and make a new one with the same name

  • @marian7429
    @marian7429 2 роки тому

    sus directory name

  • @swattertroops-yaaa
    @swattertroops-yaaa 2 роки тому +4

    choice of filepath name wasn't tasteful I must say

  • @ugokrollak2315
    @ugokrollak2315 Рік тому

    Mmmm

  • @mingsumsze6026
    @mingsumsze6026 2 роки тому

    50/50 that directory is for porn

  • @thunderskull258
    @thunderskull258 2 роки тому

    Isn't python better

    • @rahulr9539
      @rahulr9539 2 роки тому

      do you even know how to use async/await in python?

  • @rahulr9539
    @rahulr9539 2 роки тому +2

    Warning: while using Promise.all() with recursive calls, I once tried to hash files in a directory recursively. And all 4500+ files were processed at the same time and the system froze. Another problem with Promise.all() is it throws error if any of the task fails. use Promise.allSettled(), but still ot doesn't solve the first problem, for that you will have to use some sort of buffered queue

  • @shimadabr
    @shimadabr 2 роки тому

    Meanwhile in 1969 (Unix):
    rm /path/to/dir/*

  • @NamasteProgramming
    @NamasteProgramming 2 роки тому

    Wow, I used to use utli.promisfy to make callback into promise