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

« Previous Version 3 Next »

Overview

Backport allows you to check the status of any JS API feature so that your script can act accordingly.

Availability

Backport.js v0.1 and above

Syntax

var returnValue = backport(name);

Parameters

ParameterTypeMandatoryDescriptionBackport version
nameString(tick)The name (key) of the feature as a string (in quotes).0.1

Return values

ValueTypeSummaryDescriptionBackport version
-1Number(plus) AddedFeature was missing from JS API, but has been added via backports.0.1
1Number(warning) UpgradedFeature was present in JS API, but has been upgraded/extended by backports.0.1
nullNull(minus) Removed

Feature was present in JS API, but has been removed by backports.

(Deprecated features are removed if new approach is backported).

0.1
trueBoolean(tick) NativeFeature is present in JS API, has not been altered by backports.0.1
undefinedBoolean(error) MissingFeature missing from JS API.0.1

It's important to remember that Javascript uses type coercion - see Examples below for more information.

Examples

var status = backport("orderDroid"); // orderDroid() was added in Warzone 3.2
 
// basic type coercion examples
 
if (status) { // the feature exists
  // status could be true, -1 or 1
}
 
if (!status) { // the feature does not exist
  // status could be null or undefined
}
 
// remember that == (equality operator) also type coerces!
 
if (status == true) {
  // status could be true, -1 or 1
}
 
if (status != true) {
  // status could be null or undefined
}
 
if (status == null) {
  // status could be null or undefined
}
 
// use === (strict equality operator) if you need to check a specific value
 
if (status === -1) { // the feature was added by a backport script
  // status must be exactly -1
}
 
if (status === null) { // a deprecated feature was removed
  // status must be exactly null
}
 
if (status === true) { // the native, unaltered feature is present
  // status must be exactly true
}

See also

  • No labels