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.5 to 0.1.0

16

lib/ip.js

@@ -296,4 +296,20 @@ var ip = exports,

ip.toLong = function toInt(ip){
var ipl=0;
ip.split('.').forEach(function( octet ) {
ipl<<=8;
ipl+=parseInt(octet);
});
return(ipl >>>0);
};
ip.fromLong = function fromInt(ipl){
return ( (ipl>>>24) +'.' +
(ipl>>16 & 255) +'.' +
(ipl>>8 & 255) +'.' +
(ipl & 255) );
};
function _normalizeFamily(family) {
return family ? family.toLowerCase() : 'ipv4';
}

2

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

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

@@ -24,2 +24,7 @@ # IP

ip.toString(buf, offset, 4); // '127.0.0.1'
// ipv4 long conversion
ip.toLong('127.0.0.1'); // 2130706433
ip.fromLong(2130706433); // '127.0.0.1'
```

@@ -26,0 +31,0 @@

@@ -211,2 +211,18 @@ var ip = require('..'),

});
describe('toLong() method', function(){
it('should respond with a int', function(){
assert.equal(ip.toLong('127.0.0.1'), 2130706433);
assert.equal(ip.toLong('255.255.255.255'), 4294967295);
});
});
describe('fromLong() method', function(){
it('should repond with ipv4 address', function(){
assert.equal(ip.fromLong(2130706433), '127.0.0.1');
assert.equal(ip.fromLong(4294967295), '255.255.255.255');
});
})
});
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