Skip to content

Commit 3f9db08

Browse files
Use some() instead of find() where possible
1 parent 5ef9d63 commit 3f9db08

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/emitter.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -296,7 +296,7 @@ export function emitWebIdl(webidl: Browser.WebIdl, flavor: Flavor, iterator: boo
296296
}
297297
else {
298298
const types = obj.type.map(convertDomTypeToTsTypeWorker);
299-
const isAny = types.find(t => t.name === "any");
299+
const isAny = types.some(t => t.name === "any");
300300
if (isAny) {
301301
type = {
302302
name: "any",
@@ -306,7 +306,7 @@ export function emitWebIdl(webidl: Browser.WebIdl, flavor: Flavor, iterator: boo
306306
else {
307307
type = {
308308
name: types.map(t => t.name).join(" | "),
309-
nullable: !!types.find(t => t.nullable) || !!obj.nullable
309+
nullable: types.some(t => t.nullable) || !!obj.nullable
310310
};
311311
}
312312
}
@@ -590,9 +590,9 @@ export function emitWebIdl(webidl: Browser.WebIdl, flavor: Flavor, iterator: boo
590590
function isCovariantEventHandler(i: Browser.Interface, p: Browser.Property) {
591591
return isEventHandler(p) &&
592592
iNameToEhParents[i.name] && iNameToEhParents[i.name].length > 0 &&
593-
!!iNameToEhParents[i.name].find(
593+
iNameToEhParents[i.name].some(
594594
i => iNameToEhList[i.name] && iNameToEhList[i.name].length > 0 &&
595-
!!iNameToEhList[i.name].find(e => e.name === p.name));
595+
iNameToEhList[i.name].some(e => e.name === p.name));
596596
}
597597

598598
function emitProperty(prefix: string, i: Browser.Interface, emitScope: EmitScope, p: Browser.Property) {
@@ -990,8 +990,8 @@ export function emitWebIdl(webidl: Browser.WebIdl, flavor: Flavor, iterator: boo
990990
// Some types are static types with non-static members. For example,
991991
// NodeFilter is a static method itself, however it has an "acceptNode" method
992992
// that expects the user to implement.
993-
const hasNonStaticMethod = i.methods && !!mapToArray(i.methods.method).find(m => !m.static);
994-
const hasProperty = i.properties && mapToArray(i.properties.property).find(p => !p.static);
993+
const hasNonStaticMethod = i.methods && mapToArray(i.methods.method).some(m => !m.static);
994+
const hasProperty = i.properties && mapToArray(i.properties.property).some(p => !p.static);
995995
const hasNonStaticMember = hasNonStaticMethod || hasProperty;
996996

997997
// For static types with non-static members, we put the non-static members into an

0 commit comments

Comments
 (0)