ipaddr.js
Advanced tools
Comparing version 0.1.1 to 0.1.2
@@ -1,1 +0,1 @@ | ||
(function(){var a,b,c,d,e,f,g,h;b={},h=this,typeof module!="undefined"&&module!==null&&module.exports?module.exports=b:h.ipaddr=b,g=function(a,b,c,d){var e,f;if(a.length!==b.length)throw new Error("ipaddr: cannot match CIDR for objects with different lengths");e=0;while(d>0){f=c-d,f<0&&(f=0);if(a[e]>>f!==b[e]>>f)return!1;d-=c,e+=1}return!0},b.subnetMatch=function(a,b,c){var d,e,f,g,h;c==null&&(c="unicast");for(d in b){e=b[d],toString.call(e[0])!=="[object Array]"&&(e=[e]);for(g=0,h=e.length;g<h;g++){f=e[g];if(a.match.apply(a,f))return d}}return c},b.IPv4=function(){function a(a){var b,c,d;if(a.length!==4)throw new Error("ipaddr: ipv4 octet count should be 4");for(c=0,d=a.length;c<d;c++){b=a[c];if(!(0<=b&&b<=255))throw new Error("ipaddr: ipv4 octet is a byte")}this.octets=a}a.prototype.kind=function(){return"ipv4"},a.prototype.toString=function(){return this.octets.join(".")},a.prototype.toByteArray=function(){return this.octets.slice(0)},a.prototype.match=function(a,b){if(a.kind()!=="ipv4")throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one");return g(this.octets,a.octets,8,b)},a.prototype.SpecialRanges={broadcast:[[new a([255,255,255,255]),32]],multicast:[[new a([224,0,0,0]),4]],linkLocal:[[new a([169,254,0,0]),16]],loopback:[[new a([127,0,0,0]),8]],"private":[[new a([10,0,0,0]),8],[new a([172,16,0,0]),12],[new a([192,168,0,0]),16]],reserved:[[new a([192,0,0,0]),24],[new a([192,0,2,0]),24],[new a([192,88,99,0]),24],[new a([198,51,100,0]),24],[new a([203,0,113,0]),24],[new a([240,0,0,0]),4]]},a.prototype.range=function(){return b.subnetMatch(this,this.SpecialRanges)},a.prototype.toIPv4MappedAddress=function(){return b.IPv6.parse("::ffff:"+this.toString())};return a}(),c="(0?\\d+|0x[a-f0-9]+)",d={fourOctet:new RegExp("^"+c+"\\."+c+"\\."+c+"\\."+c+"$","i"),longValue:new RegExp("^"+c+"$","i")},b.IPv4.parser=function(a){var b,c,e,f,g,h,i,j;if(b=a.match(d.fourOctet)){i=b.slice(1,6),j=[];for(g=0,h=i.length;g<h;g++)c=i[g],j.push(parseInt(c));return j}if(b=a.match(d.longValue)){f=parseInt(b[1]);return function(){var a,b;a=[];for(e=0,b=8;e<=24;e+=b)a.push(f>>e&255);return a}().reverse()}return null},b.IPv6=function(){function a(a){var b,c,d;if(a.length!==8)throw new Error("ipaddr: ipv6 part count should be 8");for(c=0,d=a.length;c<d;c++){b=a[c];if(!(0<=b&&b<=65535))throw new Error("ipaddr: ipv6 part should fit to two octets")}this.parts=a}a.prototype.kind=function(){return"ipv6"},a.prototype.toString=function(){var a,b,c,d,e,f,g;e=function(){var a,c,d,e;d=this.parts,e=[];for(a=0,c=d.length;a<c;a++)b=d[a],e.push(b.toString(16));return e}.call(this),a=[],c=function(b){return a.push(b)},d=0;for(f=0,g=e.length;f<g;f++){b=e[f];switch(d){case 0:b==="0"?c(""):c(b),d=1;break;case 1:b==="0"?d=2:c(b);break;case 2:b!=="0"&&(c(""),c(b),d=3);break;case 3:c(b)}}d===2&&(c(""),c(""));return a.join(":")},a.prototype.toByteArray=function(){var a,b,c,d,e;a=[],e=this.parts;for(c=0,d=e.length;c<d;c++)b=e[c],a.push(b>>8),a.push(b&255);return a},a.prototype.toNormalizedString=function(){var a;return function(){var b,c,d,e;d=this.parts,e=[];for(b=0,c=d.length;b<c;b++)a=d[b],e.push(a.toString(16));return e}.call(this).join(":")},a.prototype.match=function(a,b){if(a.kind()!=="ipv6")throw new Error("ipaddr: cannot match ipv6 address with non-ipv6 one");return g(this.parts,a.parts,16,b)},a.prototype.SpecialRanges={unspecified:[new a([0,0,0,0,0,0,0,0]),128],linkLocal:[new a([65152,0,0,0,0,0,0,0]),10],multicast:[new a([65280,0,0,0,0,0,0,0]),8],loopback:[new a([0,0,0,0,0,0,0,1]),128],uniqueLocal:[new a([64512,0,0,0,0,0,0,0]),7],ipv4Mapped:[new a([0,0,0,0,0,65535,0,0]),96],rfc6145:[new a([0,0,0,0,65535,0,0,0]),96],rfc6052:[new a([100,65435,0,0,0,0,0,0]),96],"6to4":[new a([8194,0,0,0,0,0,0,0]),16],teredo:[new a([8193,0,0,0,0,0,0,0]),32],reserved:[[new a([8193,3512,0,0,0,0,0,0]),32]]},a.prototype.range=function(){return b.subnetMatch(this,this.SpecialRanges)},a.prototype.isIPv4MappedAddress=function(){return this.range()==="ipv4Mapped"},a.prototype.toIPv4Address=function(){var a,c,d;if(!this.isIPv4MappedAddress())throw new Error("ipaddr: trying to convert a generic ipv6 address to ipv4");d=this.parts.slice(-2),a=d[0],c=d[1];return new b.IPv4([a>>8,a&255,c>>8,c&255])};return a}(),e="(?:[0-9a-f]+::?)+",f={"native":new RegExp("^(::)?("+e+")?([0-9a-f]+)?(::)?$","i"),transitional:new RegExp("^((?:"+e+")|(?:::)(?:"+e+")?)"+(""+c+"\\."+c+"\\."+c+"\\."+c+"$"),"i")},a=function(a,b){var c,d,e,f,g,h,i,j,k;if(a.indexOf("::")!==a.lastIndexOf("::"))return null;c=0,d=-1;while((d=a.indexOf(":",d+1))>=0)c++;a[0]===":"&&c--,a[a.length-1]===":"&&c--,g=b-c,f=":";while(g--)f+="0:";a=a.replace("::",f),a[0]===":"&&(a=a.slice(1)),a[a.length-1]===":"&&(a=a.slice(0,-1)),j=a.split(":"),k=[];for(h=0,i=j.length;h<i;h++)e=j[h],k.push(parseInt(e,16));return k},b.IPv6.parser=function(b){var c,d;if(b.match(f["native"]))return a(b,8);if(c=b.match(f.transitional)){d=a(c[1].slice(0,-1),6);if(d){d.push(parseInt(c[2])<<8|parseInt(c[3])),d.push(parseInt(c[4])<<8|parseInt(c[5]));return d}}return null},b.IPv4.isIPv4=b.IPv6.isIPv6=function(a){return this.parser(a)!==null},b.IPv4.isValid=b.IPv6.isValid=function(a){try{new this(this.parser(a));return!0}catch(b){return!1}},b.IPv4.parse=b.IPv6.parse=function(a){var b;b=this.parser(a);if(b===null)throw new Error("ipaddr: string is not formatted like ip address");return new this(b)},b.isValid=function(a){return b.IPv6.isValid(a)||b.IPv4.isValid(a)},b.parse=function(a){if(b.IPv6.isIPv6(a))return b.IPv6.parse(a);if(b.IPv4.isIPv4(a))return b.IPv4.parse(a);throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format")},b.process=function(a){var b;b=this.parse(a);return b.kind()==="ipv6"&&b.isIPv4MappedAddress()?b.toIPv4Address():b}}).call(this) | ||
(function(){var t,r,n,e,i,o,a,s;r={},s=this,"undefined"!=typeof module&&null!==module&&module.exports?module.exports=r:s.ipaddr=r,a=function(t,r,n,e){var i,o;if(t.length!==r.length)throw new Error("ipaddr: cannot match CIDR for objects with different lengths");for(i=0;e>0;){if(o=n-e,0>o&&(o=0),t[i]>>o!==r[i]>>o)return!1;e-=n,i+=1}return!0},r.subnetMatch=function(t,r,n){var e,i,o,a,s;null==n&&(n="unicast");for(e in r)for(i=r[e],"[object Array]"!==toString.call(i[0])&&(i=[i]),a=0,s=i.length;s>a;a++)if(o=i[a],t.match.apply(t,o))return e;return n},r.IPv4=function(){function t(t){var r,n,e;if(4!==t.length)throw new Error("ipaddr: ipv4 octet count should be 4");for(n=0,e=t.length;e>n;n++)if(r=t[n],!(r>=0&&255>=r))throw new Error("ipaddr: ipv4 octet is a byte");this.octets=t}return t.prototype.kind=function(){return"ipv4"},t.prototype.toString=function(){return this.octets.join(".")},t.prototype.toByteArray=function(){return this.octets.slice(0)},t.prototype.match=function(t,r){if("ipv4"!==t.kind())throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one");return a(this.octets,t.octets,8,r)},t.prototype.SpecialRanges={broadcast:[[new t([255,255,255,255]),32]],multicast:[[new t([224,0,0,0]),4]],linkLocal:[[new t([169,254,0,0]),16]],loopback:[[new t([127,0,0,0]),8]],"private":[[new t([10,0,0,0]),8],[new t([172,16,0,0]),12],[new t([192,168,0,0]),16]],reserved:[[new t([192,0,0,0]),24],[new t([192,0,2,0]),24],[new t([192,88,99,0]),24],[new t([198,51,100,0]),24],[new t([203,0,113,0]),24],[new t([240,0,0,0]),4]]},t.prototype.range=function(){return r.subnetMatch(this,this.SpecialRanges)},t.prototype.toIPv4MappedAddress=function(){return r.IPv6.parse("::ffff:"+this.toString())},t}(),n="(0?\\d+|0x[a-f0-9]+)",e={fourOctet:new RegExp("^"+n+"\\."+n+"\\."+n+"\\."+n+"$","i"),longValue:new RegExp("^"+n+"$","i")},r.IPv4.parser=function(t){var r,n,i,o,a;return n=function(t){return"0"===t[0]&&"x"!==t[1]?parseInt(t,8):parseInt(t)},(r=t.match(e.fourOctet))?function(){var t,e,o,a;for(o=r.slice(1,6),a=[],t=0,e=o.length;e>t;t++)i=o[t],a.push(n(i));return a}():(r=t.match(e.longValue))?(a=n(r[1]),function(){var t,r;for(r=[],o=t=0;24>=t;o=t+=8)r.push(a>>o&255);return r}().reverse()):null},r.IPv6=function(){function t(t){var r,n,e;if(8!==t.length)throw new Error("ipaddr: ipv6 part count should be 8");for(n=0,e=t.length;e>n;n++)if(r=t[n],!(r>=0&&65535>=r))throw new Error("ipaddr: ipv6 part should fit to two octets");this.parts=t}return t.prototype.kind=function(){return"ipv6"},t.prototype.toString=function(){var t,r,n,e,i,o,a;for(i=function(){var t,n,e,i;for(e=this.parts,i=[],t=0,n=e.length;n>t;t++)r=e[t],i.push(r.toString(16));return i}.call(this),t=[],n=function(r){return t.push(r)},e=0,o=0,a=i.length;a>o;o++)switch(r=i[o],e){case 0:"0"===r?n(""):n(r),e=1;break;case 1:"0"===r?e=2:n(r);break;case 2:"0"!==r&&(n(""),n(r),e=3);break;case 3:n(r)}return 2===e&&(n(""),n("")),t.join(":")},t.prototype.toByteArray=function(){var t,r,n,e,i;for(t=[],i=this.parts,n=0,e=i.length;e>n;n++)r=i[n],t.push(r>>8),t.push(255&r);return t},t.prototype.toNormalizedString=function(){var t;return function(){var r,n,e,i;for(e=this.parts,i=[],r=0,n=e.length;n>r;r++)t=e[r],i.push(t.toString(16));return i}.call(this).join(":")},t.prototype.match=function(t,r){if("ipv6"!==t.kind())throw new Error("ipaddr: cannot match ipv6 address with non-ipv6 one");return a(this.parts,t.parts,16,r)},t.prototype.SpecialRanges={unspecified:[new t([0,0,0,0,0,0,0,0]),128],linkLocal:[new t([65152,0,0,0,0,0,0,0]),10],multicast:[new t([65280,0,0,0,0,0,0,0]),8],loopback:[new t([0,0,0,0,0,0,0,1]),128],uniqueLocal:[new t([64512,0,0,0,0,0,0,0]),7],ipv4Mapped:[new t([0,0,0,0,0,65535,0,0]),96],rfc6145:[new t([0,0,0,0,65535,0,0,0]),96],rfc6052:[new t([100,65435,0,0,0,0,0,0]),96],"6to4":[new t([8194,0,0,0,0,0,0,0]),16],teredo:[new t([8193,0,0,0,0,0,0,0]),32],reserved:[[new t([8193,3512,0,0,0,0,0,0]),32]]},t.prototype.range=function(){return r.subnetMatch(this,this.SpecialRanges)},t.prototype.isIPv4MappedAddress=function(){return"ipv4Mapped"===this.range()},t.prototype.toIPv4Address=function(){var t,n,e;if(!this.isIPv4MappedAddress())throw new Error("ipaddr: trying to convert a generic ipv6 address to ipv4");return e=this.parts.slice(-2),t=e[0],n=e[1],new r.IPv4([t>>8,255&t,n>>8,255&n])},t}(),i="(?:[0-9a-f]+::?)+",o={"native":new RegExp("^(::)?("+i+")?([0-9a-f]+)?(::)?$","i"),transitional:new RegExp("^((?:"+i+")|(?:::)(?:"+i+")?)"+(""+n+"\\."+n+"\\."+n+"\\."+n+"$"),"i")},t=function(t,r){var n,e,i,o,a;if(t.indexOf("::")!==t.lastIndexOf("::"))return null;for(n=0,e=-1;(e=t.indexOf(":",e+1))>=0;)n++;for(":"===t[0]&&n--,":"===t[t.length-1]&&n--,a=r-n,o=":";a--;)o+="0:";return t=t.replace("::",o),":"===t[0]&&(t=t.slice(1)),":"===t[t.length-1]&&(t=t.slice(0,-1)),function(){var r,n,e,o;for(e=t.split(":"),o=[],r=0,n=e.length;n>r;r++)i=e[r],o.push(parseInt(i,16));return o}()},r.IPv6.parser=function(r){var n,e;return r.match(o["native"])?t(r,8):(n=r.match(o.transitional))&&(e=t(n[1].slice(0,-1),6))?(e.push(parseInt(n[2])<<8|parseInt(n[3])),e.push(parseInt(n[4])<<8|parseInt(n[5])),e):null},r.IPv4.isIPv4=r.IPv6.isIPv6=function(t){return null!==this.parser(t)},r.IPv4.isValid=r.IPv6.isValid=function(t){var r;try{return new this(this.parser(t)),!0}catch(n){return r=n,!1}},r.IPv4.parse=r.IPv6.parse=function(t){var r;if(r=this.parser(t),null===r)throw new Error("ipaddr: string is not formatted like ip address");return new this(r)},r.isValid=function(t){return r.IPv6.isValid(t)||r.IPv4.isValid(t)},r.parse=function(t){if(r.IPv6.isIPv6(t))return r.IPv6.parse(t);if(r.IPv4.isIPv4(t))return r.IPv4.parse(t);throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format")},r.process=function(t){var r;return r=this.parse(t),"ipv6"===r.kind()&&r.isIPv4MappedAddress()?r.toIPv4Address():r}}).call(this); |
(function() { | ||
var expandIPv6, ipaddr, ipv4Part, ipv4Regexes, ipv6Part, ipv6Regexes, matchCIDR, root; | ||
ipaddr = {}; | ||
root = this; | ||
if ((typeof module !== "undefined" && module !== null) && module.exports) { | ||
@@ -10,2 +13,3 @@ module.exports = ipaddr; | ||
} | ||
matchCIDR = function(first, second, partSize, cidrBits) { | ||
@@ -30,2 +34,3 @@ var part, shift; | ||
}; | ||
ipaddr.subnetMatch = function(address, rangeList, defaultName) { | ||
@@ -50,2 +55,3 @@ var rangeName, rangeSubnets, subnet, _i, _len; | ||
}; | ||
ipaddr.IPv4 = (function() { | ||
@@ -65,11 +71,15 @@ function IPv4(octets) { | ||
} | ||
IPv4.prototype.kind = function() { | ||
return 'ipv4'; | ||
}; | ||
IPv4.prototype.toString = function() { | ||
return this.octets.join("."); | ||
}; | ||
IPv4.prototype.toByteArray = function() { | ||
return this.octets.slice(0); | ||
}; | ||
IPv4.prototype.match = function(other, cidrRange) { | ||
@@ -81,2 +91,3 @@ if (other.kind() !== 'ipv4') { | ||
}; | ||
IPv4.prototype.SpecialRanges = { | ||
@@ -87,14 +98,20 @@ broadcast: [[new IPv4([255, 255, 255, 255]), 32]], | ||
loopback: [[new IPv4([127, 0, 0, 0]), 8]], | ||
private: [[new IPv4([10, 0, 0, 0]), 8], [new IPv4([172, 16, 0, 0]), 12], [new IPv4([192, 168, 0, 0]), 16]], | ||
"private": [[new IPv4([10, 0, 0, 0]), 8], [new IPv4([172, 16, 0, 0]), 12], [new IPv4([192, 168, 0, 0]), 16]], | ||
reserved: [[new IPv4([192, 0, 0, 0]), 24], [new IPv4([192, 0, 2, 0]), 24], [new IPv4([192, 88, 99, 0]), 24], [new IPv4([198, 51, 100, 0]), 24], [new IPv4([203, 0, 113, 0]), 24], [new IPv4([240, 0, 0, 0]), 4]] | ||
}; | ||
IPv4.prototype.range = function() { | ||
return ipaddr.subnetMatch(this, this.SpecialRanges); | ||
}; | ||
IPv4.prototype.toIPv4MappedAddress = function() { | ||
return ipaddr.IPv6.parse("::ffff:" + (this.toString())); | ||
}; | ||
return IPv4; | ||
})(); | ||
ipv4Part = "(0?\\d+|0x[a-f0-9]+)"; | ||
ipv4Regexes = { | ||
@@ -104,21 +121,32 @@ fourOctet: new RegExp("^" + ipv4Part + "\\." + ipv4Part + "\\." + ipv4Part + "\\." + ipv4Part + "$", 'i'), | ||
}; | ||
ipaddr.IPv4.parser = function(string) { | ||
var match, part, shift, value, _i, _len, _ref, _results; | ||
var match, parseIntAuto, part, shift, value; | ||
parseIntAuto = function(string) { | ||
if (string[0] === "0" && string[1] !== "x") { | ||
return parseInt(string, 8); | ||
} else { | ||
return parseInt(string); | ||
} | ||
}; | ||
if (match = string.match(ipv4Regexes.fourOctet)) { | ||
_ref = match.slice(1, 6); | ||
_results = []; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
part = _ref[_i]; | ||
_results.push(parseInt(part)); | ||
} | ||
return _results; | ||
return (function() { | ||
var _i, _len, _ref, _results; | ||
_ref = match.slice(1, 6); | ||
_results = []; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
part = _ref[_i]; | ||
_results.push(parseIntAuto(part)); | ||
} | ||
return _results; | ||
})(); | ||
} else if (match = string.match(ipv4Regexes.longValue)) { | ||
value = parseInt(match[1]); | ||
value = parseIntAuto(match[1]); | ||
return ((function() { | ||
var _results2, _step; | ||
_results2 = []; | ||
for (shift = 0, _step = 8; shift <= 24; shift += _step) { | ||
_results2.push((value >> shift) & 0xff); | ||
var _i, _results; | ||
_results = []; | ||
for (shift = _i = 0; _i <= 24; shift = _i += 8) { | ||
_results.push((value >> shift) & 0xff); | ||
} | ||
return _results2; | ||
return _results; | ||
})()).reverse(); | ||
@@ -129,2 +157,3 @@ } else { | ||
}; | ||
ipaddr.IPv6 = (function() { | ||
@@ -144,5 +173,7 @@ function IPv6(parts) { | ||
} | ||
IPv6.prototype.kind = function() { | ||
return 'ipv6'; | ||
}; | ||
IPv6.prototype.toString = function() { | ||
@@ -200,2 +231,3 @@ var compactStringParts, part, pushPart, state, stringParts, _i, _len; | ||
}; | ||
IPv6.prototype.toByteArray = function() { | ||
@@ -212,2 +244,3 @@ var bytes, part, _i, _len, _ref; | ||
}; | ||
IPv6.prototype.toNormalizedString = function() { | ||
@@ -226,2 +259,3 @@ var part; | ||
}; | ||
IPv6.prototype.match = function(other, cidrRange) { | ||
@@ -233,2 +267,3 @@ if (other.kind() !== 'ipv6') { | ||
}; | ||
IPv6.prototype.SpecialRanges = { | ||
@@ -247,8 +282,11 @@ unspecified: [new IPv6([0, 0, 0, 0, 0, 0, 0, 0]), 128], | ||
}; | ||
IPv6.prototype.range = function() { | ||
return ipaddr.subnetMatch(this, this.SpecialRanges); | ||
}; | ||
IPv6.prototype.isIPv4MappedAddress = function() { | ||
return this.range() === 'ipv4Mapped'; | ||
}; | ||
IPv6.prototype.toIPv4Address = function() { | ||
@@ -262,5 +300,9 @@ var high, low, _ref; | ||
}; | ||
return IPv6; | ||
})(); | ||
ipv6Part = "(?:[0-9a-f]+::?)+"; | ||
ipv6Regexes = { | ||
@@ -270,4 +312,5 @@ "native": new RegExp("^(::)?(" + ipv6Part + ")?([0-9a-f]+)?(::)?$", 'i'), | ||
}; | ||
expandIPv6 = function(string, parts) { | ||
var colonCount, lastColon, part, replacement, replacementCount, _i, _len, _ref, _results; | ||
var colonCount, lastColon, part, replacement, replacementCount; | ||
if (string.indexOf('::') !== string.lastIndexOf('::')) { | ||
@@ -299,10 +342,14 @@ return null; | ||
} | ||
_ref = string.split(":"); | ||
_results = []; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
part = _ref[_i]; | ||
_results.push(parseInt(part, 16)); | ||
} | ||
return _results; | ||
return (function() { | ||
var _i, _len, _ref, _results; | ||
_ref = string.split(":"); | ||
_results = []; | ||
for (_i = 0, _len = _ref.length; _i < _len; _i++) { | ||
part = _ref[_i]; | ||
_results.push(parseInt(part, 16)); | ||
} | ||
return _results; | ||
})(); | ||
}; | ||
ipaddr.IPv6.parser = function(string) { | ||
@@ -322,13 +369,18 @@ var match, parts; | ||
}; | ||
ipaddr.IPv4.isIPv4 = ipaddr.IPv6.isIPv6 = function(string) { | ||
return this.parser(string) !== null; | ||
}; | ||
ipaddr.IPv4.isValid = ipaddr.IPv6.isValid = function(string) { | ||
var e; | ||
try { | ||
new this(this.parser(string)); | ||
return true; | ||
} catch (e) { | ||
} catch (_error) { | ||
e = _error; | ||
return false; | ||
} | ||
}; | ||
ipaddr.IPv4.parse = ipaddr.IPv6.parse = function(string) { | ||
@@ -342,5 +394,7 @@ var parts; | ||
}; | ||
ipaddr.isValid = function(string) { | ||
return ipaddr.IPv6.isValid(string) || ipaddr.IPv4.isValid(string); | ||
}; | ||
ipaddr.parse = function(string) { | ||
@@ -355,2 +409,3 @@ if (ipaddr.IPv6.isIPv6(string)) { | ||
}; | ||
ipaddr.process = function(string) { | ||
@@ -365,2 +420,3 @@ var addr; | ||
}; | ||
}).call(this); |
{ | ||
"name": "ipaddr.js", | ||
"description": "A library for manipulating IPv4 and IPv6 addresses in JavaScript.", | ||
"version": "0.1.1", | ||
"version": "0.1.2", | ||
"author": "Peter Zotov <whitequark@whitequark.org>", | ||
@@ -9,9 +9,11 @@ "directories": { | ||
}, | ||
"dependencies": { | ||
"coffee-script": ">= 1.1.1" | ||
}, | ||
"dependencies": {}, | ||
"devDependencies": { | ||
"nodeunit": "0.5.3", | ||
"coffee-script": "~1.6", | ||
"nodeunit": "~0.5.3", | ||
"uglify-js": "latest" | ||
}, | ||
"scripts": { | ||
"test": "cake build test" | ||
}, | ||
"keywords": ["ip", "ipv4", "ipv6"], | ||
@@ -18,0 +20,0 @@ "repository": "git://github.com/whitequark/ipaddr.js", |
@@ -14,2 +14,6 @@ # ipaddr.js — an IPv6 and IPv4 address manipulation library | ||
## Installation | ||
`npm install ipaddr.js` | ||
## API | ||
@@ -21,3 +25,3 @@ | ||
```js | ||
var ipaddr = require('ipaddr'); | ||
var ipaddr = require('ipaddr.js'); | ||
``` | ||
@@ -29,6 +33,6 @@ | ||
There are three global methods defined: `ipaddr.verify`, `ipaddr.parse` and | ||
There are three global methods defined: `ipaddr.isValid`, `ipaddr.parse` and | ||
`ipaddr.process`. All of them receive a string as a single parameter. | ||
The `ipaddr.verify` method returns `true` if the address is a valid IPv4 or | ||
The `ipaddr.isValid` method returns `true` if the address is a valid IPv4 or | ||
IPv6 address, and `false` otherwise. It does not throw any exceptions. | ||
@@ -35,0 +39,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
Non-existent author
Supply chain riskThe package was published by an npm account that no longer exists.
Found 1 instance in 1 package
45872
0
360
150
0
3
1
- Removedcoffee-script@>= 1.1.1
- Removedcoffee-script@1.12.7(transitive)