I think there is many way to classify the idiom.
Wrapper of course, but it can lead to many patterns associate with it.
book Implementation Patterns mentions some patterns:
LIBRARY CLASS
in Chapter 5:
Where do you put functionality that doesn’t fit into any object? One solution is to create static methods on an otherwise-empty class. No one is expected to ever create instances of this class. It is just there as a holder for the functions in the library.
also METHOD OBJECT
in Chapter 7:
This is one of my favorite patterns, probably because I use it so infrequently but the results are spectacular when I do. Creating method object can help you turn a tangled mass of code packed into an impossible method into readable, clear code that gradually reveals details to readers. This is a pattern I apply after I have some code working, and the more complex the method the better.
Also I think it is a simple Adapter/Facade pattern as @Joel Harmon already mention.
I think The purpose of the idiom in your case:
- Requests library:
- reveals details to readers/users
- keep api easy to use
- Layers Architecture, High Level Low Level divide, low level can change, high level api won't
Date.now:
I look on https://developer.mozilla.org
Description
Because now() is a static method of Date, you always use it as Date.now().
Polyfill
This method was standardized in ECMA-262 5th edition. Engines which have not been updated to support this method can work around the absence of this method using the following shim:
if (!Date.now) {
Date.now = function now() {
return new Date().getTime();
};
}
- "using the following shim" so it is a adapter
- "static method of Date", yes
LIBRARY CLASS
as the book Implementation Patterns said.