• rtxn@lemmy.world
    link
    fedilink
    arrow-up
    2
    ·
    8 days 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.

    • magikmw@piefed.social
      link
      fedilink
      English
      arrow-up
      1
      ·
      7 days ago

      I still find it hilarious people think linking to some lib online on a live website makes sense. And people still do. Ehh.

  • bleistift2@sopuli.xyz
    link
    fedilink
    English
    arrow-up
    1
    ·
    8 days 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.

  • abbadon420@sh.itjust.works
    link
    fedilink
    arrow-up
    0
    ·
    8 days ago

    I get that this is a joke, but would something like import Math.random as getRandom work better? Because that basically what you’re doing here, renaming the function.

    • sunnie@sopuli.xyz
      link
      fedilink
      arrow-up
      0
      ·
      8 days ago

      that’s not really a thing in JS as Math isn’t imported, it’s just an object available globally. the closest you can get is like const { random: getRandom } = Mathbut that’s just uglier.

      the implication is that this function is exported from a library so they have to keep the function around - obviously in a modern project you’d just do Math.random()

  • Avicenna@programming.dev
    link
    fedilink
    arrow-up
    0
    ·
    8 days ago

    I can imagine multiple scenarios where this could be useful. Simplest is perhaps the coder imagined at the time they could extend the function in later stages.

  • katy ✨@piefed.blahaj.zone
    link
    fedilink
    English
    arrow-up
    0
    ·
    8 days ago

    i mean its still good to use an abstraction layer in case you ever have to change the underlying call; it’s far easier to change it in one place instead of replacing every call