Instantly share code, notes, and snippets.

View await.js
/**
* A helper that simplifies waiting for something to happen. It acts like an observer without any
* particular observable. So your 'evaluator' function may do anything, untill it's returns non-undefined value
*
* For example, you may want to "observe" a sessionStorage value regardless of browser support of the
* "storage" events.
*
* @example
* ```js
* var awaiter = await(
View gist:77c90944804f7da71ecd
var
INTERNET_EXPLORER = 'Internet Explorer',
FIREFOX = 'Firefox',
CHROME = 'Chrome',
OPERA = 'Opera',
OPERA_MINI = 'Opera Mini',
SAFARI = 'Safari',
MAXTHON = 'Maxthon',
WEBKIT = 'WebKit',
TRIDENT = 'Trident',
View gist:1486161
/**
* Evaluates the given number against array of numbers, and returns
* the one that is the "closest"
* @param value Value to be tested
* @param array Array of numbers
* @param method uint a comparison method. 0 - round, 1 - ceil, 2 - floor
* @return The closest value from <code>array</code> parameter
*/
public static function closestAgainstArray(value:Number, array:Array, method:uint = 0):Number
{