Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(820)

Unified Diff: node_modules/vulcanize/node_modules/update-notifier/node_modules/configstore/node_modules/uuid/misc/compare.js

Issue 800513006: Added vulcanize under third_party/npm_modules (Closed) Base URL: https://chromium.googlesource.com/infra/third_party/npm_modules.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: node_modules/vulcanize/node_modules/update-notifier/node_modules/configstore/node_modules/uuid/misc/compare.js
diff --git a/node_modules/vulcanize/node_modules/update-notifier/node_modules/configstore/node_modules/uuid/misc/compare.js b/node_modules/vulcanize/node_modules/update-notifier/node_modules/configstore/node_modules/uuid/misc/compare.js
new file mode 100644
index 0000000000000000000000000000000000000000..3de34151df2b4125b86848b694256eafbe49f51f
--- /dev/null
+++ b/node_modules/vulcanize/node_modules/update-notifier/node_modules/configstore/node_modules/uuid/misc/compare.js
@@ -0,0 +1,62 @@
+var assert = require('assert'),
+ nodeuuid = require('../'),
+ uuidjs = require('uuid-js'),
+ util = require('util'),
+ exec = require('child_process').exec,
+ os = require('os');
+
+// On Mac Os X / macports there's only the ossp-uuid package that provides uuid
+// On Linux there's uuid-runtime which provides uuidgen
+var uuidCmd = os.type() === 'Darwin' ? 'uuid -1' : 'uuidgen -t';
+
+function compare(ids) {
+ console.log(ids);
+ for (var i = 0; i < ids.length; i++) {
+ var id = ids[i].split('-');
+ id = [id[2], id[1], id[0]].join('');
+ ids[i] = id;
+ }
+ var sorted = ([].concat(ids)).sort();
+
+ if (sorted.toString() !== ids.toString()) {
+ console.log('Warning: sorted !== ids');
+ } else {
+ console.log('everything in order!');
+ }
+}
+
+// Test time order of v1 uuids
+var ids = [];
+while (ids.length < 10e3) ids.push(nodeuuid.v1());
+
+var max = 10;
+console.log('node-uuid:');
+ids = [];
+for (var i = 0; i < max; i++) ids.push(nodeuuid.v1());
+compare(ids);
+
+console.log('');
+console.log('uuidjs:');
+ids = [];
+for (var i = 0; i < max; i++) ids.push(uuidjs.create(1).toString());
+compare(ids);
+
+console.log('');
+console.log('libuuid:');
+ids = [];
+var count = 0;
+var last = function() {
+ compare(ids);
+}
+var cb = function(err, stdout, stderr) {
+ ids.push(stdout.substring(0, stdout.length-1));
+ count++;
+ if (count < max) {
+ return next();
+ }
+ last();
+};
+var next = function() {
+ exec(uuidCmd, cb);
+};
+next();

Powered by Google App Engine
This is Rietveld 408576698