You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

hash-index

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hash-index

A hashing function which outputs integers with a possible max value

Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

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 where n is the max value given upon initialization of the module.

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

Build status

js-standard-style

Installation

npm install hash-index

Usage

// initialize with a max output of 100
var hasher = require('hash-index')(100)

hasher('foo') // => 9
hasher('bar') // => 73
hasher('foo') // => 9
hasher('bar') // => 73

Non-standard Usage

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

If the input is not either a non-empty string, a non-empty array or a number, NaN will be returned.

License

MIT

Keywords

hash

FAQs

Package last updated on 19 May 2015

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts