Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Excerpt

Returns true if a dependency is available, otherwise false.

 

Syntax

Code Block
themeRDark
languagejavascript
linenumberstrue
if (uHas(file, ver)) {
  // do something that needs that file
} else {
  // do it a different way
}

Parameters

ParameterTypeMandatoryNotesUtil.js version
fileString(tick)Filename of dependency0.8
verNumber(error)

Minimum version of that file

0.8

Return Values

ValueTypeNotesUtil.js version
trueBooleanIndicates the file (and optionally version) are available.0.8
falseBoolean

Either:

  • The specified filename is not available
  • The specified version of that file is not present
0.8
<error>ErrorSomething unexpected happened, most likely invalid parameters.0.8
<object>ObjectObject with named properties (file names) and numeric values (versions) of all provided libraries. See "NotesuHas()" below for more information. 

Example

Code Block
themeRDark
languagejavascript
titleUsing different approaches based on available dependency
linenumberstrue
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.

Div
classbox

Availability

Requires:

  • Util.js v0.8 or above
Div
classbox

See Also

Related documentation:

Child pages (Children Display)
pageDependency Checking
excerpttrue