> For the complete documentation index, see [llms.txt](https://roman-sarder.gitbook.io/csp-coffee/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://roman-sarder.gitbook.io/csp-coffee/packages-and-api/operators/creation.md).

# Creation

## fromArray\<Arr extends any\[]>(arr: Arr): Channel\<Flatten>

`fromArray` will take an array of values and create a channel which will contain all of these values. The result channel will be closed when all values are taken.

```javascript
import { fromArray, iterate } from 'csp-coffee/operators'
import { go } from 'csp-coffee/go';

const ch = fromArray([1, 2, 3]);

function* testGenerator () {
    yield iterate((value) => {
        console.log(value);
    }, ch);
}

go(testGenerator)
// 1
// 2
// 3
```

## fromPromise\<PromiseType extends Promise>(promise: PromiseType, { bufferType, capacity }?: ChannelConfiguration): Channel\<PromiseResponseType>

`fromPromise` will take a promise and produce a channel which will contain a value resolved from promise. Result channel will be closed once that value is taken. You can additionally pass a **buffer type and capacity** of a result channel. By default result channel will have an **Unblocking** buffer with unlimited **capacity**.

```javascript
import { fromPromise, iterate } from 'csp-coffee/operators'
import { go } from 'csp-coffee/go';

const ch = fromPromise(Promise.resolve(1));

function* testGenerator () {
    yield iterate((value) => {
        console.log(value);
    }, ch);
}

go(testGenerator)
// 1
```
