Compare commits
4 Commits
Author | SHA1 | Date | |
---|---|---|---|
f709238e50 | |||
49940635d5 | |||
ec4121cbcf | |||
ea9a2572f9 |
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartnetwork",
|
"name": "@pushrocks/smartnetwork",
|
||||||
"version": "2.0.0",
|
"version": "2.0.2",
|
||||||
"lockfileVersion": 1,
|
"lockfileVersion": 1,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartnetwork",
|
"name": "@pushrocks/smartnetwork",
|
||||||
"version": "2.0.0",
|
"version": "2.0.2",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "network diagnostics",
|
"description": "network diagnostics",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
|
@ -9,13 +9,13 @@ tap.test('should create a valid instance of SmartNetwork', async () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
tap.test('should perform a speedtest', async () => {
|
tap.test('should perform a speedtest', async () => {
|
||||||
let result = await testSmartNetwork.getSpeed();
|
const result = await testSmartNetwork.getSpeed();
|
||||||
console.log(`Download speed for this instance is ${result.speeds.download}`);
|
console.log(`Download speed for this instance is ${result.speeds.download}`);
|
||||||
console.log(`Upload speed for this instance is ${result.speeds.upload}`);
|
console.log(`Upload speed for this instance is ${result.speeds.upload}`);
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('should determine wether a port is free', async () => {
|
tap.test('should determine wether a port is free', async () => {
|
||||||
await expect(testSmartNetwork.isLocalPortAvailable(8080)).to.eventually.be.true;
|
await expect(testSmartNetwork.isLocalPortUnused(8080)).to.eventually.be.true;
|
||||||
});
|
});
|
||||||
|
|
||||||
tap.test('should scan a port', async () => {
|
tap.test('should scan a port', async () => {
|
||||||
|
@ -57,7 +57,7 @@ export class SmartNetwork {
|
|||||||
* note: false also resolves with false as argument
|
* note: false also resolves with false as argument
|
||||||
* @param port
|
* @param port
|
||||||
*/
|
*/
|
||||||
public async isLocalPortAvailable(port: number): Promise<boolean> {
|
public async isLocalPortUnused(port: number): Promise<boolean> {
|
||||||
const doneIpV4 = plugins.smartpromise.defer<boolean>();
|
const doneIpV4 = plugins.smartpromise.defer<boolean>();
|
||||||
const doneIpV6 = plugins.smartpromise.defer<boolean>();
|
const doneIpV6 = plugins.smartpromise.defer<boolean>();
|
||||||
const net = await import('net'); // creates only one instance of net ;) even on multiple calls
|
const net = await import('net'); // creates only one instance of net ;) even on multiple calls
|
||||||
|
Reference in New Issue
Block a user