From 951974dff61c9c70d817dba50f7bc777a97409ba Mon Sep 17 00:00:00 2001 From: Andy Date: Tue, 19 Sep 2017 08:27:31 -0700 Subject: [PATCH] Use `find` array helper (#18557) * Use `find` array helper * Provide explicit type argument to `find` --- src/services/refactors/extractMethod.ts | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/src/services/refactors/extractMethod.ts b/src/services/refactors/extractMethod.ts index 3b8ea19a9f0..8e97b145aac 100644 --- a/src/services/refactors/extractMethod.ts +++ b/src/services/refactors/extractMethod.ts @@ -934,12 +934,8 @@ namespace ts.refactor.extractMethod { * Otherwise, return `undefined`. */ function getNodeToInsertBefore(minPos: number, scope: Scope): Node | undefined { - const children = getStatementsOrClassElements(scope); - for (const child of children) { - if (child.pos >= minPos && isFunctionLike(child) && !isConstructorDeclaration(child)) { - return child; - } - } + return find(getStatementsOrClassElements(scope), child => + child.pos >= minPos && isFunctionLike(child) && !isConstructorDeclaration(child)); } function getPropertyAssignmentsForWrites(writes: ReadonlyArray): ShorthandPropertyAssignment[] {