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
9
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.5.3 to 1.5.4

16

CHANGELOG.md

@@ -0,1 +1,17 @@

## [1.5.4](https://github.com/webtorrent/addr-to-ip-port/compare/v1.5.3...v1.5.4) (2021-07-30)
### Performance Improvements
* use Map ([#8](https://github.com/webtorrent/addr-to-ip-port/issues/8)) ([99a86a4](https://github.com/webtorrent/addr-to-ip-port/commit/99a86a4d7c75c04688b89d2f57936447779cb4f2))
### BREAKING CHANGES
* reset function removed
* perf: use Map
* use clear
## [1.5.3](https://github.com/webtorrent/addr-to-ip-port/compare/v1.5.2...v1.5.3) (2021-07-23)

@@ -2,0 +18,0 @@

20

index.js

@@ -1,23 +0,15 @@

const ADDR_RE = /^\[?([^\]]+)\]?:(\d+)$/ // ipv4/ipv6/hostname + port
const ADDR_RE = /^\[?([^\]]+)]?:(\d+)$/ // ipv4/ipv6/hostname + port
let cache = {}
let cache = new Map()
// 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
let size = 0
module.exports = function addrToIPPort (addr) {
if (size === 100000) module.exports.reset()
if (!cache[addr]) {
if (cache.size === 100000) cache.clear()
if (!cache.has(addr)) {
const m = ADDR_RE.exec(addr)
if (!m) throw new Error(`invalid addr: ${addr}`)
cache[addr] = [ m[1], Number(m[2]) ]
size += 1
cache.set(addr, [ m[1], Number(m[2]) ])
}
return cache[addr]
return cache.get(addr)
}
module.exports.reset = function reset () {
cache = {}
size = 0
}
{
"name": "addr-to-ip-port",
"description": "Convert an 'address:port' string to an array [address:string, port:number]",
"version": "1.5.3",
"version": "1.5.4",
"author": {

@@ -18,3 +18,3 @@ "name": "WebTorrent, LLC",

"semantic-release": "17.4.4",
"tape": "4.13.3"
"tape": "5.3.0"
},

@@ -21,0 +21,0 @@ "homepage": "https://github.com/webtorrent/addr-to-ip-port",

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