This AI is still in early stages of development.
Check.ANY_VERSION
- Aubergine
Owned by Aubergine
Skip version checking for a dependency check...
Notes
Use Check.ANY_VERSION as a replacement for a version number on any function that checks dependencies or for dependencies listed in a Dependency Descriptor Object.
Examples
Example of incorrect use...
// DO NOT use Check.ANY_VERSION in a Self Descriptor Object var self = {file:"bar.js", ver: Check.ANY_VERSION); // Error
Examples of correct use...
if (Check.has("foo.js", Check.ANY_VERSION)) { // code here will run if any version of foo.js is loaded } // same as... if (Check.has("foo.js")) { // version defaults to Check.ANY_VERSION // code here will run if any version of foo.js is loaded } var dependencies = {"foo.js": Check.ANY_VERSION}; // boz.js will be loaded (if it's path is in Check.paths) when // any version of foo.js becomes available Check.doWhen(dependencies, self, "boz.js", Check.LAZY_LOAD); // will validate if any version of foo.js is loaded // will throw an error if foo.js is not loaded Check.required(dependencies, self);
Strict vs. normal equality...
var version = Check.versionOf("foo.js"); if (version == Check.ANY_VERSION) { // some version is loaded // because normal equality used (== instead of ===) } if (version === Check.ANY_VERSION) { // will never get called // because strict equality used (=== instead of ==) } // switch statements also use strict equality switch (version) { case Check.NOT_LOADED: { // will match if foo.js isn't loaded break; } case Check.ANY_VERSION: { // will *never* match break; } case 1.0 { // will only match if v1.0 of foo.js is loaded } default: { // will match if any version of foo.js is loaded break; } }
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...