Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

detect-port

Package Overview
Dependencies
Maintainers
1
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

detect-port - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

.CONTRIBUTING.md.swm

4

CONTRIBUTING.md

@@ -1,3 +0,3 @@

Contributing to macaca
======================
Contributing to detect-port
===========================

@@ -4,0 +4,0 @@ - Fork the project, make a change, and send a pull request;

@@ -18,7 +18,16 @@ /* ================================================================

var localhost = '0.0.0.0';
var options = global.__detect ? global.__detect.options : {};
var inject = function(port) {
var options = global.__detect ? global.__detect.options : {};
if (options.verbose) {
console.log('port %d was occupied', port);
}
};
function detect(port, fn) {
var _detect = function(_fn) {
var server = http.createServer();
server.listen(port, localhost, function() {

@@ -35,7 +44,5 @@ server.once('close', function() {

});
server.on('error', function() {
if (options.verbose) {
console.log('Port %d was occupied', port);
}
inject(port);
port++;

@@ -42,0 +49,0 @@

{
"name": "detect-port",
"version": "0.1.0",
"description": "detect free port",
"version": "0.1.1",
"description": "port detector",
"keywords": ["detect", "port", "detect-port"],

@@ -16,4 +16,3 @@ "bin": {

"dependencies": {
"co": "3",
"commander": "~2.0.0"
"commander": "~2.8.1"
},

@@ -24,3 +23,3 @@ "devDependencies": {

"istanbul": "*",
"should": "~4.0.4",
"should": "~6.0.3",
"jshint": "*"

@@ -36,3 +35,3 @@ },

"engines": {
"node": ">= 10.0.x"
"node": ">= 11.14.x"
},

@@ -39,0 +38,0 @@ "author": "xudafeng",

detect-port
===========
[![NPM version][npm-image]][npm-url]
[![build status][travis-image]][travis-url]
[![Test coverage][coveralls-image]][coveralls-url]
[![node version][node-image]][node-url]
[![npm download][download-image]][download-url]
[npm-image]: https://img.shields.io/npm/v/detect-port.svg?style=flat-square
[npm-url]: https://npmjs.org/package/detect-port
[travis-image]: https://img.shields.io/travis/xudafeng/detect-port.svg?style=flat-square
[travis-url]: https://travis-ci.org/xudafeng/detect-port
[coveralls-image]: https://img.shields.io/coveralls/xudafeng/detect-port.svg?style=flat-square
[coveralls-url]: https://coveralls.io/r/xudafeng/detect-port?branch=master
[node-image]: https://img.shields.io/badge/node.js-%3E=_0.11.14-green.svg?style=flat-square
[node-url]: http://nodejs.org/download/
[download-image]: https://img.shields.io/npm/dm/detect-port.svg?style=flat-square
[download-url]: https://npmjs.org/package/detect-port
> port detector

@@ -8,3 +25,3 @@

```bash
```shell
$ npm i detect-port -g

@@ -15,6 +32,72 @@ ```

```bash
```shell
# detect port 80
$ detect -p 80
# or like this
$ detect --port 80
# will get result below
$ port: 80 was occupied, try port: 1024
# with verbose
$ detect --port 80 --verbose
# more help?
$ detect -h
```
## Use As Module
```js
var detect = require('detect-port');
/**
* normal usage
*/
detect(port, function(_port) {
if (port === _port) {
console.log('port: %d was not occupied', port);
} else {
console.log('port: %d was occupied, try port: %d', port, _port);
}
});
/**
* use in co v3
* for a yield syntax instead of callback function implement
*/
var co = require('co');
co(function *() {
var _port = yield detect(port);
if (port === _port) {
console.log('port: %d was not occupied', port);
} else {
console.log('port: %d was occupied, try port: %d', port, _port);
}
})();
```
## Clone and Run test
```shell
# clone from git
$ git clone git://github.com/xudafeng/detect-port.git
$ cd detect-port
# install dependencies
$ make install
# test and coverage
$ make test
```
## License

@@ -24,2 +107,2 @@

Copyright (c) 2014 xdf
Copyright (c) 2015 xdf

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc