blob: 9c14e462bda65948b3b90485bf63800ecf315fb9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
|
---
title: AsyncIterator
slug: Web/JavaScript/Reference/Global_Objects/AsyncIterator
tags:
- 异步迭代器
- 类
translation_of: Web/JavaScript/Reference/Global_Objects/AsyncIterator
---
<p>{{JSRef}}{{Draft}}</p>
<p><strong><code>AsyncIterator</code></strong> 全局对象是一个提供辅助方法的抽象类,与暴露在{{JSxRef("Array")}} 实例上的那些类似。</p>
<h2 id="构造函数">构造函数</h2>
<dl>
<dt>{{JSxRef("AsyncIterator.AsyncIterator", "AsyncIterator()")}} </dt>
<dd>一个抽象构造函数,仅能够通过 {{JSxRef("Operators/super", "super()")}} 来调用。</dd>
</dl>
<h2 id="属性">属性</h2>
<dl>
<dt><code>AsyncIterator.prototype</code></dt>
<dd><code>%AsyncIteratorPrototype%</code> 内部对象。</dd>
</dl>
<h2 id="方法">方法</h2>
<dl>
<dt>{{JSxRef("AsyncIterator.from()")}} </dt>
<dd>等同于在传入的对象上调用 <code>@@asyncIterator</code> 。</dd>
</dl>
<h2 id="AsyncIterator_原型"><code>AsyncIterator</code> 原型</h2>
<h3 id="原型属性">原型属性</h3>
<dl>
<dt><code>AsyncIterator.prototype.constructor</code></dt>
<dd>指定创建对的象原型的函数.</dd>
<dt><code>AsyncIterator.prototype[@@toStringTag]</code> </dt>
<dd><code>字符串 "Iterator"</code>.</dd>
</dl>
<h3 id="原型方法">原型方法</h3>
<dl>
<dt>{{JSxRef("AsyncIterator.prototype.map()")}} </dt>
<dd>...</dd>
<dt>{{JSxRef("AsyncIterator.prototype.filter()")}} </dt>
<dd>...</dd>
<dt>{{JSxRef("AsyncIterator.prototype.take()")}} </dt>
<dd>...</dd>
<dt>{{JSxRef("AsyncIterator.prototype.drop()")}} </dt>
<dd>...</dd>
<dt>{{JSxRef("AsyncIterator.prototype.asIndexedPairs()")}} </dt>
<dd>...</dd>
<dt>{{JSxRef("AsyncIterator.prototype.flatMap()")}} </dt>
<dd>...</dd>
<dt>{{JSxRef("AsyncIterator.prototype.reduce()")}} </dt>
<dd>...</dd>
<dt>{{JSxRef("AsyncIterator.prototype.toArray()")}} </dt>
<dd>...</dd>
<dt>{{JSxRef("AsyncIterator.prototype.forEach()")}} </dt>
<dd>...</dd>
<dt>{{JSxRef("AsyncIterator.prototype.some()")}} </dt>
<dd>...</dd>
<dt>{{JSxRef("AsyncIterator.prototype.every()")}} </dt>
<dd>...</dd>
<dt>{{JSxRef("AsyncIterator.prototype.find()")}} </dt>
<dd>...</dd>
<dt>{{JSxRef("AsyncIterator.prototype.@@iterator()", "AsyncIterator.prototype[@@iterator]()")}}</dt>
<dd>返回该 <code>AsyncIterator</code> 实例。</dd>
</dl>
<h2 id="实现方法">实现方法</h2>
<dl>
<dt>{{JSxRef("AsyncIterator.prototype.next()", "<<var>implementation</var>>.prototype.next()")}}</dt>
<dd>获取 <code>AsyncIterator</code> 中的下一项</dd>
<dt>{{JSxRef("AsyncIterator.prototype.return()", "<<var>implementation</var>>.prototype.next()")}}{{Optional_Inline}}</dt>
<dd>返回给出的值,并结束迭代。</dd>
<dt>{{JSxRef("AsyncIterator.prototype.throw()", "<<var>implementation</var>>.prototype.next()")}}{{Optional_Inline}}</dt>
<dd>抛出一个迭代器错误(同时也终止了迭代器,除非是在该迭代器内部被捕获)。</dd>
</dl>
<h2 id="规范">规范</h2>
<table class="standard-table">
<thead>
<tr>
<th scope="col">Specification</th>
<th scope="col">Status</th>
<th scope="col">Comment</th>
</tr>
</thead>
<tbody>
<tr>
<td><a href="https://tc39.es/proposal-iterator-helpers/#sec-asynciterator-constructor">ESNext Iterator Helpers Proposal</a></td>
<td><span class="spec-Draft">Stage 2 Draft</span></td>
<td>Initial definition</td>
</tr>
</tbody>
</table>
<h2 id="浏览器兼容性">浏览器兼容性</h2>
<p>{{Compat("javascript.builtins.AsyncIterator")}}</p>
<h2 id="另请参阅">另请参阅</h2>
<ul>
<li>{{JSxRef("Iteration_protocols", "Iteration protocols", "", "1")}}</li>
<li>{{JSxRef("Generator")}}</li>
<li>{{JSxRef("Global_Objects/AsyncGenerator", "AsyncGenerator")}}</li>
<li>{{JSxRef("Iterator")}} </li>
</ul>
|