Skip to content

Instantly share code, notes, and snippets.

@mcavage
Created January 31, 2012 19:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mcavage/1712462 to your computer and use it in GitHub Desktop.
Save mcavage/1712462 to your computer and use it in GitHub Desktop.
Argument checking simplification
if (!String.prototype.capitalize) {
String.prototype.capitalize = function() {
return this.charAt(0).toUpperCase() + this.slice(1);
}
}
function assertArg(name, type) {
if (typeof(name) !== type)
throw new TypeError(name + '(' + type.capitalize() + ') required');
}
CA.prototype.listSchema = function(customer, callback) {
assertArg(customer, 'string');
assertArg(callback, 'function');
var path = sprintf(CA_FMT, customer);
return this.client.get(path, commonCallback(callback));
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment