@@ -169,27 +169,39 @@ since the C<list> call.
169
169
170
170
= head2 method grab
171
171
172
- method grab(Supply:D: &process --> Supply:D)
172
+ method grab(Supply:D: &when-done --> Supply:D)
173
173
174
- Waits until the given supply is done. It will then call the given process
175
- closure passing all of the values seen, Then creates a supply to which all
176
- values returned from the process closure.
174
+ Waits until the given C < Supply > is done. It will then call the C < &when-done >
175
+ closure passing all of the values seen, Then creates a C < Supply > to which all
176
+ values returned from the C < &when-done > closure are emitted.
177
+
178
+ my $s = Supply.from-list(4, 10, 3, 2);
179
+ my $t = $s.grab(&sum);
180
+ $t.tap(&say); # OUTPUT: «19»
177
181
178
182
= head2 method reverse
179
183
180
184
method reverse(Supply:D: --> Supply:D)
181
185
182
- Waits until the given supply is done, then creates a supply to which all
186
+ Waits until the given C < Supply > is done, then creates a C < Supply > to which all
183
187
values seen are emitted in reverse order.
184
188
189
+ my $s = Supply.from-list(1, 2, 3);
190
+ my $t = $s.reverse;
191
+ $t.tap(&say); # OUTPUT: «321»
192
+
185
193
= head2 method sort
186
194
187
195
method sort(Supply:D: &by? --> Supply:D)
188
196
189
- Waits until the given supply is done, then creates a supply to which all
197
+ Waits until the given C < Supply > is done, then creates a C < Supply > to which all
190
198
values seen are emitted in sorted order. Optionally accepts a comparator
191
199
L < Block|/type/Block > .
192
200
201
+ my $s = Supply.from-list(4, 10, 3, 2);
202
+ my $t = $s.sort();
203
+ $t.tap(&say); # OUTPUT: «23410»
204
+
193
205
= head1 Methods that return another Supply
194
206
195
207
= head2 method from-list
0 commit comments