Reference Source
import ItemList from 'flarum/utils/ItemList'
public class | source

ItemList

The ItemList class collects items and then arranges them into an array by priority.

Constructor Summary

Public Constructor
public

Member Summary

Public Members
public

The items in the list.

Method Summary

Public Methods
public

add(key: String, content: *, priority: Integer): ItemList

Add an item to the list.

public

get(key: String): *

Get the content of an item.

public

has(key: *): boolean

Check whether an item is present in the list.

public

Check whether the list is empty.

public

Merge another list's items into this one.

public

Remove an item from the list.

public

replace(key: String, content: *, priority: Integer): ItemList

Replace an item in the list, only if it is already present.

public

Convert the list into an array of item content arranged by priority.

Public Constructors

public constructor() source

Public Members

public items: Object source

The items in the list.

Public Methods

public add(key: String, content: *, priority: Integer): ItemList source

Add an item to the list.

Params:

NameTypeAttributeDescription
key String

A unique key for the item.

content *

The item's content.

priority Integer
  • optional

The priority of the item. Items with a higher priority will be positioned before items with a lower priority.

Return:

ItemList

public get(key: String): * source

Get the content of an item.

Params:

NameTypeAttributeDescription
key String

Return:

*

public has(key: *): boolean source

Check whether an item is present in the list.

Params:

NameTypeAttributeDescription
key *

Return:

boolean

public isEmpty(): boolean source

Check whether the list is empty.

Return:

boolean

public merge(items: ItemList): ItemList source

Merge another list's items into this one.

Params:

NameTypeAttributeDescription
items ItemList

Return:

ItemList

public remove(key: String): ItemList source

Remove an item from the list.

Params:

NameTypeAttributeDescription
key String

Return:

ItemList

public replace(key: String, content: *, priority: Integer): ItemList source

Replace an item in the list, only if it is already present.

Params:

NameTypeAttributeDescription
key String
content *
  • optional
priority Integer
  • optional

Return:

ItemList

public toArray(): Array source

Convert the list into an array of item content arranged by priority. Each item's content will be assigned an itemName property equal to the item's unique key.

Return:

Array