broofa/node-uuid — pull request #25 by ctavan (2011-12-19 16:42:31+00:00)
Title: Clockseq

I just got the quite unlikely case of a clockseq overlow:

```
$ node test/test.js
Pass: uuids with current time have expected order
Pass: uuids with time option have expected order
Pass: IDs created at same msec are different
Fail: IDs created at same 100 nsec throw an error
Pass: IDs created at t and t - 100ns have different clockseq
Pass: Explicit options produce expected id
Pass: 1ns separation between adjacent uuids
Pass: Short parse
Pass: Dirty parse

Sanity check 10000 v1 uuids

node.js:201
throw e; // process.nextTick error, or 'error' event on first tick
^
Error: 5470a8a0-2a5d-11e1-c000-7938e6977d1e is not a valid UUID string
at Error (unknown source)
at Object. (/****/node-uuid/test/test.js:157:13)
at Module._compile (module.js:432:26)
at Object..js (module.js:450:10)
at Module.load (module.js:351:31)
at Function._load (module.js:310:12)
at Array.0 (module.js:470:10)
at EventEmitter._tickCallback (node.js:192:40)
```

The clock-seq-part is `c000` which is invalid. Apparently we got an overflow from `0x3fff` to `0x4000` of the clockseq here.

I tried to write a test to catch this, but it's currently not possible since we cannot control the _seedBytes from the outside. Still I think my patch should fix this.