title: How to enumerate a sync observable?
body: <p>For example, if you have an observable <code>from(['a', 'b'])</code>, how to get an observable that emits <code>[0, 'a']</code> and <code>[1, 'b']</code>?</p>
  
  <p>I have tried <code>from('a', 'b').pipe(zip(range(0, Number.POSITIVE_INFINITY)))</code>, but this creates an infinite loop: if you try <code>Rx.Observable.from(['a', 'b']).zip(Rx.Observable.range(0, Number.POSITIVE_INFINITY)).do(console.log).subscribe()</code> in the console (tip: the page <a href="http://reactivex.io/rxjs/manual/overview.html" rel="nofollow noreferrer">http://reactivex.io/rxjs/manual/overview.html</a> has Rx already imported), this will cause the page to hang (the <code>range</code> is pushing values indefinitely). In my context (working with IndexedDB) I can't use an async scheduler, and anyway it won't make sense from the point of view of performance.</p>
  
  <p>I worked around this by creating a custom operator</p>
  
  <pre><code>import { Observable } from 'rxjs/Observable';
  import { map } from 'rxjs/operators';
  
  export const enumerate = &lt;T&gt;(source: Observable&lt;T&gt;) =&gt; {
    let index = 0;
    return source.pipe(map(source =&gt; ({ value: source, index: index++ })));
  };
  </code></pre>
  
  <p>but am I missing a simpler solution? It's just strange that RxJS has this gotcha in it...</p>