Versions Compared

Key

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

Check if a dependency is available, try and load it if not, return availability state...

 

Syntax

Code Block
themeRDark
languagejavascript
linenumberstrue
var available = Check.has(file[, ver[, lazy]])

Parameters

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

Number

Constant

(error)

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

  • Check.ANY_VERSION – skip version check
  • Check.NOT_LOADED – fail dependency check if the file is already loaded

Default: Check.ANY_VERSION

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
trueBooleanThe dependency check was successful.1.0
falseBoolean

The dependency check failed.

1.0
<error>ErrorAn error occurred, most likely invalid parameters.1.0

Example

Code Block
themeRDark
languagejavascript
titleCheck specific version of file...
linenumberstrue
function bleh() {
  if (Check.has("foo.js", 1.2)) {
    // do it the foo.js v1.2 way
  } else {
    // do it without any foo
  }
}
Code Block
themeRDark
languagejavascript
titlePrevent autoloading foo.js...
linenumberstrue
function bleh() {
  if (Check.has("foo.js", 1.2, Check.LAZY_LOAD)) {
    // do it the foo.js v1.2 way
  } else {
    // do it without any foo
  }
}

Notes

You can get a list of all provided dependencies using Util API diagnostics (requires Diag API).

Div
classbox
Availability
Status
colourYellow
titleBeta

Requires:

Div
classbox
Contents

Jump to:

Table of Contents
maxLevel5

Div
classbox

Dependency Checking

Topics:

Child pages (Children Display)
alltrue
depthall
pageDependency Checking
excerpttrue