Created
June 23, 2011 12:38
-
-
Save kaheglar/1042463 to your computer and use it in GitHub Desktop.
jQuery assert - throw error msg if condition false
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function($) { | |
$.assert = function(condition, msg) { | |
if (!condition) { | |
$.error(msg); | |
} | |
}; | |
})(jQuery); |
The method should end with "return this".
Hmm, or maybe not ... my bad.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Usage
$.assert(typeof arg === "string", "Invalid argument - string expected");