{"id":17749292,"url":"https://github.com/joeltg/it-zip","last_synced_at":"2025-04-01T17:33:21.932Z","repository":{"id":57406165,"uuid":"312441931","full_name":"joeltg/it-zip","owner":"joeltg","description":"Generic, variadic, iterable zip","archived":false,"fork":false,"pushed_at":"2024-10-17T15:19:20.000Z","size":48,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-10-29T22:57:22.546Z","etag":null,"topics":["functional-programming","iterable","iterator","typescript","zip"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/joeltg.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}},"created_at":"2020-11-13T01:37:21.000Z","updated_at":"2024-10-17T15:19:25.000Z","dependencies_parsed_at":"2024-10-12T08:47:56.686Z","dependency_job_id":"5c6e1123-b831-42b9-b068-25339ec9aa03","html_url":"https://github.com/joeltg/it-zip","commit_stats":{"total_commits":21,"total_committers":1,"mean_commits":21.0,"dds":0.0,"last_synced_commit":"9213f8060308b926a643cc09f97b6e2ac19f033f"},"previous_names":["joeltg/it-zip","joeltg/ziterable"],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joeltg%2Fit-zip","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joeltg%2Fit-zip/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joeltg%2Fit-zip/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/joeltg%2Fit-zip/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/joeltg","download_url":"https://codeload.github.com/joeltg/it-zip/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":222706870,"owners_count":17026326,"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":["functional-programming","iterable","iterator","typescript","zip"],"created_at":"2024-10-26T11:20:24.805Z","updated_at":"2024-11-02T17:07:58.777Z","avatar_url":"https://github.com/joeltg.png","language":"TypeScript","readme":"# it-zip\n\n[![standard-readme compliant](https://img.shields.io/badge/readme%20style-standard-brightgreen.svg)](https://github.com/RichardLitt/standard-readme) [![license](https://img.shields.io/github/license/joeltg/it-zip)](https://opensource.org/licenses/MIT) [![NPM version](https://img.shields.io/npm/v/it-zip)](https://www.npmjs.com/package/it-zip) ![TypeScript types](https://img.shields.io/npm/types/it-zip)\n\nGeneric, variadic, iterable zip.\n\nSometimes you want to iterate over several ES6 Iterables at once, but writing your own `zip` function can be annoying and it's hard to get it to work with TypeScript well. it-zip is a tiny package that does exactly this so that you don't have to think about it.\n\nThe source code is 25 lines of code and the package has no dependencies. You need TypeScript 4.0+ and `downlevelIteration` must be enabled if your target is ES5 or earlier.\n\n## Table of Contents\n\n- [Install](#install)\n- [Usage](#usage)\n- [Contributing](#contributing)\n- [License](#license)\n\n## Install\n\n```\nnpm i it-zip\n```\n\n## Usage\n\nThe package exports a function `zip` that takes arbitrarily many ES6 iterables, and returns an iterable of typed tuples. The iterable that `zip` returns yields iterators that terminate when the **first** of its component iterators terminates.\n\nFor example, if you pass `zip` three arguments of type `Iterable\u003cstring\u003e`, `Iterable\u003cnumber\u003e`, and `Iterable\u003cboolean\u003e`, it will return an iterable of type `Iterable\u003c[string, number, boolean, number]\u003e`. The last tuple slot is the iteration index.\n\n```ts\nimport { zip } from \"it-zip\"\n\nconst A = [4, 5, 1, 9]\nconst B = [\"foo\", \"bar\", \"baz\"]\nconst C = [true, true, false]\n\nconst print = (a: number, b: string, c: boolean) =\u003e console.log(a, b, c)\n\nfor (const [a, b, c, i] of zip(A, B, C)) {\n\tconsole.log(\"index\", i)\n\tprint(a, b, c)\n}\n```\n\nThere is also a `zipAsync` function that does the does the same thing for async iterables.\n\n```ts\nimport { zipAsync } from \"it-zip\"\n\nasync function* A(): AsyncIterable\u003cnumber\u003e {\n\tyield 1\n\tyield 2\n}\n\nasync function* B(): AsyncIterable\u003cstring\u003e {\n\tyield \"hello\"\n\tyield \"world\"\n}\n\nfor await (const [a, b] of zipAsync(A(), B())) {\n\t// [a: number, b: string]\n}\n```\n\n## Contributing\n\nit-zip is meant to be a minimal utility library - it's unlikely that I'll want to add new features to it, but if you find bugs, have interface or API suggestions, or general feedback, feel free to open an issue to discuss it!\n\n## License\n\nMIT © 2020 Joel Gustafson\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoeltg%2Fit-zip","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjoeltg%2Fit-zip","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjoeltg%2Fit-zip/lists"}