• bleistift2@sopuli.xyz
    link
    fedilink
    English
    arrow-up
    3
    ·
    2 months ago

    One way in which this could have come about is that Math.random wasn’t supported in all relevant browsers when the library author wrote the library. So they had to roll their own randomness with blackjack and hookers. Later the web standards evolved and the author was able to remove the custom code, but now had people relying on his library’s exposing a getRandom function.

    • Billygoat@piefed.social
      link
      fedilink
      English
      arrow-up
      2
      ·
      2 months ago

      You see this kind of stuff in C all the time when a code base supports multiple OSs by using macros.

      • chonglibloodsport@lemmy.world
        link
        fedilink
        arrow-up
        1
        ·
        2 months ago

        Yes, though at least with C you have the compiler to optimize the cruft out of your binary and end up with a nice, clean program.

        With JavaScript this is going to incur some runtime cost everywhere this library is used, even if it only happens once when getting optimized out by the JIT compiler.

  • rtxn@lemmy.world
    link
    fedilink
    arrow-up
    2
    ·
    2 months ago

    Considering how many websites were temporarily obliterated by the left-pad fiasco, being an npmjs maintainer might be an even higher power-to-effort ratio (by virtue of a near-zero denominator) than being a billionaire CEO.