{"id":29866634,"url":"https://github.com/lima1909/ztep","last_synced_at":"2025-08-07T21:13:04.134Z","repository":{"id":306476806,"uuid":"1026210193","full_name":"lima1909/ztep","owner":"lima1909","description":"ZTEP is an extension for Zig-Iterators.","archived":false,"fork":false,"pushed_at":"2025-07-25T17:52:20.000Z","size":5,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-26T00:15:12.382Z","etag":null,"topics":["iterator","itertools","zig-library","ziglang"],"latest_commit_sha":null,"homepage":"","language":"Zig","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/lima1909.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-25T13:46:28.000Z","updated_at":"2025-07-25T17:52:23.000Z","dependencies_parsed_at":"2025-07-26T00:15:42.915Z","dependency_job_id":null,"html_url":"https://github.com/lima1909/ztep","commit_stats":null,"previous_names":["lima1909/ztep"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/lima1909/ztep","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lima1909%2Fztep","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lima1909%2Fztep/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lima1909%2Fztep/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lima1909%2Fztep/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/lima1909","download_url":"https://codeload.github.com/lima1909/ztep/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/lima1909%2Fztep/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":267873778,"owners_count":24158695,"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","status":"online","status_checked_at":"2025-07-30T02:00:09.044Z","response_time":70,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"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":["iterator","itertools","zig-library","ziglang"],"created_at":"2025-07-30T13:01:07.074Z","updated_at":"2025-08-07T21:13:04.110Z","avatar_url":"https://github.com/lima1909.png","language":"Zig","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\n# ZTEP \n\n[![Build Status](https://img.shields.io/github/actions/workflow/status/lima1909/ztep/ci.yaml?style=for-the-badge)](https://github.com/lima1909/ztep/actions)\n![License](https://img.shields.io/github/license/lima1909/ztep?style=for-the-badge)\n[![Stars](https://img.shields.io/github/stars/lima1909/ztep?style=for-the-badge)](https://github.com/lima1909/ztep/stargazers)\n\n\u003c/div\u003e\n\n`ztep` is an extension for Iterators written in ⚡ZIG ⚡.\n\nIt is heavily inspired by the iterators in the Rust standard library [std::iter::Iterator](https://doc.rust-lang.org/std/iter/trait.Iterator.html).\n\n### Examples\n\n#### Extend a zig-std-iterator: `std.mem.TokenIterator`\n\n```zig\nconst std = @import(\"std\");\nconst iter = @import(\"ztep\");\n\nfn firstChar(in: []const u8) u8 {\n    return in[0];\n}\n\ntest \"extend\" {\n    var it = iter.extend(std.mem.tokenizeScalar(u8, \"x BB ccc\", ' '))\n        .map(u8, firstChar)\n        .filter(std.ascii.isLower)\n        .enumerate();\n\n    try std.testing.expectEqualDeep(.{ 0, 'x' }, it.next().?);\n    try std.testing.expectEqualDeep(.{ 1, 'c' }, it.next().?);\n    try std.testing.expectEqual(null, it.next());\n}\n```\n\n#### Create an Iterator for a given Slice\n\n```zig\nconst std = @import(\"std\");\nconst iter = @import(\"ztep\");\n\nfn firstChar(in: []const u8) u8 {\n    return in[0];\n}\n\ntest \"from slice\" {\n    var it = iter.fromSlice(\u0026[_][]const u8{ \"x\", \"BB\", \"ccc\" })\n        .map(u8, firstChar)\n        .filter(std.ascii.isLower)\n        .enumerate();\n\n    try std.testing.expectEqualDeep(.{ 0, 'x' }, it.next().?);\n    try std.testing.expectEqualDeep(.{ 1, 'c' }, it.next().?);\n    try std.testing.expectEqual(null, it.next());\n}\n```\n\n#### Extend a zig-std-iterator: `std.fs.Dir.Walker`, which next-method returns an error_union\n\n```zig\nconst std = @import(\"std\");\nconst iter = @import(\"ztep\");\n\ntest \"iterator with error\" {\n    const dir = try std.fs.cwd().openDir(\".\", .{ .iterate = true });\n    var walker = try dir.walk(std.testing.allocator);\n    defer walker.deinit();\n\n    // errors are ignored and the next Item is yield\n    const build = iter.extendWithError(\u0026walker, null).find(struct {\n        fn find(entry: std.fs.Dir.Walker.Entry) bool {\n            if (std.mem.eql(u8, \"build.zig\", entry.basename)) return true else return false;\n        }\n    }.find);\n\n    try std.testing.expectEqualStrings(\"build.zig\", build.?.basename);\n}\n```\n\n\n### Iterators\n\n#### Create or extend a Iterator \n\n| Function          | Description                                                                                      |\n|-------------------|--------------------------------------------------------------------------------------------------|\n| `empty`           | Creates an iterator that yields nothing.                                                         |\n| `extend`          | Extend a given Iterator with the additional methods.                                             |\n| `extendWithError` | Extend an Iterator which has a next-method, which returns an error_union (next() anyerror!Item). |\n| `fromFn`          | Creates an custom iterator with the initialized (start) value and the provided (next) function.  |\n| `fromSlice`       | Create an Iterator from a given slice.                                                           |\n| `once`            | Creates an iterator that yields an element exactly once.                                         |\n| `range`           | Create an Iterator from a given start and end value (end is excluded).                           |\n| `rangeIncl`       | Create an Iterator from a given start and end value (end is inclusive).                          |\n| `repeatN`         | Creates a new iterator that N times repeats a given value.                                       |\n \n\n#### The following iterators are available: \n\n| Iterators        | Description                                                                                            |\n|------------------|--------------------------------------------------------------------------------------------------------|\n| `chain`          | Takes two iterators and creates a new iterator over both in sequence.                                  |\n| `count`          | Consumes the iterator, counting the number of iterations and returning it.                             |\n| `enumerate`      | Creates an iterator which gives the current iteration count as well as the next value.                 |\n| `filter`         | Creates an iterator which uses a function to determine if an element should be yielded.                |\n| `filterMap`      | Creates an iterator that both filters and maps in one call.                                            |\n| `find`           | Searches for an element of an iterator that satisfies a predicate.                                     |\n| `fold`           | Folds every element into an accumulator by applying an operation, returning the final result.          |\n| `forEach`        | Calls a function fn(Item) on each element of an iterator.                                              |\n| `inspect`        | This iterator do nothing, the purpose is for debugging.                                                |\n| `last`           | Calls a function fn(Item) on each element of an iterator.                                              |\n| `map`            | Transforms one iterator into another by a given mapping function.                                      |\n| `nth`            | Consumes the iterator, returning the nth element.                                                      |\n| `reduce`         | Reduces the elements to a single one, by repeatedly applying a reducing function.                      |\n| `skip`           | Creates an iterator that skips the first n elements.                                                   |\n| `stepBy`         | Creates an iterator starting at the same point, but stepping by the given amount at each iteration.    |\n| `take`           | Creates an iterator that yields the first n elements, or fewer if the underlying iterator ends sooner. |\n| `tryCollect`     | Collects all the items from an iterator into a given  buffer.                                          |\n| `tryCollectInto` | Collects all the items from an iterator into a given collection.                                       |\n| `zip`            | Zips up’ two iterators into a single iterator of pairs.                                                |\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flima1909%2Fztep","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flima1909%2Fztep","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flima1909%2Fztep/lists"}