Comparing version 1.2.3 to 1.2.4
@@ -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(); | ||
}; |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
405609
11414