addr-to-ip-port
Advanced tools
Comparing version 1.0.1 to 1.1.0
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 = {} | ||
} |
{ | ||
"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 |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5080
8
58
2