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: undefined, priority: number): undefined

Add an item to the list.

public

Get the content of an item.

public

has(key: string): 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: undefined, priority: number): undefined

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: undefined source

The items in the list

Public Methods

public add(key: string, content: undefined, priority: number): undefined source

Add an item to the list.

Params:

NameTypeAttributeDescription
key string
content undefined
priority number

Return:

undefined

public get(key: string): undefined source

Get the content of an item.

Params:

NameTypeAttributeDescription
key string

Return:

undefined

public has(key: string): boolean source

Check whether an item is present in the list.

Params:

NameTypeAttributeDescription
key string

Return:

boolean

public isEmpty(): boolean source

Check whether the list is empty.

Return:

boolean

public merge(items: undefined): undefined source

Merge another list's items into this one.

Params:

NameTypeAttributeDescription
items undefined

Return:

undefined

public remove(key: string): undefined source

Remove an item from the list.

Params:

NameTypeAttributeDescription
key string

Return:

undefined

public replace(key: string, content: undefined, priority: number): undefined source

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

Params:

NameTypeAttributeDescription
key string
content undefined
priority number

Return:

undefined

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

undefined