From 9e07c6adc7a0616eec40e78024a8501ec7d96559 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sun, 18 Aug 2024 23:31:36 -0400 Subject: Add Channel:peek() --- api/channels.md | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'api') diff --git a/api/channels.md b/api/channels.md index dbb6707a..ca7ce17e 100644 --- a/api/channels.md +++ b/api/channels.md @@ -91,6 +91,32 @@ get(channel:|T|) -> T **Returns:** The item removed from the channel. +**Example:** +```markdown +>> channel:peek() += "Hello" +``` + +--- + +### `peek` + +**Description:** +Returns the next item that will come out of the channel, but without removing +it. If the channel is empty, it waits until an item is available. + +**Usage:** +```markdown +peek(channel:|T|) -> T +``` + +**Parameters:** + +- `channel`: The channel from which to remove an item. + +**Returns:** +The item removed from the channel. + **Example:** ```markdown >> channel:get() -- cgit v1.2.3