title: Async transactions in javascript
body: <p>First of all rollback is something that I do not care about.</p>
  
  <p>I would like to be able to lock a sequence of async functions/promises/tasks (let's call it a "transaction") with a name/id (or array of names), so that they happen in sequence, and so that any other "transaction" with the same name(s) that are run by another part of the system are delayed from starting until the running transaction using the same name(s) has completed.  So it basically is queueing the sequences of async tasks, or "transaction"s.</p>
  
  <p>Here is some example code of the situation:</p>
  
  <pre><code>function a()
  {
    // do stuff
    return new Promise(/*...*/);
  }
  
  
  function b()
  {
    // do stuff
    return new Promise(/*...*/);
  }
  
  
  
  function c()
  {
    // do stuff
    return a.then(() =&gt; b());
  }
  </code></pre>
  
  <p>Now at any time the system could call <code>a</code>, <code>b</code>, or <code>c</code>, and when it does I don't want <code>c</code> and <code>b</code> running at the same time, but obvious <code>c</code> depends on <code>b</code>.</p>
  
  <p>I've been looking for a package on npm to help with this but I haven't found anything, I wonder if anyone can suggest something that I might have missed that would help with this?</p>