Comparing version 1.0.2 to 1.1.0
@@ -208,3 +208,6 @@ 'use strict'; | ||
numberOfAddresses : numberOfAddresses - 2, | ||
length: numberOfAddresses | ||
length: numberOfAddresses, | ||
contains: function(other) { | ||
return networkAddress === ip.toLong(ip.mask(other, mask)); | ||
} | ||
}; | ||
@@ -211,0 +214,0 @@ }; |
{ | ||
"name": "ip", | ||
"version": "1.0.2", | ||
"version": "1.1.0", | ||
"author": "Fedor Indutny <fedor@indutny.com>", | ||
@@ -17,5 +17,6 @@ "homepage": "https://github.com/indutny/node-ip", | ||
"scripts": { | ||
"test": "jscs lib/*.js test/*.js && jshint lib/*.js && mocha --reporter spec test/*-test.js" | ||
"test": "jscs lib/*.js test/*.js && jshint lib/*.js && mocha --reporter spec test/*-test.js", | ||
"fix": "jscs lib/*.js test/*.js --fix" | ||
}, | ||
"license": "MIT" | ||
} |
@@ -53,6 +53,11 @@ # IP | ||
// numHosts: 62, | ||
// length: 64 } | ||
// length: 64, | ||
// contains: function(addr){...} } | ||
ip.cidrSubnet('192.168.1.134/26') | ||
// Same as previous. | ||
// range checking | ||
ip.cidrSubnet('192.168.1.134/26').contains('192.168.1.190') // true | ||
// ipv4 long conversion | ||
@@ -59,0 +64,0 @@ ip.toLong('127.0.0.1'); // 2130706433 |
@@ -133,2 +133,10 @@ 'use strict'; | ||
}); | ||
it('should know whether a subnet contains an address', function() { | ||
assert.equal(ipv4Subnet.contains('192.168.1.180'), true); | ||
}); | ||
it('should know whether a subnet does not contain an address', function() { | ||
assert.equal(ipv4Subnet.contains('192.168.1.195'), false); | ||
}); | ||
}); | ||
@@ -203,2 +211,11 @@ | ||
}); | ||
it('should know whether a subnet contains an address', function() { | ||
assert.equal(ipv4Subnet.contains('192.168.1.180'), true); | ||
}); | ||
it('should know whether a subnet contains an address', function() { | ||
assert.equal(ipv4Subnet.contains('192.168.1.195'), false); | ||
}); | ||
}); | ||
@@ -205,0 +222,0 @@ |
35206
674
91