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",
|
||||
"version": "1.0.3",
|
||||
"version": "1.0.7",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "@pushrocks/smartping",
|
||||
"version": "1.0.3",
|
||||
"version": "1.0.7",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.1.25",
|
||||
|
||||
10
package.json
10
package.json
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@pushrocks/smartping",
|
||||
"version": "1.0.3",
|
||||
"version": "1.0.7",
|
||||
"private": false,
|
||||
"description": "a ping utility",
|
||||
"main": "dist_ts/index.js",
|
||||
@@ -13,15 +13,19 @@
|
||||
"build": "(tsbuild --web --allowimplicitany)",
|
||||
"buildDocs": "(tsdoc)"
|
||||
},
|
||||
"dependencies": {
|
||||
"@types/ping": "^0.4.1",
|
||||
"ping": "^0.4.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@gitzone/tsbuild": "^2.1.25",
|
||||
"@gitzone/tsbundle": "^2.0.5",
|
||||
"@gitzone/tsdoc": "^1.1.10",
|
||||
"@gitzone/tsrun": "^1.2.38",
|
||||
"@gitzone/tstest": "^1.0.44",
|
||||
"@pushrocks/tapbundle": "^5.0.3",
|
||||
"@types/node": "^17.0.41"
|
||||
"@types/node": "^18.11.2"
|
||||
},
|
||||
"dependencies": {},
|
||||
"browserslist": [
|
||||
"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 * as smartping from '../ts/index.js';
|
||||
|
||||
tap.test('first test', async () => {
|
||||
console.log(smartping);
|
||||
let testPing: smartping.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();
|
||||
|
||||
@@ -3,6 +3,6 @@
|
||||
*/
|
||||
export const commitinfo = {
|
||||
name: '@pushrocks/smartping',
|
||||
version: '1.0.3',
|
||||
version: '1.0.7',
|
||||
description: 'a ping utility'
|
||||
}
|
||||
|
||||
@@ -1,3 +1 @@
|
||||
import * as plugins from './smartping.plugins.js';
|
||||
|
||||
export let demoExport = 'Hi there! :) This is an exported string';
|
||||
export * from './smartping.classes.smartping.js';
|
||||
|
||||
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 = {};
|
||||
export { removeme };
|
||||
import ping from 'ping';
|
||||
|
||||
export {
|
||||
ping
|
||||
}
|
||||
Reference in New Issue
Block a user