UNPKG

1.81 kBMarkdownView Raw
1# requires-port
2
3[![Made by unshift](https://img.shields.io/badge/made%20by-unshift-00ffcc.svg?style=flat-square)](http://unshift.io)[![Version npm](http://img.shields.io/npm/v/requires-port.svg?style=flat-square)](http://browsenpm.org/package/requires-port)[![Build Status](http://img.shields.io/travis/unshiftio/requires-port/master.svg?style=flat-square)](https://travis-ci.org/unshiftio/requires-port)[![Dependencies](https://img.shields.io/david/unshiftio/requires-port.svg?style=flat-square)](https://david-dm.org/unshiftio/requires-port)[![Coverage Status](http://img.shields.io/coveralls/unshiftio/requires-port/master.svg?style=flat-square)](https://coveralls.io/r/unshiftio/requires-port?branch=master)[![IRC channel](http://img.shields.io/badge/IRC-irc.freenode.net%23unshift-00a8ff.svg?style=flat-square)](http://webchat.freenode.net/?channels=unshift)
4
5The module name says it all, check if a protocol requires a given port.
6
7## Installation
8
9This module is intended to be used with browserify or Node.js and is distributed
10in the public npm registry. To install it simply run the following command from
11your CLI:
12
13```j
14npm install --save requires-port
15```
16
17## Usage
18
19The module exports it self as function and requires 2 arguments:
20
211. The port number, can be a string or number.
222. Protocol, can be `http`, `http:` or even `https://yomoma.com`. We just split
23 it at `:` and use the first result. We currently accept the following
24 protocols:
25 - `http`
26 - `https`
27 - `ws`
28 - `wss`
29 - `ftp`
30 - `gopher`
31 - `file`
32
33It returns a boolean that indicates if protocol requires this port to be added
34to your URL.
35
36```js
37'use strict';
38
39var required = require('requires-port');
40
41console.log(required('8080', 'http')) // true
42console.log(required('80', 'http')) // false
43```
44
45# License
46
47MIT