Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 5f1b4a784e | |||
| 2da9122c68 | |||
| 5d80323baa | |||
| 72fccebf14 | |||
| 7faf31147d | |||
| d479cd9e7e | |||
| f479c11574 | |||
| 7df770f9fb |
4
package-lock.json
generated
4
package-lock.json
generated
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartping",
|
"name": "@pushrocks/smartping",
|
||||||
"version": "1.0.3",
|
"version": "1.0.7",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "@pushrocks/smartping",
|
"name": "@pushrocks/smartping",
|
||||||
"version": "1.0.3",
|
"version": "1.0.7",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.25",
|
"@gitzone/tsbuild": "^2.1.25",
|
||||||
|
|||||||
10
package.json
10
package.json
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartping",
|
"name": "@pushrocks/smartping",
|
||||||
"version": "1.0.3",
|
"version": "1.0.7",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "a ping utility",
|
"description": "a ping utility",
|
||||||
"main": "dist_ts/index.js",
|
"main": "dist_ts/index.js",
|
||||||
@@ -13,15 +13,19 @@
|
|||||||
"build": "(tsbuild --web --allowimplicitany)",
|
"build": "(tsbuild --web --allowimplicitany)",
|
||||||
"buildDocs": "(tsdoc)"
|
"buildDocs": "(tsdoc)"
|
||||||
},
|
},
|
||||||
|
"dependencies": {
|
||||||
|
"@types/ping": "^0.4.1",
|
||||||
|
"ping": "^0.4.2"
|
||||||
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@gitzone/tsbuild": "^2.1.25",
|
"@gitzone/tsbuild": "^2.1.25",
|
||||||
"@gitzone/tsbundle": "^2.0.5",
|
"@gitzone/tsbundle": "^2.0.5",
|
||||||
"@gitzone/tsdoc": "^1.1.10",
|
"@gitzone/tsdoc": "^1.1.10",
|
||||||
|
"@gitzone/tsrun": "^1.2.38",
|
||||||
"@gitzone/tstest": "^1.0.44",
|
"@gitzone/tstest": "^1.0.44",
|
||||||
"@pushrocks/tapbundle": "^5.0.3",
|
"@pushrocks/tapbundle": "^5.0.3",
|
||||||
"@types/node": "^17.0.41"
|
"@types/node": "^18.11.2"
|
||||||
},
|
},
|
||||||
"dependencies": {},
|
|
||||||
"browserslist": [
|
"browserslist": [
|
||||||
"last 1 chrome versions"
|
"last 1 chrome versions"
|
||||||
],
|
],
|
||||||
|
|||||||
4409
pnpm-lock.yaml
generated
Normal file
4409
pnpm-lock.yaml
generated
Normal file
File diff suppressed because it is too large
Load Diff
16
test/test.ts
16
test/test.ts
@@ -1,8 +1,20 @@
|
|||||||
import { expect, expectAsync, tap } from '@pushrocks/tapbundle';
|
import { expect, expectAsync, tap } from '@pushrocks/tapbundle';
|
||||||
import * as smartping from '../ts/index.js';
|
import * as smartping from '../ts/index.js';
|
||||||
|
|
||||||
tap.test('first test', async () => {
|
let testPing: smartping.Smartping;
|
||||||
console.log(smartping);
|
|
||||||
|
tap.test('should create an instance of Smartping', async () => {
|
||||||
|
testPing = new smartping.Smartping();
|
||||||
|
expect(testPing).toBeInstanceOf(smartping.Smartping);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
tap.test('should deliver a ping result', async () => {
|
||||||
|
const result = await testPing.ping('lossless.com', 1000);
|
||||||
|
console.log(result);
|
||||||
|
})
|
||||||
|
|
||||||
|
tap.test('should detect alive', async () => {
|
||||||
|
await expectAsync(testPing.pingAlive('lossless.com', 1000)).toBeTrue();
|
||||||
|
})
|
||||||
|
|
||||||
tap.start();
|
tap.start();
|
||||||
|
|||||||
@@ -3,6 +3,6 @@
|
|||||||
*/
|
*/
|
||||||
export const commitinfo = {
|
export const commitinfo = {
|
||||||
name: '@pushrocks/smartping',
|
name: '@pushrocks/smartping',
|
||||||
version: '1.0.3',
|
version: '1.0.7',
|
||||||
description: 'a ping utility'
|
description: 'a ping utility'
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +1 @@
|
|||||||
import * as plugins from './smartping.plugins.js';
|
export * from './smartping.classes.smartping.js';
|
||||||
|
|
||||||
export let demoExport = 'Hi there! :) This is an exported string';
|
|
||||||
|
|||||||
22
ts/smartping.classes.smartping.ts
Normal file
22
ts/smartping.classes.smartping.ts
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import * as plugins from './smartping.plugins.js';
|
||||||
|
|
||||||
|
export class Smartping {
|
||||||
|
public async ping(hostArg: string, timeoutArg: number = 500): Promise<plugins.ping.PingResponse> {
|
||||||
|
const result = await plugins.ping.promise.probe(hostArg, {
|
||||||
|
timeout: timeoutArg
|
||||||
|
})
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async pingAlive(hostArg: string, timeoutArg: number = 500): Promise<boolean> {
|
||||||
|
const result = await plugins.ping.promise.probe(hostArg, {
|
||||||
|
timeout: timeoutArg
|
||||||
|
}).catch();
|
||||||
|
//console.log(result);
|
||||||
|
if (result.alive) {
|
||||||
|
return true;
|
||||||
|
} else {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,2 +1,5 @@
|
|||||||
const removeme = {};
|
import ping from 'ping';
|
||||||
export { removeme };
|
|
||||||
|
export {
|
||||||
|
ping
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user