Sha256: 0e7796b7fae5f0460ad72c6b09a02b624ca48255e2ea97e7a43d8f1faffa8251

Contents?: true

Size: 679 Bytes

Versions: 39

Compression:

Stored size: 679 Bytes

Contents

var rng = require('./lib/rng');
var bytesToUuid = require('./lib/bytesToUuid');

function v4(options, buf, offset) {
  var i = buf && offset || 0;

  if (typeof(options) == 'string') {
    buf = options == 'binary' ? new Array(16) : null;
    options = null;
  }
  options = options || {};

  var rnds = options.random || (options.rng || rng)();

  // Per 4.4, set bits for version and `clock_seq_hi_and_reserved`
  rnds[6] = (rnds[6] & 0x0f) | 0x40;
  rnds[8] = (rnds[8] & 0x3f) | 0x80;

  // Copy bytes to buffer, if provided
  if (buf) {
    for (var ii = 0; ii < 16; ++ii) {
      buf[i + ii] = rnds[ii];
    }
  }

  return buf || bytesToUuid(rnds);
}

module.exports = v4;

Version data entries

39 entries across 38 versions & 4 rubygems

Version Path
sumomo-0.8.7 data/sumomo/api_modules/node_modules/uuid/v4.js
sumomo-0.8.6 data/sumomo/api_modules/node_modules/uuid/v4.js
sumomo-0.8.4 data/sumomo/api_modules/node_modules/uuid/v4.js
sumomo-0.8.3 data/sumomo/api_modules/node_modules/uuid/v4.js
sumomo-0.8.2 data/sumomo/api_modules/node_modules/uuid/v4.js
sumomo-0.8.1 data/sumomo/api_modules/node_modules/uuid/v4.js
sumomo-0.8.0 data/sumomo/api_modules/node_modules/uuid/v4.js
sumomo-0.7.3 data/sumomo/api_modules/node_modules/uuid/v4.js
sumomo-0.7.2 data/sumomo/api_modules/node_modules/uuid/v4.js
sumomo-0.7.1 data/sumomo/api_modules/node_modules/uuid/v4.js
sumomo-0.6.4 data/sumomo/api_modules/node_modules/uuid/v4.js
sumomo-0.6.3 data/sumomo/api_modules/node_modules/uuid/v4.js
sumomo-0.6.2 data/sumomo/api_modules/node_modules/uuid/v4.js
sumomo-0.6.1 data/sumomo/api_modules/node_modules/uuid/v4.js
affiliator-0.2.1 node_modules/fsevents/node_modules/uuid/v4.js
sumomo-0.6.0 data/sumomo/api_modules/node_modules/uuid/v4.js
lanes-0.8.0 node_modules/fsevents/node_modules/uuid/v4.js
lanes-0.8.0 node_modules/request/node_modules/uuid/v4.js
select_all-rails-0.3.1 node_modules/uuid/v4.js