Socket
Socket
Sign inDemoInstall

cuid

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cuid - npm Package Compare versions

Comparing version 1.2.3 to 1.2.4

6

dist/browser-cuid.js

@@ -70,7 +70,7 @@ /**

api.fingerprint().slice(-1),
random = randomBlock().slice(-1);
random = randomBlock().slice(-2);
counter = safeCounter().toString(36).slice(-1);
counter = safeCounter().toString(36).slice(-4);
return date.slice(2,4) + date.slice(-2) +
return date.slice(-2) +
counter + print + random;

@@ -77,0 +77,0 @@ };

@@ -70,7 +70,7 @@ /**

api.fingerprint().slice(-1),
random = randomBlock().slice(-1);
random = randomBlock().slice(-2);
counter = safeCounter().toString(36).slice(-1);
counter = safeCounter().toString(36).slice(-4);
return date.slice(2,4) + date.slice(-2) +
return date.slice(-2) +
counter + print + random;

@@ -77,0 +77,0 @@ };

{
"name": "cuid",
"version": "1.2.3",
"version": "1.2.4",
"description": "Collision-resistant ids optimized for horizontal scaling and performance. For node and browsers.",

@@ -33,3 +33,3 @@ "author": {

"scripts": {
"test": "grunt testall"
"test": "grunt test"
},

@@ -36,0 +36,0 @@ "engines": {

@@ -36,3 +36,3 @@ /**

c++; // this is not subliminal
return c-1;
return c - 1;
},

@@ -71,8 +71,8 @@

api.fingerprint().slice(-1),
random = randomBlock().slice(-1);
random = randomBlock().slice(-2);
counter = safeCounter().toString(36).slice(-1);
counter = safeCounter().toString(36).slice(-4);
return date.slice(2,4) + date.slice(-2) +
return date.slice(-2) +
counter + print + random;
};

@@ -1,29 +0,36 @@

/*global require console exports */
var cuid = require('../dist/node-cuid.js');
exports.testcuid = function (test) {
var collision = false;
(function () {
var ids = test.ids = {},
i,
id;
for (i = 0; i < 600000; i++) {
id = cuid();
if (!ids[id]) {
ids[id] = id;
} else {
collision = true;
break;
}
var MAX = 1200000;
var collisionTest = function collisionTest(fn) {
var i = 0,
id,
ids = {},
pass = true;
while (i < MAX) {
id = fn();
if (!ids[id]) {
ids[id] = id;
} else {
pass = false;
console.log('Failed at ' + i + ' iterations.');
break;
}
i++;
}
return pass;
};
test.ok(typeof cuid() === 'string',
'.cuid() should return a string');
exports.testcuid = function (test) {
test.ok(typeof cuid() === 'string',
'.cuid() should return a string.');
test.ok(!collision,
'ids should not collide');
test.ok(collisionTest(cuid),
'ids should not collide.');
test.done();
test.ok(collisionTest(cuid.slug),
'slugs should not collide.');
}());
};
test.done();
};
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