I'm having trouble working out how to extend a static function (momentjs) so that I can override the methods, but without altering the original function.
To be clear I know how to extend an instance of moment to override the functions, but I want to extend the library directly so I get my own named instance of moment
that I can use in the same way as momentjs.
As an example, I'd like to be able to do the following
extendedMoment().customFunction() //do something custom
extendedMoment().toString() //use customised toString() method
extendedMoment().format() //use the original momentjs method
I've tried a few options with copying the prototype etc, but editing the prototype of the new extendedMoment
function seems to affect the original.
Update: answered below by @PatrickRoberts