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

nuid

Package Overview
Dependencies
Maintainers
1
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nuid - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

.eslintignore

80

lib/nuid.js

@@ -16,3 +16,2 @@ /*

/* jslint node: true */
'use strict';

@@ -24,3 +23,3 @@

var crypto = require('crypto');
const crypto = require('crypto');

@@ -30,11 +29,11 @@ /**

*/
var VERSION = '1.0.0',
digits = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ',
base = 36,
preLen = 12,
seqLen = 10,
maxSeq = 3656158440062976, // base^seqLen == 36^10
minInc = 33,
maxInc = 333,
totalLen = preLen + seqLen;
const VERSION = '1.0.0',
digits = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ',
base = 36,
preLen = 12,
seqLen = 10,
maxSeq = 3656158440062976, // base^seqLen == 36^10
minInc = 33,
maxInc = 333,
totalLen = preLen + seqLen;

@@ -50,4 +49,4 @@ exports.version = VERSION;

function Nuid() {
this.buf = Buffer.alloc(totalLen);
this.init();
this.buf = Buffer.alloc(totalLen);
this.init();
}

@@ -63,5 +62,5 @@

Nuid.prototype.init = function() {
this.setPre();
this.initSeqAndInc();
this.fillSeq();
this.setPre();
this.initSeqAndInc();
this.fillSeq();
};

@@ -76,4 +75,4 @@

Nuid.prototype.initSeqAndInc = function() {
this.seq = Math.floor(Math.random()*maxSeq);
this.inc = Math.floor(Math.random()*(maxInc-minInc)+minInc);
this.seq = Math.floor(Math.random() * maxSeq);
this.inc = Math.floor((Math.random() * (maxInc - minInc)) + minInc);
};

@@ -88,7 +87,7 @@

Nuid.prototype.setPre = function() {
var cbuf = crypto.randomBytes(preLen);
for (var i = 0; i < preLen; i++) {
var di = cbuf[i]%base;
this.buf[i] = digits.charCodeAt(di);
}
const cbuf = crypto.randomBytes(preLen);
for (let i = 0; i < preLen; i++) {
const di = cbuf[i] % base;
this.buf[i] = digits.charCodeAt(di);
}
};

@@ -103,7 +102,7 @@

Nuid.prototype.fillSeq = function() {
var n = this.seq;
for (var i = totalLen-1; i >= preLen; i--) {
this.buf[i] = digits.charCodeAt(n%base);
n = Math.floor(n/base);
}
let n = this.seq;
for (let i = totalLen - 1; i >= preLen; i--) {
this.buf[i] = digits.charCodeAt(n % base);
n = Math.floor(n / base);
}
};

@@ -118,13 +117,13 @@

Nuid.prototype.next = function() {
this.seq += this.inc;
if (this.seq > maxSeq) {
this.setPre();
this.initSeqAndInc();
}
this.fillSeq();
return (this.buf.toString('ascii'));
this.seq += this.inc;
if (this.seq > maxSeq) {
this.setPre();
this.initSeqAndInc();
}
this.fillSeq();
return (this.buf.toString('ascii'));
};
/* Global Nuid */
var g = new Nuid();
const g = new Nuid();

@@ -139,3 +138,3 @@ /**

exports.reset = function() {
g.init();
g.init();
};

@@ -150,3 +149,3 @@

exports.next = function() {
return g.next();
return g.next();
};

@@ -158,4 +157,5 @@

*/
exports._global = g;
exports.getGlobalNuid = function() {
return g;
};
{
"name": "nuid",
"version": "1.0.0",
"version": "1.1.0",
"description": "NUID - A highly performant unique identifier generator.",

@@ -26,3 +26,2 @@ "keywords": [

"scripts": {
"lint": "jshint --reporter node_modules/jshint-stylish lib/*.js test/*.js test/support/*.js examples/*.js",
"depcheck": "dependency-check . lib/*",

@@ -33,17 +32,25 @@ "depcheck:unused": "dependency-check ./package.json --unused --no-dev lib/*",

"coveralls": "npm run cover -- --report lcovonly && cat ./reports/coverage/lcov.info | coveralls",
"cover": "istanbul cover _mocha"
"cover": "istanbul cover _mocha",
"lint": "if-node-version '>=4' eslint ./lib ./examples ./test",
"fmt": "js-beautify -n --config crockford.jscsrc -r lib/* test/*.js examples/*",
"publish-npm": "npm publish --access public",
"publish-npm:beta": "npm publish --tag=next"
},
"engines": {
"node": ">= 4.5.0"
"node": ">= 6.0.0"
},
"dependencies": {},
"devDependencies": {
"jshint": "2.9.x",
"minimist": "^1.2.0",
"coveralls": "^3.0.2",
"dependency-check": "^3.2.1",
"eslint": "^5.10.0",
"if-node-version": "^1.1.1",
"istanbul": "^0.4.5",
"js-beautify": "^1.6.12",
"jshint": "^2.9.6",
"jshint-stylish": "2.2.x",
"mocha": "2.5.x",
"mocha-multi": "0.9.x",
"mocha": "^5.2.0",
"mocha-lcov-reporter": "1.2.x",
"dependency-check": "2.5.x",
"istanbul": "0.4.x",
"coveralls": "^2.11.2",
"mocha-multi": "^1.0.1",
"should": ">= 9.0.0"

@@ -50,0 +57,0 @@ },

@@ -6,4 +6,5 @@ # NODE NUID

[![Coveralls github branch](https://img.shields.io/coveralls/github/nats-io/node-nuid/master.svg)]()
[![npm](https://img.shields.io/npm/v/nuid.svg)](https://www.npmjs.com/package/nats)
[![npm](https://img.shields.io/npm/dt/nuid.svg)](https://www.npmjs.com/package/nats)
[![npm](https://img.shields.io/npm/v/nuid.svg)](https://www.npmjs.com/package/node-nuid)
[![npm](https://img.shields.io/npm/dt/nuid.svg)](https://www.npmjs.com/package/node-nuid)
[![npm](https://img.shields.io/npm/dm/nuid.svg)](https://www.npmjs.com/package/node-nuid)

@@ -21,4 +22,4 @@ A highly performant unique identifier generator.

var NUID = require('nuid');
var nuid = NUID.next();
const NUID = require('nuid');
let nuid = NUID.next();

@@ -25,0 +26,0 @@

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