One way in which this could have come about is that
Math.randomwasn’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 agetRandomfunction.You see this kind of stuff in C all the time when a code base supports multiple OSs by using macros.
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
YAGNI
Just do a find and replace
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.
Currently having a new hire write a library in python and I noticed he was doing this in a few PRs. I went and explained to him this was not necessary and that he could just call the original function where he needed it. While showing him how to inline the functions I realised he was actually adding type annotations to functions which did not have them in the original libraries.
Nevermind what I told you, keep doing this.
Its a modernized version of Infinite monkey theorem but instead of typewriters and Shakespeare its importing libraries and Facebook.
How to forget my first pull request.





