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.3.0 to 1.4.0

11

index.js

@@ -5,3 +5,8 @@ var ADDR_RE = /^\[?([^\]]+)\]?:(\d+)$/ // ipv4/ipv6/hostname + port

// reset cache when it gets to 100,000 elements (~ 600KB of ipv4 addresses)
// so it will not grow to consume all memory in long-running processes
var size = 0
module.exports = function addrToIPPort (addr) {
if (size === 100000) cache = {}
if (!cache[addr]) {

@@ -11,2 +16,3 @@ var m = ADDR_RE.exec(addr)

cache[addr] = [ m[1], Number(m[2]) ]
size += 1
}

@@ -19,6 +25,1 @@ return cache[addr]

}
// reset cache every hour so it will not grow to consume all memory
// in long-running processes (like in server dameons)
var interval = setInterval(module.exports.reset, 60 * 60 * 1000)
if (interval.unref) interval.unref()
{
"name": "addr-to-ip-port",
"description": "Convert an 'address:port' string to an array [address:string, port:number]",
"version": "1.3.0",
"version": "1.4.0",
"author": "Feross Aboukhadijeh <feross@feross.org> (http://feross.org/)",

@@ -6,0 +6,0 @@ "bugs": {

@@ -13,5 +13,9 @@ var addrToIPPort = require('../')

addrToIPPort.reset()
var ipPort
for (var i = 0, len = addrs.length; i < len; i++) {
var ipPort = addrToIPPort(addrs[i])
ipPort = addrToIPPort(addrs[i])
}
for (var i = 0, len = addrs.length; i < len; i++) {
ipPort = addrToIPPort(addrs[i])
}
})
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