Returns true if a dependency is available, otherwise false.
Syntax
if (uHas(file, ver)) {
// do something that needs that file
} else {
// do it a different way
}
Parameters
Parameter
Type
Mandatory
Notes
Util.js version
file
String
Filename of dependency
0.8
ver
Number
Minimum version of that file
0.8
Return Values
Value
Type
Notes
Util.js version
true
Boolean
Indicates the file (and optionally version) are available.
0.8
false
Boolean
Either:
The specified filename is not available
The specified version of that file is not present
0.8
<error>
Error
Something unexpected happened, most likely invalid parameters.
0.8
<object>
Object
Object with named properties (file names) and numeric values (versions) of all provided libraries. See "Notes" below for more information.
Example
Using different approaches based on available dependency
function bleh() {
if (uHas("foo.js",0.3)) {
// do it the foo.js v0.3 or higher way
} else if (uHas("foo.js")) {
// do it the foo.js v0.2 or earlier way
} else {
// do it without using foo.js
}
}
Notes
You can get a list of all provided dependencies using Diag API Diagnostics or by calling uHas() without any parameters.
Availability
Requires:
Util.js v0.8 or above
See Also
Related functions:
Check() — Perform a soft-check to see if a dependency is available...