Compare commits

...

4 Commits

Author SHA1 Message Date
f709238e50 2.0.2 2021-04-13 10:09:40 +00:00
49940635d5 fix(core): update 2021-04-13 10:09:39 +00:00
ec4121cbcf 2.0.1 2021-04-13 10:09:09 +00:00
ea9a2572f9 fix(core): update 2021-04-13 10:09:09 +00:00
4 changed files with 5 additions and 5 deletions

2
package-lock.json generated
View File

@ -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": {

View File

@ -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",

View File

@ -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 () => {

View File

@ -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