Skip to content

Commit

Permalink
Use filterMutate instead of removeWhere
Browse files Browse the repository at this point in the history
  • Loading branch information
sheetalkamat committed Oct 11, 2017
1 parent c4298a3 commit c5b4f5e
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/harness/unittests/telemetry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,11 +257,12 @@ namespace ts.projectSystem {

getEventsWithName<T extends server.ProjectServiceEvent>(eventName: T["eventName"]): ReadonlyArray<T> {
let events: T[];
removeWhere(this.events, event => {
filterMutate(this.events, event => {
if (event.eventName === eventName) {
(events || (events = [])).push(event as T);
return true;
return false;
}
return true;
});
return events || emptyArray;
}
Expand Down Expand Up @@ -291,14 +292,15 @@ namespace ts.projectSystem {

getEvent<T extends server.ProjectServiceEvent>(eventName: T["eventName"]): T["data"] {
let event: server.ProjectServiceEvent;
removeWhere(this.events, e => {
filterMutate(this.events, e => {
if (e.eventName === eventName) {
if (event) {
assert(false, "more than one event found");
}
event = e;
return true;
return false;
}
return true;
});
assert.equal(event.eventName, eventName);
return event.data;
Expand Down

0 comments on commit c5b4f5e

Please sign in to comment.