Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UUID v3 Support #217

Merged
merged 8 commits into from
Sep 7, 2017
Merged

UUID v3 Support #217

merged 8 commits into from
Sep 7, 2017

Conversation

abstein2
Copy link
Contributor

@abstein2 abstein2 commented Aug 28, 2017

Adds support for UUID v3 based on the code for v5. Since v3 and v5 are generated in almost exactly the same way the major addition to this is added md5 (using crypto) and md5-browser (based on the implementation in https://github.com/blueimp/JavaScript-MD5) to the lib directory and then using them.

Updated tests, CLI commands, README_js.md, and tests. I needed v3 support for older systems as we migrate them to JavaScript.

Happy to make any additional changes.

@broofa
Copy link
Member

broofa commented Aug 31, 2017

This looks good, thanks! (It'll be nice to finally round out all the uuid versions in this module after all these years. :-D )

One change: v3.js and v5.js are identical but for a couple lines. Let's factor that code into a common module (e.g. lib/v35.js?) thusly ...

v35.js:

module.exports = function(name, version, hash) {
  var uuid = function(name, namespace, buf, offset) {
    ... (guts of v3()/v5() implementations) ...
    var bytes = hash(namespace.concat(name));
    bytes[6] = (bytes[6] & 0x0f) | version;
    ...
  }
  uuid.name = name; // Set function name shown in debuggers
  return uuid;
}

v3.js

var v35 = require('./lib/v35.js');
var md5 = require('./lib/md5');
module.exports = v35('v3', 0x03, md5);

v5.js

var v35 = require('./lib/v35.js');
var md5 = require('./lib/sha1');
module.exports = v35('v5', 0x05, sha1);

@abstein2
Copy link
Contributor Author

Good idea. Updates made.

@broofa broofa merged commit dc02a76 into uuidjs:master Sep 7, 2017
broofa added a commit that referenced this pull request Jan 16, 2018
Note: Actual change is in dc02a76.
Just making a placeholder commit here so the note gets picked up by
standard-version and put in the CHANGELOG.md file.
broofa added a commit that referenced this pull request Jan 16, 2018
* +package-lock.json because npm requires it

* 3.2.0

* README updates

* fix: remove mistakenly added typescript dependency, rollback version (standard-version will auto-increment)

* chore: fixup README, update package-lock

* feat: Add v3 Support (#217)

Note: Actual change is in dc02a76.
Just making a placeholder commit here so the note gets picked up by
standard-version and put in the CHANGELOG.md file.

* chore(release): 3.2.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants