Logos DX
    Preparing search index...

    Function allItemsValid

    • Performs a for-of loop that breaks when the check function returns false.

      Iterates over iterable values (arrays, Sets, Maps) and stops early if the check function returns false for any value.

      Type Parameters

      Parameters

      • item: I

        iterable to iterate over (Array, Set, Map, etc.)

      • check: (v: unknown) => boolean

        function to test each value

      Returns boolean

      true if all values pass the check, false otherwise

      const numbers = [2, 4, 6, 8, 10];
      const allEven = allItemsValid(numbers, (num) => num % 2 === 0); // true

      const mixed = [2, 4, 5, 8];
      const allEven2 = allItemsValid(mixed, (num) => num % 2 === 0); // false (stops at 5)
      const userIds = new Set(['user1', 'user2', 'user3']);
      const allValidIds = allItemsValid(userIds, (id) => {
      return typeof id === 'string' && id.startsWith('user');
      }); // true
      // Check if all files exist before processing
      const files = ['config.json', 'data.csv', 'template.html'];
      const allExist = allItemsValid(files, (filename) => {
      return fs.existsSync(filename);
      });