Reference Source
import ItemList from 'flarum/common/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

items: {}

The items in the list

Method Summary

Public Methods
public

add(key: undefined, content: undefined, priority: undefined): *

Add an item to the list.

public

get(key: undefined): *

Get the content of an item.

public

has(key: undefined): *

Check whether an item is present in the list.

public

Check whether the list is empty.

public

merge(items: undefined): *

Merge another list's items into this one.

public

remove(key: undefined): *

Remove an item from the list.

public

replace(key: undefined, content: undefined, priority: undefined): *

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

public

toArray(): *

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

Public Constructors

public constructor() source

Public Members

public items: {} source

The items in the list

Public Methods

public add(key: undefined, content: undefined, priority: undefined): * source

Add an item to the list.

Params:

NameTypeAttributeDescription
key undefined
content undefined
priority undefined

Return:

*

public get(key: undefined): * source

Get the content of an item.

Params:

NameTypeAttributeDescription
key undefined

Return:

*

public has(key: undefined): * source

Check whether an item is present in the list.

Params:

NameTypeAttributeDescription
key undefined

Return:

*

public isEmpty(): boolean source

Check whether the list is empty.

Return:

boolean

public merge(items: undefined): * source

Merge another list's items into this one.

Params:

NameTypeAttributeDescription
items undefined

Return:

*

public remove(key: undefined): * source

Remove an item from the list.

Params:

NameTypeAttributeDescription
key undefined

Return:

*

public replace(key: undefined, content: undefined, priority: undefined): * source

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

Params:

NameTypeAttributeDescription
key undefined
content undefined
priority undefined

Return:

*

public toArray(): * 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:

*