Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

shortid

Package Overview
Dependencies
Maintainers
1
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

shortid - npm Package Compare versions

Comparing version 1.0.5 to 1.0.6

33

lib/shortid.js

@@ -6,4 +6,6 @@ /*

*/
var randomBytes = require('crypto').randomBytes
var randomBytes = require('crypto').randomBytes;
var DEBUG = false;
// Older (pre 0.6) versions of Node don't have a randomBytes function

@@ -34,2 +36,11 @@ if (!randomBytes) {

function toString(buffer) {
var str = '';
var i;
for(i = 0; i < buffer.length; i++) {
str = str + ALPHABET_SHUFFLED[buffer[i]];
}
return str;
}
/**

@@ -41,3 +52,3 @@ * Generate the id

var seconds = Date.now() - LESS_TIME >> 10; //divide by 10 to get seconds
var seconds = Math.round((Date.now() - LESS_TIME) * 0.01); // using >> got us negative numbers somehow

@@ -59,16 +70,22 @@ counter = seconds == previousSeconds ? counter + 1 : 0;

encode(options.version);
DEBUG && console.log('just version', toString(buffer));
encode(options.worker);
DEBUG && console.log('worker', toString(buffer));
if (counter > 0) {
encode(counter);
DEBUG && console.log('counter', toString(buffer));
}
encode(seconds); //seconds since this module was created. >> 10 removes the milliseconds more or less.
DEBUG && console.log('seconds', toString(buffer), seconds);
previousSeconds = seconds;
var str = '';
var i;
for(i = 0; i < buffer.length; i++) {
str = str + ALPHABET_SHUFFLED[buffer[i]];
}
return str;
return toString(buffer);
}

@@ -75,0 +92,0 @@

{
"name":"shortid",
"version":"1.0.5",
"version":"1.0.6",
"description":"Amazingly short non-sequential url-friendly unique id generator.",

@@ -5,0 +5,0 @@ "keywords": ["short", "tiny", "id", "uuid", "bitly", "shorten", "mongoid", "shortid", "tinyid", "id"],

Sorry, the diff of this file is not supported yet

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