Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/alkihis/python-enumerate
https://github.com/alkihis/python-enumerate
Last synced: about 1 month ago
JSON representation
- Host: GitHub
- URL: https://github.com/alkihis/python-enumerate
- Owner: alkihis
- License: cc-by-sa-4.0
- Created: 2019-05-16T09:24:25.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2020-08-13T16:02:49.000Z (over 4 years ago)
- Last Synced: 2024-10-12T12:32:57.998Z (about 1 month ago)
- Language: JavaScript
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# python-enumerate
> Enumerate through an Iterable and get the index
Python's build-in function in JS.
# Install
```bash
npm i python-enumerate
```# Usage
Takes one iterable, and return a tuple of [index, current_element].
You can specify a base index (it will NOT change the order / beginning of where the iteration starts in iterable).## Default
```ts
import enumerate from 'python-enumerate';const a = [1, 3, 5];
for (const [i, v] of enumerate(a)) {
console.log(i, v); // => 0 1 then 1 3 then 2 5
}
```