GWicke has submitted this change and it was merged.

Change subject: Update restbase & dependencies
......................................................................


Update restbase & dependencies

Change-Id: I21df2c6d0d54a1a1b799635e34d8dfcb077f474a
---
A node_modules/.bin/uuid
A node_modules/gelf-stream/.npmignore
A node_modules/gelf-stream/.travis.yml
A node_modules/gelf-stream/LICENSE.txt
A node_modules/gelf-stream/README.md
A node_modules/gelf-stream/example.js
A node_modules/gelf-stream/gelf-stream.js
A node_modules/gelf-stream/node_modules/gelfling/.npmignore
A node_modules/gelf-stream/node_modules/gelfling/LICENSE.txt
A node_modules/gelf-stream/node_modules/gelfling/README.md
A node_modules/gelf-stream/node_modules/gelfling/example.js
A node_modules/gelf-stream/node_modules/gelfling/gelfling.js
A node_modules/gelf-stream/node_modules/gelfling/package.json
A node_modules/gelf-stream/package.json
A node_modules/gelf-stream/test/fast.js
R node_modules/node-uuid/.gitignore
M node_modules/node-uuid/README.md
A node_modules/node-uuid/bin/uuid
M node_modules/node-uuid/package.json
M node_modules/node-uuid/uuid.js
M restbase
21 files changed, 666 insertions(+), 32 deletions(-)

Approvals:
  GWicke: Verified; Looks good to me, approved



