|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 11 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
1.8 KB
|
| Line | |
|---|
| 1 | # requires-port
|
|---|
| 2 |
|
|---|
| 3 | [](http://unshift.io)[](http://browsenpm.org/package/requires-port)[](https://travis-ci.org/unshiftio/requires-port)[](https://david-dm.org/unshiftio/requires-port)[](https://coveralls.io/r/unshiftio/requires-port?branch=master)[](http://webchat.freenode.net/?channels=unshift)
|
|---|
| 4 |
|
|---|
| 5 | The module name says it all, check if a protocol requires a given port.
|
|---|
| 6 |
|
|---|
| 7 | ## Installation
|
|---|
| 8 |
|
|---|
| 9 | This module is intended to be used with browserify or Node.js and is distributed
|
|---|
| 10 | in the public npm registry. To install it simply run the following command from
|
|---|
| 11 | your CLI:
|
|---|
| 12 |
|
|---|
| 13 | ```j
|
|---|
| 14 | npm install --save requires-port
|
|---|
| 15 | ```
|
|---|
| 16 |
|
|---|
| 17 | ## Usage
|
|---|
| 18 |
|
|---|
| 19 | The module exports it self as function and requires 2 arguments:
|
|---|
| 20 |
|
|---|
| 21 | 1. The port number, can be a string or number.
|
|---|
| 22 | 2. 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 |
|
|---|
| 33 | It returns a boolean that indicates if protocol requires this port to be added
|
|---|
| 34 | to your URL.
|
|---|
| 35 |
|
|---|
| 36 | ```js
|
|---|
| 37 | 'use strict';
|
|---|
| 38 |
|
|---|
| 39 | var required = require('requires-port');
|
|---|
| 40 |
|
|---|
| 41 | console.log(required('8080', 'http')) // true
|
|---|
| 42 | console.log(required('80', 'http')) // false
|
|---|
| 43 | ```
|
|---|
| 44 |
|
|---|
| 45 | # License
|
|---|
| 46 |
|
|---|
| 47 | MIT
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.