Reference Source
public class | source

Collection

Extends:

LoggableErrorableCollectionBase → Collection

Instance objects collection.

Example:

API:
		->set_all(arg_items):nothing - Set all collection items.
		->get_all(arg_types):array - Get all collection items or filter items with given type.
		->get_all_names(arg_types):array - Get all items names with or without a filter on items types.
		->get_all_ids():array - Get all items ids with or without a filter on items types.

		->item(arg_name):Instance - Get an item by its name.

		->get_count():number - Get all items count.
		->get_first():object|undefined - Get first item.
		->get_last():object|undefined - Get last item.

		->add(arg_item):nothing - Add an item to the collection.
		->add_first(arg_item):nothing - Add an item to the collection at the first position.
		->remove(arg_item):nothing - Remove an item from the collection.
		->has(arg_item):boolean -  Test if an item is inside the collection.

		->find_by_name(arg_name):Instance|undefined - Find an item by its name into the collection.
		->find_by_id(arg_id):Instance|undefined - Find an item by its id into the collection.
		->find_by_attr(arg_attr_name, arg_attr_value):Instance|undefined - Find an item by one of its attributes into the collection.
		->find_by_filter(arg_filter_function):Instance|undefined - Find an item by a filter function.

		->filter_by_attr(arg_attr_name, arg_attr_value):array - Filter items by one of theirs attributes into the collection.
		->filter_by_filter(arg_filter_function):array - Filter items by a filter function.

 		->get_accepted_types():array - Get all collection accepted types.
		->set_accepted_types(arg_types):nothing - Set all collection accepted types.
		->add_accepted_type(arg_type):nothing - Add one collection accepted type.
		->has_accepted_type(arg_type):boolean - Test if collection has given accepted type.

		->forEach(arg_cb):nothing - forEach wrapper on ordered items.

Constructor Summary

Public Constructor
public

constructor(args: ...Instance): nothing

Create a collection of Instance objects.

Member Summary

Public Members
public

Class type flag.

Inherited Summary

From class Loggable
public

Log context.

public

Class type flag.

public

Trace is enabled for this flag.

private

Logger manager instance (default undefined)

public

debug(args: string | array): nothing

Trace DEBUG formatted message.

public

disable_trace(): nothing

Disable traces.

public

enable_trace(): nothing

Enable traces.

public

enter_group(arg_group: string): nothing

Trace INFO message on "enter trace group".

public

error(args: string | array): nothing

Trace ERROR formatted message.

public

Define get class name method for non Instance classes.

public

Get instance context.

public

Get logger manager.

public

Define get instance name method for non Instance classes.

public

Get trace flag.

public

info(args: string | array): nothing

Trace INFO formatted message.

public

leave_group(arg_group: string): nothing

Trace INFO message on "leave trace group".

public

separate_level_1(): nothing

Trace INFO trace level 1 separator.

public

separate_level_2(): nothing

Trace INFO trace level 2 separator.

public

separate_level_3(): nothing

Trace INFO trace level 3 separator.

public

set_trace(arg_value: boolean): nothing

Set trace flag.

public

should_trace(arg_traces_cfg: object): boolean

Calculate should trace flag.

public

should_trace_class(arg_traces_cfg: object): boolean

Calculate should trace flag for classes.

public

should_trace_collection_item(arg_traces_cfg: object, arg_collection_name: string, arg_this_item_accessor: string): boolean

Calculate should trace flag for given collection of names or patterns.

public

should_trace_module(arg_traces_cfg: object): boolean

Calculate should trace flag for modules.

public

should_trace_name(arg_traces_cfg: object): boolean

Calculate should trace flag for instances names.

public

Toggle trace flag.

public

Update trace enabled flag.

public

warn(args: string | array): nothing

Trace WARN formatted message.

From class Errorable
private

Error text (default null).

private

Has error flag (default false).

public

error(arg_msg: string): nothing

Set an error.

public

Default helper for "not implemented" error.

public

Get error message.

public

Test is an error is set.

From class CollectionBase
public

Class type flag.

private

Accepted types array.

private

_items_array: array

Items array.

private

Items ids map.

private

Items names map.

public

add(arg_item: Instance): nothing

Add an item to the collection.

public

add_accepted_type(arg_type: string): nothing

Add one collection accepted type.

public

add_first(arg_item: Instance): nothing

Add an item to the collection at the first position.

public

filter_by_attr(arg_attr_name: string, arg_attr_value: any): array

Filter items by one of theirs attributes into the collection.

public

filter_by_filter(arg_filter_function: string): array

Filter items by a filter function.

public

find_by_attr(arg_attr_name: string, arg_attr_value: any): Instance | undefined

Find an item by one of its attributes into the collection.

public

find_by_filter(arg_filter_function: string): Instance | undefined

Find an item by a filter function.

public

Find an item by its id into the collection.

public

Find an item by its name into the collection.

public

forEach(arg_cb: function): nothing

forEach wrapper on ordered items.

public

get(arg_name: string): Instance | undefined

Get an item by its name.

public

Get all collection accepted types.

public

get_all(arg_types: array | string | nothing): array

Get all collection items or filter items with given type.

public

get_all_ids(): array

Get all items ids with or without a filter on items types.

public

get_all_names(arg_types: array | string | nothing): array

Get all items names with or without a filter on items types.

public

Get all items count.

public

Get first item.

public

Get last item.

public

has(arg_item: Instance): boolean

Test if an item is inside the collection.

public

Test if collection has given accepted type.

public

item(arg_name: string): Instance | undefined

Get an item by its name.

public

remove(arg_item: Instance): nothing

Remove an item from the collection.

public

set_accepted_types(arg_types: array): nothing

Set all collection accepted types.

public

set_all(arg_items: Instance | array): nothing

Set all collection items.

public

toString(): *

Format string dump.

private

_add(arg_item: Instance): nothing

Add an item to the collection without type checks (unsafe).

private

_add_first(arg_item: Instance): nothing

Add an item to the collection without type checks at first position (unsafe).

private

_get_all(): array

Get all collection items.

private

_has(arg_item: Instance): boolean

Test if an item is inside the collection without type checks (unsafe).

private

_remove(arg_item: Instance): nothing

Remove an item from the collection without type checks (unsafe).

private

_set_all(arg_items: array): nothing

Set all collection items.

Public Constructors

public constructor(args: ...Instance): nothing source

Create a collection of Instance objects.

Override:

CollectionBase#constructor

Params:

NameTypeAttributeDescription
args ...Instance

variadic list of Instance.

Return:

nothing

Public Members

public is_collection: boolean source

Class type flag.