Socket
Socket
Sign inDemoInstall

ip

Package Overview
Dependencies
0
Maintainers
1
Versions
26
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.2 to 0.0.3

29

lib/ip.js

@@ -104,2 +104,31 @@ var ip = exports,

ip.or = function or(a, b) {
a = ip.toBuffer(a);
b = ip.toBuffer(b);
// same protocol
if (a.length == b.length) {
for (var i = 0; i < a.length; ++i) {
a[i] |= b[i];
}
return ip.toString(a);
// mixed protocols
} else {
var buff = a;
var other = b;
if (b.length > a.length) {
buff = b;
other = a;
}
var offset = buff.length - other.length;
for (var i = offset; i < buff.length; ++i) {
buff[i] |= other[i - offset];
}
return ip.toString(buff);
}
};
ip.isEqual = function isEqual(a, b) {

@@ -106,0 +135,0 @@ a = ip.toBuffer(a);

2

package.json
{
"name": "ip",
"version": "0.0.2",
"version": "0.0.3",
"author": "Fedor Indutny <fedor@indutny.com>",

@@ -5,0 +5,0 @@ "homepage": "https://github.com/indutny/node-ip",

@@ -15,2 +15,3 @@ # IP

ip.not('255.255.255.0') // 0.0.0.255
ip.or('192.168.1.134', '0.0.0.255') // 192.168.1.255
ip.isPrivate('127.0.0.1') // true

@@ -17,0 +18,0 @@ ```

@@ -29,2 +29,14 @@ var ip = require('..'),

describe('or() method', function() {
it('should or bits in ipv4 addresses', function() {
assert.equal(ip.or('0.0.0.255', '192.168.1.10'), '192.168.1.255');
});
it('should or bits in ipv6 addresses', function() {
assert.equal(ip.or('::ff', '::abcd:dcba:abcd:dcba'), '::abcd:dcba:abcd:dcff');
});
it('should or bits in mixed addresses', function() {
assert.equal(ip.or('0.0.0.255', '::abcd:dcba:abcd:dcba'), '::abcd:dcba:abcd:dcff');
});
});
describe('mask() method', function() {

@@ -31,0 +43,0 @@ it('should mask bits in address', function() {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc