Constructor
new BooleanFilterOptionList()
Extends
- CountedList
- module:api/counted_list~CountedList
Members
objs
Has side effect of mutating the
CountedList.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 javascript
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
incrementCount(name, newObjDecoratoropt) → {T}
Increment
numToots for the given name. If no obj with name exists
create a new one and call newObjDecorator() to fill in 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
this.objs.
- Overrides:
maxValue(propertyName) → {number|undefined}
Get the maximum value for a given property across the
this.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:
removeKeywords(keywords)
Remove any obj whose
name matches any of the 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>