This AI is still in early stages of development.

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

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

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 "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:

 

  • No labels