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
//! §27.1 — what an iterator remembers between two calls to `next`.
//!
//! # Why this is a field and not a property
//!
//! An Array Iterator's position is an internal slot (§23.1.5.1's `[[ArrayLikeNextIndex]]`), and
//! that is not a detail. A property could be read, written and deleted by any script that got hold
//! of the iterator — so `for (const x of a)` could be made to skip, repeat or never end by code
//! that never touched the array. The position lives here, where nothing in the language can reach
//! it, for the same reason an Array's `length` is exotic rather than ordinary.
//!
//! # One type for four iterators
//!
//! §23.1.5 makes three Array Iterators — over keys, over values, over both — and §22.1.5 makes one
//! over a String's *code points*. They differ in what each step answers and in nothing else: the
//! same position, the same "and now it is done", the same object shape coming back. So this is one
//! record with a [`Iterated`] saying which, rather than four that would drift.
//!
//! The String one is not an Array Iterator with a String in it. §22.1.5.1 walks code *points*, so
//! a surrogate pair is one step and `"😀"` iterates once where `.length` says two — which is the
//! whole reason `for`-`of` over a String is not the same as a `for` over its indices.
use crateValue;
/// What an iterator answers at each step.
/// Where an iterator has got to — §23.1.5.1 and §22.1.5.1's internal slots, together.