https://github.com/lambdalisue/deno-indexer
🦕 The indexer library is a Deno module that provides a class called Indexer, which generates index numbers.
https://github.com/lambdalisue/deno-indexer
deno indexer jsr
Last synced: 27 days ago
JSON representation
🦕 The indexer library is a Deno module that provides a class called Indexer, which generates index numbers.
- Host: GitHub
- URL: https://github.com/lambdalisue/deno-indexer
- Owner: lambdalisue
- License: mit
- Created: 2023-04-27T14:00:15.000Z (almost 2 years ago)
- Default Branch: main
- Last Pushed: 2024-04-06T07:27:45.000Z (about 1 year ago)
- Last Synced: 2025-03-09T05:47:14.978Z (about 2 months ago)
- Topics: deno, indexer, jsr
- Language: TypeScript
- Homepage: https://jsr.io/@lambdalisue/indexer
- Size: 9.77 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# indexer
[](https://jsr.io/@lambdalisue/indexer)
[](https://github.com/lambdalisue/deno-indexer/releases)
[](https://doc.deno.land/https/deno.land/x/indexer/mod.ts)
[](https://github.com/lambdalisue/deno-indexer/actions?query=workflow%3ATest)The `indexer` library is a [Deno] module that provides a class called `Indexer`,
which generates index numbers.## Usage
To use the `Indexer` class, you first need to import it from the `indexer`
module:```typescript
import { Indexer } from "@lambdalisue/indexer";
```You can then create a new instance of the `Indexer` class with an optional `max`
value:```typescript
const indexer = new Indexer(10);
```This creates an `Indexer` instance with a maximum index value of 10. If the
`max` parameter is omitted, the maximum safe integer value will be used instead.You can generate index numbers by calling the `next()` method on the `Indexer`
instance:```typescript
const index1 = indexer.next(); // 0
const index2 = indexer.next(); // 1
const index3 = indexer.next(); // 2
// ...
const index10 = indexer.next(); // 9
```When the index number reaches the maximum value, it will be reset to 0 and the
`next()` method will start generating index numbers from 0 again.## License
The code follows the MIT license written in [LICENSE](./LICENSE). Contributors
need to agree that any modifications sent in this repository follow the license.[Deno]: https://deno.land/