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
//! §27.1.5's Iterator Helper — a `map`, `filter`, `take`, `drop` or `flatMap` part-way through.
//!
//! # Why these are objects rather than closures
//!
//! `[1, 2, 3].values().map(f)` returns *immediately*, having called `f` not at all. What comes back
//! is an iterator that will call it once per `next`, and the specification models that as a
//! generator with internal slots. ViperJS has no generators yet, so the state a generator would keep
//! in its frame is kept here explicitly: what it is drawing from, what it does to what it draws,
//! and how far it has got.
//!
//! That is not a workaround for the missing generators — it is what the slots hold either way. When
//! the interpreter can suspend a frame this could become one, and nothing a program can see would
//! change.
//!
//! # Why `done` is remembered rather than re-derived
//!
//! §27.1.5.1's `[[GeneratorState]]` becomes `completed` and stays there. Once a helper has said it
//! is done it must go on saying so, even if the iterator underneath it starts answering again —
//! `take(2)` that has yielded two values is finished whatever the source does next.
use crateValue;
/// What a helper does to each value it draws.
/// §27.1.5.3's internal slots — the underlying iterator, the operation, and where it has got to.