From 83cd9507aceff7b692ce004aae6a57cdf2c7ad39 Mon Sep 17 00:00:00 2001 From: Philipp Kunz Date: Sun, 14 Apr 2024 18:08:27 +0200 Subject: [PATCH] update tsconfig --- npmextra.json | 15 ++++-- package.json | 11 +++- readme.hints.md | 1 + readme.md | 138 ++++++++++++++++++++++++++++++++++++++---------- 4 files changed, 134 insertions(+), 31 deletions(-) create mode 100644 readme.hints.md diff --git a/npmextra.json b/npmextra.json index a0cc193..2b5444f 100644 --- a/npmextra.json +++ b/npmextra.json @@ -5,17 +5,26 @@ "githost": "code.foss.global", "gitscope": "push.rocks", "gitrepo": "smartping", - "description": "a ping utility", + "description": "A utility for performing ping operations in Node.js environments.", "npmPackagename": "@push.rocks/smartping", "license": "MIT", - "projectDomain": "push.rocks" + "projectDomain": "push.rocks", + "keywords": [ + "ping", + "network", + "connectivity", + "Node.js", + "utility", + "async", + "promise" + ] } }, "npmci": { "npmGlobalTools": [], "npmAccessLevel": "public" }, - "tsdocs": { + "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" } } \ No newline at end of file diff --git a/package.json b/package.json index 338c856..d67ebf7 100644 --- a/package.json +++ b/package.json @@ -2,7 +2,7 @@ "name": "@push.rocks/smartping", "version": "1.0.8", "private": false, - "description": "a ping utility", + "description": "A utility for performing ping operations in Node.js environments.", "main": "dist_ts/index.js", "typings": "dist_ts/index.d.ts", "type": "module", @@ -40,5 +40,14 @@ "cli.js", "npmextra.json", "readme.md" + ], + "keywords": [ + "ping", + "network", + "connectivity", + "Node.js", + "utility", + "async", + "promise" ] } \ No newline at end of file diff --git a/readme.hints.md b/readme.hints.md new file mode 100644 index 0000000..0519ecb --- /dev/null +++ b/readme.hints.md @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/readme.md b/readme.md index 9ccdd11..b36dec6 100644 --- a/readme.md +++ b/readme.md @@ -1,39 +1,123 @@ -# @pushrocks/smartping +# @push.rocks/smartping a ping utility -## Availabililty and Links -* [npmjs.org (npm package)](https://www.npmjs.com/package/@pushrocks/smartping) -* [gitlab.com (source)](https://gitlab.com/pushrocks/smartping) -* [github.com (source mirror)](https://github.com/pushrocks/smartping) -* [docs (typedoc)](https://pushrocks.gitlab.io/smartping/) +## Install -## Status for master +To install `@push.rocks/smartping`, run the following command in your project directory: -Status Category | Status Badge --- | -- -GitLab Pipelines | [![pipeline status](https://gitlab.com/pushrocks/smartping/badges/master/pipeline.svg)](https://lossless.cloud) -GitLab Pipline Test Coverage | [![coverage report](https://gitlab.com/pushrocks/smartping/badges/master/coverage.svg)](https://lossless.cloud) -npm | [![npm downloads per month](https://badgen.net/npm/dy/@pushrocks/smartping)](https://lossless.cloud) -Snyk | [![Known Vulnerabilities](https://badgen.net/snyk/pushrocks/smartping)](https://lossless.cloud) -TypeScript Support | [![TypeScript](https://badgen.net/badge/TypeScript/>=%203.x/blue?icon=typescript)](https://lossless.cloud) -node Support | [![node](https://img.shields.io/badge/node->=%2010.x.x-blue.svg)](https://nodejs.org/dist/latest-v10.x/docs/api/) -Code Style | [![Code Style](https://badgen.net/badge/style/prettier/purple)](https://lossless.cloud) -PackagePhobia (total standalone install weight) | [![PackagePhobia](https://badgen.net/packagephobia/install/@pushrocks/smartping)](https://lossless.cloud) -PackagePhobia (package size on registry) | [![PackagePhobia](https://badgen.net/packagephobia/publish/@pushrocks/smartping)](https://lossless.cloud) -BundlePhobia (total size when bundled) | [![BundlePhobia](https://badgen.net/bundlephobia/minzip/@pushrocks/smartping)](https://lossless.cloud) -Platform support | [![Supports Windows 10](https://badgen.net/badge/supports%20Windows%2010/yes/green?icon=windows)](https://lossless.cloud) [![Supports Mac OS X](https://badgen.net/badge/supports%20Mac%20OS%20X/yes/green?icon=apple)](https://lossless.cloud) +```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 -Use TypeScript for best in class intellisense +`@push.rocks/smartping` leverages TypeScript and ESM syntax for a seamless development experience, offering straightforward methods to conduct ping operations within your applications. -## Contribution +Before diving into the usage scenarios, ensure that you import the module in your TypeScript files using: -We are always happy for code contributions. If you are not the code contributing type that is ok. Still, maintaining Open Source repositories takes considerable time and thought. If you like the quality of what we do and our modules are useful to you we would appreciate a little monthly contribution: You can [contribute one time](https://lossless.link/contribute-onetime) or [contribute monthly](https://lossless.link/contribute). :) +```typescript +import { Smartping } from '@push.rocks/smartping'; +``` -For further information read the linked docs at the top of this readme. +### Basic Ping -> MIT licensed | **©** [Lossless GmbH](https://lossless.gmbh) -| By using this npm module you agree to our [privacy policy](https://lossless.gmbH/privacy) +To perform a basic ping operation to check the reachability of a host, you can do the following: -[![repo-footer](https://lossless.gitlab.io/publicrelations/repofooter.svg)](https://maintainedby.lossless.com) +```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.