When URI is used without the new keyword it will return a new instance of itself passing both an url and base parameter.
if (!(this instanceof URI)) {
return new URI(url, base);
}
Since these parameters are both undefined at this point, it is caught by the undefined check on the url and then also passes the check on the arguments length, throwing a TypeError.
if (url === undefined) {
if (arguments.length) {
throw new TypeError('undefined is not a valid argument for URI');
}