New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ko-port

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ko-port

make sure get an available port on your server

  • 1.2.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

ko-port

make sure get an available port on your server

支持本地安装(Local Installation)

$ npm install ko-port

支持全局安装(Global Installation)

$ npm install ko-port -g

支持API

  • asyncPort(port: number): Promise<any>

识别指定port是否可用,否则递归加1,返回有效port

样例:

var koport = require('ko-port');

koport.asyncPort(3000)
  .then((port) => {
      // 返回有效port
      http.createServer(app).listen(port, function () {
          console.log('listening on port ', port)
      })
  })
  .catch((err) => {
      // 返回err
  });
  • killPort(port: number): Promise<any>

杀死指定的port占用进程

样例:

var koport = require('ko-port');

koport.killPort(3000)
  .then(() => {
      // success
  })
  .catch((err) => {
      // error
  });

如果是全局(Global)安装:

$ koport 3000

Keywords

FAQs

Package last updated on 30 Jul 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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