Rob Kinyon - Try-0.01
NAME
Class
DESCRIPTION
This provides a useful way to create classes. See below for more details.
DEPENDENCIES
This requires JSAN to be installed.
STATIC CLASSES
These are classes that are not instantiable, but instead provide a useful set of operations. (In Javascript terms, they do not provide a prototype member, so you will never call new upon them.)
Try
Try is provided as a way of testing a series of items and returning the first one that doesn't throw an error.
Try provides the these() function,
used as so in the Ajax class.
getTransport: function() {
return Try.these(
function() {return new ActiveXObject('Msxml2.XMLHTTP')},
function() {return new ActiveXObject('Microsoft.XMLHTTP')},
function() {return new XMLHttpRequest()}
) || false;
}
SUPPORT
Currently, there is no mailing list or IRC channel. Please send bug reports and patches to the author.
AUTHOR
Rob Kinyon (rob.kinyon@iinteractive.com)
Originally written by Sam Stephenson (sam@conio.net)
My time is generously donated by Infinity Interactive, Inc. http://www.iinteractive.com
/*
=head1 NAME
Class
=head1 DESCRIPTION
This provides a useful way to create classes. See below for more details.
=head1 DEPENDENCIES
This requires JSAN to be installed.
=cut
*/
/*
=head1 STATIC CLASSES
These are classes that are not instantiable, but instead provide a useful set of operations. (In Javascript terms, they do not provide a prototype member, so you will never call new upon them.)
=cut
*/
/*
=head2 Try
Try is provided as a way of testing a series of items and returning the first one that doesn't throw an error.
Try provides the C<these()> function, used as so in the Ajax class.
getTransport: function() {
return Try.these(
function() {return new ActiveXObject('Msxml2.XMLHTTP')},
function() {return new ActiveXObject('Microsoft.XMLHTTP')},
function() {return new XMLHttpRequest()}
) || false;
}
=cut
*/
var Try = {
these: function() {
var returnValue;
for (var i = 0; i < arguments.length; i++) {
var lambda = arguments[i];
try {
returnValue = lambda();
break;
} catch (e) {}
}
return returnValue;
}
};
Try.VERSION = '0.01';
/*
=head1 SUPPORT
Currently, there is no mailing list or IRC channel. Please send bug reports and patches to the author.
=head1 AUTHOR
Rob Kinyon (rob.kinyon@iinteractive.com)
Originally written by Sam Stephenson (sam@conio.net)
My time is generously donated by Infinity Interactive, Inc. L<http://www.iinteractive.com>
=cut
*/