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

ItemList

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

Member Summary

Public Members
public

[i]: *

public

[key]: *

Method Summary

Public Methods
public

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

Add an item to the list.

public

merge(items: ItemList)

Merge another list's items into this one.

public

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

Public Members

public [i]: * source

public [key]: * source

Public Methods

public add(key: String, content: *, priority: Integer) 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.

public merge(items: ItemList) source

Merge another list's items into this one.

Params:

NameTypeAttributeDescription
items 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