Compare commits
23 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| d61a1cf7f6 | |||
| 1477ceda5d | |||
| 2632bf2082 | |||
| 9803cf6b90 | |||
| 83cd9507ac | |||
| 0837945b81 | |||
| 68c064f260 | |||
| bd95de9152 | |||
| 6864bed88d | |||
| 0bdddc32d1 | |||
| 40651a5660 | |||
| 5f1b4a784e | |||
| 2da9122c68 | |||
| 5d80323baa | |||
| 72fccebf14 | |||
| 7faf31147d | |||
| d479cd9e7e | |||
| f479c11574 | |||
| 7df770f9fb | |||
| 84a6aebd08 | |||
| 15d5ae2669 | |||
| c07f1e42d3 | |||
| d6a4fd0e04 |
+15
-1
@@ -1,6 +1,20 @@
|
|||||||
.nogit/
|
.nogit/
|
||||||
node_modules/
|
|
||||||
|
# artifacts
|
||||||
coverage/
|
coverage/
|
||||||
public/
|
public/
|
||||||
pages/
|
pages/
|
||||||
|
|
||||||
|
# installs
|
||||||
|
node_modules/
|
||||||
|
|
||||||
|
# caches
|
||||||
.yarn/
|
.yarn/
|
||||||
|
.cache/
|
||||||
|
.rpt2_cache
|
||||||
|
|
||||||
|
# builds
|
||||||
|
dist/
|
||||||
|
dist_*/
|
||||||
|
|
||||||
|
# custom
|
||||||
-137
@@ -1,137 +0,0 @@
|
|||||||
# gitzone standard
|
|
||||||
image: hosttoday/ht-docker-node:npmci
|
|
||||||
|
|
||||||
cache:
|
|
||||||
paths:
|
|
||||||
- .npmci_cache/
|
|
||||||
key: "$CI_BUILD_STAGE"
|
|
||||||
|
|
||||||
stages:
|
|
||||||
- security
|
|
||||||
- test
|
|
||||||
- release
|
|
||||||
- metadata
|
|
||||||
|
|
||||||
# ====================
|
|
||||||
# security stage
|
|
||||||
# ====================
|
|
||||||
mirror:
|
|
||||||
stage: security
|
|
||||||
script:
|
|
||||||
- npmci git mirror
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
snyk:
|
|
||||||
stage: security
|
|
||||||
script:
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci command npm install -g snyk
|
|
||||||
- npmci command npm install --ignore-scripts
|
|
||||||
- npmci command snyk test
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
# ====================
|
|
||||||
# test stage
|
|
||||||
# ====================
|
|
||||||
testLEGACY:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci node install legacy
|
|
||||||
- npmci npm install
|
|
||||||
- npmci npm test
|
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
allow_failure: true
|
|
||||||
|
|
||||||
testLTS:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci node install lts
|
|
||||||
- npmci npm install
|
|
||||||
- npmci npm test
|
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
testSTABLE:
|
|
||||||
stage: test
|
|
||||||
script:
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci node install stable
|
|
||||||
- npmci npm install
|
|
||||||
- npmci npm test
|
|
||||||
coverage: /\d+.?\d+?\%\s*coverage/
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
release:
|
|
||||||
stage: release
|
|
||||||
script:
|
|
||||||
- npmci node install stable
|
|
||||||
- npmci npm publish
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
# ====================
|
|
||||||
# metadata stage
|
|
||||||
# ====================
|
|
||||||
codequality:
|
|
||||||
stage: metadata
|
|
||||||
image: docker:stable
|
|
||||||
allow_failure: true
|
|
||||||
services:
|
|
||||||
- docker:stable-dind
|
|
||||||
script:
|
|
||||||
- export SP_VERSION=$(echo "$CI_SERVER_VERSION" | sed 's/^\([0-9]*\)\.\([0-9]*\).*/\1-\2-stable/')
|
|
||||||
- docker run
|
|
||||||
--env SOURCE_CODE="$PWD"
|
|
||||||
--volume "$PWD":/code
|
|
||||||
--volume /var/run/docker.sock:/var/run/docker.sock
|
|
||||||
"registry.gitlab.com/gitlab-org/security-products/codequality:$SP_VERSION" /code
|
|
||||||
artifacts:
|
|
||||||
paths: [codeclimate.json]
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
- priv
|
|
||||||
|
|
||||||
trigger:
|
|
||||||
stage: metadata
|
|
||||||
script:
|
|
||||||
- npmci trigger
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
|
|
||||||
pages:
|
|
||||||
image: hosttoday/ht-docker-node:npmci
|
|
||||||
stage: metadata
|
|
||||||
script:
|
|
||||||
- npmci command npm install -g typedoc typescript
|
|
||||||
- npmci npm prepare
|
|
||||||
- npmci npm install
|
|
||||||
- npmci command typedoc --module "commonjs" --target "ES2016" --out public/ ts/
|
|
||||||
tags:
|
|
||||||
- docker
|
|
||||||
- notpriv
|
|
||||||
only:
|
|
||||||
- tags
|
|
||||||
artifacts:
|
|
||||||
expire_in: 1 week
|
|
||||||
paths:
|
|
||||||
- public
|
|
||||||
allow_failure: true
|
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
{
|
||||||
|
"@ship.zone/szci": {
|
||||||
|
"npmGlobalTools": [],
|
||||||
|
"npmRegistryUrl": "registry.npmjs.org"
|
||||||
|
},
|
||||||
|
"@git.zone/cli": {
|
||||||
|
"projectType": "npm",
|
||||||
|
"module": {
|
||||||
|
"githost": "code.foss.global",
|
||||||
|
"gitscope": "push.rocks",
|
||||||
|
"gitrepo": "smartping",
|
||||||
|
"shortDescription": "Node.js ping utility",
|
||||||
|
"description": "A utility for performing ping operations in Node.js environments.",
|
||||||
|
"npmPackagename": "@push.rocks/smartping",
|
||||||
|
"license": "MIT",
|
||||||
|
"keywords": [
|
||||||
|
"ping",
|
||||||
|
"network",
|
||||||
|
"connectivity",
|
||||||
|
"Node.js",
|
||||||
|
"utility",
|
||||||
|
"async",
|
||||||
|
"promise"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"release": {
|
||||||
|
"registries": [
|
||||||
|
"https://verdaccio.lossless.digital",
|
||||||
|
"https://registry.npmjs.org"
|
||||||
|
],
|
||||||
|
"accessLevel": "public"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"@git.zone/tsdoc": {
|
||||||
|
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
|
||||||
|
}
|
||||||
|
}
|
||||||
Vendored
+11
@@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"command": "npm test",
|
||||||
|
"name": "Run npm test",
|
||||||
|
"request": "launch",
|
||||||
|
"type": "node-terminal"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
Vendored
+26
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"json.schemas": [
|
||||||
|
{
|
||||||
|
"fileMatch": ["/npmextra.json"],
|
||||||
|
"schema": {
|
||||||
|
"type": "object",
|
||||||
|
"properties": {
|
||||||
|
"npmci": {
|
||||||
|
"type": "object",
|
||||||
|
"description": "settings for npmci"
|
||||||
|
},
|
||||||
|
"gitzone": {
|
||||||
|
"type": "object",
|
||||||
|
"description": "settings for gitzone",
|
||||||
|
"properties": {
|
||||||
|
"projectType": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": ["website", "element", "service", "npm", "wcc"]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
@@ -0,0 +1,34 @@
|
|||||||
|
# Changelog
|
||||||
|
|
||||||
|
## 2026-05-01 - 1.0.9 - fix(package)
|
||||||
|
modernize package configuration and stabilize ping typings and tests
|
||||||
|
|
||||||
|
- add package exports and include project metadata files in published package
|
||||||
|
- update build and test tooling to current @git.zone packages and newer ping dependency
|
||||||
|
- replace external host-based tests with localhost node tests for more reliable execution
|
||||||
|
- derive ping response type from the ping library and simplify pingAlive error handling
|
||||||
|
|
||||||
|
## 2026-03-01 - 1.0.8 - maintenance
|
||||||
|
Project maintenance and repository metadata updates across the 1.0.8 line.
|
||||||
|
|
||||||
|
- Removed the `.gitlab-ci.yml` configuration
|
||||||
|
- Updated package metadata and repository hosting configuration
|
||||||
|
- Refreshed TypeScript configuration and project description
|
||||||
|
- Consolidates trivial maintenance changes from 2023-07-10 through 2026-03-01
|
||||||
|
|
||||||
|
## 2023-04-19 - 1.0.8 - core
|
||||||
|
Core update release.
|
||||||
|
|
||||||
|
- Applied a core update
|
||||||
|
|
||||||
|
## 2022-10-21 - 1.0.7 - core
|
||||||
|
Patch release continuing a series of core fixes.
|
||||||
|
|
||||||
|
- Applied a core update
|
||||||
|
- Summarizes repeated trivial patch releases across 1.0.4 to 1.0.7
|
||||||
|
|
||||||
|
## 2018-11-18 - 1.0.1 - core
|
||||||
|
Initial recorded core patch release.
|
||||||
|
|
||||||
|
- Applied a core update
|
||||||
|
- Includes the initial version tagging activity through 1.0.2
|
||||||
@@ -1,4 +1,4 @@
|
|||||||
Copyright (c) 2018 Lossless GmbH (hello@lossless.com)
|
Copyright (c) 2026 Task Venture Capital GmbH <hello@task.vc>
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||||
of this software and associated documentation files (the "Software"), to deal
|
of this software and associated documentation files (the "Software"), to deal
|
||||||
@@ -16,4 +16,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|||||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
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
|
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||||
SOFTWARE.
|
SOFTWARE.
|
||||||
|
|||||||
+34
-2
@@ -1,6 +1,38 @@
|
|||||||
{
|
{
|
||||||
"npmci": {
|
"@ship.zone/szci": {
|
||||||
"npmGlobalTools": [],
|
"npmGlobalTools": [],
|
||||||
"npmAccessLevel": "public"
|
"npmRegistryUrl": "registry.npmjs.org"
|
||||||
|
},
|
||||||
|
"@git.zone/cli": {
|
||||||
|
"projectType": "npm",
|
||||||
|
"module": {
|
||||||
|
"githost": "code.foss.global",
|
||||||
|
"gitscope": "push.rocks",
|
||||||
|
"gitrepo": "smartping",
|
||||||
|
"shortDescription": "Node.js ping utility",
|
||||||
|
"description": "A utility for performing ping operations in Node.js environments.",
|
||||||
|
"npmPackagename": "@push.rocks/smartping",
|
||||||
|
"license": "MIT",
|
||||||
|
"projectDomain": "push.rocks",
|
||||||
|
"keywords": [
|
||||||
|
"ping",
|
||||||
|
"network",
|
||||||
|
"connectivity",
|
||||||
|
"Node.js",
|
||||||
|
"utility",
|
||||||
|
"async",
|
||||||
|
"promise"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"release": {
|
||||||
|
"registries": [
|
||||||
|
"https://verdaccio.lossless.digital",
|
||||||
|
"https://registry.npmjs.org"
|
||||||
|
],
|
||||||
|
"accessLevel": "public"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"@git.zone/tsdoc": {
|
||||||
|
"legal": "\n## License and Legal Information\n\nThis repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository. \n\n**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.\n\n### Trademarks\n\nThis project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.\n\n### Company Information\n\nTask Venture Capital GmbH \nRegistered at District court Bremen HRB 35230 HB, Germany\n\nFor any legal inquiries or if you require further information, please contact us via email at hello@task.vc.\n\nBy using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.\n"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Generated
-1075
File diff suppressed because it is too large
Load Diff
+50
-18
@@ -1,26 +1,58 @@
|
|||||||
{
|
{
|
||||||
"name": "@pushrocks/smartping",
|
"name": "@push.rocks/smartping",
|
||||||
"version": "1.0.2",
|
"version": "1.0.9",
|
||||||
"private": false,
|
"private": false,
|
||||||
"description": "ping urls and ips",
|
"description": "A utility for performing ping operations in Node.js environments.",
|
||||||
"main": "dist/index.js",
|
"exports": {
|
||||||
"typings": "dist/index.d.ts",
|
".": "./dist_ts/index.js"
|
||||||
"author": "Lossless GmbH",
|
},
|
||||||
|
"main": "dist_ts/index.js",
|
||||||
|
"typings": "dist_ts/index.d.ts",
|
||||||
|
"type": "module",
|
||||||
|
"author": "Task Venture Capital GmbH <hello@task.vc>",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "(tstest test/)",
|
"test": "tstest test/",
|
||||||
"build": "(tsbuild)",
|
"build": "tsbuild",
|
||||||
"format": "(gitzone format)"
|
"buildDocs": "tsdoc"
|
||||||
},
|
|
||||||
"devDependencies": {
|
|
||||||
"@gitzone/tsbuild": "^2.0.22",
|
|
||||||
"@gitzone/tstest": "^1.0.15",
|
|
||||||
"@pushrocks/tapbundle": "^3.0.7",
|
|
||||||
"@types/node": "^10.11.7",
|
|
||||||
"tslint": "^5.11.0",
|
|
||||||
"tslint-config-prettier": "^1.15.0"
|
|
||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"ping": "^0.2.2"
|
"ping": "^1.0.0"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"@git.zone/tsbuild": "^4.4.0",
|
||||||
|
"@git.zone/tstest": "^3.6.3",
|
||||||
|
"@types/node": "^25.6.0"
|
||||||
|
},
|
||||||
|
"browserslist": [
|
||||||
|
"last 1 chrome versions"
|
||||||
|
],
|
||||||
|
"files": [
|
||||||
|
"ts/**/*",
|
||||||
|
"ts_web/**/*",
|
||||||
|
"dist/**/*",
|
||||||
|
"dist_*/**/*",
|
||||||
|
"dist_ts/**/*",
|
||||||
|
"dist_ts_web/**/*",
|
||||||
|
"assets/**/*",
|
||||||
|
"cli.js",
|
||||||
|
".smartconfig.json",
|
||||||
|
"license",
|
||||||
|
"npmextra.json",
|
||||||
|
"readme.md"
|
||||||
|
],
|
||||||
|
"keywords": [
|
||||||
|
"ping",
|
||||||
|
"network",
|
||||||
|
"connectivity",
|
||||||
|
"Node.js",
|
||||||
|
"utility",
|
||||||
|
"async",
|
||||||
|
"promise"
|
||||||
|
],
|
||||||
|
"homepage": "https://code.foss.global/push.rocks/smartping",
|
||||||
|
"repository": {
|
||||||
|
"type": "git",
|
||||||
|
"url": "https://code.foss.global/push.rocks/smartping.git"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Generated
+7515
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1 @@
|
|||||||
|
|
||||||
@@ -0,0 +1,123 @@
|
|||||||
|
# @push.rocks/smartping
|
||||||
|
a ping utility
|
||||||
|
|
||||||
|
## Install
|
||||||
|
|
||||||
|
To install `@push.rocks/smartping`, run the following command in your project directory:
|
||||||
|
|
||||||
|
```bash
|
||||||
|
npm install @push.rocks/smartping --save
|
||||||
|
```
|
||||||
|
|
||||||
|
This command adds `@push.rocks/smartping` to your project's dependencies and ensures you can begin utilizing it to manage your network ping needs efficiently.
|
||||||
|
|
||||||
|
## Usage
|
||||||
|
|
||||||
|
`@push.rocks/smartping` leverages TypeScript and ESM syntax for a seamless development experience, offering straightforward methods to conduct ping operations within your applications.
|
||||||
|
|
||||||
|
Before diving into the usage scenarios, ensure that you import the module in your TypeScript files using:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { Smartping } from '@push.rocks/smartping';
|
||||||
|
```
|
||||||
|
|
||||||
|
### Basic Ping
|
||||||
|
|
||||||
|
To perform a basic ping operation to check the reachability of a host, you can do the following:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { Smartping } from '@push.rocks/smartping';
|
||||||
|
|
||||||
|
const pingInstance = new Smartping();
|
||||||
|
|
||||||
|
async function basicPing() {
|
||||||
|
const pingResponse = await pingInstance.ping('google.com');
|
||||||
|
console.log(pingResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
basicPing();
|
||||||
|
```
|
||||||
|
|
||||||
|
This will output the ping response from `google.com`, including whether the host is alive, the time it took for the response, and other detailed information.
|
||||||
|
|
||||||
|
### Ping with Timeout
|
||||||
|
|
||||||
|
Sometimes, you may want to specify a timeout for the ping operation to avoid long waiting times if the host is not reachable. You can easily do this as follows:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { Smartping } from '@push.rocks/smartping';
|
||||||
|
|
||||||
|
const pingInstance = new Smartping();
|
||||||
|
|
||||||
|
async function pingWithTimeout() {
|
||||||
|
const pingResponse = await pingInstance.ping('google.com', 1000); // Timeout set to 1000 milliseconds
|
||||||
|
console.log(pingResponse);
|
||||||
|
}
|
||||||
|
|
||||||
|
pingWithTimeout();
|
||||||
|
```
|
||||||
|
|
||||||
|
### Checking if Host is Alive
|
||||||
|
|
||||||
|
If you're only interested in whether a host is alive without the need for detailed ping information, you can use the `pingAlive` method:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
import { Smartping } from '@push.rocks/smartping';
|
||||||
|
|
||||||
|
const pingInstance = new Smartping();
|
||||||
|
|
||||||
|
async function checkHostAlive() {
|
||||||
|
const isAlive = await pingInstance.pingAlive('google.com');
|
||||||
|
console.log(`Is Google alive? ${isAlive}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
checkHostAlive();
|
||||||
|
```
|
||||||
|
|
||||||
|
This method is particularly useful for quickly verifying the availability of a server or an API endpoint.
|
||||||
|
|
||||||
|
### Advanced Usage Scenarios
|
||||||
|
|
||||||
|
`@push.rocks/smartping` can be integrated into health-check mechanisms, automated network diagnostics, server monitoring tools, or any application requiring network communication verification. Its straightforward API and promise-based architecture allow it to be seamlessly incorporated into asynchronous flow control, enhancing both the development experience and performance.
|
||||||
|
|
||||||
|
### Error Handling
|
||||||
|
|
||||||
|
While using `@push.rocks/smartping`, you might encounter errors, particularly when dealing with unreachable hosts or network issues. It is recommended to implement proper error handling to manage such scenarios gracefully:
|
||||||
|
|
||||||
|
```typescript
|
||||||
|
async function safePingWithTimeout() {
|
||||||
|
try {
|
||||||
|
const pingResponse = await pingInstance.ping('google.com', 500);
|
||||||
|
console.log(pingResponse);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('Ping operation failed:', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
safePingWithTimeout();
|
||||||
|
```
|
||||||
|
|
||||||
|
### Wrapping Up
|
||||||
|
|
||||||
|
Whether integrating into existing applications for network diagnostics or constructing a new solution requiring ping capabilities, `@push.rocks/smartping` provides an efficient and easy-to-use interface to accomplish these tasks with minimal code. Its design and implementation cater to modern development practices, promoting clean and maintainable code.
|
||||||
|
|
||||||
|
For more complex scenarios or contributions, please consult the documentation and source code available on GitHub and NPM. Contributions are always welcome to enhance the module's capabilities and address the evolving needs of developers and applications alike.
|
||||||
|
|
||||||
|
## License and Legal Information
|
||||||
|
|
||||||
|
This repository contains open-source code that is licensed under the MIT License. A copy of the MIT License can be found in the [license](license) file within this repository.
|
||||||
|
|
||||||
|
**Please note:** The MIT License does not grant permission to use the trade names, trademarks, service marks, or product names of the project, except as required for reasonable and customary use in describing the origin of the work and reproducing the content of the NOTICE file.
|
||||||
|
|
||||||
|
### Trademarks
|
||||||
|
|
||||||
|
This project is owned and maintained by Task Venture Capital GmbH. The names and logos associated with Task Venture Capital GmbH and any related products or services are trademarks of Task Venture Capital GmbH and are not included within the scope of the MIT license granted herein. Use of these trademarks must comply with Task Venture Capital GmbH's Trademark Guidelines, and any usage must be approved in writing by Task Venture Capital GmbH.
|
||||||
|
|
||||||
|
### Company Information
|
||||||
|
|
||||||
|
Task Venture Capital GmbH
|
||||||
|
Registered at District court Bremen HRB 35230 HB, Germany
|
||||||
|
|
||||||
|
For any legal inquiries or if you require further information, please contact us via email at hello@task.vc.
|
||||||
|
|
||||||
|
By using this repository, you acknowledge that you have read this section, agree to comply with its terms, and understand that the licensing of the code does not imply endorsement by Task Venture Capital GmbH of any derivative works.
|
||||||
@@ -0,0 +1,20 @@
|
|||||||
|
import { expect, tap } from '@git.zone/tstest/tapbundle';
|
||||||
|
import * as smartping from '../ts/index.js';
|
||||||
|
|
||||||
|
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('127.0.0.1', 1);
|
||||||
|
expect(result.alive).toBeTrue();
|
||||||
|
});
|
||||||
|
|
||||||
|
tap.test('should detect alive', async () => {
|
||||||
|
expect(await testPing.pingAlive('127.0.0.1', 1)).toBeTrue();
|
||||||
|
});
|
||||||
|
|
||||||
|
export default tap.start();
|
||||||
@@ -1,8 +0,0 @@
|
|||||||
import { expect, tap } from '@pushrocks/tapbundle';
|
|
||||||
import * as smartping from '../ts/index'
|
|
||||||
|
|
||||||
tap.test('first test', async () => {
|
|
||||||
console.log(smartping.standardExport)
|
|
||||||
})
|
|
||||||
|
|
||||||
tap.start()
|
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
/**
|
||||||
|
* autocreated commitinfo by @push.rocks/commitinfo
|
||||||
|
*/
|
||||||
|
export const commitinfo = {
|
||||||
|
name: '@push.rocks/smartping',
|
||||||
|
version: '1.0.9',
|
||||||
|
description: 'A utility for performing ping operations in Node.js environments.'
|
||||||
|
}
|
||||||
+1
-3
@@ -1,3 +1 @@
|
|||||||
import * as plugins from './smartping.plugins';
|
export * from './smartping.classes.smartping.js';
|
||||||
|
|
||||||
export let standardExport = 'Hi there! :) This is an exported string';
|
|
||||||
|
|||||||
@@ -0,0 +1,21 @@
|
|||||||
|
import * as plugins from './smartping.plugins.js';
|
||||||
|
|
||||||
|
export type TPingResponse = Awaited<ReturnType<typeof plugins.ping.promise.probe>>;
|
||||||
|
|
||||||
|
export class Smartping {
|
||||||
|
public async ping(hostArg: string, timeoutArg: number = 500): Promise<TPingResponse> {
|
||||||
|
const result = await plugins.ping.promise.probe(hostArg, {
|
||||||
|
timeout: timeoutArg
|
||||||
|
});
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
public async pingAlive(hostArg: string, timeoutArg: number = 500): Promise<boolean> {
|
||||||
|
try {
|
||||||
|
const result = await this.ping(hostArg, timeoutArg);
|
||||||
|
return result.alive;
|
||||||
|
} catch {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
import * as ping from 'ping';
|
import ping from 'ping';
|
||||||
|
|
||||||
export {
|
export {
|
||||||
ping
|
ping
|
||||||
}
|
};
|
||||||
|
|||||||
@@ -0,0 +1,16 @@
|
|||||||
|
{
|
||||||
|
"compilerOptions": {
|
||||||
|
"experimentalDecorators": true,
|
||||||
|
"useDefineForClassFields": false,
|
||||||
|
"target": "ES2022",
|
||||||
|
"module": "NodeNext",
|
||||||
|
"moduleResolution": "NodeNext",
|
||||||
|
"noImplicitAny": true,
|
||||||
|
"esModuleInterop": true,
|
||||||
|
"verbatimModuleSyntax": true,
|
||||||
|
"types": ["node"]
|
||||||
|
},
|
||||||
|
"exclude": [
|
||||||
|
"dist_*/**/*.d.ts"
|
||||||
|
]
|
||||||
|
}
|
||||||
-17
@@ -1,17 +0,0 @@
|
|||||||
{
|
|
||||||
"extends": ["tslint:latest", "tslint-config-prettier"],
|
|
||||||
"rules": {
|
|
||||||
"semicolon": [true, "always"],
|
|
||||||
"no-console": false,
|
|
||||||
"ordered-imports": false,
|
|
||||||
"object-literal-sort-keys": false,
|
|
||||||
"member-ordering": {
|
|
||||||
"options":{
|
|
||||||
"order": [
|
|
||||||
"static-method"
|
|
||||||
]
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"defaultSeverity": "warning"
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user