python-enumerate
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

python-enumerate

Enumerate through an Iterable and get the index

Python's build-in function in JS.

Install

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

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 4 then 2 6
}

Readme

Keywords

Package Sidebar

Install

npm i python-enumerate

Weekly Downloads

1

Version

1.0.1

License

CC BY-SA 4.0

Unpacked Size

23.1 kB

Total Files

7

Last publish

Collaborators

  • alkihis