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

addr-to-ip-port

Package Overview
Dependencies
Maintainers
1
Versions
15
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

addr-to-ip-port - npm Package Compare versions

Comparing version 1.0.1 to 1.1.0

perf/basic.js

10

index.js

@@ -0,1 +1,3 @@

var ADDR_RE = /^\[?([^\]]+)\]?:(\d+)$/ // ipv4/ipv6/hostname + port
var cache = {}

@@ -5,6 +7,10 @@

if (!cache[addr]) {
var s = addr.split(':')
cache[addr] = [ s[0], Number(s[1]) ]
var m = ADDR_RE.exec(addr)
cache[addr] = [ m[1], Number(m[2]) ]
}
return cache[addr]
}
module.exports.reset = function () {
cache = {}
}

6

package.json
{
"name": "addr-to-ip-port",
"description": "Convert an 'address:port' string to an array [address:string, port:number]",
"version": "1.0.1",
"version": "1.1.0",
"author": "Feross Aboukhadijeh <feross@feross.org> (http://feross.org/)",

@@ -11,2 +11,3 @@ "bugs": {

"devDependencies": {
"benchmark": "^1.0.0",
"tape": "2.x"

@@ -33,3 +34,4 @@ },

"scripts": {
"test": "tape test/*.js"
"test": "tape test/*.js",
"perf": "node perf/basic.js"
},

@@ -36,0 +38,0 @@ "testling": {

@@ -7,2 +7,4 @@ var addrToIPPort = require('../')

t.deepEqual(addrToIPPort('2.3.4.5:1000'), [ '2.3.4.5', 1000 ])
t.deepEqual(addrToIPPort('[2a00:1450:4008:801::1011]:80'), [ '2a00:1450:4008:801::1011', 80 ])
t.deepEqual(addrToIPPort('webtorrent.io:80'), [ 'webtorrent.io', 80 ])

@@ -9,0 +11,0 @@ // test that cache works correctly

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