# enumerate-array

> Clones an Array and wraps it in a Java-like Enumeration interface.

Latest version **1.0.0** (published 2016-03-08) · ISC license · 0 weekly downloads

## Install

```sh
npm install enumerate-array
pnpm add enumerate-array
yarn add enumerate-array
bun add enumerate-array
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2016-03-08 |
| First published | 2016-03-08 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Ethan B Martin |
| Maintainers | ethan.b.martin |
| Keywords | enumerate, enumeration, Enumeration-interface, array, list, hasNext, hasMoreElements |

## Links

- npm: https://www.npmjs.com/package/enumerate-array
- Repository: https://github.com/Pilatch/enumerate-array
- Homepage: https://github.com/Pilatch/enumerate-array#readme
- Issues: https://github.com/Pilatch/enumerate-array/issues
- npm.io page: https://npm.io/package/enumerate-array

## Recent versions

- 1.0.0 (latest) — 2016-03-08

## README

# enumerate-array

Node utility that clones an Array and wraps it in a [Java-like Enumeration interface](https://docs.oracle.com/javase/7/docs/api/java/util/Enumeration.html).

## Usage

    var enumerateArray = require("enumerate-array")
    var enumeration = enumerateArray(["foo", "bar", "baz"])

That enumeration has the following methods:

    .hasNext() // returns a Boolean showing whether the enumeration has more elements
    .next() // remove the next element from the enumeration, and return it
    .toArray() // clone the enumeration's internal array, and return it
    .toString() // return the internal array's .toString()

## Examples

Here we loop through an array, while-style.

    var enumerateArray = require("enumerate-array")
    var greenIceCreamsArray = ["pistachio", "mink chocolate chip", "green tea"]
    var greenIceCreamsEnumeration = enumerateArray(greenIceCreamsArray)

    while ( greenIceCreamsEnumeration.hasNext() ) {
      console.log( greenIceCreamsEnumeration.next() )
    }
    // -> "pistachio"
    // -> "mink chocolate chip"
    // -> "green tea"

    console.log(greenIceCreamsArray) // the original array is unchanged
    // -> [ 'pistachio', 'mink chocolate chip', 'green tea' ]

We can also get a copy of the enumeration as an array, minus the elements we used.

    var coolNumbersArray = [2.71828, 3.14159, 42, 451, 1984, 9001, 8675309]
    var coolNumbersEnumeration = enumerateArray(coolNumbersArray)

    console.log( coolNumbersEnumeration.next() )
    // -> 2.71828
    console.log( coolNumbersEnumeration.next() )
    // -> 3.14159
    console.log( coolNumbersEnumeration.toArray() )
    // -> [ 42, 451, 1984, 9001, 8675309 ]
    console.log( coolNumbersEnumeration.next() )
    // -> 42

---
_Source: https://npm.io/package/enumerate-array · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
