Class BaseCollectionAbstract

Basic collection abstract class; serves as the top class for all collections.

class MyCollection extends BaseCollection {
constructor(owner: object) {
super(owner);
}

add(element: any) {
// Add element logic
}

clear() {
// collection initialization logic
}

_remove(pos: number): boolean {
// Element deletion logic
return true;
}
}

const myCollection = new MyCollection(someOwner);
myCollection.add(someElement);
console.log(myCollection.count);

Hierarchy (view full)

Implements

Properties

_elemTypes: any[]

Defines the type constraints for the collection element.

_guid: string

Unique identifier of the object (GUID). Uniquely identifies the object.

_list: any[]

An array that stores a list of elements in a collection. This array contains actual data from the collection.

_owner: object

Owned object of the collection.

_type: Function

The generator function of the object. The function used when the object was created.

count: number

Returns the number of elements in the current collection.

length: number

Returns the number of elements in the current collection.

_NS: string

Indicates the namespace.

'Meta'
_PARAM: []

List of parameters used for the constructor.

_UNION: []

List of implemented interfaces.

[IObject, IMarshal]

Methods

  • Protected

    Default descriptor set when adding elements to a collection.

    Parameters

    • idx: number

      Index of the element to which the technician will be imported.

    Returns object

  • Generates an 'onAdd' event.

    Parameters

    • idx: number

      Index of the element to be added.

    • elem: any

      The element to add.

    Returns void

    BaseCollection#onAdd

  • Generates an 'onAdd' event.

    Parameters

    • idx: number

      Index of added elements.

    • elem: any

      Added element.

    Returns void

    BaseCollection#onAdded

  • Generates an 'onChanged' event.

    Parameters

    • idx: number

      Index of the changed element.

    • elem: any

      Changed element.

    Returns any

    BaseCollection#onChanged

  • Generates an 'onChanging' event.

    Parameters

    • idx: number

      Index of the element to be changed.

    • elem: any

      The element to be changed.

    Returns any

    BaseCollection#onChanging

  • Generates an 'onClear' event.

    Returns any

    BaseCollection#onClear

  • Generates an 'onCheared' event.

    Returns any

    BaseCollection#onCleared

  • Create an 'onRemove' event.

    Parameters

    • idx: number

      Index of the element to be deleted.

    • elem: any

    Returns void

    BaseCollection#onRemove

  • Generates an 'onRemoved' event.

    Parameters

    • idx: number

      Index of the element to be deleted.

    • elem: any

      The element to delete.

    Returns void

    BaseCollection#onRemoved

  • Deletes an element in the collection (use internally)

    Parameters

    • pos: number

      Index of the element to be deleted.

    Returns boolean

    This is a Boolean value that indicates whether deletion is successful or not.

  • Add an element to the collection.

    Parameters

    • Rest...args: any[]

    Returns number

  • Initialize the collection.

    Returns void

  • Verify that the element exists in the collection.

    Parameters

    • elem: any

      This is the element to check.

    Returns boolean

    This is a Boolean value indicating the presence or absence of an element.

    const exists = myCollection.contains(someElement);
    console.log(`element exists: ${exists}`);
  • Compare the current object with the specified object.

    Parameters

    • target: object

      the object to be compared to.

    Returns boolean

    Returns whether the two objects are the same.

  • Test that all elements pass the test implemented with the provided function.

    Parameters

    • callback: ((value: any, index: number, array: this) => any)

      콜백함수 입니다. (currentValue, index, array) => boolean

        • (value, index, array): any
        • Parameters

          • value: any
          • index: number
          • array: this

          Returns any

    • OptionalthisArg: any

      The value to use as this when executing the callback function.

    Returns boolean

    True if you return a true value for all array elements, otherwise false.

  • Filter only to elements that have passed the test implemented by the provided function

    Parameters

    • callback: ((value: any, index: number, array: this) => any)

      콜백함수 입니다.(currentValue, index, array) => boolean

        • (value, index, array): any
        • Parameters

          • value: any
          • index: number
          • array: this

          Returns any

    • OptionalthisArg: any

      The value to use as this when executing the callback function.

    Returns any[]

    Returns a new array of results.

  • Returns the first element that satisfies the provided test function

    Parameters

    • callback: ((value: any, index: number, array: this) => any)

      This is the callback function. (currentValue, index, array) => any

        • (value, index, array): any
        • Parameters

          • value: any
          • index: number
          • array: this

          Returns any

    • OptionalthisArg: any

      The value to use as this when executing the callback function.

    Returns any

    The first element in the array that satisfies the test function. If no element satisfies the test function, undefined is returned.

  • Returns the first element that satisfies the provided test function

    Parameters

    • callback: ((value: any, index: number, array: this) => any)

      콜백함수 입니다. (currentValue, index, array) => boolean

        • (value, index, array): any
        • Parameters

          • value: any
          • index: number
          • array: this

          Returns any

    • OptionalthisArg: any

      The value to use as this when executing the callback function. Index of the first element that passes the @returns{number} test. If no match exists, return -1.

    Returns any

  • Run the function provided for each element once.

    Parameters

    • callback: ((value: any, index: number, array: this) => void)

      This is the callback function. (currentValue, index, array) => void

        • (value, index, array): void
        • Parameters

          • value: any
          • index: number
          • array: this

          Returns void

    • OptionalthisArg: any

      The value to use as this when executing the callback function.

    Returns void

  • Returns the collection object as a guide type object.
    Circular references are replaced by $ref values.

    Parameters

    • OptionalvOpt: number

      Serialization option.

      • opt=0: Reference structure (_guid: Yes, $ref: Yes)
      • opt=1: Redundant structure (_guid: Yes, $ref: Yes)
      • opt=2: Non-steep structure (_guid: No, $ref: No)
    • Optionalowned: object | object[]

    Returns object

    a.getObject(2) == b.getObject(2)
    
  • Returns the creators of the current object and all the creators of the prototype chain to the array.

    Returns Function[]

    Returns the array of generator functions.

    const types = obj.getTypes();
    console.log(types); // [Function: MetaObject]
  • Look up an element in the collection.

    Parameters

    • Optionalelem: any

      The element to look up.

    Returns number

    Index of element. If element does not exist, return -1.

    const index = myCollection.indexOf(someElement);
    console.log (index of element: ${index});
  • Verify that the current object is an instance of the specified type (including _UNION)

    Parameters

    • target: string | object

      The type of object to be checked (object or string).

    Returns boolean

    Returns whether it is an instance of the specified type.

  • Collects the results of calling a given function for each element and returns a new array.

    Parameters

    • callback: ((value: any, index: number, array: this) => any)

      This is the callback function (currentValue, index, array) => any[]

        • (value, index, array): any
        • Parameters

          • value: any
          • index: number
          • array: this

          Returns any

    • OptionalthisArg: any

      The value to use as this when executing the callback function.

    Returns any[]

    Returns a new array of results.

  • Run the given reducer function for each element and return one result.

    Parameters

    • callback: ((value: any, index: number, array: this) => any)

      콜백함수 입니다. (accumulator, currentValue, index, array) => any

        • (value, index, array): any
        • Parameters

          • value: any
          • index: number
          • array: this

          Returns any

    • OptionalinitialValue: any

      Use the first element of the array if it does not provide an initial value.

    Returns any

    Returns a new array of results.

  • Delete an element in the collection.

    Parameters

    • elem: any

      The element to delete.

    Returns number

    Index of deleted elements.

    const removedIndex = myCollection.remove(someElement);
    console.log(`Index of deleted element: ${removedIndex}`);
  • Deletes an element in the specified location from the collection.

    Parameters

    • pos: number

      Index of the element to be deleted.

    Returns boolean

    This is a Boolean value that indicates whether element deletion is successful or not.

    const success = myCollection.removeAt(0);
    console.log(`Delete element successful: ${success}`);
  • Sets the guide type object to the collection object.
    The object is initialized.

    Parameters

    • oGuid: object

      serialized object.

    • Optionalorigin: object

      This is the source object that sets the current object. The default is oGuid.

    Returns any

  • Test that at least one element passes through a given discriminant function.

    Parameters

    • callback: ((value: any, index: number, array: this) => any)

      콜백함수 입니다. (currentValue, index, array) => boolean

        • (value, index, array): any
        • Parameters

          • value: any
          • index: number
          • array: this

          Returns any

    • OptionalthisArg: any

      The value to use as this when executing the callback function.

    Returns boolean

    Returns true if you return a true value for one element, or false.

