# HG changeset patch # User Lucas Thompson # Date 1499110429 -3600 # Node ID 5f3e1b275e180856b49c6e49201e6122467e13e6 # Parent ae96db60f25c4684a7145c739a68cb9f925d5bf6 Poorly named method for slightly reducing code duplication (performing some option if index found) diff -r ae96db60f25c -r 5f3e1b275e18 src/app/Session.ts --- a/src/app/Session.ts Mon Jul 03 20:32:51 2017 +0100 +++ b/src/app/Session.ts Mon Jul 03 20:33:49 2017 +0100 @@ -101,6 +101,18 @@ return this.stack.findIndex(predicate); } + findIndexAndUse(predicate: (value: T, + index: number, + array: T[]) => boolean, + use: (index: number) => void): boolean { + const index = this.stack.findIndex(predicate); + const didFind = index !== -1; + if (didFind) { + use(index); + } + return didFind; + } + filter(predicate: (value: T, index: number, array: T[]) => boolean): T[] { return this.stack.filter(predicate); }