Remove last external use of unorderedRemoveFirstItemWhere

This commit is contained in:
Andy Hanson 2016-08-22 06:30:41 -07:00
parent d6aa65daf1
commit e3a1a98113
2 changed files with 4 additions and 3 deletions

View File

@ -1415,7 +1415,7 @@ namespace ts {
}
/** Remove the *first* element satisfying `predicate`. */
export function unorderedRemoveFirstItemWhere<T>(array: T[], predicate: (element: T) => boolean): void {
function unorderedRemoveFirstItemWhere<T>(array: T[], predicate: (element: T) => boolean): void {
for (let i = 0; i < array.length; i++) {
if (predicate(array[i])) {
unorderedRemoveItemAt(array, i);

View File

@ -209,12 +209,13 @@ namespace ts {
watchDirectory(directoryName: string, callback: DirectoryWatcherCallback, recursive: boolean): DirectoryWatcher {
const path = this.toPath(directoryName);
const callbacks = lookUp(this.watchedDirectories, path) || (this.watchedDirectories[path] = []);
callbacks.push({ cb: callback, recursive });
const cbWithRecursive = { cb: callback, recursive };
callbacks.push(cbWithRecursive);
return {
referenceCount: 0,
directoryName,
close: () => {
unorderedRemoveFirstItemWhere(callbacks, cb => cb.cb === callback);
unorderedRemoveItem(cbWithRecursive, callbacks);
if (!callbacks.length) {
delete this.watchedDirectories[path];
}