comparison src/app/Session.ts @ 485:5f3e1b275e18

Poorly named method for slightly reducing code duplication (performing some option if index found)
author Lucas Thompson <dev@lucas.im>
date Mon, 03 Jul 2017 20:33:49 +0100
parents 2fb2357420f9
children 7ac80ad913c1
comparison
equal deleted inserted replaced
484:ae96db60f25c 485:5f3e1b275e18
99 index: number, 99 index: number,
100 array: T[]) => boolean): number { 100 array: T[]) => boolean): number {
101 return this.stack.findIndex(predicate); 101 return this.stack.findIndex(predicate);
102 } 102 }
103 103
104 findIndexAndUse(predicate: (value: T,
105 index: number,
106 array: T[]) => boolean,
107 use: (index: number) => void): boolean {
108 const index = this.stack.findIndex(predicate);
109 const didFind = index !== -1;
110 if (didFind) {
111 use(index);
112 }
113 return didFind;
114 }
115
104 filter(predicate: (value: T, index: number, array: T[]) => boolean): T[] { 116 filter(predicate: (value: T, index: number, array: T[]) => boolean): T[] {
105 return this.stack.filter(predicate); 117 return this.stack.filter(predicate);
106 } 118 }
107 119
108 get(index: number): T { 120 get(index: number): T {