This AI is still in early stages of development.
Check()
- Aubergine
Owned by Aubergine
Perform a soft-check to see if a dependency is available...
Syntax
var available = Check(file, ver);
Parameters
Parameter | Type | Mandatory | Notes | API Version |
---|---|---|---|---|
file | String Array of String | The name of the file to check, or an array of file names. Must match the value of the 'file' property specified in the Self Descriptor Object of the file you want to check. If an array is passed in, all files will be checked for the same ver (if specified). | 1.0 | |
ver | Number Constant | The version of the dependency, or one of the following constants:
Default: Check.ANY_VERSION | 1.0 |
Return values
Value | Type | Notes | API Version |
---|---|---|---|
true | Boolean | The specified requirements were met | 1.0 |
false | Boolean | One or more of the specified requirements was not met | 1.0 |
Notes
This function is similar to Check.has() with some notable differences:
- Check() allows an array of filenames in the first parameter, Check.has() does not
- Check() does not attempt to autoload missing files, Check.has() does (unless told not to)
Example
if (Check("foo.js")) { // do stuff that relies on foo.js (any version) } if (Check(["bar.js", "baz.js"], 1.2)) { // do stuff that requires v1.2 of bar.js and v1.2 of baz.js } if (Check("foo.js", Check.NOT_LOADED)) { // do stuff that relies on foo.js being unavailable }
Contents
Jump to:
Dependency Checking
Topics:
- Tricks for including files — Some tricks with the include() function...
- Dependency Descriptor Object — Define one or more dependencies for your script...
- Check() — Perform a soft-check to see if a dependency is available...
- Check.basePath — The base path to the folder that contains the APIs folder...
- Check.paths[] — Define one or more folder paths to enable autoloading...
- Check.doWhen() — Perform a task when dependencies become available.
- Check.has() — Check if a dependency is available, try and load it if not, return availability state...
- Check.LAZY_LOAD — Disable autoloading during a dependency check...
- Check.required() — Thrown a descriptive error if dependency check fails...
- Check.NOT_LOADED — Indicates a script is not yet loaded, or must not be loaded, depending on the Check function being used...
- Check.ANY_VERSION — Skip version checking for a dependency check...
- Check.provide() — Indicate a file is now available.
- Check.versionOf() — Check the version of a dependency.
- Self Descriptor Object — Define the filename and version of your script...