Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/mafintosh/hash-to-port

Hash a value to a valid port
https://github.com/mafintosh/hash-to-port

Last synced: 17 days ago
JSON representation

Hash a value to a valid port

Awesome Lists containing this project

README

        

# hash-to-port

Hash a value to a valid port

```
npm install hash-to-port
```

[![build status](http://img.shields.io/travis/mafintosh/hash-to-port.svg?style=flat)](http://travis-ci.org/mafintosh/hash-to-port)

## Usage

``` js
var toPort = require('hash-to-port')

console.log(toPort('example.com')) // returns 22019
```

## API

#### `var port = toPort(value, ?from, ?to)`

Hash the given value to a valid port (`>= from <= to`).
The same value will *always* hash to the same port but note that two different values might hash to the same port as well

- `value`
- `from` (default: `1024`)
- `to` (default: `65535`)

## License

MIT