Events

onAdd: ((idx: number, elem: any, _this: object) => void)

Events that occur before adding an element to a collection.

BaseCollection#onAdd

Type declaration

    • (idx, elem, _this): void
    • Parameters

      • idx: number

        Index of the element to be added.

      • elem: any

        The element to add.

      • _this: object

        current collection object.

      Returns void

myCollection.onAdd = function(idx, elem, _this) {
console.log(`Before adding elements: index ${idx}, element ${elem}`);
};
onAdded: ((idx: number, elem: any, _this: object) => void)

Events that occur after you add an element to a collection.

BaseCollection#onAdded

Type declaration

    • (idx, elem, _this): void
    • Parameters

      • idx: number

        Index of added elements.

      • elem: any

        Added element.

      • _this: object

        current collection object.

      Returns void

myCollection.onAdded = function(idx, elem, _this) {
console.log ('After adding elements: index ${idx}, element ${elem}');
};
onChanged: ((idx: number, elem: any, _this: object) => void)

Events that occur after you change an element in a collection.

BaseCollection#onChanged

Type declaration

    • (idx, elem, _this): void
    • Parameters

      • idx: number

        Index of the changed element.

      • elem: any

        Changed element.

      • _this: object

        current collection object.

      Returns void

myCollection.onChanged = function(idx, elem, _this) {
console.log ('After element change: index ${idx}, element ${elem}');
};
onChanging: ((idx: number, elem: any, _this: object) => void)

