Class: TagList

TagList()

Subclass of CountedList for lists of TagWithUsageCounts objects.

Constructor

new TagList()


Extends

Members

objs

Has side effect of mutating the 'nameDict' property.
Overrides:

Methods

addObjs(objs)

Add objects we don't already have. This does NOT set the numToots property on incoming objs!
Parameters:
Name Type Description
objs Array.<T> Array of objects to add to the list.
Overrides:

filter(predicate) → {module:api/counted_list~CountedList.<T>}

Like the standard Array.filter().
Parameters:
Name Type Description
predicate function Function to test each object in the list.
Overrides:
Returns:
A new CountedList containing only the objects that match the predicate.
Type
module:api/counted_list~CountedList.<T>

forEach()

Standard Array.forEach() approximation that invokes a callback for each object in the objs array.
Overrides:

getObj(name) → {T|undefined}

Returns the object in the list with the given name (case-insensitive) if it exists.
Parameters:
Name Type Description
name string The name of the object to retrieve.
Overrides:
Returns:
The object with the specified name, or undefined if not found.
Type
T | undefined

getTag(tag) → {NamedTootCount|undefined}

Like getObj() but takes a MastodonTag argument.
Parameters:
Name Type Description
tag Hashtag Tag whose name to find an obj for.
Returns:
The NamedTootCount obj with the same name (if it exists).
Type
NamedTootCount | undefined

incrementCount(name, newObjDecoratoropt) → {T}

Increment numToots for the given 'name'. If no obj with 'name' exists create a new one and call newObjDecorator() to get its properties.
Parameters:
Name Type Attributes Description
name string The name of the object to increment.
newObjDecorator function <optional>
Optional function to decorate the new object with additional properties.
Overrides:
Returns:
The object with the incremented numToots.
Type
T

map()

Standard map function that applies a callback to each object in the objs array.
Overrides:

maxValue(propertyName) → {number|undefined}

Get the maximum value for a given key across the objs array
Parameters:
Name Type Description
propertyName
Overrides:
Returns:
The maximum value for the specified property, or undefined if none exist.
Type
number | undefined

nameToNumTootsDict() → {StringNumberDict}

Returns a dict of 'obj.name' to 'obj.numToots'.
Overrides:
Returns:
Dictionary mapping object names to their numToots counts.
Type
StringNumberDict

populateByCountingProps(objs, propExtractor)

Populate the objs array by counting the number of times each 'name' (given by propExtractor) appears. Resulting BooleanFilterOptions will be decorated with properties returned by propExtractor().
Parameters:
Name Type Description
objs Array.<U> Array of objects to count properties from.
propExtractor function Function to extract the decorator properties for the counted objects.
Overrides:

(async) removeFollowedTags()

Remove any hashtags that are followed by the FediAlgo user.

(async) removeInvalidTrendingTags()

Remove the configured list of invalid trending tags as well as japanese/korean etc. tags.

removeKeywords(keywords)

Remove any obj whose 'name' is watches any of 'keywords'.
Parameters:
Name Type Description
keywords Array.<string> Array of keywords to match against the object's name.
Overrides:

topObjs(maxObjsopt) → {Array.<T>}

Returns the objs in the list sorted by numAccounts if it exists, otherwise by numToots, and then by name. If maxObjs is provided, returns only the top maxObjs objects.
Parameters:
Name Type Attributes Description
maxObjs number <optional>
Optional maximum number of objects to return.
Overrides:
Returns:
Objects sorted by numAccounts if it exists, otherwise numToots, then by name
Type
Array.<T>

(async, static) buildFavouritedTags()

Alternate constructor to build tags where numToots is set to the # of times user favourited that tag.

(async, static) buildParticipatedTags()

Alternate constructor to build a list of tags the user has posted about recently.

(static) fromParticipations(recentToots, includeRetootsopt) → {module:api/tag_list~TagList}

Alternate constructor that builds a list of Tags the user has posted about based on their toot history.
Parameters:
Name Type Attributes Description
recentToots Array.<Toot> Array of Toot objects to count tags from.
includeRetoots boolean <optional>
If true, includes retoots when counting tag usages.
Returns:
A new TagList instance with tags counted from the recent user toots.
Type
module:api/tag_list~TagList

(static) fromUsageCounts(toots, source) → {module:api/tag_list~TagList}

Alternate constructor that populates this.objs with TagWithUsageCounts objects with numToots set to the # of times the tag appears in the 'toots' array. Note the special handling of retooters.
Parameters:
Name Type Description
toots Array.<Toot> Array of Toot objects to count tags from.
source CountedListSource Source of the list (for logging/context).
Returns:
A new TagList instance with tags counted from the toots.
Type
module:api/tag_list~TagList