Class: Listing

Listing(list)

new Listing(list)

Create Listing instance
Parameters:
Name Type Description
list string = ''
Source:

Members

delimiter

Get list delimiter. Returns "," as default delimiter.
Source:

length

Get list length
Source:

Methods

(static) arrayToList(array, delimiter) → {Listing}

Create new Listing instance from array
Parameters:
Name Type Default Description
array Array.<string> | Array.<number>
delimiter string , = ','
Source:
Returns:
new instance
Type
Listing

(static) isValidDelimiter(delimiter) → {boolean}

Check if the given delimiter is valid
Parameters:
Name Type Description
delimiter string
Source:
Returns:
Type
boolean

append(item)

Append new item to list
Parameters:
Name Type Description
item string | number
Source:

clear()

Clear list
Source:

concat(list)

Concat list with another given one.
Parameters:
Name Type Description
list Listing
Source:

contains(substring) → {number}

Check if a list item contains a given substring and return its position (case-sensitive). Return -1 otherwise.
Parameters:
Name Type Description
substring string
Source:
Returns:
position
Type
number

containsNoCase(substring) → {number}

Check if a list item contains a certain substring and return its position (case-insensitive). Return -1 otherwise.
Parameters:
Name Type Description
substring string
Source:
Returns:
position
Type
number

deleteAt(position) → {string}

Delete a list item at a given position and return it.
Parameters:
Name Type Description
position number
Source:
Returns:
deleted item
Type
string

each(callbackFn)

Iterate list and call a given callback function for each item.
Parameters:
Name Type Description
callbackFn function callback function
Source:

eachParsed(callbackFn)

Iterate list and call a given callback function for each item parsed as number.
Parameters:
Name Type Description
callbackFn function callback function
Source:

equals(list) → {boolean}

Check for equality with given list
Parameters:
Name Type Description
list Listing
Source:
Returns:
Type
boolean

every(compareFn) → {boolean}

Determines whether all list elements satisfy the specified test.
Parameters:
Name Type Description
compareFn function compare function
Source:
Returns:
Type
boolean

filter(callbackFn) → {Listing}

Return the items that meet the condition specified in a callback function.
Parameters:
Name Type Description
callbackFn function filter function
Source:
Returns:
filtered list
Type
Listing

find(item) → {boolean}

Check if th list includes a given item (case-sensitive).
Parameters:
Name Type Description
item string
Source:
Returns:
Type
boolean

findNoCase(item) → {boolean}

Check if the list includes a given item (case-insensitive).
Parameters:
Name Type Description
item string
Source:
Returns:
Type
boolean

first() → {string|undefined}

Get the first list item.
Source:
Returns:
first item
Type
string | undefined

getAt(position) → {string|undefined}

Get the list item at a given position. Use negative position to start from the list end.
Parameters:
Name Type Description
position number
Source:
Returns:
item
Type
string | undefined

getDuplicates() → {Listing}

Return new listing instance of duplicated list items.
Source:
Returns:
duplicated items
Type
Listing

indexOf(item) → {number}

Get position in list of a given item.
Parameters:
Name Type Description
item string
Source:
Returns:
position
Type
number

insertAt(position, item)

Insert item at given position.
Parameters:
Name Type Description
position number
item string
Source:

isEmpty() → {boolean}

Returns true if the list is empty or otherwise.
Source:
Returns:
Type
boolean

last() → {string|undefined}

Get last list item.
Source:
Returns:
last item
Type
string | undefined

map(callbackFn)

Call a defined callback function on each item, and return a list that contains the results.
Parameters:
Name Type Description
callbackFn function map function
Source:

merge(list)

Merge list and skip duplicated values.
Parameters:
Name Type Description
list Listing
Source:

prepend(item)

Prepend an item to the list.
Parameters:
Name Type Description
item string | number
Source:

qualify(item)

Add an item at the start and end of the list.
Parameters:
Name Type Description
item string | number
Source:

removeDuplicates()

Remove duplicated list items.
Source:

rest() → {Listing}

Get the list without the first item.
Source:
Returns:
Type
Listing

reverse()

Reverse list items in place.
Source:

setAt(position, value)

Set a list item to a value at a given position. Use negative position to start from the list end.
Parameters:
Name Type Description
position string
value string
Source:

setDelimiter(delimiter)

Set list delimiter.
Parameters:
Name Type Description
delimiter string
Source:

shuffle()

Shuffle list in place.
Source:

slice(start, end) → {Listing}

Slice list from start to end position.
Parameters:
Name Type Default Description
start number 0 = 0
end number = list length
Source:
Returns:
sliced list
Type
Listing

some(compareFn) → {boolean}

Determines whether at least one list elements satisfy the specified test.
Parameters:
Name Type Description
compareFn function compare function
Source:
Returns:
Type
boolean

sort(compareFn)

Sort list in place.
Parameters:
Name Type Description
compareFn function compare function
Source:

swap(position1, position2)

Swap list items at given positions. Use negative position to start from the list end.
Parameters:
Name Type Description
position1 number
position2 number
Source:

toArray() → {Array.<string>}

Transform list to array based on current delimiter.
Source:
Returns:
array
Type
Array.<string>

(generator) values()

Get a new Iterator object that contains the values for each list item.
Source: