nodejs-tcp-ping
TypeScript icon, indicating that this package has built-in type declarations

1.0.3 • Public • Published

nodejs-tcp-ping

TCP Ping is a Node.JS based TCP ping utility written in Typescript

Getting Started

If you are using yarn (RECOMMENDED!)

yarn add nodejs-tcp-ping

If you are using npm

npm install nodejs-tcp-ping --save

Using with JavaScript

const nodejsTcpPing = require('nodejsTcpPing');
 
// If you are not specify any options
// then ping localhost:80 five times
// with 5000ms timeout
nodejsTcpPing.tcpPing().then(results => {
  // It return an array of ping data
  // The returned data array (result) is looks like this,
  // if everthing was successful: [{ ping: number }, ...]
  // if some attempts timedout: [ { ping: null, error: 'Connection timed out' } ]
}).catch(reason => {
  // Or a reason why it failed
});
 
// There is the full specification of options
nodejsTcpPing.tcpPing({
  attempts: 5,
  host: 'localhost',
  port: 80,
  timeout: 5000
}).then(results => {
  // It return an array of ping data
}).catch(reason => {
  // Or a reason why it failed
});

Using with TypeScript

import { tcpPing, IPingData } from 'nodejsTcpPing';
 
tcpPing().then((result: IPingData[]) => {
  // ...
}).catch((reason: any) => {
  // ...
});
 
// Or
 
tcpPing({
  attempts: 5,
  host: 'localhost',
  port: 80,
  timeout: 5000
}).then((result: IPingData[]) => {
  // ...
}).catch((reason: any) => {
  // ...
});

Testing with yarn

1. Install all the dependencies with yarn

yarn

2. Build the lib with yarn

yarn build

3. Run all the tests with yarn

yarn test

Testing with npm

1. Install all the dependencies with npm

npm install

2. Build the lib with npm

npm run build

3. Run all the tests with npm

npm test

Dependencies (0)

    Dev Dependencies (6)

    Package Sidebar

    Install

    npm i nodejs-tcp-ping

    Weekly Downloads

    302

    Version

    1.0.3

    License

    MIT

    Unpacked Size

    10.9 kB

    Total Files

    24

    Last publish

    Collaborators

    • azuweyapp