Circle V2 API Docs
    Preparing search index...

    Interface ListCollection<T>

    interface ListCollection<T extends CollectionItem = CollectionItem> {
        append: (...items: T[]) => ListCollection<T>;
        at: (index: number) => T | null;
        compareValue: (a: string, b: string) => -1 | 0 | 1;
        copy: (items?: T[]) => ListCollection<T>;
        filter: (
            fn: (itemString: string, index: number, item: T) => boolean,
        ) => ListCollection<T>;
        find: (value: string | null | undefined) => T | null;
        findMany: (values: string[]) => T[];
        getItemDisabled: (item: T | null) => boolean;
        getItemValue: (item: T | null | undefined) => string | null;
        getNextValue: (
            value: string,
            step?: number,
            clamp?: boolean,
        ) => string | null;
        getPreviousValue: (
            value: string,
            step?: number,
            clamp?: boolean,
        ) => string | null;
        getValueRange: (from: string | null, to: string | null) => string[];
        getValues: (items?: T[]) => string[];
        group: () => [string, T[]][];
        has: (value: string | null) => boolean;
        hasItem: (item: T | null) => boolean;
        indexOf: (value: string | null) => number;
        insert: (index: number, ...items: T[]) => ListCollection<T>;
        insertAfter: (value: string, ...items: T[]) => ListCollection<T>;
        insertBefore: (value: string, ...items: T[]) => ListCollection<T>;
        isEqual: (other: ListCollection<T>) => boolean;
        items: T[];
        move: (value: string, toIndex: number) => ListCollection<T>;
        moveAfter: (value: string, ...values: string[]) => ListCollection<T>;
        moveBefore: (value: string, ...values: string[]) => ListCollection<T>;
        prepend: (...items: T[]) => ListCollection<T>;
        remove: (...itemsOrValues: (string | T)[]) => ListCollection<T>;
        reorder: (fromIndex: number, toIndex: number) => ListCollection<T>;
        search: (
            queryString: string,
            options: CollectionSearchOptions,
        ) => string | null;
        setItems: (items: T[]) => ListCollection<T>;
        sort: (values: string[]) => string[];
        stringify: (value: string | null) => string | null;
        stringifyItem: (item: T | null) => string | null;
        stringifyItems: (items: T[], separator?: string) => string;
        stringifyMany: (value: string[], separator?: string) => string;
        toJSON: () => { first: string | null; last: string | null; size: number };
        toString: () => string;
        update: (value: string, item: T) => ListCollection<T>;
        upsert: (
            value: string,
            item: T,
            mode?: "append" | "prepend",
        ) => ListCollection<T>;
        get firstValue(): string | null;
        get lastValue(): string | null;
        get size(): number;
        "[iterator]"(): Generator<T, void, unknown>;
    }

    Type Parameters

    • T extends CollectionItem = CollectionItem
    Index

    Properties

    append: (...items: T[]) => ListCollection<T>

    Append items to the collection

    at: (index: number) => T | null

    Get the item based on its index

    compareValue: (a: string, b: string) => -1 | 0 | 1

    Compare two values

    copy: (items?: T[]) => ListCollection<T>

    Copy the collection

    filter: (
        fn: (itemString: string, index: number, item: T) => boolean,
    ) => ListCollection<T>

    Filter the collection

    find: (value: string | null | undefined) => T | null

    Get the item based on its value

    findMany: (values: string[]) => T[]

    Get the items based on its values

    getItemDisabled: (item: T | null) => boolean

    Whether an item is disabled

    getItemValue: (item: T | null | undefined) => string | null

    Convert an item to a value

    getNextValue: (value: string, step?: number, clamp?: boolean) => string | null

    Returns the next value in the collection

    getPreviousValue: (
        value: string,
        step?: number,
        clamp?: boolean,
    ) => string | null

    Returns the previous value in the collection

    getValueRange: (from: string | null, to: string | null) => string[]

    Get the range of values between two values

    getValues: (items?: T[]) => string[]

    Returns all the values in the collection

    group: () => [string, T[]][]

    Group items by the groupBy function provided in options Returns an array of [groupKey, items] tuples

    has: (value: string | null) => boolean

    Whether the collection has a value

    hasItem: (item: T | null) => boolean

    Whether the collection has an item

    indexOf: (value: string | null) => number

    Get the index of an item based on its key

    insert: (index: number, ...items: T[]) => ListCollection<T>

    Insert items at a specific index

    insertAfter: (value: string, ...items: T[]) => ListCollection<T>

    Insert items after a specific value

    insertBefore: (value: string, ...items: T[]) => ListCollection<T>

    Insert items before a specific value

    isEqual: (other: ListCollection<T>) => boolean

    Check if the collection is equal to another collection

    items: T[]

    The items in the collection

    move: (value: string, toIndex: number) => ListCollection<T>

    Move an item to a specific index

    moveAfter: (value: string, ...values: string[]) => ListCollection<T>

    Move items after a specific value

    moveBefore: (value: string, ...values: string[]) => ListCollection<T>

    Move items before a specific value

    prepend: (...items: T[]) => ListCollection<T>

    Prepend items to the collection

    remove: (...itemsOrValues: (string | T)[]) => ListCollection<T>

    Remove items from the collection

    reorder: (fromIndex: number, toIndex: number) => ListCollection<T>

    Reorder items

    search: (queryString: string, options: CollectionSearchOptions) => string | null

    Search for a value based on a query

    setItems: (items: T[]) => ListCollection<T>

    Function to update the collection items

    sort: (values: string[]) => string[]

    Sort the values based on their index

    stringify: (value: string | null) => string | null

    Convert a value to a string

    stringifyItem: (item: T | null) => string | null

    Convert an item to a string

    stringifyItems: (items: T[], separator?: string) => string

    Convert an array of items to a string

    stringifyMany: (value: string[], separator?: string) => string

    Convert an array of items to a string

    toJSON: () => { first: string | null; last: string | null; size: number }

    Convert the collection to a JSON object

    toString: () => string

    Convert the collection to a string

    update: (value: string, item: T) => ListCollection<T>

    Update an item in the collection

    upsert: (
        value: string,
        item: T,
        mode?: "append" | "prepend",
    ) => ListCollection<T>

    Update an item in the collection if it exists, otherwise append it

    Accessors

    • get firstValue(): string | null

      Returns the first value in the collection

      Returns string | null

    • get lastValue(): string | null

      Returns the last value in the collection

      Returns string | null

    • get size(): number

      Returns the number of items in the collection

      Returns number

    Methods

    • Returns Generator<T, void, unknown>