Adding missing functions

Overview

Backport allows you to implement missing functions by providing your own functions.

Availability

Backport v0.1 and above.

Syntax

if (!backport(functionName)) { // function is missing, need to add it
  var status = backport(functionName,function(...) {
    // do stuff
  });
  // status === 1 indicates that all went well
}
 
// then elsewhere in the code access the function as usual
var foo = functionName(params);

Parameters

ParameterTypeMandatoryDescriptionBackport version
functionNameString(tick)The name of the function to check/create0.1
<function>Function(tick)The function to assign to functionName0.1

Return values

See status return values.

Examples

See the following backport scripts for great examples:

  • objFromId.js – very simple example of function addition
  • backport.orderDroid.js – more advanced function addition/upgrade, also has a little API to extend what orders it can accept

See also