@mikuroxina/mini-fn
    Preparing search index...

    Function findIndex

    • Finds the position of element which satisfies pred in the list. If the list is infinite and the element is not found, this will hang forever.

      Type Parameters

      • T

      Parameters

      • pred: (value: T) => boolean

        The match condition of element to find.

      Returns (list: List.List<T>) => Option.Option<number>

      The found position if exists.

      Examples

      const list = fromArray([1, 4, 2, 3, 5]);

      expect(findIndex((x: number) => 4 <= x)(list)).toStrictEqual(Option.some(1));
      expect(findIndex((x: number) => 0 <= x)(list)).toStrictEqual(Option.some(0));
      expect(findIndex((x: number) => 8 <= x)(list)).toStrictEqual(Option.none());