Skip to content

Commit 2aa3c9f

Browse files
committed
[io grant] Document new behaviour of IO::Handle.Supply
- Expand description - Add examples
1 parent a30fae6 commit 2aa3c9f

File tree

1 file changed

+19
-5
lines changed

1 file changed

+19
-5
lines changed

doc/Type/IO/Handle.pod6

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -235,13 +235,27 @@ otherwise the return will be a C<Str> with the optional encoding C<:enc>.
235235
236236
=head2 method Supply
237237
238-
multi method Supply(IO::Handle:D: :$size = 65536, :$bin --> Supply)
238+
multi method Supply(IO::Handle:D: :$size = 65536)
239239
240240
Returns a C<Supply> that will emit the contents of the handle in chunks.
241-
The size of the chunks is determined by the optional C<:size> named parameter
242-
and defaults to 64K. The optional C<:bin> named parameter can be specified
243-
to indicate binary reading of the contents, rather than character based
244-
reading.
241+
The chunks will be L«C<Buf>|/type/Buf» if the handle is in binary mode
242+
or, if it isn't, L«C<Str>|/type/Str» decoded using same encoding as L«C<IO::Handle.encoding>|/routine/encoding».
243+
244+
The size of the chunks is determined by the optional C<:size> named
245+
parameter and C<65536> bytes in binary mode or C<65536> characters in non-binary
246+
mode.
247+
248+
=for code :skip-test
249+
"foo".IO.open(:bin).Supply(:size<10>).tap: *.perl.say;
250+
# OUTPUT:
251+
# Buf[uint8].new(73,32,226,153,165,32,80,101,114,108)
252+
# Buf[uint8].new(32,54,33,10)
253+
254+
"foo".IO.open.Supply(:size<10>).tap: *.perl.say;
255+
# OUTPUT:
256+
# "I ♥ Perl 6"
257+
# "!\n"
258+
245259
246260
=head2 method path
247261

0 commit comments

Comments
 (0)