This would allow the API user to do the work only once.
Now the next question (less question, more obstacle) is if the defaults transcend the URI.parse() method, so that the following behaves the same way:
var uri = URI.withDefaults({ protocol: 'http' })('portquiz.net:8');
uri.href('portquiz.net:9')
I guess URI.withDefaults() would work like a factory, bootstrapping the URI “class” so that any instance of that customized URI behaves consistently. We’ve dealt with this in an ugly and global way in the past, as URI.escapeQuerySpace can attest.
In that case I’d prefer to go the functional programming route:
This would allow the API user to do the work only once.
Now the next question (less question, more obstacle) is if the defaults transcend the
URI.parse()
method, so that the following behaves the same way:I guess
URI.withDefaults()
would work like a factory, bootstrapping the URI “class” so that any instance of that customized URI behaves consistently. We’ve dealt with this in an ugly and global way in the past, as URI.escapeQuerySpace can attest.