Skip to content

Commit

Permalink
Turn separator into a named argument for spork/stream/lines
Browse files Browse the repository at this point in the history
Also, fix minor issues with docstring in spork/stream functions.
  • Loading branch information
amano-kenji committed Feb 16, 2024
1 parent 2c7ea84 commit 21298e0
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions spork/stream.janet
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
(defn lines
```
Returns a fiber that yields each line from a core/stream value. If separator is not specified, the default separator
is `\n`. If the stream is closed before the fiber yields all lines, an error is thrown from the stream.
is `\n`. After the fiber yields the last line, it returns `nil`. If the fiber is resumed after the stream is closed or
after the fiber returns `nil`, an error is thrown.
```
[stream &opt separator]
[stream &named separator]
(default separator "\n")
(defn yield-lines
[chunk]
Expand All @@ -30,17 +31,13 @@
```
Returns a channel that gives each line from a core/stream value. An asynchronous task feeds lines to the channel. If
separator is not specified, the default separator is `\n`. To make sure that the task is finished, drain all lines
from the channel, or close the stream and the channel. Otherwise, the task remains frozen in the background. The
channel gives `nil` after one of those conditions applies.
* end of stream is reached.
* stream or channel is closed.
If `supervisor` is a channel, the channel is used as the supervisor channel. If `supervisor` is nil or not specified,
the task inherits the current supervisor channel.
from the channel, or close the stream and the channel. Otherwise, the task remains frozen in the background. After the
channel gives the last line, the channel is closed. After stream or channel is closed, the channel gives `nil`. If
`supervisor` is a channel, the channel is used as the supervisor channel. If `supervisor` is nil or not specified, the
task inherits the current supervisor channel.
```
[stream &named separator supervisor]
(def fiber (lines stream separator))
(def fiber (lines stream :separator separator))
(def ch (ev/chan))
(defn give-lines
[]
Expand Down

0 comments on commit 21298e0

Please sign in to comment.