Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3
Excerpt

Returns true Check if a dependency is available, otherwise falsetry and load it if not, return availability state...

 

Syntax

Code Block
themeRDark
languagejavascript
linenumberstrue
if (uHas(filevar available = Check.has(file[, ver)) {
  // do something that needs that file
} else {
  // do it a different way
}[, lazy]])

Parameters

ParameterTypeMandatoryNotesUtil.js version
fileString(tick)Filename of dependency1.0.8
ver

Number

(error)

Minimum version of that file

0.8

Constant

(error)

Specify the required version of the file (exact match) or a version constant:

Default: Check.ANY_VERSION

For more information on autolaoding, see: Check.paths[].

1.0
lazyConstant(error)

By default, Check.has() will attempt to autoload missing dependencies.

If you want to prevent autoloading, specify Check.LAZY_LOAD

1.0

Return Values

ValueTypeNotesUtil.js version
trueBooleanIndicates the file (and optionally version) are available.0.8The dependency check was successful.1.0
falseBoolean

Either:

  • The specified filename is not available
  • The specified version of that file is not present
0.8

The dependency check failed.

1.0
<error>ErrorSomething unexpected happenedAn error occurred, 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. 1.0

Example

Code Block
themeRDark
languagejavascript
titleUsing different approaches based on available dependencyCheck specific version of file...
linenumberstrue
function bleh() {
  if (uHasCheck.has("foo.js",0 1.32)) {
    // do it the foo.js v0.3 or higher wayv1.2 way
  } else {
    // do it without any foo
  }
else}
Code Block
themeRDark
languagejavascript
titlePrevent autoloading foo.js...
linenumberstrue
function bleh() {
  if (uHasCheck.has("foo.js", 1.2, Check.LAZY_LOAD)) {
    // do it the foo.js v0v1.2 or earlier way
  } else {
    // do it without usingany foo.js
  }
}

Notes

You can get a list of all provided dependencies using using Util API diagnostics (requires Diag API Diagnostics or by calling uHas() without any parameters.

Div
classbox
Availability
Status
colourYellow
titleBeta

Requires:

  • Util.js v0.8 Warzone 3.1 or above
  • Util API
Div
classbox

See Also

Related functions:

children
Contents

Jump to:

Table of Contents
maxLevel5

Div
classbox

Dependency Checking

Topics:

Child pages (Children Display)
alltrue
depthall
pageDependency Checking
excerpttrue