test: replace .filter()[0] with .find()

PR-URL: https://github.com/nodejs/node/pull/58872
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
This commit is contained in:
Livia Medeiros 2025-06-30 02:58:29 +08:00 committed by GitHub
parent 0b88e0927f
commit f6a4305d16
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 3 additions and 3 deletions

View File

@ -16,7 +16,7 @@ tmpdir.refresh();
spawnSync(process.execPath, [ '--prof', '-p', '42' ], { cwd: tmpdir.path }); spawnSync(process.execPath, [ '--prof', '-p', '42' ], { cwd: tmpdir.path });
const files = fs.readdirSync(tmpdir.path); const files = fs.readdirSync(tmpdir.path);
const logfile = files.filter((name) => /\.log$/.test(name))[0]; const logfile = files.find((name) => /\.log$/.test(name));
assert(logfile); assert(logfile);
// Make sure that the --preprocess argument is passed through correctly, // Make sure that the --preprocess argument is passed through correctly,

View File

@ -13,7 +13,7 @@ const { once } = require('events');
assert.strictEqual(fh.constructor.name, 'FileHandle'); assert.strictEqual(fh.constructor.name, 'FileHandle');
const kTransfer = Object.getOwnPropertySymbols(Object.getPrototypeOf(fh)) const kTransfer = Object.getOwnPropertySymbols(Object.getPrototypeOf(fh))
.filter((symbol) => symbol.description === 'messaging_transfer_symbol')[0]; .find((symbol) => symbol.description === 'messaging_transfer_symbol');
assert.strictEqual(typeof kTransfer, 'symbol'); assert.strictEqual(typeof kTransfer, 'symbol');
fh[kTransfer] = () => { fh[kTransfer] = () => {
return { return {

View File

@ -17,7 +17,7 @@ module.exports = {
assert.strictEqual(fh.constructor.name, 'FileHandle'); assert.strictEqual(fh.constructor.name, 'FileHandle');
const kTransfer = Object.getOwnPropertySymbols(Object.getPrototypeOf(fh)) const kTransfer = Object.getOwnPropertySymbols(Object.getPrototypeOf(fh))
.filter((symbol) => symbol.description === 'messaging_transfer_symbol')[0]; .find((symbol) => symbol.description === 'messaging_transfer_symbol');
assert.strictEqual(typeof kTransfer, 'symbol'); assert.strictEqual(typeof kTransfer, 'symbol');
fh[kTransfer] = () => { fh[kTransfer] = () => {
return { return {