• WhiteRice@lemmy.ml
    link
    fedilink
    arrow-up
    2
    ·
    edit-2
    10 hours ago

    Can you override Math.random within a local scope?

    At my shop we do create generic covers for vendor specific functionality, for the reasons you stated. Though the practice was started in case we ever needed to swap vendors.

    • bleistift2@sopuli.xyz
      link
      fedilink
      English
      arrow-up
      6
      ·
      6 hours ago

      You can, but you shouldn’t. You don’t know what else relies on Math.random. That’s why there’s the wrapper function. That you can override in unit tests without worrying about other, unrelated code.