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

uuid4

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

uuid4 - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

browser.js

40

index.js

@@ -7,23 +7,15 @@ 'use strict';

exports = module.exports = generateUuid;
exports.async = generateUuidAsync;
exports.sync = generateUuidSync;
exports.valid = generateUuid;
exports = module.exports = genUUID;
exports.valid = isUUID;
function isUUID(uuid) {
return uuidPattern.test(uuid);
}
function generateUuidSync() {
var rnd = crypto.randomBytes(16);
rnd[6] = (rnd[6] & 0x0f) | 0x40;
rnd[8] = (rnd[8] & 0x3f) | 0x80;
rnd = rnd.toString('hex').match(/(.{8})(.{4})(.{4})(.{4})(.{12})/);
rnd.shift();
return rnd.join('-');
}
function generateUuidAsync(callback) {
function genUUID(callback) {
if (typeof(callback) !== 'function') {
var rnd = crypto.randomBytes(16);
rnd[6] = (rnd[6] & 0x0f) | 0x40;
rnd[8] = (rnd[8] & 0x3f) | 0x80;
rnd = rnd.toString('hex').match(/(.{8})(.{4})(.{4})(.{4})(.{12})/);
rnd.shift();
return rnd.join('-');
}
crypto.randomBytes(16, function(err, rnd) {

@@ -34,9 +26,9 @@ rnd[6] = (rnd[6] & 0x0f) | 0x40;

rnd.shift();
callback(null, rnd.join('-'));
return rnd.join('-');
});
}
function generateUuid(callback) {
if (typeof callback !== 'function') return generateUuidSync();
return generateUuidAsync(callback);
}
function isUUID(uuid) {
return uuidPattern.test(uuid);
}

3

package.json
{
"name": "uuid4",
"version": "1.0.0",
"version": "1.1.0",
"description": "Node UUID v4 Generator",
"main": "index.js",
"browser": "browser.js",
"scripts": {

@@ -7,0 +8,0 @@ "test": "echo \"Error: no test specified\" && exit 1"

@@ -5,2 +5,4 @@ # uuid4

Note v1.1 adds a browser entry for use in browsers, `crypto` api for rng in modern browser, fallback to `Math.random()`
## Install

@@ -15,12 +17,12 @@

```javascript
var uuid = require('uuid4');
var uuid4 = require('uuid4');
// Generate a new UUID
var id = uuid();
var id = uuid4();
// Validate a UUID as proper V4 format
uuid.valid(id); // true
uuid4.valid(id); // true
// Generate a new UUID Asyncronously
uuid(function(err, id){
// NODE ONLY: Generate a new UUID Asynchronously
uuid4(function(err, id){
//if (err) ...;

@@ -27,0 +29,0 @@

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