uft
    Preparing search index...

    Function filteredForEach

    • Applies a filter function to the elements of the given array, and then calls a forEach function with each of the filtered elements.

      Type Parameters

      • T extends readonly unknown[]
      • S extends unknown

      Parameters

      • array: T

        The array to iterate over.

      • filter: (element: T[number], index: number) => element is S

        A function that determines whether an element should be included.

      • forEach: (element: S, index: number) => void

        A function to call for each included element.

      Returns void

      filteredForEach(
      [1, 2, 3, 4, 5],
      (value) => value > 3,
      (value) => console.log(value ** 2)
      ) // Prints: 16, 25
      import { isString } from 'uft'

      filteredForEach(
      ['foo', { a: 1 }, [], 'bar'],
      isString,
      (value) => {
      value // type: string
      console.log(value.toUpperCase())
      }
      ) // Prints: FOO, BAR
    • Applies a filter function to the elements of the given array, and then calls a forEach function with each of the filtered elements.

      Type Parameters

      • T extends readonly unknown[]
      • S

      Parameters

      • array: T

        The array to iterate over.

      • filter: (element: T[number], index: number) => element is S

        A function that determines whether an element should be included.

      • forEach: (element: AssignableTo<T[number], S>, index: number) => void

        A function to call for each included element.

      Returns void

      filteredForEach(
      [1, 2, 3, 4, 5],
      (value) => value > 3,
      (value) => console.log(value ** 2)
      ) // Prints: 16, 25
      import { isString } from 'uft'

      filteredForEach(
      ['foo', { a: 1 }, [], 'bar'],
      isString,
      (value) => {
      value // type: string
      console.log(value.toUpperCase())
      }
      ) // Prints: FOO, BAR
    • Applies a filter function to the elements of the given array, and then calls a forEach function with each of the filtered elements.

      Type Parameters

      • T extends readonly unknown[]

      Parameters

      • array: T

        The array to iterate over.

      • filter: (element: T[number], index: number) => boolean

        A function that determines whether an element should be included.

      • forEach: (element: T[number], index: number) => void

        A function to call for each included element.

      Returns void

      filteredForEach(
      [1, 2, 3, 4, 5],
      (value) => value > 3,
      (value) => console.log(value ** 2)
      ) // Prints: 16, 25
      import { isString } from 'uft'

      filteredForEach(
      ['foo', { a: 1 }, [], 'bar'],
      isString,
      (value) => {
      value // type: string
      console.log(value.toUpperCase())
      }
      ) // Prints: FOO, BAR