@studiokeywi/banjo - v0.0.1
    Preparing search index...

    Interface RingArray<Type>

    Wrapper of the base array type in JavaScript to provide cyclic-based interactions

    interface RingArray<Type> {
        get contents(): Type[];
        get index(): number;
        add(...values: Type[]): this;
        get(index: number): undefined | Type;
        insert(value: Type, idx: number): this;
        jump(index: number): this;
        next(): undefined | Type;
        remove(value: Type): this;
        removeAt(idx: number): this;
    }

    Type Parameters

    • Type
    Index

    Accessors

    • get contents(): Type[]

      Read-only view of the current contents held in the array. This is a shallow-dereference through spread syntax, so any objects contained in the array are still mutable

      Returns Type[]

    • get index(): number

      Index of the most recently returned value from the ring

      Returns number

    Methods

    • Adds a new value into the RingArray. This is similar to someArray.push(...values), but returns the RingArray for chaining.

      Parameters

      • ...values: Type[]

        The new values to append

      Returns this

      The RingArray for chaining

    • Gets the entry of the source array at the given index. Like a direct index access (eg someArray[someIndex]), will return undefined if the index is out of range.

      Parameters

      • index: number

        Location in the array to return

      Returns undefined | Type

      An entry from the source array (if the index was in range), otherwise undefined

    • Inserts a new value into the RingArray at a specified location. This is similar to someArray.splice(idx, 0, value), but returns the RingArray for chaining.

      Parameters

      • value: Type

        The new value to insert

      • idx: number

        The position in which to insert the new value

      Returns this

      The RingArray for chaining

    • Jumps the internal location of the RingArray to a new location and returns the RingArray for chaining.

      Parameters

      • index: number

        Location in the array to use next

      Returns this

      The RingArray for chaining

    • Gets the next entry of the source array, based on previous steps through the source. Initially this returns the first value (as if someArray[0]) and continues until reaching the equivalent of someArray[someArray.length - 1]. At that point, the internal location wraps back to the start of the array.

      Returns undefined | Type

      The next entry from the source array

    • Removes the specified value from the RingArray. This is similar to someArray.splice(someArray.indexOf(value), 1), but returns the RingArray for chaining.

      Parameters

      • value: Type

        The value to remove

      Returns this

      The RingArray for chaining

    • Removes the specified value from the RingArray. This is similar to someArray.splice(idx, 1), but returns the RingArray for chaining.

      Parameters

      • idx: number

        Location in the array to remove

      Returns this

      The RingArray for chaining