diff --git a/node_modules/.bin/uuid b/node_modules/.bin/uuid
new file mode 120000
index 0000000..80eb14a
--- /dev/null
+++ b/node_modules/.bin/uuid
@@ -0,0 +1 @@
+../node-uuid/bin/uuid
\ No newline at end of file
diff --git a/node_modules/gelf-stream/.npmignore 
b/node_modules/gelf-stream/.npmignore
new file mode 100644
index 0000000..93f1361
--- /dev/null
+++ b/node_modules/gelf-stream/.npmignore
@@ -0,0 +1,2 @@
+node_modules
+npm-debug.log
diff --git a/node_modules/gelf-stream/.travis.yml 
b/node_modules/gelf-stream/.travis.yml
new file mode 100644
index 0000000..baa0031
--- /dev/null
+++ b/node_modules/gelf-stream/.travis.yml
@@ -0,0 +1,3 @@
+language: node_js
+node_js:
+  - 0.8
diff --git a/node_modules/gelf-stream/LICENSE.txt 
b/node_modules/gelf-stream/LICENSE.txt
new file mode 100644
index 0000000..c3d139f
--- /dev/null
+++ b/node_modules/gelf-stream/LICENSE.txt
@@ -0,0 +1,4 @@
+Copyright 2013 Michael Hart ([email protected])
+
+This project is free software released under the MIT license:
+http://www.opensource.org/licenses/mit-license.php
diff --git a/node_modules/gelf-stream/README.md 
b/node_modules/gelf-stream/README.md
new file mode 100644
index 0000000..b9e7f0b
--- /dev/null
+++ b/node_modules/gelf-stream/README.md
@@ -0,0 +1,59 @@
+gelf-stream
+-----------
+
+[![Build 
Status](https://secure.travis-ci.org/mhart/gelf-stream.png?branch=master)](http://travis-ci.org/mhart/gelf-stream)
+
+A node.js stream to send JS objects to a
+[Graylog2](http://graylog2.org/) server (in
+[GELF](http://www.graylog2.org/about/gelf) format).
+
+Also provides a stream that can be used directly in
+[Bunyan](https://github.com/trentm/node-bunyan) and provides
+a number of sane mappings.
+
+Example
+-------
+
+```javascript
+var split = require('split'),
+    bunyan = require('bunyan'),
+    gelfStream = require('gelf-stream')
+
+// gelf-stream comes with Bunyan support
+
+var stream = gelfStream.forBunyan('localhost')
+
+var log = bunyan.createLogger({name: 'foo', streams: [{type: 'raw', stream: 
stream}]})
+
+log.info('Testing Bunyan') // will be sent to the Graylog2 server on localhost
+
+log.error(new Error('Oh noes!')) // will extract file/line numbers too
+
+stream.end() // Bunyan doesn't currently end the stream when the program has 
finished
+
+// Or you can use it to stream any sort of object/string
+
+process.stdin
+  .pipe(split()) // split into lines
+  .pipe(gelfStream.create('localhost', {defaults: {level: 6}}))
+
+process.stdin.resume()
+```
+
+API
+---
+
+### gelfStream.create([host], [port], [options])
+
+### gelfStream.forBunyan([host], [port], [options])
+
+
+Installation
+------------
+
+With [npm](http://npmjs.org/) do:
+
+```
+npm install gelf-stream
+```
+
diff --git a/node_modules/gelf-stream/example.js 
b/node_modules/gelf-stream/example.js
new file mode 100644
index 0000000..fce6430
--- /dev/null
+++ b/node_modules/gelf-stream/example.js
@@ -0,0 +1,24 @@
+var split = require('split'),
+    bunyan = require('bunyan'),
+    gelfStream = require('./') // require('gelf-stream')
+
+// gelf-stream comes with Bunyan support
+
+var stream = gelfStream.forBunyan('localhost')
+
+var log = bunyan.createLogger({name: 'foo', streams: [{type: 'raw', stream: 
stream}]})
+
+log.info('Testing Bunyan') // will be sent to the Graylog2 server on localhost
+
+log.error(new Error('Oh noes!')) // will extract file/line numbers too
+
+stream.end() // Bunyan doesn't currently end the stream when the program has 
finished
+
+// Or you can use it to stream any sort of object/string
+
+process.stdin
+  .pipe(split()) // split into lines
+  .pipe(gelfStream.create('localhost', {defaults: {level: 6}}))
+
+process.stdin.resume()
+
diff --git a/node_modules/gelf-stream/gelf-stream.js 
b/node_modules/gelf-stream/gelf-stream.js
new file mode 100644
index 0000000..82419fb
--- /dev/null
+++ b/node_modules/gelf-stream/gelf-stream.js
@@ -0,0 +1,119 @@
+var gelfStream = exports
+var gelfling   = require('gelfling')
+var Stream     = require('stream').Stream
+
+function create(host, port, options) {
+  if (options == null && typeof port === 'object') {
+    options = port
+    port = null
+    if (options == null && typeof host === 'object') {
+      options = host
+      host = null
+    }
+  }
+  if (options == null) options = {}
+
+  if (options.keepAlive == null) options.keepAlive = true
+
+  var client = gelfling(host, port, options),
+      stream = new Stream()
+
+  client.errHandler = function(err) {
+    if (err) stream.emit('error', err)
+  }
+
+  stream.writable = true
+  stream.write = function(log) {
+    if (!options.filter || options.filter(log))
+      client.send(options.map ? options.map(log) : log, client.errHandler)
+  }
+  stream.end = function(log) {
+    if (arguments.length) stream.write(log)
+    stream.writable = false
+    process.nextTick(function() { client.close() })
+  }
+
+  return stream
+}
+
+// ---------------------------
+// Bunyan stuff
+// ---------------------------
+
+function mapGelfLevel(bunyanLevel) {
+  switch (bunyanLevel) {
+    case 10 /*bunyan.TRACE*/: return gelfling.DEBUG
+    case 20 /*bunyan.DEBUG*/: return gelfling.DEBUG
+    case 30 /*bunyan.INFO*/:  return gelfling.INFO
+    case 40 /*bunyan.WARN*/:  return gelfling.WARNING
+    case 50 /*bunyan.ERROR*/: return gelfling.ERROR
+    case 60 /*bunyan.FATAL*/: return gelfling.EMERGENCY
+    default:                  return gelfling.WARNING
+  }
+}
+
+function flatten(obj, into, prefix, sep) {
+  if (into == null) into = {}
+  if (prefix == null) prefix = ''
+  if (sep == null) sep = '.'
+  var key, prop
+  for (key in obj) {
+    if (!Object.prototype.hasOwnProperty.call(obj, key)) continue
+    prop = obj[key]
+    if (typeof prop === 'object' && !(prop instanceof Date) && !(prop 
instanceof RegExp))
+      flatten(prop, into, prefix + key + sep, sep)
+    else
+      into[prefix + key] = prop
+  }
+  return into
+}
+
+function bunyanToGelf(log) {
+  /*jshint camelcase:false */
+  var errFile, key,
+      ignoreFields = ['hostname', 'time', 'msg', 'name', 'level', 'v'],
+      flattenedLog = flatten(log),
+      gelfMsg = {
+        host:          log.hostname,
+        timestamp:     +new Date(log.time) / 1000,
+        short_message: log.msg,
+        facility:      log.name,
+        level:         mapGelfLevel(log.level),
+        full_message:  JSON.stringify(log, null, 2)
+      }
+
+  if (log.err && log.err.stack &&
+      (errFile = log.err.stack.match(/\n\s+at .+ \(([^:]+)\:([0-9]+)/)) != 
null) {
+    if (errFile[1]) gelfMsg.file = errFile[1]
+    if (errFile[2]) gelfMsg.line = errFile[2]
+  }
+
+  for (key in flattenedLog) {
+    if (ignoreFields.indexOf(key) < 0 && gelfMsg[key] == null)
+      gelfMsg[key] = flattenedLog[key]
+  }
+
+  return gelfMsg
+}
+
+function forBunyan(host, port, options) {
+  if (options == null && typeof port === 'object') {
+    options = port
+    port = null
+    if (options == null && typeof host === 'object') {
+      options = host
+      host = null
+    }
+  }
+  if (options == null) options = {}
+
+  options.map = bunyanToGelf
+
+  return create(host, port, options)
+}
+
+gelfStream.create = create
+gelfStream.forBunyan = forBunyan
+gelfStream.bunyanToGelf = bunyanToGelf
+gelfStream.mapGelfLevel = mapGelfLevel
+gelfStream.flatten = flatten
diff --git a/node_modules/gelf-stream/node_modules/gelfling/.npmignore 
b/node_modules/gelf-stream/node_modules/gelfling/.npmignore
new file mode 100644
index 0000000..7dccd97
--- /dev/null
+++ b/node_modules/gelf-stream/node_modules/gelfling/.npmignore
@@ -0,0 +1,15 @@
+lib-cov
+*.seed
+*.log
+*.csv
+*.dat
+*.out
+*.pid
+*.gz
+
+pids
+logs
+results
+
+node_modules
+npm-debug.log
\ No newline at end of file
diff --git a/node_modules/gelf-stream/node_modules/gelfling/LICENSE.txt 
b/node_modules/gelf-stream/node_modules/gelfling/LICENSE.txt
new file mode 100644
index 0000000..c3d139f
--- /dev/null
+++ b/node_modules/gelf-stream/node_modules/gelfling/LICENSE.txt
@@ -0,0 +1,4 @@
+Copyright 2013 Michael Hart ([email protected])
+
+This project is free software released under the MIT license:
+http://www.opensource.org/licenses/mit-license.php
diff --git a/node_modules/gelf-stream/node_modules/gelfling/README.md 
b/node_modules/gelf-stream/node_modules/gelfling/README.md
new file mode 100644
index 0000000..007bb97
--- /dev/null
+++ b/node_modules/gelf-stream/node_modules/gelfling/README.md
@@ -0,0 +1,25 @@
+# GELF (Graylog2) messages in node.js
+
+Includes chunked messages, so messages can be any size
+(couldn't find another node.js lib that does this)
+
+```javascript
+var gelfling = require('gelfling')
+
+var client = gelfling()
+
+client.send('Message', function(err) { console.log('Sent') })
+
+client.send({ short_message: 'Message', facility: 'myApp', level: 
gelfling.INFO })
+
+var complexClient = gelfling('localhost', 12201, {
+  defaults: {
+    facility: 'myApp',
+    level: gelfling.INFO,
+    short_message: function(msg) { var txt = msg.txt; delete msg.txt; return 
txt }
+    myAvg: function(msg) { return msg.myTotal / msg.myCount }
+  }
+})
+
+complexClient.send({ txt: 'Hi', myTotal: 1337, myCount: 23 })
+```
diff --git a/node_modules/gelf-stream/node_modules/gelfling/example.js 
b/node_modules/gelf-stream/node_modules/gelfling/example.js
new file mode 100644
index 0000000..49f0015
--- /dev/null
+++ b/node_modules/gelf-stream/node_modules/gelfling/example.js
@@ -0,0 +1,16 @@
+var gelfling = require('./') // require('gelfling')
+
+var msg = {
+  short_message: "Message at " + (+new Date),
+  full_message: ("start/" + new Buffer(20000).toString('base64') + 
"/end").replace(/\//g, "\n"),
+  id: 34,
+  some_other_field: "Dude!\nIt's a multi line\nMessage!",
+  //full_message: {a: 1, b: 2},
+  obj_field: {a: 1, b: 2},
+  file: '/usr/home/thing.js',
+  //line: 345
+}
+
+var client = gelfling('localhost', 12201, { defaults: { line: function(msg) { 
return msg.id } } })
+client.send(msg, function(err) { console.log("all done") })
+
diff --git a/node_modules/gelf-stream/node_modules/gelfling/gelfling.js 
b/node_modules/gelf-stream/node_modules/gelfling/gelfling.js
new file mode 100644
index 0000000..eedd03f
--- /dev/null
+++ b/node_modules/gelf-stream/node_modules/gelfling/gelfling.js
@@ -0,0 +1,133 @@
+var zlib   = require('zlib')
+var dgram  = require('dgram')
+var crypto = require('crypto')
+
+// From https://github.com/Graylog2/graylog2-docs/wiki/GELF
+// and https://github.com/Graylog2/gelf-php/blob/master/GELFMessage.php
+var GELF_ID      = [0x1e, 0x0f]
+  , GELF_KEYS    = ['version', 'host', 'short_message', 'full_message',
+                    'timestamp', 'level', 'facility', 'line', 'file']
+  , ILLEGAL_KEYS = ['_id']
+
+function Gelfling(host, port, options) {
+  this.host = host != null ? host : 'localhost'
+  this.port = port != null ? port : 12201
+  if (options == null) options = {}
+
+  this.maxChunkSize = this.getMaxChunkSize(options.maxChunkSize)
+  this.defaults = options.defaults || {}
+  this.errHandler = options.errHandler || console.error
+  this.keepAlive = options.keepAlive
+}
+
+Gelfling.prototype.send = function(data, callback) {
+  if (callback == null) callback = function() {}
+  if (Buffer.isBuffer(data)) data = [data]
+  var udpClient, remaining, i, that = this
+
+  if (!Array.isArray(data))
+    return this.encode(this.convert(data), function(err, chunks) {
+      if (err) return callback(err)
+      that.send(chunks, callback)
+    })
+
+  if (!this.keepAlive || !this.udpClient) {
+    udpClient = dgram.createSocket('udp4')
+    udpClient.on('error', this.errHandler)
+    if (this.keepAlive) this.udpClient = udpClient
+  } else {
+    udpClient = this.udpClient
+  }
+  remaining = data.length
+  function checkDone(err) {
+    if (err || --remaining === 0) {
+      if (!that.keepAlive) udpClient.close()
+      callback(err)
+    }
+  }
+  for (i = 0; i < data.length; i++)
+    udpClient.send(data[i], 0, data[i].length, this.port, this.host, checkDone)
+}
+
+Gelfling.prototype.close = function() {
+  if (this.udpClient) this.udpClient.close()
+}
+
+Gelfling.prototype.encode = function(msg, callback) {
+  if (callback == null) callback = function() {}
+  var that = this
+  zlib.gzip(new Buffer(JSON.stringify(msg)), function(err, compressed) {
+    if (err) return callback(err)
+    callback(null, that.split(compressed))
+  })
+}
+
+Gelfling.prototype.split = function(data, chunkSize) {
+  if (chunkSize == null) chunkSize = this.maxChunkSize
+  if (data.length <= chunkSize) return [data]
+
+  var msgId     = [].slice.call(crypto.randomBytes(8))
+    , numChunks = Math.ceil(data.length / chunkSize)
+    , chunks    = new Array(numChunks)
+    , chunkIx, dataSlice, dataStart
+
+  for (chunkIx = 0; chunkIx < numChunks; chunkIx++) {
+    dataStart = chunkIx * chunkSize
+    dataSlice = [].slice.call(data, dataStart, dataStart + chunkSize)
+    chunks[chunkIx] = new Buffer(GELF_ID.concat(msgId, chunkIx, numChunks, 
dataSlice))
+  }
+
+  return chunks
+}
+
+Gelfling.prototype.convert = function(msg) {
+  if (typeof msg !== 'object') msg = { short_message: msg }
+
+  var gelfMsg  = {}
+    , defaults = this.defaults
+    , key, val
+
+  for (key in defaults) {
+    if (!defaults.hasOwnProperty(key)) continue
+    val = defaults[key]
+    gelfMsg[key] = typeof val === 'function' ? val(msg) : val
+  }
+
+  for (key in msg) {
+    if (!msg.hasOwnProperty(key)) continue
+    val = msg[key]
+    if (GELF_KEYS.indexOf(key) < 0) key = '_' + key
+    if (ILLEGAL_KEYS.indexOf(key) >= 0) key = '_' + key
+    gelfMsg[key] = val
+  }
+
+  if (gelfMsg.version == null) gelfMsg.version = '1.0'
+  if (gelfMsg.host == null) gelfMsg.host = require('os').hostname()
+  if (gelfMsg.timestamp == null) gelfMsg.timestamp = +(new Date) / 1000
+  if (gelfMsg.short_message == null) gelfMsg.short_message = 
JSON.stringify(msg)
+
+  return gelfMsg
+}
+
+Gelfling.prototype.getMaxChunkSize = function(size) {
+  if (size == null) size = 'wan'
+  switch (size.toLowerCase()) {
+    case 'wan': return 1420
+    case 'lan': return 8154
+    default:    return parseInt(size, 10)
+  }
+}
+
+var gelfling = module.exports = function(host, port, options) {
+  return new Gelfling(host, port, options)
+}
+gelfling.Gelfling = Gelfling
+
+gelfling.EMERGENCY = 0
+gelfling.ALERT     = 1
+gelfling.CRITICAL  = 2
+gelfling.ERROR     = 3
+gelfling.WARNING   = 4
+gelfling.NOTICE    = 5
+gelfling.INFO      = 6
+gelfling.DEBUG     = 7
diff --git a/node_modules/gelf-stream/node_modules/gelfling/package.json 
b/node_modules/gelf-stream/node_modules/gelfling/package.json
new file mode 100644
index 0000000..92aecf9
--- /dev/null
+++ b/node_modules/gelf-stream/node_modules/gelfling/package.json
@@ -0,0 +1,46 @@
+{
+  "name": "gelfling",
+  "version": "0.2.0",
+  "description": "Create and send GELF (Graylog2) messages, including 
chunking",
+  "author": {
+    "name": "Michael Hart",
+    "email": "[email protected]",
+    "url": "http://github.com/mhart";
+  },
+  "main": "gelfling.js",
+  "keywords": [
+    "gelf",
+    "graylog",
+    "graylog2"
+  ],
+  "repository": {
+    "type": "git",
+    "url": "https://github.com/mhart/gelfling.git";
+  },
+  "license": "MIT",
+  "readme": "# GELF (Graylog2) messages in node.js\n\nIncludes chunked 
messages, so messages can be any size\n(couldn't find another node.js lib that 
does this)\n\n```javascript\nvar gelfling = require('gelfling')\n\nvar client = 
gelfling()\n\nclient.send('Message', function(err) { console.log('Sent') 
})\n\nclient.send({ short_message: 'Message', facility: 'myApp', level: 
gelfling.INFO })\n\nvar complexClient = gelfling('localhost', 12201, {\n  
defaults: {\n    facility: 'myApp',\n    level: gelfling.INFO,\n    
short_message: function(msg) { var txt = msg.txt; delete msg.txt; return txt 
}\n    myAvg: function(msg) { return msg.myTotal / msg.myCount }\n  
}\n})\n\ncomplexClient.send({ txt: 'Hi', myTotal: 1337, myCount: 23 })\n```\n",
+  "readmeFilename": "README.md",
+  "_id": "[email protected]",
+  "dist": {
+    "shasum": "23a13c366883adae32ecfd252a566be302b88dc3",
+    "tarball": "http://registry.npmjs.org/gelfling/-/gelfling-0.2.0.tgz";
+  },
+  "_npmVersion": "1.2.0",
+  "_npmUser": {
+    "name": "hichaelmart",
+    "email": "[email protected]"
+  },
+  "maintainers": [
+    {
+      "name": "hichaelmart",
+      "email": "[email protected]"
+    }
+  ],
+  "directories": {},
+  "_shasum": "23a13c366883adae32ecfd252a566be302b88dc3",
+  "_from": "gelfling@~0.2.0",
+  "_resolved": "https://registry.npmjs.org/gelfling/-/gelfling-0.2.0.tgz";,
+  "bugs": {
+    "url": "https://github.com/mhart/gelfling/issues";
+  }
+}
diff --git a/node_modules/gelf-stream/package.json 
b/node_modules/gelf-stream/package.json
new file mode 100644
index 0000000..1058c36
--- /dev/null
+++ b/node_modules/gelf-stream/package.json
@@ -0,0 +1,58 @@
+{
+  "name": "gelf-stream",
+  "version": "0.2.4",
+  "description": "A stream to send JS objects to a Graylog2 server (in GELF 
format)",
+  "author": {
+    "name": "Michael Hart",
+    "email": "[email protected]",
+    "url": "http://github.com/mhart";
+  },
+  "main": "gelf-stream.js",
+  "keywords": [
+    "gelf",
+    "stream",
+    "graylog",
+    "graylog2",
+    "bunyan"
+  ],
+  "repository": {
+    "type": "git",
+    "url": "https://github.com/mhart/gelf-stream.git";
+  },
+  "license": "MIT",
+  "dependencies": {
+    "gelfling": "~0.2.0"
+  },
+  "devDependencies": {
+    "should": "~1.2.1",
+    "mocha": "~1.7.4"
+  },
+  "scripts": {
+    "test": "mocha ./test/fast.js -b -t 100s -R list"
+  },
+  "bugs": {
+    "url": "https://github.com/mhart/gelf-stream/issues";
+  },
+  "homepage": "https://github.com/mhart/gelf-stream";,
+  "_id": "[email protected]",
+  "_shasum": "a418c8c2e39b85b7932a3e8523f6022d6852e013",
+  "_from": "gelf-stream@^0.2.4",
+  "_npmVersion": "1.4.10",
+  "_npmUser": {
+    "name": "hichaelmart",
+    "email": "[email protected]"
+  },
+  "maintainers": [
+    {
+      "name": "hichaelmart",
+      "email": "[email protected]"
+    }
+  ],
+  "dist": {
+    "shasum": "a418c8c2e39b85b7932a3e8523f6022d6852e013",
+    "tarball": "http://registry.npmjs.org/gelf-stream/-/gelf-stream-0.2.4.tgz";
+  },
+  "directories": {},
+  "_resolved": 
"https://registry.npmjs.org/gelf-stream/-/gelf-stream-0.2.4.tgz";,
+  "readme": "ERROR: No README data found!"
+}
diff --git a/node_modules/gelf-stream/test/fast.js 
b/node_modules/gelf-stream/test/fast.js
new file mode 100644
index 0000000..e83918b
--- /dev/null
+++ b/node_modules/gelf-stream/test/fast.js
@@ -0,0 +1,7 @@
+var should     = require('should'),
+    gelfStream = require('../')
+
+describe('gelf-stream', function() {
+
+})
+
diff --git a/node_modules/node-uuid/.npmignore 
b/node_modules/node-uuid/.gitignore
similarity index 100%
rename from node_modules/node-uuid/.npmignore
rename to node_modules/node-uuid/.gitignore
diff --git a/node_modules/node-uuid/README.md b/node_modules/node-uuid/README.md
index e436a89..b7d04c9 100644
--- a/node_modules/node-uuid/README.md
+++ b/node_modules/node-uuid/README.md
@@ -10,6 +10,7 @@
 * Cryptographically strong random # generation on supporting platforms
 * 1.1K minified and gzip'ed  (Want something smaller?  Check this [crazy 
shit](https://gist.github.com/982883) out! )
 * [Annotated source code](http://broofa.github.com/node-uuid/docs/uuid.html)
+* Comes with a Command Line Interface for generating uuids on the command line
 
 ## Getting Started
 
@@ -160,13 +161,48 @@
 
 The class of container created when generating binary uuid data if no buffer 
argument is specified.  This is expected to go away, with no replacement API.
 
+## Command Line Interface
+
+To use the executable, it's probably best to install this library globally.
+
+`npm install -g node-uuid`
+
+Usage:
+
+```
+USAGE: uuid [version] [options]
+
+
+options:
+
+--help                     Display this message and exit
+```
+
+`version` must be an RFC4122 version that is supported by this library, which 
is currently version 1 and version 4 (denoted by "v1" and "v4", respectively). 
`version` defaults to version 4 when not supplied.
+
+### Examples
+
+```
+> uuid
+3a91f950-dec8-4688-ba14-5b7bbfc7a563
+```
+
+```
+> uuid v1
+9d0b43e0-7696-11e3-964b-250efa37a98e
+```
+
+```
+> uuid v4
+6790ac7c-24ac-4f98-8464-42f6d98a53ae
+```
+
 ## Testing
 
 In node.js
 
 ```
-> cd test
-> node test.js
+npm test
 ```
 
 In Browser
diff --git a/node_modules/node-uuid/bin/uuid b/node_modules/node-uuid/bin/uuid
new file mode 100755
index 0000000..f732e99
--- /dev/null
+++ b/node_modules/node-uuid/bin/uuid
@@ -0,0 +1,26 @@
+#!/usr/bin/env node
+
+var path = require('path');
+var uuid = require(path.join(__dirname, '..'));
+
+var arg = process.argv[2];
+
+if ('--help' === arg) {
+  console.log('\n  USAGE: uuid [version] [options]\n\n');
+  console.log('  options:\n');
+  console.log('  --help                     Display this message and exit\n');
+  process.exit(0);
+}
+
+if (null == arg) {
+  console.log(uuid());
+  process.exit(0);
+}
+
+if ('v1' !== arg && 'v4' !== arg) {
+  console.error('Version must be RFC4122 version 1 or version 4, denoted as 
"v1" or "v4"');
+  process.exit(1);
+}
+
+console.log(uuid[arg]());
+process.exit(0);
diff --git a/node_modules/node-uuid/package.json 
b/node_modules/node-uuid/package.json
index eb9055f..396c316 100644
--- a/node_modules/node-uuid/package.json
+++ b/node_modules/node-uuid/package.json
@@ -15,8 +15,18 @@
     {
       "name": "Christoph Tavan",
       "email": "[email protected]"
+    },
+    {
+      "name": "Gabriel Wicke",
+      "email": "[email protected]"
     }
   ],
+  "bin": {
+    "uuid": "./bin/uuid"
+  },
+  "scripts": {
+    "test": "node test/test.js"
+  },
   "lib": ".",
   "main": "./uuid.js",
   "repository": {
@@ -24,30 +34,23 @@
     "url": "https://github.com/broofa/node-uuid.git";
   },
   "version": "1.4.1",
-  "readme": "# node-uuid\n\nSimple, fast generation of 
[RFC4122](http://www.ietf.org/rfc/rfc4122.txt) UUIDS.\n\nFeatures:\n\n* 
Generate RFC4122 version 1 or version 4 UUIDs\n* Runs in node.js and all 
browsers.\n* Registered as a 
[ComponentJS](https://github.com/component/component) 
[component](https://github.com/component/component/wiki/Components) 
('broofa/node-uuid').\n* Cryptographically strong random # generation on 
supporting platforms\n* 1.1K minified and gzip'ed  (Want something smaller?  
Check this [crazy shit](https://gist.github.com/982883) out! )\n* [Annotated 
source code](http://broofa.github.com/node-uuid/docs/uuid.html)\n\n## Getting 
Started\n\nInstall it in your browser:\n\n```html\n<script 
src=\"uuid.js\"></script>\n```\n\nOr in node.js:\n\n```\nnpm install 
node-uuid\n```\n\n```javascript\nvar uuid = require('node-uuid');\n```\n\nThen 
create some ids ...\n\n```javascript\n// Generate a v1 (time-based) 
id\nuuid.v1(); // -> '6c84fb90-12c4-11e1-840d-7b25c5ee775a'\n\n// Generate a v4 
(random) id\nuuid.v4(); // -> '110ec58a-a0f2-4ac4-8393-c866d813b8d1'\n```\n\n## 
API\n\n### uuid.v1([`options` [, `buffer` [, `offset`]]])\n\nGenerate and 
return a RFC4122 v1 (timestamp-based) UUID.\n\n* `options` - (Object) Optional 
uuid state to apply. Properties may include:\n\n  * `node` - (Array) Node id as 
Array of 6 bytes (per 4.1.6). Default: Randomly generated ID.  See note 1.\n  * 
`clockseq` - (Number between 0 - 0x3fff) RFC clock sequence.  Default: An 
internally maintained clockseq is used.\n  * `msecs` - (Number | Date) Time in 
milliseconds since unix Epoch.  Default: The current time is used.\n  * `nsecs` 
- (Number between 0-9999) additional time, in 100-nanosecond units. Ignored if 
`msecs` is unspecified. Default: internal uuid counter is used, as per 
4.2.1.2.\n\n* `buffer` - (Array | Buffer) Array or buffer where UUID bytes are 
to be written.\n* `offset` - (Number) Starting index in `buffer` at which to 
begin writing.\n\nReturns `buffer`, if specified, otherwise the string form of 
the UUID\n\nNotes:\n\n1. The randomly generated node id is only guaranteed to 
stay constant for the lifetime of the current JS runtime. (Future versions of 
this module may use persistent storage mechanisms to extend this 
guarantee.)\n\nExample: Generate string UUID with fully-specified 
options\n\n```javascript\nuuid.v1({\n  node: [0x01, 0x23, 0x45, 0x67, 0x89, 
0xab],\n  clockseq: 0x1234,\n  msecs: new Date('2011-11-01').getTime(),\n  
nsecs: 5678\n});   // -> 
\"710b962e-041c-11e1-9234-0123456789ab\"\n```\n\nExample: In-place generation 
of two binary IDs\n\n```javascript\n// Generate two ids in an array\nvar arr = 
new Array(32); // -> []\nuuid.v1(null, arr, 0);   // -> [02 a2 ce 90 14 32 11 
e1 85 58 0b 48 8e 4f c1 15]\nuuid.v1(null, arr, 16);  // -> [02 a2 ce 90 14 32 
11 e1 85 58 0b 48 8e 4f c1 15 02 a3 1c b0 14 32 11 e1 85 58 0b 48 8e 4f c1 
15]\n\n// Optionally use uuid.unparse() to get stringify the 
ids\nuuid.unparse(buffer);    // -> 
'02a2ce90-1432-11e1-8558-0b488e4fc115'\nuuid.unparse(buffer, 16) // -> 
'02a31cb0-1432-11e1-8558-0b488e4fc115'\n```\n\n### uuid.v4([`options` [, 
`buffer` [, `offset`]]])\n\nGenerate and return a RFC4122 v4 UUID.\n\n* 
`options` - (Object) Optional uuid state to apply. Properties may include:\n\n  
* `random` - (Number[16]) Array of 16 numbers (0-255) to use in place of 
randomly generated values\n  * `rng` - (Function) Random # generator to use.  
Set to one of the built-in generators - `uuid.mathRNG` (all platforms), 
`uuid.nodeRNG` (node.js only), `uuid.whatwgRNG` (WebKit only) - or a custom 
function that returns an array[16] of byte values.\n\n* `buffer` - (Array | 
Buffer) Array or buffer where UUID bytes are to be written.\n* `offset` - 
(Number) Starting index in `buffer` at which to begin writing.\n\nReturns 
`buffer`, if specified, otherwise the string form of the UUID\n\nExample: 
Generate string UUID with fully-specified options\n\n```javascript\nuuid.v4({\n 
 random: [\n    0x10, 0x91, 0x56, 0xbe, 0xc4, 0xfb, 0xc1, 0xea,\n    0x71, 
0xb4, 0xef, 0xe1, 0x67, 0x1c, 0x58, 0x36\n  ]\n});\n// -> 
\"109156be-c4fb-41ea-b1b4-efe1671c5836\"\n```\n\nExample: Generate two IDs in a 
single buffer\n\n```javascript\nvar buffer = new Array(32); // (or 'new Buffer' 
in node.js)\nuuid.v4(null, buffer, 0);\nuuid.v4(null, buffer, 16);\n```\n\n### 
uuid.parse(id[, buffer[, offset]])\n### uuid.unparse(buffer[, offset])\n\nParse 
and unparse UUIDs\n\n  * `id` - (String) UUID(-like) string\n  * `buffer` - 
(Array | Buffer) Array or buffer where UUID bytes are to be written. Default: A 
new Array or Buffer is used\n  * `offset` - (Number) Starting index in `buffer` 
at which to begin writing. Default: 0\n\nExample parsing and unparsing a UUID 
string\n\n```javascript\nvar bytes = 
uuid.parse('797ff043-11eb-11e1-80d6-510998755d10'); // -> <Buffer 79 7f f0 43 
11 eb 11 e1 80 d6 51 09 98 75 5d 10>\nvar string = uuid.unparse(bytes); // -> 
'797ff043-11eb-11e1-80d6-510998755d10'\n```\n\n### 
uuid.noConflict()\n\n(Browsers only) Set `uuid` property back to it's previous 
value.\n\nReturns the node-uuid object.\n\nExample:\n\n```javascript\nvar 
myUuid = uuid.noConflict();\nmyUuid.v1(); // -> 
'6c84fb90-12c4-11e1-840d-7b25c5ee775a'\n```\n\n## Deprecated APIs\n\nSupport 
for the following v1.2 APIs is available in v1.3, but is deprecated and will be 
removed in the next major version.\n\n### uuid([format [, buffer [, 
offset]]])\n\nuuid() has become uuid.v4(), and the `format` argument is now 
implicit in the `buffer` argument. (i.e. if you specify a buffer, the format is 
assumed to be binary).\n\n### uuid.BufferClass\n\nThe class of container 
created when generating binary uuid data if no buffer argument is specified.  
This is expected to go away, with no replacement API.\n\n## Testing\n\nIn 
node.js\n\n```\n> cd test\n> node test.js\n```\n\nIn Browser\n\n```\nopen 
test/test.html\n```\n\n### Benchmarking\n\nRequires node.js\n\n```\nnpm install 
uuid uuid-js\nnode benchmark/benchmark.js\n```\n\nFor a more complete 
discussion of node-uuid performance, please see the `benchmark/README.md` file, 
and the [benchmark 
wiki](https://github.com/broofa/node-uuid/wiki/Benchmark)\n\nFor browser 
performance [checkout the JSPerf 
tests](http://jsperf.com/node-uuid-performance).\n\n## Release notes\n\n### 
1.4.0\n\n* Improved module context detection\n* Removed public RNG 
functions\n\n### 1.3.2\n\n* Improve tests and handling of v1() options (Issue 
#24)\n* Expose RNG option to allow for perf testing with different 
generators\n\n### 1.3.0\n\n* Support for version 1 ids, thanks to 
[@ctavan](https://github.com/ctavan)!\n* Support for node.js crypto API\n* 
De-emphasizing performance in favor of a) cryptographic quality PRNGs where 
available and b) more manageable code\n",
+  "dependencies": {
+    "bignum": "^0.9.0",
+    "microtime": ">=0.4.0"
+  },
+  "licenses": [
+    {
+      "type": "MIT",
+      "url": "https://raw.github.com/broofa/node-uuid/master/LICENSE.md";
+    }
+  ],
+  "readme": "# node-uuid\n\nSimple, fast generation of 
[RFC4122](http://www.ietf.org/rfc/rfc4122.txt) UUIDS.\n\nFeatures:\n\n* 
Generate RFC4122 version 1 or version 4 UUIDs\n* Runs in node.js and all 
browsers.\n* Registered as a 
[ComponentJS](https://github.com/component/component) 
[component](https://github.com/component/component/wiki/Components) 
('broofa/node-uuid').\n* Cryptographically strong random # generation on 
supporting platforms\n* 1.1K minified and gzip'ed  (Want something smaller?  
Check this [crazy shit](https://gist.github.com/982883) out! )\n* [Annotated 
source code](http://broofa.github.com/node-uuid/docs/uuid.html)\n* Comes with a 
Command Line Interface for generating uuids on the command line\n\n## Getting 
Started\n\nInstall it in your browser:\n\n```html\n<script 
src=\"uuid.js\"></script>\n```\n\nOr in node.js:\n\n```\nnpm install 
node-uuid\n```\n\n```javascript\nvar uuid = require('node-uuid');\n```\n\nThen 
create some ids ...\n\n```javascript\n// Generate a v1 (time-based) 
id\nuuid.v1(); // -> '6c84fb90-12c4-11e1-840d-7b25c5ee775a'\n\n// Generate a v4 
(random) id\nuuid.v4(); // -> '110ec58a-a0f2-4ac4-8393-c866d813b8d1'\n```\n\n## 
API\n\n### uuid.v1([`options` [, `buffer` [, `offset`]]])\n\nGenerate and 
return a RFC4122 v1 (timestamp-based) UUID.\n\n* `options` - (Object) Optional 
uuid state to apply. Properties may include:\n\n  * `node` - (Array) Node id as 
Array of 6 bytes (per 4.1.6). Default: Randomly generated ID.  See note 1.\n  * 
`clockseq` - (Number between 0 - 0x3fff) RFC clock sequence.  Default: An 
internally maintained clockseq is used.\n  * `msecs` - (Number | Date) Time in 
milliseconds since unix Epoch.  Default: The current time is used.\n  * `nsecs` 
- (Number between 0-9999) additional time, in 100-nanosecond units. Ignored if 
`msecs` is unspecified. Default: internal uuid counter is used, as per 
4.2.1.2.\n\n* `buffer` - (Array | Buffer) Array or buffer where UUID bytes are 
to be written.\n* `offset` - (Number) Starting index in `buffer` at which to 
begin writing.\n\nReturns `buffer`, if specified, otherwise the string form of 
the UUID\n\nNotes:\n\n1. The randomly generated node id is only guaranteed to 
stay constant for the lifetime of the current JS runtime. (Future versions of 
this module may use persistent storage mechanisms to extend this 
guarantee.)\n\nExample: Generate string UUID with fully-specified 
options\n\n```javascript\nuuid.v1({\n  node: [0x01, 0x23, 0x45, 0x67, 0x89, 
0xab],\n  clockseq: 0x1234,\n  msecs: new Date('2011-11-01').getTime(),\n  
nsecs: 5678\n});   // -> 
\"710b962e-041c-11e1-9234-0123456789ab\"\n```\n\nExample: In-place generation 
of two binary IDs\n\n```javascript\n// Generate two ids in an array\nvar arr = 
new Array(32); // -> []\nuuid.v1(null, arr, 0);   // -> [02 a2 ce 90 14 32 11 
e1 85 58 0b 48 8e 4f c1 15]\nuuid.v1(null, arr, 16);  // -> [02 a2 ce 90 14 32 
11 e1 85 58 0b 48 8e 4f c1 15 02 a3 1c b0 14 32 11 e1 85 58 0b 48 8e 4f c1 
15]\n\n// Optionally use uuid.unparse() to get stringify the 
ids\nuuid.unparse(buffer);    // -> 
'02a2ce90-1432-11e1-8558-0b488e4fc115'\nuuid.unparse(buffer, 16) // -> 
'02a31cb0-1432-11e1-8558-0b488e4fc115'\n```\n\n### uuid.v4([`options` [, 
`buffer` [, `offset`]]])\n\nGenerate and return a RFC4122 v4 UUID.\n\n* 
`options` - (Object) Optional uuid state to apply. Properties may include:\n\n  
* `random` - (Number[16]) Array of 16 numbers (0-255) to use in place of 
randomly generated values\n  * `rng` - (Function) Random # generator to use.  
Set to one of the built-in generators - `uuid.mathRNG` (all platforms), 
`uuid.nodeRNG` (node.js only), `uuid.whatwgRNG` (WebKit only) - or a custom 
function that returns an array[16] of byte values.\n\n* `buffer` - (Array | 
Buffer) Array or buffer where UUID bytes are to be written.\n* `offset` - 
(Number) Starting index in `buffer` at which to begin writing.\n\nReturns 
`buffer`, if specified, otherwise the string form of the UUID\n\nExample: 
Generate string UUID with fully-specified options\n\n```javascript\nuuid.v4({\n 
 random: [\n    0x10, 0x91, 0x56, 0xbe, 0xc4, 0xfb, 0xc1, 0xea,\n    0x71, 
0xb4, 0xef, 0xe1, 0x67, 0x1c, 0x58, 0x36\n  ]\n});\n// -> 
\"109156be-c4fb-41ea-b1b4-efe1671c5836\"\n```\n\nExample: Generate two IDs in a 
single buffer\n\n```javascript\nvar buffer = new Array(32); // (or 'new Buffer' 
in node.js)\nuuid.v4(null, buffer, 0);\nuuid.v4(null, buffer, 16);\n```\n\n### 
uuid.parse(id[, buffer[, offset]])\n### uuid.unparse(buffer[, offset])\n\nParse 
and unparse UUIDs\n\n  * `id` - (String) UUID(-like) string\n  * `buffer` - 
(Array | Buffer) Array or buffer where UUID bytes are to be written. Default: A 
new Array or Buffer is used\n  * `offset` - (Number) Starting index in `buffer` 
at which to begin writing. Default: 0\n\nExample parsing and unparsing a UUID 
string\n\n```javascript\nvar bytes = 
uuid.parse('797ff043-11eb-11e1-80d6-510998755d10'); // -> <Buffer 79 7f f0 43 
11 eb 11 e1 80 d6 51 09 98 75 5d 10>\nvar string = uuid.unparse(bytes); // -> 
'797ff043-11eb-11e1-80d6-510998755d10'\n```\n\n### 
uuid.noConflict()\n\n(Browsers only) Set `uuid` property back to it's previous 
value.\n\nReturns the node-uuid object.\n\nExample:\n\n```javascript\nvar 
myUuid = uuid.noConflict();\nmyUuid.v1(); // -> 
'6c84fb90-12c4-11e1-840d-7b25c5ee775a'\n```\n\n## Deprecated APIs\n\nSupport 
for the following v1.2 APIs is available in v1.3, but is deprecated and will be 
removed in the next major version.\n\n### uuid([format [, buffer [, 
offset]]])\n\nuuid() has become uuid.v4(), and the `format` argument is now 
implicit in the `buffer` argument. (i.e. if you specify a buffer, the format is 
assumed to be binary).\n\n### uuid.BufferClass\n\nThe class of container 
created when generating binary uuid data if no buffer argument is specified.  
This is expected to go away, with no replacement API.\n\n## Command Line 
Interface\n\nTo use the executable, it's probably best to install this library 
globally.\n\n`npm install -g node-uuid`\n\nUsage:\n\n```\nUSAGE: uuid [version] 
[options]\n\n\noptions:\n\n--help                     Display this message and 
exit\n```\n\n`version` must be an RFC4122 version that is supported by this 
library, which is currently version 1 and version 4 (denoted by \"v1\" and 
\"v4\", respectively). `version` defaults to version 4 when not 
supplied.\n\n### Examples\n\n```\n> 
uuid\n3a91f950-dec8-4688-ba14-5b7bbfc7a563\n```\n\n```\n> uuid 
v1\n9d0b43e0-7696-11e3-964b-250efa37a98e\n```\n\n```\n> uuid 
v4\n6790ac7c-24ac-4f98-8464-42f6d98a53ae\n```\n\n## Testing\n\nIn 
node.js\n\n```\nnpm test\n```\n\nIn Browser\n\n```\nopen 
test/test.html\n```\n\n### Benchmarking\n\nRequires node.js\n\n```\nnpm install 
uuid uuid-js\nnode benchmark/benchmark.js\n```\n\nFor a more complete 
discussion of node-uuid performance, please see the `benchmark/README.md` file, 
and the [benchmark 
wiki](https://github.com/broofa/node-uuid/wiki/Benchmark)\n\nFor browser 
performance [checkout the JSPerf 
tests](http://jsperf.com/node-uuid-performance).\n\n## Release notes\n\n### 
1.4.0\n\n* Improved module context detection\n* Removed public RNG 
functions\n\n### 1.3.2\n\n* Improve tests and handling of v1() options (Issue 
#24)\n* Expose RNG option to allow for perf testing with different 
generators\n\n### 1.3.0\n\n* Support for version 1 ids, thanks to 
[@ctavan](https://github.com/ctavan)!\n* Support for node.js crypto API\n* 
De-emphasizing performance in favor of a) cryptographic quality PRNGs where 
available and b) more manageable code\n",
   "readmeFilename": "README.md",
   "bugs": {
     "url": "https://github.com/broofa/node-uuid/issues";
   },
   "_id": "[email protected]",
-  "dist": {
-    "shasum": "39aef510e5889a3dca9c895b506c73aae1bac048",
-    "tarball": "http://registry.npmjs.org/node-uuid/-/node-uuid-1.4.1.tgz";
-  },
-  "_from": "node-uuid@^1.4.1",
-  "_npmVersion": "1.3.6",
-  "_npmUser": {
-    "name": "broofa",
-    "email": "[email protected]"
-  },
-  "maintainers": [
-    {
-      "name": "broofa",
-      "email": "[email protected]"
-    }
-  ],
-  "directories": {},
-  "_shasum": "39aef510e5889a3dca9c895b506c73aae1bac048",
-  "_resolved": "https://registry.npmjs.org/node-uuid/-/node-uuid-1.4.1.tgz";,
-  "homepage": "https://github.com/broofa/node-uuid";
+  "_shasum": "ef0686e625de814e821dc5a2b52d806271c3b7e4",
+  "_resolved": 
"git+https://github.com/gwicke/node-uuid#2c5dff86f3b40169bc1b6de68898cd4c78eb1dfd";,
+  "_from": "node-uuid@git+https://github.com/gwicke/node-uuid#master";
 }
diff --git a/node_modules/node-uuid/uuid.js b/node_modules/node-uuid/uuid.js
index 2fac6dc..16efdc0 100644
--- a/node_modules/node-uuid/uuid.js
+++ b/node_modules/node-uuid/uuid.js
@@ -3,6 +3,9 @@
 //     Copyright (c) 2010-2012 Robert Kieffer
 //     MIT License - http://opensource.org/licenses/mit-license.php
 
+var microtime = require('microtime');
+var bignum = require('bignum');
+
 (function() {
   var _global = this;
 
@@ -14,9 +17,9 @@
   // Node.js crypto-based RNG - http://nodejs.org/docs/v0.6.2/api/crypto.html
   //
   // Moderately fast, high quality
-  if (typeof(require) == 'function') {
+  if (typeof(_global.require) == 'function') {
     try {
-      var _rb = require('crypto').randomBytes;
+      var _rb = _global.require('crypto').randomBytes;
       _rng = _rb && function() {return _rb(16);};
     } catch(e) {}
   }
@@ -49,7 +52,7 @@
   }
 
   // Buffer class to use
-  var BufferClass = typeof(Buffer) == 'function' ? Buffer : Array;
+  var BufferClass = typeof(_global.Buffer) == 'function' ? _global.Buffer : 
Array;
 
   // Maps for number <-> hex string conversion
   var _byteToHex = [];
@@ -124,11 +127,14 @@
     // (1582-10-15 00:00).  JSNumbers aren't precise enough for this, so
     // time is handled internally as 'msecs' (integer milliseconds) and 'nsecs'
     // (100-nanoseconds offset from msecs) since unix epoch, 1970-01-01 00:00.
-    var msecs = options.msecs != null ? options.msecs : new Date().getTime();
+    var _curTime = microtime.nowStruct();
+    var msecs = options.msecs != null ? options.msecs :
+        _curTime[0] * 1000 + Math.floor(_curTime[1] / 1000);
 
     // Per 4.2.1.2, use count of uuid's generated during the current clock
     // cycle to simulate higher resolution clock
-    var nsecs = options.nsecs != null ? options.nsecs : _lastNSecs + 1;
+    var _nextNSecs = (_curTime[1] % 1000) * 10;
+    var nsecs = options.nsecs != null ? options.nsecs : _nextNSecs;
 
     // Time since last uuid creation (in msecs)
     var dt = (msecs - _lastMSecs) + (nsecs - _lastNSecs)/10000;
@@ -140,9 +146,9 @@
 
     // Reset nsecs if clock regresses (new clockseq) or we've moved onto a new
     // time interval
-    if ((dt < 0 || msecs > _lastMSecs) && options.nsecs == null) {
-      nsecs = 0;
-    }
+    //if ((dt < 0 || msecs > _lastMSecs) && options.nsecs == null) {
+    //  nsecs = 0;
+    //}
 
     // Per 4.2.1.2 Throw error if too many uuids are requested
     if (nsecs >= 10000) {
@@ -154,10 +160,11 @@
     _clockseq = clockseq;
 
     // Per 4.1.4 - Convert from unix epoch to Gregorian epoch
+    //console.log('new ', msecs, nsecs);
     msecs += 12219292800000;
 
     // `time_low`
-    var tl = ((msecs & 0xfffffff) * 10000 + nsecs) % 0x100000000;
+    var tl = ((msecs >>> 0) * 10000 + nsecs) % 0x100000000;
     b[i++] = tl >>> 24 & 0xff;
     b[i++] = tl >>> 16 & 0xff;
     b[i++] = tl >>> 8 & 0xff;
@@ -216,12 +223,58 @@
     return buf || unparse(rnds);
   }
 
+  // extracts time (msecs) from v1 type uuid
+  function v1time(buf, offset) {
+    if (typeof buf === 'string') {
+        buf = parse(buf);
+    }
+
+    var msec = 0, nsec = 0;
+    var i = buf && offset || 0;
+    var b = buf||[];
+
+    // inspect version at offset 6
+    if ((b[i+6]&0x10)!=0x10) {
+      throw new Error("uuid version 1 expected"); }
+
+    // 'time_low'
+    var tl = 0;
+    tl |= ( b[i++] & 0xff ) << 24;
+    tl |= ( b[i++] & 0xff ) << 16;
+    tl |= ( b[i++] & 0xff ) << 8;
+    tl |=   b[i++] & 0xff ;
+
+    // `time_mid`
+    var tmh = 0;
+    tmh |= ( b[i++] & 0xff ) << 8;
+    tmh |=   b[i++] & 0xff;
+
+    // `time_high_minus_version`
+    tmh |= ( b[i++] & 0xf ) << 24;
+    tmh |= ( b[i++] & 0xff ) << 16;
+
+    // (tl >>> 0) to interpret tl as unsigned. tmh can't be signed, as the
+    // highest byte is & 0xf above.
+    nsec = bignum(tl >>> 0).add(bignum(tmh).mul(0x100000000));
+
+    // Per 4.1.4 - Convert from Gregorian epoch to unix epoch
+    nsec = nsec.sub(122192928000000000);
+
+    msec = nsec.toNumber() / 10000;
+
+    // Recover exact nanosecond fraction
+    // nsec = nsec.mod(10000).toNumber());
+
+    return msec;
+  }
+
   // Export public API
   var uuid = v4;
   uuid.v1 = v1;
   uuid.v4 = v4;
   uuid.parse = parse;
   uuid.unparse = unparse;
+  uuid.v1time = v1time;
   uuid.BufferClass = BufferClass;
 
   if (typeof define === 'function' && define.amd) {
diff --git a/restbase b/restbase
index 18b7a85..faadab5 160000
--- a/restbase
+++ b/restbase
-Subproject commit 18b7a857817b199f4c113f9ffcb713295fffb7b9
+Subproject commit faadab5621e29fd1fc286d8d3b658f63ffe76971

-- 
To view, visit https://gerrit.wikimedia.org/r/171794
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I21df2c6d0d54a1a1b799635e34d8dfcb077f474a
Gerrit-PatchSet: 1
Gerrit-Project: mediawiki/services/restbase/deploy
Gerrit-Branch: master
Gerrit-Owner: GWicke <[email protected]>
Gerrit-Reviewer: GWicke <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to