Repository: node
Issue: When using `glob` can't exclude all directs
Labels: fs

### Version

v23.4.0

### Platform

```text
Microsoft Windows NT 10.0.22631.0 x64
```


### Subsystem

_No response_

### What steps will reproduce the bug?

1. Create a folder and open it in your code editor (we use this as current working directory).
2. Make/create the files/folders shown below:
   
   ```
   src
   src\a
   src\a\b
   src\a\c
   src\index.ts
   src\zip.ts
   ```

4. Run the code below:

   ```js
   console.log(
       fs.globSync("src/**", {
           withFileTypes: true,
           cwd: process.cwd(),
           exclude: (dirent) => {
               console.log(dirent)
           },
       }),
   )
   ```

### How often does it reproduce? Is there a required condition?

.

### What is the expected behavior? Why is that the expected behavior?

I expect the `exclude` function to receive all the output directs, so that they can be excluded. (See "Additional information" part).

Even with just returning `true` in `exclude` function, you can exclude `DirentFromStats` from the result.

### What do you see instead?

The first direct from output is missing in exclude. (See "Additional information" part).

### Additional information



Exclude:

```js
Dirent {
  name: 'a',
  parentPath: 'C:\\Users\\Babak\\Documents\\Code\\tosk\\src',
  path: 'C:\\Users\\Babak\\Documents\\Code\\tosk\\src',
  [Symbol(type)]: 2
}
Dirent {
  name: 'index.ts',
  parentPath: 'C:\\Users\\Babak\\Documents\\Code\\tosk\\src',
  path: 'C:\\Users\\Babak\\Documents\\Code\\tosk\\src',
  [Symbol(type)]: 1
}
Dirent {
  name: 'zip.ts',
  parentPath: 'C:\\Users\\Babak\\Documents\\Code\\tosk\\src',
  path: 'C:\\Users\\Babak\\Documents\\Code\\tosk\\src',
  [Symbol(type)]: 1
}
Dirent {
  name: 'b',
  parentPath: 'C:\\Users\\Babak\\Documents\\Code\\tosk\\src\\a',
  path: 'C:\\Users\\Babak\\Documents\\Code\\tosk\\src\\a',
  [Symbol(type)]: 2
}
Dirent {
  name: 'c',
  parentPath: 'C:\\Users\\Babak\\Documents\\Code\\tosk\\src\\a',
  path: 'C:\\Users\\Babak\\Documents\\Code\\tosk\\src\\a',
  [Symbol(type)]: 2
}
```

Output:

```js
[
  DirentFromStats {
    name: 'src',
    parentPath: 'C:\\Users\\Babak\\Documents\\Code\\tosk',
    path: 'C:\\Users\\Babak\\Documents\\Code\\tosk',
    [Symbol(type)]: null,
    [Symbol(stats)]: Stats {
      dev: 1247631908,
      mode: 16822,
      nlink: 1,
      uid: 0,
      gid: 0,
      rdev: 0,
      blksize: 4096,
      ino: 1970324837878618,
      size: 0,
      blocks: 0,
      atimeMs: 1734234059936.9617,
      mtimeMs: 1734231659493.8164,
      ctimeMs: 1734231659493.8164,
      birthtimeMs: 1734197097735.2148
    }
  },
  Dirent {
    name: 'index.ts',
    parentPath: 'C:\\Users\\Babak\\Documents\\Code\\tosk\\src',
    path: 'C:\\Users\\Babak\\Documents\\Code\\tosk\\src',
    [Symbol(type)]: 1
  },
  Dirent {
    name: 'zip.ts',
    parentPath: 'C:\\Users\\Babak\\Documents\\Code\\tosk\\src',
    path: 'C:\\Users\\Babak\\Documents\\Code\\tosk\\src',
    [Symbol(type)]: 1
  },
  Dirent {
    name: 'a',
    parentPath: 'C:\\Users\\Babak\\Documents\\Code\\tosk\\src',
    path: 'C:\\Users\\Babak\\Documents\\Code\\tosk\\src',
    [Symbol(type)]: 2
  },
  Dirent {
    name: 'c',
    parentPath: 'C:\\Users\\Babak\\Documents\\Code\\tosk\\src\\a',
    path: 'C:\\Users\\Babak\\Documents\\Code\\tosk\\src\\a',
    [Symbol(type)]: 2
  },
  Dirent {
    name: 'b',
    parentPath: 'C:\\Users\\Babak\\Documents\\Code\\tosk\\src\\a',
    path: 'C:\\Users\\Babak\\Documents\\Code\\tosk\\src\\a',
    [Symbol(type)]: 2
  }
]
```