new GroupList( GedCom , Caller )
GroupList class contains groups which contain lists.
Parameters:
Name | Type | Description |
---|---|---|
GedCom |
GedCom | GedCom parser instance |
Caller |
mixed | Caller instance where the class is being called |
- Copyright:
-
- Dávid Imre 2016. See full of rights.
Extends
Members
-
(private) caller :mixed
-
Caller instance where the class has been called.
Type:
- mixed
- Inherited From:
-
(private) constructors :Array.<string>
-
Class chaining.
Type:
- Array.<string>
- Inherited From:
- Overrides:
-
(private) gedcom :GedCom
-
GedCom parser instance.
Type:
- Inherited From:
-
(private) groups :Object
-
Groups.
Type:
- Object
-
(readonly) idPattern :string
-
Default item ID pattern. The List#create method will append the index before last @.
Type:
- string
- Inherited From:
-
(private) length :Number
-
Items length.
Type:
- Number
- Inherited From:
-
(private) listKey :string
-
Items property ID.
Type:
- string
-
(private) pointer :Number
-
Items pointer.
Type:
- Number
- Inherited From:
Methods
-
add( …id [, item] ) → {List}
-
Adds an item.
Parameters:
Name Type Argument Description id
List|Data|Object|Number|string <repeatable>
Added items as List, or added item as Data, or added item ID as Number or string item
Data <optional>
Added item, required if argument 1 is an item ID - Inherited From:
Returns:
-
{List} - Self instance
Examples:
new List(<gedcom>, <instance>).add(new List(<gedcom>, <instance>));
new List(<gedcom>, <instance>).add(new Data(<gedcom>, <instance>));
new List(<gedcom>, <instance>).add(<id>, new Data(<gedcom>, <instance>));
-
copy( ) → {List}
-
Copies Self instance to a new list.
- Inherited From:
Returns:
-
{List} - Copied list
Example:
new List(<gedcom>, <instance>).copy();
-
each( func ) → {boolean}
-
Iterates items.
Parameters:
Name Type Description func
ListIterator The iterator that will be executed on every item. - Inherited From:
Returns:
-
{boolean} - When true, iteration is executed, false otherwise
Example:
new List(<gedcom>, <instance>).each(function(id, item, index){ document.write(id + ': ' + item.toString()); });
-
(private) eachCallback( args ) → {GroupList}
-
Calls the caller method on every groups.
Parameters:
Name Type Description args
Arguments Arguments of the caller method Returns:
-
{GroupList} - New grouped list
-
-
extend( opts ) → {boolean}
-
Merge the contents of passed Object into the Self instance.
Parameters:
Name Type Description opts
Object Extended options - Inherited From:
- Overrides:
Returns:
-
{boolean} - True if extending is succeeded, false otherwise
Example:
new Base().extend({ <property>: <value>, <method>: function(){ } });
-
filter( …list1 [, value] ) → {List}
-
Reduces the set of matched items to those that match the passed items.
Parameters:
Name Type Argument Description list1
List|Data|Number|string|Array <repeatable>
Filtered items as List, or filtered item as Data, or filtered item ID as Number or string, or key of a filtered property as Array value
mixed <optional>
Filtered item value, required if Argument 1 is key of a property - Overrides:
Returns:
-
{List} - Reduced list
Examples:
new GroupList(<gedcom>, <instance>).filter(new List(<gedcom>, <instance>), new List(<gedcom>, <instance>));
new GroupList(<gedcom>, <instance>).filter(new Data(<gedcom>, <instance>), new Data(<gedcom>, <instance>));
new GroupList(<gedcom>, <instance>).filter(<id1>, <id2>);
new GroupList(<gedcom>, <instance>).filter(['NAME', 'FIRST'], <value>);
-
(private) filterByKeyAndValue( key , value ) → {List}
-
Reduces the set of matched items to whose property value match the passed property value.
Parameters:
Name Type Description key
Array Key of a filtered property value
mixed Filtered item value - Overrides:
Returns:
-
{List} - Reduced list
Example:
new GroupList(<gedcom>, <instance>).filterByKeyAndValue(['NAME', 'FIRST'], <value>);
-
first( ) → {Data}
-
Get the first item.
- Inherited From:
Returns:
-
{Data} - First item
Example:
new List(<gedcom>, <instance>).first();
-
fromObject( object , deep ) → {List}
-
Imports items from a specific primitive Object.
Parameters:
Name Type Description object
Object Object which will be imported deep
boolean When true, the import will run recursively - Inherited From:
Returns:
-
{List} - Self instance
Examples:
new List(<gedcom>, <instance>).from(new Object({ type: 'List', items: new Object({ <id1>: new Object({ props: { 'NAME': new Object({ props: { //RECURSIVELY }, value: <value>, type: 'Data' } }, value: <value>, type: 'Data' }, <id2>: new Object({ props: { 'NAME': new Object({ props: { //RECURSIVELY }, value: <value>, type: 'Data' } }, value: <value>, type: 'Data' }, <id3>: new Object({ props: { 'NAME': new Object({ props: { //RECURSIVELY }, value: <value>, type: 'Data' } }, value: <value>, type: 'Data' } }) }));
new List(<gedcom>, <instance>).from(new Object({ type: 'List', items: new Object({ <id1>: new Object({ props: { 'NAME': new Object({ props: { //RECURSIVELY }, value: <value>, type: 'Data' } }, value: <value>, type: 'Data' }, <id2>: new Object({ props: { 'NAME': new Object({ props: { //RECURSIVELY }, value: <value>, type: 'Data' } }, value: <value>, type: 'Data' }, <id3>: new Object({ props: { 'NAME': new Object({ props: { //RECURSIVELY }, value: <value>, type: 'Data' } }, value: <value>, type: 'Data' } }) }), true);
-
get( group [, create] ) → {List}
-
Get a group from GroupList.
Parameters:
Name Type Argument Default Description group
string|Number Group ID create
boolean <optional>
false When true, non existed group will be created - Overrides:
Returns:
-
{List} - Selected group
Example:
new GroupList(<gedcom>, <instance>).get(<id>, true);
-
(private) getCaller( ) → {mixed}
-
Get the List caller instance.
- Inherited From:
Returns:
-
{mixed} - List caller instance or Self instance
Example:
new List(<gedcom>, <instance>).getCaller();
-
getGroupIds( ) → {Array}
-
Get all groups IDs.
Returns:
-
{Array} - All groups IDs
Example:
new GroupList(<gedcom>, <instance>).getGroupIds();
-
-
getHighestKey( ) → {string|Number}
-
Get the highest key of items.
- Inherited From:
Returns:
-
{string|Number} - Highest key of item
Example:
new List(<gedcom>, <instance>).getHighestKey();
-
getIdPattern( [id] ) → {string}
-
Get the default item ID pattern. The List#create method will append the index before last @.
Parameters:
Name Type Argument Description id
string|Number <optional>
ID that will be parsed - Inherited From:
Returns:
-
{string} - ID pattern
-
getIds( ) → {Array}
-
Get all items IDs of all groups.
- Overrides:
Returns:
-
{Array} - All items IDs of all groups
Example:
new GroupList(<gedcom>, <instance>).getIds();
-
(private) getList( ) → {Object}
-
Get all items
- Inherited From:
Returns:
-
{Object} - Items set
Example:
new List(<gedcom>, <instance>).getList();
-
(private) getMethodName( [instance] , method [, method [, indexInStack]] ) → {string}
-
Get the method name.
Parameters:
Name Type Argument Description instance
mixed <optional>
A class instance method
function The method method
string <optional>
Calling stack, only used in strict mode indexInStack
number <optional>
Caller method index in stack, only used in strict mode - Inherited From:
- Overrides:
Returns:
-
{string} - The method name
-
(private) getMethodParams( [instance] , method ) → {Array.<string>}
-
Get the method params.
Parameters:
Name Type Argument Description instance
mixed <optional>
A class instance method
string The method name - Inherited From:
- Overrides:
Returns:
-
{Array.<string>} - The method params
-
getNextKey( ) → {string|Number}
-
Get the next key of items.
- Inherited From:
Returns:
-
{string|Number} - Next key of item
Example:
new List(<gedcom>, <instance>).getNextKey();
-
getProperties( property [, property] ) → {Array}
-
Get all items selected properties of all groups.
Parameters:
Name Type Argument Description property
string|Array|boolean Key of selected property or when true, the property value will be converted to string property
string <optional>
Key of selected property, required if Argument 1 is a boolean - Overrides:
Returns:
-
{Array} - All items Selected properties of all groups
Examples:
new GroupList(<gedcom>, <instance>).getProperties('NAME');
new GroupList(<gedcom>, <instance>).getProperties(true, 'NAME');
-
getType( ) → {string}
-
Get the type of a class.
- Inherited From:
- Overrides:
Returns:
-
{string} - The type of a class
Examples:
new Properties(<gedcom>, <instance>).getType();
new List(<gedcom>, <instance>).getType();
new Data(<gedcom>, <instance>).getType();
-
(private) init( instance )
-
Creates a class.
Parameters:
Name Type Description instance
function Self class -
inList( id ) → {boolean}
-
Checks for a specified ID within items.
Parameters:
Name Type Description id
string|Number Checked item ID - Inherited From:
Returns:
-
{boolean} - True if item is found in items, false otherwise
Example:
new List(<gedcom>, <instance>).inList(<id>);
-
keys( [index] ) → {Array|string|Number}
-
Get all keys of items.
Parameters:
Name Type Argument Description index
Number <optional>
Index of selected key - Inherited From:
Returns:
-
{Array|string|Number} - All keys of items or selected key
Examples:
new List(<gedcom>, <instance>).key();
new List(<gedcom>, <instance>).key(10);
-
last( ) → {Data}
-
Get the last item
- Inherited From:
Returns:
-
{Data} - Last item
Example:
new List(<gedcom>, <instance>).last();
-
merge( …list ) → {List}
-
Merges any Lists into Self instance.
Parameters:
Name Type Argument Description list
List <repeatable>
Merged lists - Inherited From:
Returns:
-
{List} - Self instance
Example:
new List(<gedcom>, <instance>).merge( new List(<gedcom>, <instance>), new List(<gedcom>, <instance>) );
-
not( …list1 [, value] ) → {List}
-
Removes elements from the set of matched items.
Parameters:
Name Type Argument Description list1
List|Data|Number|string|Array <repeatable>
Not removed items as List, or not removed item as Data, or not removed item ID as Number or string, or key of not filtered property as Array value
mixed <optional>
Not removed item value, required if Argument 1 is key of a property - Overrides:
Returns:
-
{List} - Reduced list
Examples:
new GroupList(<gedcom>, <instance>).not(new List(<gedcom>, <instance>), new List(<gedcom>, <instance>));
new GroupList(<gedcom>, <instance>).not(new Data(<gedcom>, <instance>), new Data(<gedcom>, <instance>));
new GroupList(<gedcom>, <instance>).not(<id1>, <id2>);
new GroupList(<gedcom>, <instance>).not(['NAME', 'FIRST'], <value>);
-
orderBy( …key [, …sort] ) → {List}
-
Orders items by property in every groups
Parameters:
Name Type Argument Default Description key
string|Array <repeatable>
Key of selected property sort
Types.Order <optional>
<repeatable>
Types.Order.Asc Order type - Overrides:
Returns:
-
{List} - Ordered grouped list
Example:
new GroupList(<gedcom>, <instance>).orderBy('NAME', 'asc'); GroupList new List(<gedcom>, <instance>).orderBy(['NAME', 'FIRST'], 'asc', 'BIRTHDAY', 'desc');
-
remove( id ) → {List}
-
Removes an item.
Parameters:
Name Type Description id
Number|string Removed item ID - Inherited From:
Returns:
-
{List} - Self instance
Example:
new List(<gedcom>, <instance>).remove(<id>);
-
set( key , value )
-
Set an item
Parameters:
Name Type Description key
string|Number Pointer or an item ID value
Data Item value - Inherited From:
Example:
new List(<gedcom>, <instance>).set(<id>, new Data(<gedcom>, <instance>);
-
(private) setCaller( instance ) → {mixed}
-
Set the Data caller instance.
Parameters:
Name Type Description instance
mixed The List caller instance - Inherited From:
Returns:
-
{mixed} - Self instance
Example:
new List(<gedcom>, <instance>).setCaller(<instance>);
-
setList( list ) → {Object}
-
Set all items
Parameters:
Name Type Description list
Object New items set - Inherited From:
Returns:
-
{Object} - Items set
Example:
new List(<gedcom>, <instance>).setList(new Object({ <id1> : new Data(<gedcom>, <instance>), <id2> : new Data(<gedcom>, <instance>), <id3> : new Data(<gedcom>, <instance>) }));
-
toArray( [deep] ) → {Array}
-
Converts items to Array.
Parameters:
Name Type Argument Default Description deep
boolean <optional>
false When true, the convert will run recursively - Inherited From:
Returns:
-
{Array} - Converted items
Example:
new List(<gedcom>, <instance>).toArray();
-
toGedCom( ) → {string}
-
Converts items to GEDCOM structure string.
- Inherited From:
Returns:
-
{string} - GEDCOM structure string
Example:
new List(<gedcom>, <instance>).toGedCom();
-
toList( [type] ) → {List}
-
Converts all groups into one list.
Parameters:
Name Type Argument Default Description type
Types.List|string <optional>
Default is same as the type of groups Type of output list or output list name. Returns:
-
{List} - Converted List
Examples:
new GroupList(<gedcom>, <instance>).toList();
new GroupList(<gedcom>, <instance>).toList(List);
new GroupList(<gedcom>, <instance>).toList('List');
-
-
toObject( [deep] ) → {Object}
-
Converts items to a specific pritimive Object.
Parameters:
Name Type Argument Default Description deep
boolean <optional>
false When true, the convert will run recursively - Inherited From:
Returns:
-
{Object} - Converted items
Example:
new List(<gedcom>, <instance>).toObject();
-
toString( [returnIds] ) → {string}
-
Converts items to string.
Parameters:
Name Type Argument Default Description returnIds
boolean <optional>
true When true, convert get every item ID as string - Overrides:
Returns:
-
{string} - Grouped list group IDs or type of list if Argument 1 is not true
Examples:
new GroupList(<gedcom>, <instance>).toString();
new GroupList(<gedcom>, <instance>).toString(false);
-
(private) validateKey( key ) → {string|Number}
-
Validates key of an item. If Argument 1 is an item as Data, item ID will be returned.
Parameters:
Name Type Description key
string|Number|Data Key of an item or item as Data - Inherited From:
Returns:
-
{string|Number} - Key of an item
Examples:
new List(<gedcom>, <instance>).validateKey(<id>);
new List(<gedcom>, <instance>).validateKey(new Data(<gedcom>, <instance>);