'use babel'

/* @flow */

import {CompositeDisposable} from 'atom'

export class Connections {
  subscriptions: CompositeDisposable;

  constructor() {
    this.subscriptions = new CompositeDisposable()
  }
  add(path: string) {

  }
  remove(path: string) {

  }
  dispose() {
    this.subscriptions.dispose()
  }
}

@@ -64,218 +64,905 @@
 om'%0A
-%0Aexport class Connections %7B%0A  subscriptions: CompositeDisposable;%0A%0A  constructor() %7B%0A    this.subscriptions = new CompositeDisposable()%0A  %7D%0A  add(path: string) %7B%0A%0A  %7D%0A  remove(path: string) %7B%0A%0A  %7D%0A  dispose() %7B
+import %7BConnection%7D from './connection'%0A%0Aexport class Connections %7B%0A  queue: Promise;%0A  connections: Map%3Cstring, Connection%3E;%0A  subscriptions: CompositeDisposable;%0A%0A  constructor() %7B%0A    this.queue = Promise.resolve()%0A    this.connections = new Map()%0A    this.subscriptions = new CompositeDisposable()%0A  %7D%0A  add(path: string) %7B%0A    this.queue = this.queue.then(async () =%3E %7B%0A      const connection = await Connection.create(path)%0A      if (connection) %7B%0A        this.connections.set(path, connection)%0A      %7D%0A    %7D)%0A  %7D%0A  remove(path: string) %7B%0A    this.queue = this.queue.then(() =%3E %7B%0A      this.connections.delete(path)%0A    %7D)%0A  %7D%0A  getByFilePath(path: string): ?Connection %7B%0A    for (const connection of this.connections.values()) %7B%0A      if (path.indexOf(connection.getDirectory()) === 0) %7B%0A        return connection%0A      %7D%0A    %7D%0A    return null%0A  %7D%0A  dispose() %7B%0A    this.connections.clear()
 %0A   

Implement a complete connections class