Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

port-numbers

Package Overview
Dependencies
Maintainers
1
Versions
156
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

port-numbers - npm Package Compare versions

Comparing version 1.1.18 to 1.1.19

58

index.js
"use strict";
var pn = {},
ports = require("./ports.json"),
services = require("./services.json");
var pn = {};
var ports = require("./ports.json");
var services = require("./services.json");
// port -> service
pn.getService = function getService(port, protocol) {
if (typeof port !== "number") {
throw new Error("expected a 'number'");
}
if (typeof port !== "number") {
throw new Error("expected a 'number'");
}
if (!protocol) {
protocol = "tcp";
}
if (!protocol) {
protocol = "tcp";
}
return ports[port + "/" + protocol] || null;
return ports[port + "/" + protocol] || null;
};

@@ -23,26 +23,26 @@

pn.getPort = function getPort(service, protocol) {
var port, entry;
if (typeof service !== "string") {
throw new Error("expected a 'string'");
}
var port, entry;
if (typeof service !== "string") {
throw new Error("expected a 'string'");
}
if (!protocol) {
protocol = "tcp";
}
if (!protocol) {
protocol = "tcp";
}
// services are always lowercase
entry = services[service.toLowerCase()];
if (entry) {
// filter non-matching protocols
port = entry.ports.filter(function (port) {
return /\w+$/.exec(port)[0] === protocol;
})[0];
// return the first matching port
if (port) {
return {port: Number(/^\d+/.exec(port)[0]), protocol: /\w+$/.exec(port)[0], description: entry.description};
}
// services are always lowercase
entry = services[service.toLowerCase()];
if (entry) {
// filter non-matching protocols
port = entry.ports.filter(function (port) {
return /\w+$/.exec(port)[0] === protocol;
})[0];
// return the first matching port
if (port) {
return {port: Number(/^\d+/.exec(port)[0]), protocol: /\w+$/.exec(port)[0], description: entry.description};
}
return null;
}
return null;
};
module.exports = pn;
{
"name": "port-numbers",
"version": "1.1.18",
"version": "1.1.19",
"description": "Get the information on network port numbers, based on IANA's public listing",

@@ -5,0 +5,0 @@ "author": "silverwind <me@silverwind.io> (https://github.com/silverwind)",

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc