From fb8371d0cdc7ec81b812d068a30ed677653a9576 Mon Sep 17 00:00:00 2001 From: coderaiser Date: Fri, 4 Jul 2014 09:45:44 -0400 Subject: [PATCH] feature(util) add checkType --- lib/util.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/lib/util.js b/lib/util.js index 83923ffb..ba551c2e 100644 --- a/lib/util.js +++ b/lib/util.js @@ -144,6 +144,22 @@ } }; + /** + * Check is type of arg with name is equal to type + * + * @param name + * @param arg + * @param type + */ + this.checkType = function(name, arg, type) { + var is = Util.getType(arg) === type; + + if (!is) + throw(Error(name + ' should be ' + type)); + + return this; + }; + /** * Check is Properties exists and they are true if neaded *