pingman 1.1.5 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -12,18 +12,18 @@ const messages_1 = require("../messages");
12
12
  //Create instance of builder depending on platform
13
13
  function builderFactory(ip, platform, options) {
14
14
  let builder;
15
- helper_1.validateIp(ip);
16
- if (!helper_1.isPlatformSupported(platform)) {
15
+ (0, helper_1.validateIp)(ip);
16
+ if (!(0, helper_1.isPlatformSupported)(platform)) {
17
17
  throw new errors_1.supportedError(messages_1.ERROR_MESSAGES.PLATFORM_NOT_SUPPORTED.replace('platform', platform));
18
18
  }
19
19
  if (platform === 'win32') {
20
- builder = windows_1.default(ip, options); //creates and builds commands for windows
20
+ builder = (0, windows_1.default)(ip, options); //creates and builds commands for windows
21
21
  }
22
22
  else if (platform === 'darwin') {
23
- builder = mac_1.default(ip, options); //creates and builds commands for mac
23
+ builder = (0, mac_1.default)(ip, options); //creates and builds commands for mac
24
24
  }
25
25
  else {
26
- builder = linux_1.default(ip, options); //creates and builds commands for linux
26
+ builder = (0, linux_1.default)(ip, options); //creates and builds commands for linux
27
27
  }
28
28
  return builder;
29
29
  }
@@ -1,3 +1,3 @@
1
1
  import { commandBuilder, extendedPingOptions } from '../types';
2
- declare const linux: (ip: string, options?: extendedPingOptions | undefined) => commandBuilder;
2
+ declare const linux: (ip: string, options?: extendedPingOptions) => commandBuilder;
3
3
  export default linux;
@@ -27,7 +27,7 @@ const linux = (ip, options) => {
27
27
  if (typeof (options === null || options === void 0 ? void 0 : options.interval) === 'number') {
28
28
  if (options === null || options === void 0 ? void 0 : options.floodPing) {
29
29
  args.push('-f');
30
- process_1.emitWarning(messages_1.ERROR_MESSAGES.FLOOD_AND_INTERVAL_ARGS, 'argumentWarning'); //Catch the warning and process it
30
+ (0, process_1.emitWarning)(messages_1.ERROR_MESSAGES.FLOOD_AND_INTERVAL_ARGS, 'argumentWarning'); //Catch the warning and process it
31
31
  }
32
32
  else {
33
33
  args.push('-i', options === null || options === void 0 ? void 0 : options.interval.toString());
@@ -36,7 +36,7 @@ const linux = (ip, options) => {
36
36
  if (options === null || options === void 0 ? void 0 : options.floodPing) {
37
37
  if (typeof (options === null || options === void 0 ? void 0 : options.interval) === 'number') {
38
38
  args.push('-i', options === null || options === void 0 ? void 0 : options.interval.toString());
39
- process_1.emitWarning(messages_1.ERROR_MESSAGES.FLOOD_AND_INTERVAL_ARGS, 'argumentWarning');
39
+ (0, process_1.emitWarning)(messages_1.ERROR_MESSAGES.FLOOD_AND_INTERVAL_ARGS, 'argumentWarning');
40
40
  }
41
41
  else {
42
42
  args.push('-f');
@@ -1,3 +1,3 @@
1
1
  import { commandBuilder, extendedPingOptions } from '../types';
2
- declare const mac: (ip: string, options?: extendedPingOptions | undefined) => commandBuilder;
2
+ declare const mac: (ip: string, options?: extendedPingOptions) => commandBuilder;
3
3
  export default mac;
@@ -27,7 +27,7 @@ const mac = (ip, options) => {
27
27
  if (typeof (options === null || options === void 0 ? void 0 : options.interval) === 'number') {
28
28
  if (options === null || options === void 0 ? void 0 : options.floodPing) {
29
29
  args.push('-f');
30
- process_1.emitWarning(messages_1.ERROR_MESSAGES.FLOOD_AND_INTERVAL_ARGS, 'argumentWarning');
30
+ (0, process_1.emitWarning)(messages_1.ERROR_MESSAGES.FLOOD_AND_INTERVAL_ARGS, 'argumentWarning');
31
31
  }
32
32
  else {
33
33
  args.push('-i', options === null || options === void 0 ? void 0 : options.interval.toString());
@@ -39,7 +39,7 @@ const mac = (ip, options) => {
39
39
  }
40
40
  else {
41
41
  args.push('-f');
42
- process_1.emitWarning(messages_1.ERROR_MESSAGES.FLOOD_AND_INTERVAL_ARGS, 'argumentWarning');
42
+ (0, process_1.emitWarning)(messages_1.ERROR_MESSAGES.FLOOD_AND_INTERVAL_ARGS, 'argumentWarning');
43
43
  }
44
44
  }
45
45
  if (typeof (options === null || options === void 0 ? void 0 : options.interfaceAddress) === 'string') {
@@ -1,3 +1,3 @@
1
1
  import { commandBuilder, extendedPingOptions } from '../types';
2
- declare const windows: (ip: string, options?: extendedPingOptions | undefined) => commandBuilder;
2
+ declare const windows: (ip: string, options?: extendedPingOptions) => commandBuilder;
3
3
  export default windows;
@@ -65,7 +65,7 @@ function checkForIpV4SpecificFields(options) {
65
65
  optionsUsed = optionsUsed.concat(',', options.hopTimestamp.toString());
66
66
  }
67
67
  if (optionsUsed.length > 0) {
68
- process_1.emitWarning(messages_1.ERROR_MESSAGES.ENABLE_IPV4_EXPLICIT.replace('commands', optionsUsed), 'IPV4OnlyWarning');
68
+ (0, process_1.emitWarning)(messages_1.ERROR_MESSAGES.ENABLE_IPV4_EXPLICIT.replace('commands', optionsUsed), 'IPV4OnlyWarning');
69
69
  }
70
70
  }
71
71
  return args;
@@ -85,7 +85,7 @@ function checkForIpV6SpecificFields(options) {
85
85
  optionsUsed = optionsUsed.concat(',', options.srcAddr);
86
86
  }
87
87
  if (optionsUsed.length > 0) {
88
- process_1.emitWarning(messages_1.ERROR_MESSAGES.ENABLE_IPV6_EXPLICIT.replace('commands', optionsUsed), 'IPV6OnlyWarning');
88
+ (0, process_1.emitWarning)(messages_1.ERROR_MESSAGES.ENABLE_IPV6_EXPLICIT.replace('commands', optionsUsed), 'IPV6OnlyWarning');
89
89
  }
90
90
  }
91
91
  return args;
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.supportedError = exports.ipError = exports.pingError = void 0;
3
4
  class pingError extends Error {
4
5
  constructor(message, code) {
5
6
  super(message);
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isPlatformSupported = exports.validateIp = void 0;
3
4
  const errors_1 = require("./errors");
4
5
  const messages_1 = require("./messages");
5
6
  //Function to validate ip given as input
@@ -1,4 +1,4 @@
1
1
  import { extendedPingOptions, pingResponse } from './types';
2
- declare const ping: (ipAddress: string, pingOptions?: extendedPingOptions | undefined) => Promise<pingResponse>;
2
+ declare const ping: (ipAddress: string, pingOptions?: extendedPingOptions) => Promise<pingResponse>;
3
3
  export default ping;
4
4
  export { extendedPingOptions, pingOptions, pingResponse } from './types';
package/dist/src/index.js CHANGED
@@ -1,14 +1,30 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
5
18
  var __importStar = (this && this.__importStar) || function (mod) {
6
19
  if (mod && mod.__esModule) return mod;
7
20
  var result = {};
8
- if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
9
- result["default"] = mod;
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
10
23
  return result;
11
24
  };
25
+ var __importDefault = (this && this.__importDefault) || function (mod) {
26
+ return (mod && mod.__esModule) ? mod : { "default": mod };
27
+ };
12
28
  Object.defineProperty(exports, "__esModule", { value: true });
13
29
  const builder_1 = __importDefault(require("./builder/builder"));
14
30
  const os = __importStar(require("os"));
@@ -22,10 +38,10 @@ const ping = async (ipAddress, pingOptions) => {
22
38
  logger = new log_1.default((pingOptions === null || pingOptions === void 0 ? void 0 : pingOptions.logFilePath) || 'log.txt', (pingOptions === null || pingOptions === void 0 ? void 0 : pingOptions.logToFile) || false);
23
39
  try {
24
40
  const platform = os.platform();
25
- const builtCommand = builder_1.default(ipAddress, platform, pingOptions);
41
+ const builtCommand = (0, builder_1.default)(ipAddress, platform, pingOptions);
26
42
  logger.writeToLogFile(JSON.stringify(builtCommand));
27
- const pingOutput = await ping_1.default(builtCommand);
28
- const parsedOutput = parserFactory_1.default(platform, pingOutput, pingOptions);
43
+ const pingOutput = await (0, ping_1.default)(builtCommand);
44
+ const parsedOutput = (0, parserFactory_1.default)(platform, pingOutput, pingOptions);
29
45
  logger.writeToLogFile(JSON.stringify(parsedOutput.output));
30
46
  return parsedOutput;
31
47
  }
@@ -1,5 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ERROR_MESSAGES = void 0;
3
4
  exports.ERROR_MESSAGES = {
4
5
  IP_NOT_PROVIDED: 'IP is not available',
5
6
  IP_NOT_VALID: 'Given IP address is not valid',
@@ -13,7 +13,7 @@ const messages_1 = require("../messages");
13
13
  function parserFactory(platform, output, options) {
14
14
  let parser;
15
15
  let isWindows = false;
16
- if (!helper_1.isPlatformSupported(platform)) {
16
+ if (!(0, helper_1.isPlatformSupported)(platform)) {
17
17
  throw new errors_1.supportedError(messages_1.ERROR_MESSAGES.PLATFORM_NOT_SUPPORTED.replace('platform', platform));
18
18
  }
19
19
  if (platform === 'win32') {
@@ -90,7 +90,7 @@ class windows {
90
90
  }
91
91
  }
92
92
  }
93
- //method to process IPV Specific Body
93
+ //method to process IPV6 Specific Body
94
94
  processIPV6Body(dataFields) {
95
95
  var _a, _b;
96
96
  let expectDataFieldInReplyLine = 1;
package/dist/src/ping.js CHANGED
@@ -7,7 +7,7 @@ const execute = async (builtCommand) => {
7
7
  let output = [];
8
8
  return new Promise((resolve, reject) => {
9
9
  var _a;
10
- const ping = child_process_1.spawn(builtCommand.command, builtCommand.arguments);
10
+ const ping = (0, child_process_1.spawn)(builtCommand.command, builtCommand.arguments);
11
11
  ping.once("error", () => {
12
12
  reject(new errors_1.pingError(messages_1.ERROR_MESSAGES.GENERAL_PING_ERROR.replace("cmd", builtCommand.command).replace("args", builtCommand.arguments.toString())));
13
13
  });
@@ -24,11 +24,11 @@ export interface pingOptions {
24
24
  TTL?: number;
25
25
  timeout?: number;
26
26
  }
27
- export declare type commandBuilder = {
27
+ export type commandBuilder = {
28
28
  command: string;
29
29
  arguments: string[];
30
30
  };
31
- export declare type pingResponse = {
31
+ export type pingResponse = {
32
32
  host: string | undefined;
33
33
  numericHost: string | undefined;
34
34
  alive: boolean | undefined;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pingman",
3
- "version": "1.1.5",
3
+ "version": "2.0.0",
4
4
  "description": "A ping wrapper for node with TypeScript",
5
5
  "main": "dist/src",
6
6
  "engines": {
@@ -22,13 +22,13 @@
22
22
  "url": "git://github.com/dopecodez/pingman.git"
23
23
  },
24
24
  "devDependencies": {
25
- "@ava/typescript": "^1.1.1",
26
- "@types/node": "^13.13.5",
27
- "ava": "^3.15.0",
25
+ "@ava/typescript": "^3.0.1",
26
+ "@types/node": "^18.11.10",
27
+ "ava": "^5.1.0",
28
28
  "copyfiles": "^2.2.0",
29
- "np": "^6.2.3",
29
+ "np": "^7.6.2",
30
30
  "nyc": "^15.1.0",
31
- "typescript": "^3.8.3"
31
+ "typescript": "^4.9.3"
32
32
  },
33
33
  "files": [
34
34
  "dist/src"
@@ -44,10 +44,10 @@
44
44
  "typescript": {
45
45
  "rewritePaths": {
46
46
  "test/": "dist/test/"
47
- }
47
+ },
48
+ "compile": false
48
49
  }
49
50
  },
50
- "dependencies": {},
51
51
  "keywords": [
52
52
  "ping",
53
53
  "node-ping",