# Proxies

Proxies are a plain functions which always accept a channel as an argument and return a channel which is augmented with an additional set of features using JavaScript Proxy object.

### closeOnAllValuesTaken

```javascript
import { closeOnAllValuesTaken } from 'csp-coffee/channel/proxies/closeOnAllValuesTaken'
```

This proxy will make sure that the channel is automatically closed once all values are **taken**.

### closeOnEmptyBuffer

```javascript
import { closeOnEmptyBuffer } from 'csp-coffee/channel/proxies/closeOnAllValuesTaken'
```

This proxy is mostly for internal usage. In some places channel's buffer may become empty without any **take** operations involved and this proxy is responsivle for checking whether there are no values in the channel on each read access to `isClosed` property.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://roman-sarder.gitbook.io/csp-coffee/packages-and-api/channels/proxies.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
