> For the complete documentation index, see [llms.txt](https://lochiwei.gitbook.io/web/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lochiwei.gitbook.io/web/js/iteration/generator/func/compose.md).

# composition

[JS](/web/js.md) ⟩ [objects](/web/js/val/obj.md) ⟩ [built-in](/web/js/val/builtin.md) ⟩ [Generator](/web/js/iteration/generator.md) ⟩ [generator function](/web/js/iteration/generator/func.md) ⟩ compostion

{% tabs %}
{% tab title="✨ 範例" %}

* [\*zip()](/web/js/iteration/generator/examples/zip.md) - <mark style="color:yellow;">**zip**</mark> [iterable](/web/js/iteration/iterable.md)s into a single [generator function](/web/js/iteration/generator/func.md).
* [\*interleave()](/web/js/iteration/generator/examples/interleave.md) - <mark style="color:yellow;">**interleave**</mark> the values of [iterable](/web/js/iteration/iterable.md)s.
* [\*sequence()](/web/js/iteration/generator/examples/seq.md) - yield values <mark style="color:yellow;">**sequentially**</mark>.
  {% endtab %}

{% tab title="💈範例" %}
{% hint style="success" %}
syntax：<mark style="color:blue;">`yield* <generator object>`</mark>
{% endhint %}

⬆️ 需要： [\*list()](/web/js/iteration/generator/examples/list.md)

```javascript
// ⭐️ composition of generator functions
function* alphaNumericCodes(){
    yield* list(26, {start: 97});   // a..z    // ⭐️ Note: use of `yield*`
    yield* list(26, {start: 65});   // A..Z
    yield* list(10, {start: 48});   // 0..9
}

// generator object -> array
[...alphaNumericCodes()]                 
    .map(n => String.fromCharCode(n))    // array of codes -> array of characters
    .join('')                            // 'a..zA..Z0..9'
```

{% endtab %}

{% tab title="📘 手冊" %}
\*
{% endtab %}
{% endtabs %}
