# endpoint-utils

> Utils to deal with TCP ports and hostnames. Safe for everyday use.

Latest version **1.0.2** (published 2016-06-29) · MIT license · 0 weekly downloads

## Install

```sh
npm install endpoint-utils
pnpm add endpoint-utils
yarn add endpoint-utils
bun add endpoint-utils
```

## 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.2 |
| Published | 2016-06-29 |
| First published | 2015-10-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| Author | Ivan Nikulin |
| Maintainers | inikulin |
| Keywords | free, port, get, check, tcp, server, http, host, hostname, mine |

## Links

- npm: https://www.npmjs.com/package/endpoint-utils
- Repository: https://github.com/inikulin/endpoint-utils
- Homepage: https://github.com/inikulin/endpoint-utils#readme
- Issues: https://github.com/inikulin/endpoint-utils/issues
- npm.io page: https://npm.io/package/endpoint-utils

## Dependencies (2)

- [ip](https://npm.io/package/ip.md) ^1.1.3
- [pinkie-promise](https://npm.io/package/pinkie-promise.md) ^1.0.0

## Alternatives

- [@clerk/clerk-expo](https://npm.io/package/@clerk/clerk-expo.md) — 133.6K weekly downloads
- [@pothos/plugin-authz](https://npm.io/package/@pothos/plugin-authz.md) — 12.4K weekly downloads
- [@bounded-sh/client](https://npm.io/package/@bounded-sh/client.md) — 3.2K weekly downloads
- [@luigi-project/plugin-auth-oauth2](https://npm.io/package/@luigi-project/plugin-auth-oauth2.md) — 2.3K weekly downloads
- [@nocobase/plugin-verification](https://npm.io/package/@nocobase/plugin-verification.md) — 2.0K weekly downloads

## Recent versions

- 1.0.2 (latest) — 2016-06-29
- 1.0.4-preview (preview) — 2015-12-08
- 1.0.3-preview — 2015-12-08
- 1.0.2-preview — 2015-12-08
- 1.0.1 — 2015-10-29
- 1.0.0 — 2015-10-14

## README

# endpoint-utils
[![Build Status](https://api.travis-ci.org/inikulin/endpoint-utils.svg)](https://travis-ci.org/inikulin/endpoint-utils)

*Utils to deal with TCP ports and hostnames. Safe for everyday use.*

## Install
```
npm install endpoint-utils
```

## Usage
### Get free port
```js
const getFreePort = require('endpoint-utils').getFreePort;

getFreePort().then(port => {
    console.log(port);
    //> 1337
});
```

### Get multiple free ports
```js
const getFreePorts = require('endpoint-utils').getFreePorts;

getFreePorts(3).then(ports => {
    console.log(ports);
    //> [1337, 1338, 1339]
});
```

### Check if port is free
```js
const isFreePort = require('endpoint-utils').isFreePort;

isFreePort(1337).then(isFree => {
    console.log(isFree);
    //> true
});
```

### Check if hostname or IP address resolves to the current machine
```js
const isMyHostname = require('endpoint-utils').isMyHostname;

isMyHostname('inikulin').then(isMy => {
    console.log(isMy);
    //> true
});

isMyHostname('172.22.5.80').then(isMy => {
    console.log(isMy);
    //> true
});
```

### Get hostname or IP address which can be resolved to the current machine
```js
const getMyHostname = require('endpoint-utils').getMyHostname;

getMyHostname().then(hostname => {
    console.log(hostname);
    //> "inikulin.local"
});
```

### Get IP address of current machine
```js
const getIPAddress = require('endpoint-utils').getIPAddress;

console.log(getIPAddress());
//> "172.22.5.80"
```

## Author
[Ivan Nikulin](https://github.com/inikulin) (ifaaan@gmail.com)

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