New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ipv6-to-bin

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ipv6-to-bin - npm Package Compare versions

Comparing version 0.1.2 to 0.1.3

.jscsrc

17

package.json
{
"name": "ipv6-to-bin",
"version": "0.1.2",
"version": "0.1.3",
"description": "Converts an ipv6 address to a binary form",
"main": "src/ipv6-to-bin.js",
"scripts": {
"test": "make test"
"test": "npm run test-style && make test",
"test-jshint": "jshint src/ipv6-to-bin.js test/ipv6-to-bin.js",
"test-jscs": "node_modules/jscs/bin/jscs src/ipv6-to-bin.js test/ipv6-to-bin.js",
"test-style": "npm run test-jshint && npm run test-jscs"
},
"repository": {
"type": "git",
"url": "git+https://github.com/ozipi/ipv4-to-bin.git"
},
"keywords": [

@@ -16,2 +23,6 @@ "ipv6",

"license": "MIT",
"bugs": {
"url": "https://github.com/ozipi/ipv4-to-bin/issues"
},
"homepage": "https://github.com/ozipi/ipv4-to-bin#readme",
"dependencies": {

@@ -23,2 +34,4 @@ "hex-to-binary": "^1.0.1"

"mocha": "^2.4.5",
"jscs": "^2.11.0",
"jshint": "^2.9.1",
"istanbul": "~0.2.4",

@@ -25,0 +38,0 @@ "coveralls": "~2.7.1"

16

src/ipv6-to-bin.js
var hexToBinary = require('hex-to-binary');
function ipv6ToBin(ip) {
var ipSplit = ip.split(":");
var result = [];
for (var i = 0; i < ipSplit.length; i++) {
var binarySegment = hexToBinary(ipSplit[i]);
result.push(binarySegment);
}
var ipSplit = ip.split(":");
var result = [];
for (var i = 0; i < ipSplit.length; i++) {
var binarySegment = hexToBinary(ipSplit[i]);
result.push(binarySegment);
}
return result.join(":");
return result.join(":");
}
module.exports = ipv6ToBin;
module.exports = ipv6ToBin;
var should = require('chai').should(),
ipv6ToBin = require('../src/ipv6-to-bin.js');
ipv6ToBin = require('../src/ipv6-to-bin.js');
describe('#ipv6-to-bin', function() {
it('converts 0:0:0:0:0:0:0:0001 into 0000000000000000:0000000000000000:0000000000000000:0000000000000000:0000000000000000:0000000000000000:0000000000000000:0000000000000001;', function() {
ipv6ToBin('0000:0000:0000:0000:0000:0000:0000:0001').should.equal('0000000000000000:0000000000000000:0000000000000000:0000000000000000:0000000000000000:0000000000000000:0000000000000000:0000000000000001');
});
it('converts 0:0:0:0:0:0:0:0001 into 0000000000000000:0000000000000000:0000000000000000:0000000000000000:0000000000000000:0000000000000000:0000000000000000:0000000000000001;', function() {
ipv6ToBin('0000:0000:0000:0000:0000:0000:0000:0001').should.equal('0000000000000000:0000000000000000:0000000000000000:0000000000000000:0000000000000000:0000000000000000:0000000000000000:0000000000000001');
});
it('converts 2001:4860:4860::8888 into 0010000000000001:0100100001100000:0100100001100000::1000100010001000;', function() {
ipv6ToBin('2001:4860:4860::8888').should.equal('0010000000000001:0100100001100000:0100100001100000::1000100010001000');
});
});
it('converts 2001:4860:4860::8888 into 0010000000000001:0100100001100000:0100100001100000::1000100010001000;', function() {
ipv6ToBin('2001:4860:4860::8888').should.equal('0010000000000001:0100100001100000:0100100001100000::1000100010001000');
});
});
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc