| 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 /** | 5 /** |
| 6 * This library adapts ES6 generators to implement Dart's async/await. | 6 * This library adapts ES6 generators to implement Dart's async/await. |
| 7 * | 7 * |
| 8 * It's designed to interact with Dart's Future/Stream and follow Dart | 8 * It's designed to interact with Dart's Future/Stream and follow Dart |
| 9 * async/await semantics. | 9 * async/await semantics. |
| 10 * | 10 * |
| 11 * See https://github.com/dart-lang/dev_compiler/issues/245 for ideas on | 11 * See https://github.com/dart-lang/dev_compiler/issues/245 for ideas on |
| 12 * reconciling Dart's Future and ES6 Promise. | 12 * reconciling Dart's Future and ES6 Promise. |
| 13 * | 13 * |
| 14 * Inspired by `co`: https://github.com/tj/co/blob/master/index.js, which is a | 14 * Inspired by `co`: https://github.com/tj/co/blob/master/index.js, which is a |
| 15 * stepping stone for proposed ES7 async/await, and uses ES6 Promises. | 15 * stepping stone for proposed ES7 async/await, and uses ES6 Promises. |
| 16 */ | 16 */ |
| 17 dart_library.library('dart_runtime/_generators', null, /* Imports */[ | 17 dart_library.library('dart/_generators', null, /* Imports */[ |
| 18 ], /* Lazy Imports */[ | 18 ], /* Lazy Imports */[ |
| 19 'dart_runtime/_operations', | 19 'dart/_operations', |
| 20 'dart/_js_helper', | 20 'dart/_js_helper', |
| 21 'dart/core', | 21 'dart/core', |
| 22 'dart/collection', | 22 'dart/collection', |
| 23 'dart/async' | 23 'dart/async' |
| 24 ], function(exports, _operations, _js_helper, core, collection, async) { | 24 ], function(exports, _operations, _js_helper, core, collection, async) { |
| 25 'use strict'; | 25 'use strict'; |
| 26 | 26 |
| 27 const _jsIterator = Symbol('_jsIterator'); | 27 const _jsIterator = Symbol('_jsIterator'); |
| 28 const _current = Symbol('_current'); | 28 const _current = Symbol('_current'); |
| 29 | 29 |
| (...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 225 this.controller.addError(error, stackTrace); | 225 this.controller.addError(error, stackTrace); |
| 226 } | 226 } |
| 227 } | 227 } |
| 228 | 228 |
| 229 /** Returns a Stream of T implemented by an async* function. */ | 229 /** Returns a Stream of T implemented by an async* function. */ |
| 230 function asyncStar(gen, T, ...args) { | 230 function asyncStar(gen, T, ...args) { |
| 231 return new _AsyncStarStreamController(gen, T, args).controller.stream; | 231 return new _AsyncStarStreamController(gen, T, args).controller.stream; |
| 232 } | 232 } |
| 233 exports.asyncStar = asyncStar; | 233 exports.asyncStar = asyncStar; |
| 234 }); | 234 }); |
| OLD | NEW |