Last active
April 29, 2016 14:59
-
-
Save nosajio/5472684 to your computer and use it in GitHub Desktop.
A useful little unless function written in javascript.
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
/**! | |
* Unless | |
* @created April 2013 by @jasonhowmans | |
*/ | |
var unless = function( condition, callback ) { | |
if (typeof callback === 'function') { | |
if (!condition) callback(); | |
}else{ | |
return !condition; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Here's a fiddle with a really basic test case: http://jsfiddle.net/jasonhowmans/VMLYE/3/