# hash-index

> A hashing function which returns integers with a possible max value

Latest version **3.0.0** (published 2015-07-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install hash-index
pnpm add hash-index
yarn add hash-index
bun add hash-index
```

## 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 | 3.0.0 |
| Published | 2015-07-07 |
| First published | 2015-05-19 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 30 |
| Author | Thomas Watson Steen |
| Maintainers | watson |
| Keywords | hash, hashing, rand, random, int, integer |

## Links

- npm: https://www.npmjs.com/package/hash-index
- Repository: https://github.com/watson/hash-index
- Issues: https://github.com/watson/hash-index/issues
- npm.io page: https://npm.io/package/hash-index

## Alternatives

- [eslint-plugin-sonarjs](https://npm.io/package/eslint-plugin-sonarjs.md) — 2.9M weekly downloads
- [eslint-config-expo](https://npm.io/package/eslint-config-expo.md) — 1.5M weekly downloads
- [@matter/protocol](https://npm.io/package/@matter/protocol.md) — 63.5K weekly downloads
- [@eventcatalog/linter](https://npm.io/package/@eventcatalog/linter.md) — 24.8K weekly downloads
- [@inrupt/eslint-config-base](https://npm.io/package/@inrupt/eslint-config-base.md) — 4.5K weekly downloads

## Recent versions

- 3.0.0 (latest) — 2015-07-07
- 2.0.0 — 2015-06-14
- 1.0.1 — 2015-05-19
- 1.0.0 — 2015-05-19

## README

# hash-index

A function which will always return the same output given the same
input. The output is an integer in the range 0..n. By default `n` is
infinity-1, but another max value can be provided as an optional 2nd
argument.

The output is not guaranteed to be unique - only to be predictable based
on the input.

[![Build status](https://travis-ci.org/watson/hash-index.svg?branch=master)](https://travis-ci.org/watson/hash-index)

[![js-standard-style](https://raw.githubusercontent.com/feross/standard/master/badge.png)](https://github.com/feross/standard)

## Installation

```
npm install hash-index
```

## Usage

```js
var hasher = require('hash-index')

// same input => same output
hasher('bob')   // => 79268366047899
hasher('alice') // => 90345298322240
hasher('bob')   // => 79268366047899
hasher('alice') // => 90345298322240
```

Using the optional 2nd argument, you can supply an upper limit for the
returned hash value:

```js
hasher('bob', 100)   // => 99
hasher('alice', 100) // => 40
hasher('bob', 100)   // => 99
hasher('alice', 100) // => 40
```

## Input validation

If no `max` value is given, infinity-1 is used as the max value.

If `max` is less than `1` then `NaN` will be returned.

The input have to be either a non-empty string, a number or a non-empty
array. If not, `NaN` will be returned.

## License

MIT

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