aboutsummaryrefslogtreecommitdiff
path: root/node_modules/get-port
diff options
context:
space:
mode:
authorruki <waruqi@gmail.com>2018-11-08 00:38:48 +0800
committerruki <waruqi@gmail.com>2018-11-07 21:53:09 +0800
commit26105034da4fcce7ac883c899d781f016559310d (patch)
treec459a5dc4e3aa0972d9919033ece511ce76dd129 /node_modules/get-port
parent2c77f00f1a7ecb6c8192f9c16d3b2001b254a107 (diff)
downloadxmake-docs-26105034da4fcce7ac883c899d781f016559310d.tar.gz
xmake-docs-26105034da4fcce7ac883c899d781f016559310d.zip
switch to vuepress
Diffstat (limited to 'node_modules/get-port')
-rw-r--r--node_modules/get-port/index.js28
-rw-r--r--node_modules/get-port/license9
-rw-r--r--node_modules/get-port/package.json44
-rw-r--r--node_modules/get-port/readme.md64
4 files changed, 145 insertions, 0 deletions
diff --git a/node_modules/get-port/index.js b/node_modules/get-port/index.js
new file mode 100644
index 00000000..fbd74e6e
--- /dev/null
+++ b/node_modules/get-port/index.js
@@ -0,0 +1,28 @@
+'use strict';
+const net = require('net');
+
+const getPort = options => new Promise((resolve, reject) => {
+ // For backwards compatibility with number-only input
+ // TODO: Remove this in the next major version
+ if (typeof options === 'number') {
+ options = {
+ port: options
+ };
+ }
+
+ const server = net.createServer();
+
+ server.unref();
+ server.on('error', reject);
+
+ server.listen(options, () => {
+ const port = server.address().port;
+ server.close(() => {
+ resolve(port);
+ });
+ });
+});
+
+module.exports = options => options ?
+ getPort(options).catch(() => getPort(0)) :
+ getPort(0);
diff --git a/node_modules/get-port/license b/node_modules/get-port/license
new file mode 100644
index 00000000..e7af2f77
--- /dev/null
+++ b/node_modules/get-port/license
@@ -0,0 +1,9 @@
+MIT License
+
+Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/node_modules/get-port/package.json b/node_modules/get-port/package.json
new file mode 100644
index 00000000..3fe19225
--- /dev/null
+++ b/node_modules/get-port/package.json
@@ -0,0 +1,44 @@
+{
+ "name": "get-port",
+ "version": "3.2.0",
+ "description": "Get an available port",
+ "license": "MIT",
+ "repository": "sindresorhus/get-port",
+ "author": {
+ "name": "Sindre Sorhus",
+ "email": "sindresorhus@gmail.com",
+ "url": "sindresorhus.com"
+ },
+ "engines": {
+ "node": ">=4"
+ },
+ "scripts": {
+ "test": "xo && ava"
+ },
+ "files": [
+ "index.js"
+ ],
+ "keywords": [
+ "port",
+ "find",
+ "finder",
+ "portfinder",
+ "free",
+ "available",
+ "connection",
+ "connect",
+ "open",
+ "net",
+ "tcp",
+ "scan",
+ "rand",
+ "random",
+ "preferred",
+ "chosen"
+ ],
+ "devDependencies": {
+ "ava": "*",
+ "pify": "^3.0.0",
+ "xo": "*"
+ }
+}
diff --git a/node_modules/get-port/readme.md b/node_modules/get-port/readme.md
new file mode 100644
index 00000000..72c1fbc0
--- /dev/null
+++ b/node_modules/get-port/readme.md
@@ -0,0 +1,64 @@
+# get-port [![Build Status](https://travis-ci.org/sindresorhus/get-port.svg?branch=master)](https://travis-ci.org/sindresorhus/get-port)
+
+> Get an available port
+
+
+## Install
+
+```
+$ npm install get-port
+```
+
+
+## Usage
+
+```js
+const getPort = require('get-port');
+
+getPort().then(port => {
+ console.log(port);
+ //=> 51402
+});
+```
+
+Optionally, pass in a preferred port:
+
+```js
+getPort({port: 3000}).then(port => {
+ console.log(port);
+ // Will use 3000 if available, otherwise fall back to a random port
+});
+```
+
+
+## API
+
+### getPort([options])
+
+Returns a `Promise` for a port number.
+
+#### options
+
+Type: `Object`
+
+##### port
+
+Type: `number`
+
+The preferred port to use.
+
+##### host
+
+Type: `string`
+
+The host on which port resolution should be performed. Can be either an IPv4 or IPv6 address.
+
+
+## Related
+
+- [get-port-cli](https://github.com/sindresorhus/get-port-cli) - CLI for this module
+
+
+## License
+
+MIT © [Sindre Sorhus](https://sindresorhus.com)