2009-01-27 21:42:32 +00:00
|
|
|
/**
|
2009-03-05 19:56:01 +00:00
|
|
|
* == Language ==
|
|
|
|
* Additions to JavaScript's "standard library" and extensions to
|
|
|
|
* built-in JavaScript objects.
|
2009-01-27 21:42:32 +00:00
|
|
|
**/
|
|
|
|
|
|
|
|
var Abstract = { };
|
|
|
|
|
2009-03-05 19:56:01 +00:00
|
|
|
/** section: Language
|
2009-01-27 21:42:32 +00:00
|
|
|
* Try
|
|
|
|
**/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Try.these(function...) -> ?
|
|
|
|
* - function (Function): A function that may throw an exception.
|
2009-02-27 23:02:42 +00:00
|
|
|
*
|
2009-01-27 21:42:32 +00:00
|
|
|
* Accepts an arbitrary number of functions and returns the result of the
|
|
|
|
* first one that doesn't throw an error.
|
|
|
|
**/
|
|
|
|
var Try = {
|
|
|
|
these: function() {
|
|
|
|
var returnValue;
|
|
|
|
|
|
|
|
for (var i = 0, length = arguments.length; i < length; i++) {
|
|
|
|
var lambda = arguments[i];
|
|
|
|
try {
|
|
|
|
returnValue = lambda();
|
|
|
|
break;
|
|
|
|
} catch (e) { }
|
|
|
|
}
|
|
|
|
|
|
|
|
return returnValue;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
//= require "lang/class"
|
|
|
|
//= require "lang/object"
|
|
|
|
//= require "lang/function"
|
|
|
|
//= require "lang/date"
|
|
|
|
//= require "lang/regexp"
|
|
|
|
//= require "lang/periodical_executer"
|
|
|
|
//= require "lang/string"
|
|
|
|
//= require "lang/template"
|
|
|
|
//= require "lang/enumerable"
|
|
|
|
//= require "lang/array"
|
|
|
|
//= require "lang/hash"
|
|
|
|
//= require "lang/number"
|
|
|
|
//= require "lang/range"
|