is-port-reachable 项目使用教程

随笔4小时前发布 王二
4 0 0

is-port-reachable 项目使用教程

is-port-reachableCheck if a local or remote port is reachable项目地址:https://gitcode.com/gh_mirrors/is/is-port-reachable

1. 项目的目录结构及介绍




is-port-reachable/


├── index.d.ts


├── index.js


├── license


├── package.json


├── readme.md


└── test


    └── index.js

index.d.ts: TypeScript 类型定义文件。index.js: 项目的主文件,包含主要的逻辑代码。license: 项目的许可证文件。package.json: 项目的配置文件,包含依赖、脚本等信息。readme.md: 项目的说明文档。test/index.js: 项目的测试文件。

2. 项目的启动文件介绍

项目的启动文件是 index.js,该文件导出了一个函数 isPortReachable,用于检查指定端口是否可达。




import isPortReachable from 'is-port-reachable';


 


(async () => {


  console.log(await isPortReachable(80, { host: 'google.com' })); //=> true


})();

3. 项目的配置文件介绍

项目的配置文件是 package.json,该文件包含了项目的基本信息、依赖、脚本等。




{


  "name": "is-port-reachable",


  "version": "4.0.0",


  "description": "Check if a local or remote port is reachable",


  "license": "MIT",


  "repository": "sindresorhus/is-port-reachable",


  "funding": "https://github.com/sponsors/sindresorhus",


  "author": {


    "name": "Sindre Sorhus",


    "email": "sindresorhus@gmail.com",


    "url": "sindresorhus.com"


  },


  "engines": {


    "node": ">=10"


  },


  "scripts": {


    "test": "xo && ava"


  },


  "files": [


    "index.js",


    "index.d.ts"


  ],


  "keywords": [


    "port",


    "reachable",


    "reachability",


    "local",


    "remote",


    "check",


    "tcp",


    "ip",


    "network",


    "connect",


    "connection",


    "socket"


  ],


  "dependencies": {


    "p-timeout": "^3.0.0"


  },


  "devDependencies": {


    "ava": "^2.4.0",


    "xo": "^0.25.3"


  }


}

name: 项目名称。version: 项目版本。description: 项目描述。license: 项目许可证。repository: 项目仓库地址。author: 项目作者信息。engines: 项目支持的 Node.js 版本。scripts: 项目脚本,如测试脚本。files: 项目包含的文件。keywords: 项目关键词。dependencies: 项目依赖。devDependencies: 开发依赖。

is-port-reachableCheck if a local or remote port is reachable项目地址:https://gitcode.com/gh_mirrors/is/is-port-reachable

© 版权声明

相关文章

暂无评论

您必须登录才能参与评论!
立即登录
暂无评论...