From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../global_objects/asynciterator/index.html | 119 +++++++++++++++++++++ 1 file changed, 119 insertions(+) create mode 100644 files/zh-cn/web/javascript/reference/global_objects/asynciterator/index.html (limited to 'files/zh-cn/web/javascript/reference/global_objects/asynciterator') diff --git a/files/zh-cn/web/javascript/reference/global_objects/asynciterator/index.html b/files/zh-cn/web/javascript/reference/global_objects/asynciterator/index.html new file mode 100644 index 0000000000..9c14e462bd --- /dev/null +++ b/files/zh-cn/web/javascript/reference/global_objects/asynciterator/index.html @@ -0,0 +1,119 @@ +--- +title: AsyncIterator +slug: Web/JavaScript/Reference/Global_Objects/AsyncIterator +tags: + - 异步迭代器 + - 类 +translation_of: Web/JavaScript/Reference/Global_Objects/AsyncIterator +--- +

{{JSRef}}{{Draft}}

+ +

AsyncIterator 全局对象是一个提供辅助方法的抽象类,与暴露在{{JSxRef("Array")}} 实例上的那些类似。

+ +

构造函数

+ +
+
{{JSxRef("AsyncIterator.AsyncIterator", "AsyncIterator()")}} 
+
一个抽象构造函数,仅能够通过 {{JSxRef("Operators/super", "super()")}} 来调用。
+
+ +

属性

+ +
+
AsyncIterator.prototype
+
%AsyncIteratorPrototype% 内部对象。
+
+ +

方法

+ +
+
{{JSxRef("AsyncIterator.from()")}} 
+
等同于在传入的对象上调用 @@asyncIterator 。
+
+ +

AsyncIterator 原型

+ +

原型属性

+ +
+
AsyncIterator.prototype.constructor
+
指定创建对的象原型的函数.
+
AsyncIterator.prototype[@@toStringTag] 
+
字符串 "Iterator".
+
+ +

原型方法

+ +
+
{{JSxRef("AsyncIterator.prototype.map()")}} 
+
...
+
{{JSxRef("AsyncIterator.prototype.filter()")}} 
+
...
+
{{JSxRef("AsyncIterator.prototype.take()")}} 
+
...
+
{{JSxRef("AsyncIterator.prototype.drop()")}} 
+
...
+
{{JSxRef("AsyncIterator.prototype.asIndexedPairs()")}} 
+
...
+
{{JSxRef("AsyncIterator.prototype.flatMap()")}} 
+
...
+
{{JSxRef("AsyncIterator.prototype.reduce()")}} 
+
...
+
{{JSxRef("AsyncIterator.prototype.toArray()")}} 
+
...
+
{{JSxRef("AsyncIterator.prototype.forEach()")}} 
+
...
+
{{JSxRef("AsyncIterator.prototype.some()")}} 
+
...
+
{{JSxRef("AsyncIterator.prototype.every()")}} 
+
...
+
{{JSxRef("AsyncIterator.prototype.find()")}} 
+
...
+
{{JSxRef("AsyncIterator.prototype.@@iterator()", "AsyncIterator.prototype[@@iterator]()")}}
+
返回该 AsyncIterator 实例。
+
+ +

实现方法

+ +
+
{{JSxRef("AsyncIterator.prototype.next()", "<implementation>.prototype.next()")}}
+
获取 AsyncIterator 中的下一项
+
{{JSxRef("AsyncIterator.prototype.return()", "<implementation>.prototype.next()")}}{{Optional_Inline}}
+
返回给出的值,并结束迭代。
+
{{JSxRef("AsyncIterator.prototype.throw()", "<implementation>.prototype.next()")}}{{Optional_Inline}}
+
抛出一个迭代器错误(同时也终止了迭代器,除非是在该迭代器内部被捕获)。
+
+ +

规范

+ + + + + + + + + + + + + + + + +
SpecificationStatusComment
ESNext Iterator Helpers ProposalStage 2 DraftInitial definition
+ +

浏览器兼容性

+ + + +

{{Compat("javascript.builtins.AsyncIterator")}}

+ +

另请参阅

+ + -- cgit v1.2.3-54-g00ecf