Socket
Socket
Sign inDemoInstall

hat

Package Overview
Dependencies
0
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.1 to 0.0.2

7

index.js

@@ -7,2 +7,6 @@ var hat = module.exports = function (bits, base) {

var digits = Math.log(Math.pow(2, bits)) / Math.log(base);
for (var i = 2; digits === Infinity; i *= 2) {
digits = Math.log(Math.pow(2, bits / i)) / Math.log(base) * i;
}
var rem = digits - Math.floor(digits);

@@ -23,3 +27,4 @@

if (parseInt(res, base) >= Math.pow(2, bits)) {
var parsed = parseInt(res, base);
if (parsed !== Infinity && parsed >= Math.pow(2, bits)) {
return hat(bits, base)

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

2

package.json
{
"name" : "hat",
"version" : "0.0.1",
"version" : "0.0.2",
"description" : "generate random IDs and avoid collisions",

@@ -5,0 +5,0 @@ "main" : "index.js",

@@ -40,1 +40,11 @@ var hat = require('../');

};
exports.big = function () {
var id = hat(1024);
assert.equal(id.length, 256);
};
exports.bigger = function () {
var id = hat(2048);
assert.equal(id.length, 512);
};
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