@mirei/ts-collections
    Preparing search index...

    Function none

    • Determines whether the sequence contains no elements that satisfy the optional predicate.

      Type Parameters

      • TElement

        Type of elements within the source iterable.

      Parameters

      • source: Iterable<TElement>

        The source iterable.

      • Optionalpredicate: Predicate<TElement>

        Optional predicate evaluated against each element. When omitted, the function returns true if the sequence is empty.

      Returns boolean

      true when no element satisfies the predicate (or when the sequence is empty and no predicate is provided); otherwise, false.

      This is more efficient than negating any with a predicate because iteration stops as soon as a matching element is found.

      const numbers = [1, 3, 5];
      const noEvens = none(numbers, x => x % 2 === 0);
      console.log(noEvens); // true

      const mixedNumbers = [1, 2, 3, 5];
      const noEvens2 = none(mixedNumbers, x => x % 2 === 0);
      console.log(noEvens2); // false