Last change
on this file since 76712b2 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.8 KB
|
Rev | Line | |
---|
[6a3a178] | 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 |
|
---|
| 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.