bitbybit.dev v1.0.0-rc.1
    Preparing search index...

    Class Lists

    Index

    Constructors

    add

    • Inserts an item at a specific position in the list. Example: In [10, 20, 30, 40], adding 99 at index 2 gives [10, 20, 99, 30, 40]

      Type Parameters

      • T

      Parameters

      Returns T[]

      list with added item

      add item

      false

    • Inserts the same item at multiple specified positions in the list. Example: In [10, 20, 30], adding 99 at indexes [0, 2] gives [99, 10, 20, 99, 30]

      Type Parameters

      • T

      Parameters

      Returns T[]

      list with added item

      add item at indexes

      false

    • Inserts multiple items at corresponding positions (first item at first index, second item at second index, etc.). Example: In [10, 20, 30], adding items [88, 99] at indexes [1, 2] gives [10, 88, 20, 99, 30]

      Type Parameters

      • T

      Parameters

      Returns T[]

      list with added items

      add items

      false

    • Appends an item to the end of the list. Example: To [10, 20, 30], adding 40 gives [10, 20, 30, 40]

      Type Parameters

      • T

      Parameters

      Returns T[]

      list with added item

      add item to list

      false

    • Adds an item to the beginning of the list. Example: To [10, 20, 30], prepending 5 gives [5, 10, 20, 30]

      Type Parameters

      • T

      Parameters

      Returns T[]

      list with added item

      prepend item to list

      false

    • Adds an item either at the beginning or end of the list based on the position parameter. Example: To [10, 20, 30], adding 5 at 'first' gives [5, 10, 20, 30], at 'last' gives [10, 20, 30, 5]

      Type Parameters

      • T

      Parameters

      Returns T[]

      list with added item

      item at first or last

      false

    • Combines multiple lists into a single list by joining them end-to-end. Example: From [[1, 2], [3, 4], [5, 6]], returns [1, 2, 3, 4, 5, 6]

      Type Parameters

      • T

      Parameters

      Returns T[]

      concatenated list

      concatenate lists

      false

    create

    • Creates a new empty list with no items. Example: Returns []

      Returns []

      an empty array list

      empty list

      false

    • Creates a new list by repeating an item a specified number of times. Example: Repeating 5 three times returns [5, 5, 5]

      Type Parameters

      • T

      Parameters

      Returns T[]

      list

      repeat

      false

    • Repeats a pattern of items cyclically until reaching a target list length. Example: Pattern [1, 2, 3] with length 7 returns [1, 2, 3, 1, 2, 3, 1]

      Type Parameters

      • T

      Parameters

      Returns T[]

      list

      repeat in pattern

      false

    edit

    • Reverses the order of items in the list. Example: From [1, 2, 3, 4, 5], returns [5, 4, 3, 2, 1]

      Type Parameters

      • T

      Parameters

      Returns T[]

      item

      reverse

      false

    • Randomly rearranges all items in the list (using Fisher-Yates algorithm). Example: From [1, 2, 3, 4, 5], might return [3, 1, 5, 2, 4] (order varies each time)

      Type Parameters

      • T

      Parameters

      Returns T[]

      shuffled list

      shuffle

      false

    • Transposes a 2D list by swapping rows and columns (all sublists must be equal length). Example: From [[0, 1, 2], [3, 4, 5]], returns [[0, 3], [1, 4], [2, 5]]

      Type Parameters

      • T

      Parameters

      Returns T[][]

      item

      flip lists

      false

    • Splits the list into smaller lists of n elements each. Example: From [0, 1, 2, 3, 4, 5, 6, 7, 8] with n=3, returns [[0, 1, 2], [3, 4, 5], [6, 7, 8]] Example: From [0, 1, 2, 3, 4] with n=2 and keepRemainder=true, returns [[0, 1], [2, 3], [4]]

      Type Parameters

      • T

      Parameters

      Returns T[][]

      items grouped in lists of n elements

      group elements

      false

    get

    • Gets an item from the list at a specific position using zero-based indexing. Example: From [10, 20, 30, 40], getting index 2 returns 30

      Type Parameters

      • T

      Parameters

      Returns T

      item

      item by index

      false

    • Gets the first item from the list. Example: From [10, 20, 30, 40], returns 10

      Type Parameters

      • T

      Parameters

      Returns T

      first item

      first item

      false

    • Gets the last item from the list. Example: From [10, 20, 30, 40], returns 40

      Type Parameters

      • T

      Parameters

      Returns T

      last item

      last item

      false

    • Randomly keeps items from the list based on a probability threshold (0 to 1). Example: From [1, 2, 3, 4, 5] with threshold 0.5, might return [1, 3, 5] (50% chance for each item)

      Type Parameters

      • T

      Parameters

      Returns T[]

      list with remaining items

      random get threshold

      false

    • Extracts a portion of the list between start and end positions (end is exclusive). Example: From [10, 20, 30, 40, 50] with start=1 and end=4, returns [20, 30, 40]

      Type Parameters

      • T

      Parameters

      Returns T[]

      sub list

      sublist

      false

    • Gets every nth item from the list, starting from an optional offset position. Example: From [0, 1, 2, 3, 4, 5, 6, 7, 8] with nth=3 and offset=0, returns [0, 3, 6] Example: From [0, 1, 2, 3, 4, 5, 6, 7, 8] with nth=2 and offset=1, returns [1, 3, 5, 7]

      Type Parameters

      • T

      Parameters

      Returns T[]

      list with filtered items

      every n-th

      false

    • Filters items from the list using a repeating true/false pattern. Example: From [0, 1, 2, 3, 4, 5] with pattern [true, true, false], returns [0, 1, 3, 4] (keeps items where pattern is true)

      Type Parameters

      • T

      Parameters

      Returns T[]

      list with filtered items

      by pattern

      false

    • Merges elements from multiple lists at a specific nesting level, grouping elements by position. Example: From [[0, 1, 2], [3, 4, 5]] at level 0, returns [[0, 3], [1, 4], [2, 5]]

      Type Parameters

      • T

      Parameters

      Returns T[]

      list with merged lists and flattened lists

      merge levels

      false

    • Finds the length of the longest list among multiple lists. Example: From [[1, 2], [3, 4, 5, 6], [7]], returns 4 (length of [3, 4, 5, 6])

      Type Parameters

      • T

      Parameters

      Returns number

      number of max length

      longest list length

      false

    • Checks whether the list contains a specific item. Example: List [10, 20, 30, 40] with item 30 returns true, with item 50 returns false

      Type Parameters

      • T

      Parameters

      Returns boolean

      true if item is in list

      contains item

      false

    • Finds the position (index) of the first occurrence of an item in the list. Example: In [10, 20, 30, 20, 40], finding 20 returns 1 (first occurrence), finding 50 returns -1 (not found)

      Type Parameters

      • T

      Parameters

      Returns number

      index of the item or -1 if not found

      find index

      false

    • Determines the maximum nesting level (depth) of a list structure. Example: [1, 2, 3] has depth 1, [[1, 2], [3, 4]] has depth 2, [[[1]]] has depth 3

      Parameters

      Returns number

      number of depth

      max list depth

      false

    • Returns the number of items in the list. Example: [10, 20, 30, 40, 50] returns 5, [] returns 0

      Type Parameters

      • T

      Parameters

      Returns number

      a number

      list length

      false

    remove

    • Removes the item at a specific position in the list. Example: From [10, 20, 30, 40, 50], removing index 2 gives [10, 20, 40, 50]

      Type Parameters

      • T

      Parameters

      Returns T[]

      list with removed item

      remove item

      false

    • Removes the first item from the list. Example: From [10, 20, 30, 40], returns [20, 30, 40]

      Type Parameters

      • T

      Parameters

      Returns T[]

      list with first item removed

      remove first item

      false

    • Removes the last item from the list. Example: From [10, 20, 30, 40], returns [10, 20, 30]

      Type Parameters

      • T

      Parameters

      Returns T[]

      list with last item removed

      remove last item

      false

    • Removes an item counting from the end of the list (index 0 = last item, 1 = second-to-last, etc.). Example: From [10, 20, 30, 40, 50], removing index 1 from end gives [10, 20, 30, 50] (removes 40)

      Type Parameters

      • T

      Parameters

      Returns T[]

      list with removed item

      remove item from end

      false

    • Removes items at multiple specified positions from the list. Example: From [10, 20, 30, 40, 50], removing indexes [1, 3] gives [10, 30, 50]

      Type Parameters

      • T

      Parameters

      Returns T[]

      list with removed items

      remove items

      false

    • Clears all items from the list, resulting in an empty list. Example: From [10, 20, 30, 40], returns []

      Type Parameters

      • T

      Parameters

      Returns T[]

      The length is set to 0 and same array memory object is returned

      remove all items

      false

    • Removes every nth item from the list, starting from an optional offset position. Example: From [0, 1, 2, 3, 4, 5, 6, 7, 8] with nth=3 and offset=0, returns [1, 2, 4, 5, 7, 8] (removes 0, 3, 6)

      Type Parameters

      • T

      Parameters

      Returns T[]

      list with removed item

      every n-th

      false

    • Randomly removes items from the list based on a probability threshold (0 to 1). Example: From [1, 2, 3, 4, 5] with threshold 0.5, might return [2, 4] (50% chance to remove each item)

      Type Parameters

      • T

      Parameters

      Returns T[]

      list with removed items

      random remove threshold

      false

    • Removes duplicate numbers from the list, keeping only the first occurrence of each value. Example: From [1, 2, 3, 2, 4, 3, 5], returns [1, 2, 3, 4, 5]

      Parameters

      Returns number[]

      list with unique numbers

      remove duplicate numbers

      false

    • Removes duplicate numbers that are within a specified tolerance range of each other. Example: From [1.0, 1.001, 2.0, 2.002, 3.0] with tolerance 0.01, returns [1.0, 2.0, 3.0]

      Parameters

      Returns number[]

      list with unique numbers

      remove duplicates tol

      false

    • Removes duplicate items from the list using strict equality comparison (works with any type). Example: From ['a', 'b', 'c', 'a', 'd', 'b'], returns ['a', 'b', 'c', 'd']

      Type Parameters

      • T

      Parameters

      Returns T[]

      list with unique items

      remove duplicates

      false

    sorting

    • Sorts numbers in ascending (lowest to highest) or descending (highest to lowest) order. Example: [5, 2, 8, 1, 9] ascending returns [1, 2, 5, 8, 9], descending returns [9, 8, 5, 2, 1]

      Parameters

      • inputs: SortDto<number>

        a list of numbers to sort and an option for ascending or descending order

      Returns number[]

      list

      sort numbers

      false

    • Sorts text strings alphabetically in ascending (A to Z) or descending (Z to A) order. Example: ['dog', 'apple', 'cat', 'banana'] ascending returns ['apple', 'banana', 'cat', 'dog']

      Parameters

      • inputs: SortDto<string>

        a list of texts to sort and an option for ascending or descending order

      Returns string[]

      list

      sort texts

      false

    • Sorts objects by comparing numeric values of a specified property. Example: [{age: 30}, {age: 20}, {age: 25}] sorted by 'age' ascending returns [{age: 20}, {age: 25}, {age: 30}]

      Parameters

      • inputs: SortJsonDto<any>

        a list to sort, a property to sort by and an option for ascending or descending order

      Returns any[]

      list

      sort json objects

      false

    transform

    • Combines multiple lists by alternating elements from each list (first from list1, first from list2, second from list1, etc.). Example: From [[0, 1, 2], [3, 4, 5]], returns [0, 3, 1, 4, 2, 5]

      Type Parameters

      • T

      Parameters

      Returns T[]

      Flattened interleaved list

      interleave lists

      false