ipv6-to-bin
Advanced tools
Comparing version 0.1.2 to 0.1.3
{ | ||
"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" |
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'); | ||
}); | ||
}); |
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
16304
10
21
1
1
0
6