{"id":41363642,"url":"https://github.com/thesebas/php-itertools","last_synced_at":"2026-01-23T08:10:57.460Z","repository":{"id":57068514,"uuid":"109520567","full_name":"thesebas/php-itertools","owner":"thesebas","description":null,"archived":false,"fork":false,"pushed_at":"2017-11-06T08:12:28.000Z","size":10,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-08-17T11:17:04.112Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thesebas.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2017-11-04T18:38:02.000Z","updated_at":"2017-11-04T21:53:31.000Z","dependencies_parsed_at":"2022-08-24T14:54:12.126Z","dependency_job_id":null,"html_url":"https://github.com/thesebas/php-itertools","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/thesebas/php-itertools","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thesebas%2Fphp-itertools","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thesebas%2Fphp-itertools/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thesebas%2Fphp-itertools/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thesebas%2Fphp-itertools/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thesebas","download_url":"https://codeload.github.com/thesebas/php-itertools/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thesebas%2Fphp-itertools/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28684018,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-23T05:48:07.525Z","status":"ssl_error","status_checked_at":"2026-01-23T05:48:07.129Z","response_time":59,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2026-01-23T08:10:56.986Z","updated_at":"2026-01-23T08:10:57.455Z","avatar_url":"https://github.com/thesebas.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# thesebas/itertools\n\nTools to work with iterators. ![BUILD STATUS](https://api.travis-ci.org/thesebas/php-itertools.svg?branch=master) [![Coverage Status](https://coveralls.io/repos/github/thesebas/php-itertools/badge.svg)](https://coveralls.io/github/thesebas/php-itertools)\n\n## Installation\n\n`composer require thesebas/itertools`\n\n## Usage\nLest assume we have some generator that yields letters.\n```php\nexpect(iterator_to_array(gen(3)))-\u003etoBe(['a', 'b', 'c']);\n```\n\n### tail\n\nSkip all but `n` items from Iterator. \n\n```php\n$actual = tail(gen(5), 3, false);\nexpect(iterator_to_array($actual))-\u003etoBe(['c', 'd', 'e']);\n```\n\n### head\n\nIterator over `n` first items.\n\n```php\n$actual = head(gen(10), 3);\nexpect(iterator_to_array($actual))-\u003etoBe(['a', 'b', 'c']);\n```\n\n### skip\n\nSkip `n` items and iterate over rest.\n\n```php\n\n$actual = skip(gen(10), 4);\nexpect(iterator_to_array($actual))-\u003etoBe(['e', 'f', 'g', 'h', 'i', 'j']);\n```\n### tee\n\nSplit Iterator to two independent Iterators (with internal buffering).\n\n```php\nlist($left, $right) = tee(gen(10));\n\n\nexpect(iterator_to_array(head($left, 3)))-\u003etoBe(['a', 'b', 'c']);\nexpect(iterator_to_array(head($right, 5)))-\u003etoBe(['a', 'b', 'c', 'd', 'e']);\n\nexpect(iterator_to_array(head($left, 5)))-\u003etoBe(['d', 'e', 'f', 'g', 'h']);\nexpect(iterator_to_array(head($right, 2)))-\u003etoBe(['f', 'g']);\n\nexpect(iterator_to_array(head($left, 2)))-\u003etoBe(['i', 'j']);\nexpect(iterator_to_array(head($right, 3)))-\u003etoBe(['h', 'i', 'j']);\n```\n\n### chain\n\nIterate over first, then second, third...\n\n```php\n$actual = chain(gen(5), gen(3));\nexpect(iterator_to_array($actual))-\u003etoBe(['a', 'b', 'c', 'd', 'e', 'a', 'b', 'c']);\n```\n### filter\n\nIterate ovel all but yield only filtered items.\n\n```php\n$actual = filter(gen(10), function ($item, $key) {\n    return $key % 2 == 1;\n});\nexpect(iterator_to_array($actual))-\u003etoBe(['b', 'd', 'f', 'h', 'j']);\n```\n### map\n\nReturn new Iterator with mapped values\n\n```php\n\n$actual = map(gen(3), function ($item, $key) {\n    return \"item {$key}: {$item}\";\n});\n\nexpect(iterator_to_array($actual))-\u003etoBe(['item 0: a', 'item 1: b', 'item 2: c']);\n```\n### chunk\n\nReturn iterator of chunk iterators.\n\n```php\n$actual = \\iterator_to_array(map(chunk(gen(10), 3), '\\\\iterator_to_array'));\nexpect($actual)-\u003etoBe([\n    ['a', 'b', 'c'],\n    ['d', 'e', 'f'],\n    ['g', 'h', 'i'],\n    ['j']\n]);\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthesebas%2Fphp-itertools","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthesebas%2Fphp-itertools","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthesebas%2Fphp-itertools/lists"}