Table Of Contents

aps/common

Table of contents

Public Methods

METHOD

RETURN

DESCRIPTION

encodeRQLComponent (str)

string

Method encodes a Resource Query Language (RQL) component by replacing each instance of certain characters by one, two, three, or four escape sequences representing the UTF-8 encoding of the character

escape (str)

string

Efficiently escape a string for insertion into HTML (innerHTML or attributes), replacing &, <, >, “, ‘ characters

forEach (obj, cb, thisObject)

undefined

forEach for object

getPackageId (arg)

string

Finds out and returns a package APS ID by analyzing the input argument

showMessage (message, type)

undefined

Show message in notification center

timeout (callback, delay)

object

Calls the specified callback function after the specified delay measured in milliseconds

toArray (arg)

array

Converts array-like objects / collections to a new array

encodeRQLComponent

Method encodes a Resource Query Language (RQL) component by replacing each instance of certain characters by one, two, three, or four escape sequences representing the UTF-8 encoding of the character.

Return: string

ARGUMENT

TYPE

DESCRIPTION

str

String

the string for encode

escape

Efficiently escape a string for insertion into HTML (innerHTML or attributes), replacing &, <, >, “, ‘ characters.

Return: string

ARGUMENT

TYPE

DESCRIPTION

str

String

the string to escape

forEach

forEach for object. Behavior is similar to the forEach method of the array. https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach

Return: undefined

ARGUMENT

TYPE

DESCRIPTION

obj

object

Object or array to listing

cb

function

Function to execute for each element.

thisObject

object

Optional. Value to use as this when executing callback.

Example 1

common.forEach({ a: 1, b: 2 }, function(value, name){
    console.log(name + ": " + value);  // first step: 'a: 1', second step: 'b: 2'
});

getPackageId

Finds out and returns a package APS ID by analyzing the input argument.

Return: string

ARGUMENT

TYPE

DESCRIPTION

arg

undefined

A value can be a string (URI containing the “/aps/2/packages/” pattern) or an object (one of CommonJS module, View, or ViewPlugin).

showMessage

Show message in notification center.

Return: undefined

ARGUMENT

TYPE

DESCRIPTION

message

String

The message text.

type

String

The message type.

timeout

Calls the specified callback function after the specified delay measured in milliseconds.

Return: object

ARGUMENT

TYPE

DESCRIPTION

callback

Function

Function to execute after the specified delay.

delay

Number

The number of milliseconds that the function call should be delayed.

Example 1

this.own(common.timeout(function() {
    console.log("Delayed message");
}, 1000));

toArray

Converts array-like objects / collections to a new array.

Return: array

ARGUMENT

TYPE

DESCRIPTION

arg

array

Arguments list