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 15, 2024
1 parent 2c7ea84 commit 1360e2e
Showing 1 changed file with 7 additions and 10 deletions.
17 changes: 7 additions & 10 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 Down Expand Up @@ -31,16 +32,12 @@
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.
channel gives `nil` after giving the last line, or after 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.
```
[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 1360e2e

Please sign in to comment.