Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alkihis/python-zip
https://github.com/alkihis/python-zip
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/alkihis/python-zip
- Owner: alkihis
- License: cc-by-sa-4.0
- Created: 2019-05-16T08:59:58.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2019-05-16T09:16:58.000Z (over 5 years ago)
- Last Synced: 2024-10-07T14:36:48.898Z (about 1 month ago)
- Language: JavaScript
- Size: 10.7 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# python-zip
> Iterate through Iterables together, until all or one of the iterables are over
Python's build-in function in JS.
# Install
```bash
npm i python-zip
```# Usage
Default export is the "classic" zip function (quitting when one of the iterables is over).
Another export is the `zipLongest` function, who iterates until all the iterables are over.
## Default
```ts
import zip from 'python-zip';const a = [1, 3, 5];
const b = [2, 4, 6];for (const [i, j] of zip(a, b)) {
console.log(i, j); // => 1 2 then 3 4 then 5 6
}
```## Longest
```ts
import { zipLongest } from 'python-zip';const a = [1, 3, 5, 7, 9];
const b = [2, 4, 6];for (const [i, j] of zipLongest(a, b)) {
console.log(i, j); // => 1 2 then 3 4 then 5 6 then 7 undefined then 9 undefined
}
```