Javascript Object

From Yate Documentation
Revision as of 11:40, 9 September 2024 by Marian (Talk | contribs)

(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

General

This object expose javascript Object operations.

Methods

  • assign(dest[,src[,src1 ...])

Assign object(s) properties to another object.
Parameters:
dest Destination object. Does nothing if not an object.
src Source object. Does nothing if not an object.
src1 ... Other source object(s). Does nothing if not an object.
Return:
Given dest data.


  • assignProps(dest,src[,flags,props,prefix,addPrefix])

Assign object properties to another object.
Parameters:
dest Destination object. Does nothing if not an object.
src Source object. Does nothing if not an object.
flags Numeric. Flags controlling the operation. See Object properties for description.
props Optional list of properties to copy. Comma separated list or Array. No property will be copied if this parameter is given and empty.
prefix Optional, string. Copy only proprties starting with given prefix. This applies for names given in props also.
addPrefix Optional, string. Prefix to be added to property name when assigned. Prefix is added after removing the one given in prefix if flags indicate it should be removed.
Return:
The number of assigned properties.

Flags:
Object.AssignSkipPrefix Skip given prefix in property name when setting in destination. This applies for names given in props also.
Object.AssignSkipNull Skip source properties with null value.
Object.AssignSkipUndefined Skip source properties with undefined value.
Object.AssignSkipEmpty Skip source properties with non object value evaluated to empty string.
Object.AssignSkipObject Skip source properties with object value.
Object.AssignSkipArrayProps Skip source non index properties it its an Array.
Object.AssignSkipArrayIndex Skip source index properties it its an Array.
Object.AssignDeepCopy Deep copy objects. Set reference only if this flag is not set.
Object.AssignFreezeCopy Freeze destination and all copied objects if deep copy is requested.
Object.AssignSkipExist Skip (do not assign) existing properties in destination. This is handled after final property name is resolved (prefix removed/added).

A runtime error (function call failed) will be raised if:

  • destination object is frozen
  • deep copy is required and source contains recursive references

Recursive reference example:

var a = {a1:1};
var b = {b1:1,a:a};
a.b = b;
src = {a:a, b:b}
var dest = {};
Object.assignProps(dest,src,Object.AssignDeepCopy);


Deep copy objects:
The following objects implement deep copy allowing them to keep the internal data: Array, RegExp, MatchingItem.
Any other object will loose any specific internal data. Only object properties will be copied.


  • keys([obj])

Retrieve the list of of the calling script.
Parameters:
obj Object to list keys for. List calling script's global data object keys if this parameter is not given.
Return:
Array of key values. null if given object has no properties (e.g. obj=undefined)


  • global()

Retrieve the context (data) of the calling script.
Return:
Object containing all global data of the calling script.

Properties

  • AssignSkipPrefix,AssignSkipNull,AssignSkipUndefined,AssignSkipEmpty,AssignSkipObject,AssignSkipArrayProps,AssignSkipArrayIndex,AssignDeepCopy,AssignFreezeCopy,AssignSkipExist,AssignFilled,AssignFilledSkipObject

Numeric flags used ifor assignProps() function.

Personal tools
Namespaces

Variants
Actions
Preface
Configuration
Administrators
Developers