An event that occurs before you change an element in a collection.

BaseCollection#onChanging

Type declaration

    • (idx, elem, _this): void
    • Parameters

      • idx: number

        Index of the element to be changed.

      • elem: any

        The element to be changed.

      • _this: object

        current collection object.

      Returns void

myCollection.onChanging = function(idx, elem, _this) {
console.log(`Before element change: index ${idx}, element ${elem}`);
};
onClear: ((_this: object) => {})

Events that occur before the collection is initialized.

BaseCollection#onClear

Type declaration

    • (_this): {}
    • Parameters

      • _this: object

        current collection object.

      Returns {}

    myCollection.onClear = function(_this) {
    console.log ('Before collection initialization);
    };
    onCleared: ((_this: object) => {})

    Events that occur after the collection is initialized.

    BaseCollection#onCleared

    Type declaration

      • (_this): {}
      • Parameters

        • _this: object

          current collection object.

        Returns {}

      myCollection.onCleared = function(_this) {
      console.log ('After collection initialization');
      };
      onRemove: ((idx: number, elem: any, _this: object) => void)

      An event that occurs before an element is deleted from the collection.

      BaseCollection#onRemove

      Type declaration

        • (idx, elem, _this): void
        • Parameters

          • idx: number

            Index of the element to be deleted.

          • elem: any

            The element to delete.

          • _this: object

            current collection object.

          Returns void

      myCollection.onRemove = function(idx, elem, _this) {
      console.log(`Before element deletion: index ${idx}, element ${elem}`);
      };
      onRemoved: ((idx: number, elem: any, _this: object) => void)

      Events that occur after you delete an element from a collection.

      BaseCollection#onRemoved

      Type declaration

        • (idx, elem, _this): void
        • Parameters

          • idx: number

            Index of deleted elements.

          • elem: any

            Deleted element.

          • _this: object

            current collection object.

          Returns void

      myCollection.onRemoved = function(idx, elem, _this) {
      console.log(`After element deletion: index ${idx}, element ${elem}`);
      };