[ create a new paste ] login | about

Link: http://codepad.org/AxbDIAtW    [ raw code | fork ]

aaronla - Plain Text, pasted on Oct 21:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
// async iteration in JavaScript?

function SelectAsync(asyncGenerator, asyncProjection) {
  return function(cancellationToken) {
    return spawnSequence(function*(Yielder){
      foreach (asyncItem in asyncGenerator(cancellationToken)) {
        var item = yield asyncItem;
        var result = yield asyncProjection(item, cancellationToken);
        yield Yielder.Result(result);
      }
      yield Yielder.Return();
    }
  }
}
    


Create a new paste based on this one


Comments: