| OLD | NEW |
| 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 /// This library adapts ES6 generators to implement Dart's async/await. | 5 /// This library adapts ES6 generators to implement Dart's async/await. |
| 6 /// It's designed to interact with Dart's Future/Stream and follow Dart | 6 /// It's designed to interact with Dart's Future/Stream and follow Dart |
| 7 /// async/await semantics. | 7 /// async/await semantics. |
| 8 /// See https://github.com/dart-lang/dev_compiler/issues/245 for ideas on | 8 /// See https://github.com/dart-lang/sdk/issues/27315 for ideas on |
| 9 /// reconciling Dart's Future and ES6 Promise. | 9 /// reconciling Dart's Future and ES6 Promise. |
| 10 /// Inspired by `co`: https://github.com/tj/co/blob/master/index.js, which is a | 10 /// Inspired by `co`: https://github.com/tj/co/blob/master/index.js, which is a |
| 11 /// stepping stone for proposed ES7 async/await, and uses ES6 Promises. | 11 /// stepping stone for proposed ES7 async/await, and uses ES6 Promises. |
| 12 part of dart._runtime; | 12 part of dart._runtime; |
| 13 | 13 |
| 14 final _jsIterator = JS('', 'Symbol("_jsIterator")'); | 14 final _jsIterator = JS('', 'Symbol("_jsIterator")'); |
| 15 final _current = JS('', 'Symbol("_current")'); | 15 final _current = JS('', 'Symbol("_current")'); |
| 16 | 16 |
| 17 syncStar(gen, E, @rest args) => JS('', '''(() => { | 17 syncStar(gen, E, @rest args) => JS('', '''(() => { |
| 18 const SyncIterable_E = ${getGenericClass(SyncIterable)}($E); | 18 const SyncIterable_E = ${getGenericClass(SyncIterable)}($E); |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 215 this.controller.addError(error, stackTrace); | 215 this.controller.addError(error, stackTrace); |
| 216 } | 216 } |
| 217 } | 217 } |
| 218 '''); | 218 '''); |
| 219 | 219 |
| 220 /// Returns a Stream of T implemented by an async* function. */ | 220 /// Returns a Stream of T implemented by an async* function. */ |
| 221 /// | 221 /// |
| 222 asyncStar(gen, T, @rest args) => JS('', '''(() => { | 222 asyncStar(gen, T, @rest args) => JS('', '''(() => { |
| 223 return new $_AsyncStarStreamController($gen, $T, $args).controller.stream; | 223 return new $_AsyncStarStreamController($gen, $T, $args).controller.stream; |
| 224 })()'''); | 224 })()'''); |
| OLD | NEW |