Returns an immutable wrapper around an array, initially unsorted. Sorts data and passes to wrapSorted.

  • Type Parameters

    • T

    Parameters

    • unsortedData: T[]
    • comparer: Comparer<T> = defaultComparer

    Returns {
        at: ((offset: number) => undefined | T);
        indexOf: ((sought: T, start?: number, end?: number) => number);
        insert: ((toInsert: T) => { indexOf: (sought: T, start?: number, end?: number) => number; insertionIndex: (toInsert: T) => number; insert: (toInsert: T) => ...; remove: (toRemove: T) => ...; at: (offset: number) => T | undefined; readonly length: number; readonly data: T[]; toArray: () => T[]; });
        insertionIndex: ((toInsert: T) => number);
        remove: ((toRemove: T) => { indexOf: (sought: T, start?: number, end?: number) => number; insertionIndex: (toInsert: T) => number; insert: (toInsert: T) => ...; remove: (toRemove: T) => ...; at: (offset: number) => T | undefined; readonly length: number; readonly data: T[]; toArray: () => T[]; });
        toArray: (() => T[]);
        get data(): T[];
        get length(): number;
    }

    • at: ((offset: number) => undefined | T)

      Gets item at a specified offset

        • (offset): undefined | T
        • Parameters

          • offset: number

          Returns undefined | T

    • indexOf: ((sought: T, start?: number, end?: number) => number)

      Returns index of an item, or -1 if not found

        • (sought, start?, end?): number
        • Parameters

          • sought: T

            Item to find

          • start: number = 0
          • end: number = store.length

          Returns number

    • insert: ((toInsert: T) => { indexOf: (sought: T, start?: number, end?: number) => number; insertionIndex: (toInsert: T) => number; insert: (toInsert: T) => ...; remove: (toRemove: T) => ...; at: (offset: number) => T | undefined; readonly length: number; readonly data: T[]; toArray: () => T[]; })

      Inserts an item, returning a new wrapper

        • (toInsert): { indexOf: (sought: T, start?: number, end?: number) => number; insertionIndex: (toInsert: T) => number; insert: (toInsert: T) => ...; remove: (toRemove: T) => ...; at: (offset: number) => T | undefined; readonly length: number; readonly data: T[]; toArray: () => T[]; }
        • Parameters

          • toInsert: T

          Returns { indexOf: (sought: T, start?: number, end?: number) => number; insertionIndex: (toInsert: T) => number; insert: (toInsert: T) => ...; remove: (toRemove: T) => ...; at: (offset: number) => T | undefined; readonly length: number; readonly data: T[]; toArray: () => T[]; }

    • insertionIndex: ((toInsert: T) => number)
        • (toInsert): number
        • Parameters

          • toInsert: T

          Returns number

    • remove: ((toRemove: T) => { indexOf: (sought: T, start?: number, end?: number) => number; insertionIndex: (toInsert: T) => number; insert: (toInsert: T) => ...; remove: (toRemove: T) => ...; at: (offset: number) => T | undefined; readonly length: number; readonly data: T[]; toArray: () => T[]; })

      Removes an item, returning a new wrapper

        • (toRemove): { indexOf: (sought: T, start?: number, end?: number) => number; insertionIndex: (toInsert: T) => number; insert: (toInsert: T) => ...; remove: (toRemove: T) => ...; at: (offset: number) => T | undefined; readonly length: number; readonly data: T[]; toArray: () => T[]; }
        • Parameters

          • toRemove: T

          Returns { indexOf: (sought: T, start?: number, end?: number) => number; insertionIndex: (toInsert: T) => number; insert: (toInsert: T) => ...; remove: (toRemove: T) => ...; at: (offset: number) => T | undefined; readonly length: number; readonly data: T[]; toArray: () => T[]; }

    • toArray: (() => T[])

      Returns a copy of data which is safe to modify.

        • (): T[]
        • Returns T[]

    • get data(): T[]

      Gets underlying data. Be careful not to mutate. Use toArray to get a copy that can be modified.

    • get length(): number

      Gets length