Skip to content

Instantly share code, notes, and snippets.

@wmakeev
Last active August 29, 2015 14:09
Show Gist options
  • Save wmakeev/b3e3a0672a845581fa80 to your computer and use it in GitHub Desktop.
Save wmakeev/b3e3a0672a845581fa80 to your computer and use it in GitHub Desktop.
Check type
checkType = function(type, val, name) {
if (typeof val !== type) {
return "" + name + " has to be a " + type;
}
};
err = checkType("string", id, "module ID") || checkType("function", creator, "creator") || checkType("object", options, "option parameter");
if (err) {
this.log.error("could not register module '" + id + "': " + err);
return this;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment