{"id":26322980,"url":"https://github.com/devlop/buffer","last_synced_at":"2025-03-15T17:16:05.298Z","repository":{"id":56966938,"uuid":"320839742","full_name":"devlop/buffer","owner":"devlop","description":"Simple Buffer for automatically managing a stack with a callback","archived":false,"fork":false,"pushed_at":"2021-04-01T04:44:36.000Z","size":14,"stargazers_count":0,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-19T18:17:48.261Z","etag":null,"topics":["php"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/devlop.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-12-12T13:41:30.000Z","updated_at":"2021-04-02T16:22:32.000Z","dependencies_parsed_at":"2022-08-21T11:20:23.466Z","dependency_job_id":null,"html_url":"https://github.com/devlop/buffer","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devlop%2Fbuffer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devlop%2Fbuffer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devlop%2Fbuffer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/devlop%2Fbuffer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/devlop","download_url":"https://codeload.github.com/devlop/buffer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243762249,"owners_count":20343979,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":["php"],"created_at":"2025-03-15T17:16:04.705Z","updated_at":"2025-03-15T17:16:05.291Z","avatar_url":"https://github.com/devlop.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cp align=\"center\"\u003e\n    \u003ca href=\"https://packagist.org/packages/devlop/buffer\"\u003e\u003cimg src=\"https://img.shields.io/packagist/v/devlop/buffer\" alt=\"Latest Stable Version\"\u003e\u003c/a\u003e\n    \u003ca href=\"https://github.com/devlop/buffer/blob/master/LICENSE.md\"\u003e\u003cimg src=\"https://img.shields.io/packagist/l/devlop/buffer\" alt=\"License\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n# Buffer\n\nSimple Buffer for iterating over an iteratable and regularly applying a callback.\n\nThis allows you to consume a large array with minimal memory usage.\n\n# Installation\n\n```bash\ncomposer require devlop/buffer\n```\n\n# Usage\n\n## Manual\n\nThis way gives you the most power, but also forces you to take more responsibility over execution.\n\n```php\nuse Devlop\\Buffer\\Buffer;\n\n$bigFuckingArray = [...]; // array containing between zero and many many items\n\n$buffer = new Buffer(\n    10, // max Buffer size\n    function (array $items) : void {\n        // callback to apply when buffer size reaches max\n    },\n);\n\nforeach ($bigFuckingArray as $key =\u003e $value) {\n    $buffer-\u003epush($value); // the Buffer callback will automatically be applied when needed\n}\n\n// important, after looping over the array, remember to manually call the flush() method to apply the callback on last time if needed\n$buffer-\u003eflush();\n```\n\n## Automatic\n\nThis way is the easiest way to use the Buffer and requires least work from you.\n\n```php\nuse Devlop\\Buffer\\Buffer;\n\n$bigFuckingArray = [...]; // array containing between zero and many many items\n\nBuffer::iterate(\n    $bigFuckingArray, // input iterable\n    10, // max Buffer size\n    function (array $items) : void {\n        // callback to apply when buffer size reaches max\n        // the callback will also be called one last time after finishing iterating if needed\n    },\n)\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevlop%2Fbuffer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdevlop%2Fbuffer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdevlop%2Fbuffer/lists"}