How to use the uuid.generate function in uuid

To help you get started, we’ve selected a few uuid examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github kelektiv / node-uuid / benchmark / benchmark.js View on Github external
// node-uuid - string form
for (var i = 0, t = Date.now(); i < N; i++) nodeuuid.v4();
rate('nodeuuid.v4()', t);

for (var i = 0, t = Date.now(); i < N; i++) nodeuuid.v4('binary');
rate('nodeuuid.v4(\'binary\')', t);

var buffer = new nodeuuid.BufferClass(16);
for (var i = 0, t = Date.now(); i < N; i++) nodeuuid.v4('binary', buffer);
rate('nodeuuid.v4(\'binary\', buffer)', t);

// libuuid - string form
for (var i = 0, t = Date.now(); i < N; i++) uuid();
rate('uuid()', t);

for (var i = 0, t = Date.now(); i < N; i++) uuid('binary');
rate('uuid(\'binary\')', t);

// uuid-js - string form
for (var i = 0, t = Date.now(); i < N; i++) uuidjs.create(4);
rate('uuidjs.create(4)', t);

// 140byte.es
for (var i = 0, t = Date.now(); i < N; i++) 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g,function(s,r){r=Math.random()*16|0;return (s=='x'?r:r&0x3|0x8).toString(16)});
rate('140byte.es_v4', t);

console.log('');
console.log('# v1');

// node-uuid - v1 string form
for (var i = 0, t = Date.now(); i < N; i++) nodeuuid.v1();
rate('nodeuuid.v1()', t);
github kriskowal / terminal / connection.js View on Github external
function Session(host) {

    var id = UUID.generate();
    var terminal = Terminal();
    var replay = "";
    var width;
    var height;
    var obsolesence = Q.defer();
    var readQueue = Queue();

    // construct the child
    var tty;
    tty = TTY.open("telnet", [host]);
    var fd = tty[0];
    var child = tty[1];
    var stream = new Stream(fd);
    stream.readable = stream.writable = true;
    stream.resume();
    stream.on("data", function (data) {
github rubenfonseca / map_crowd_reduce / app.js View on Github external
} catch(e) {
      res.send("bad code on s function " + e.message);
      return;
    }

    var m = fields['map'];
    var r = fields['reduce'];

    var file_data = null;
    if(files['file']) {
      console.log("Reading input file " + files['file'].path);

      file_data = fs.readFileSync(files['file'].path);
    }

    var u = uuid.generate();
    state[u] = {};

    console.log("Slicing.....");
    var m_results = [];
    var m_jobs = s.runInNewContext({})(file_data);
    for(var i=0; i
github senko / speeka / service.js View on Github external
everyone.now.createRoom = function(cb) {
    var room_id;

    while (!room_id) {
        room_id = Buffer(uuid.generate('binary')).toString('base64').slice(0, 4);
        if (chatrooms.hasOwnProperty(room_id))
            room_id = undefined;
    }

    var group = nowjs.getGroup(room_id);

    chatrooms[room_id] = {
        group: group,
        backlog: [],
        members: {}
    };

    console.log('New room created: ' + room_id);
    cb(room_id);
}
github wso2 / carbon-dashboards / apps / portal / modules / dashboards.js View on Github external
var saveBanner = function (dashboardId, username, filename, mime, stream) {
    var uuid = require('uuid');
    var registry = getRegistry();
    var path = registryBannerPath(dashboardId, username);
    var resource = {
        content: stream,
        uuid: uuid.generate(),
        mediaType: mime,
        name: filename,
        properties: {}
    };
    registry.put(path, resource);
};
github wso2 / jaggery / modules / carbon / scripts / registry / registry-osgi.js View on Github external
Registry.prototype.query = function (options) {
        var res,
            query = options.query,
            uuid = require('uuid'),
            name = options.name || uuid.generate(),
            cache = options.cache || true,
            Collections = java.util.Collections,
            path = '/_system/config/repository/components/org.wso2.carbon.registry/queries/' + name;
        if (!this.exists(path) || !cache) {
            this.put(path, {
                content: query,
                mediaType: 'application/vnd.sql.query',
                properties: {
                    resultType: options.resultType
                }
            });
        }
        res = this.registry.executeQuery(path, Collections.emptyMap());
        if (!cache) {
            this.remove(path);
        }
github usecanvas / canvas-editor / addon / lib / base62-uuid.js View on Github external
export function generate() {
  const uuid = UUID.generate().replace(/-/g, '');
  const int = parseInt(uuid, 16);
  const baseID = Base62.encode(int);
  return ensureLength(baseID);
}
github wso2 / product-es / modules / apps / store / modules / data / storage.js View on Github external
//value should contain the file path and content type
        var file;

        //If a path is given then use the path to create a file,otherwise
        //use the provided file.
        if(value.path){
            file=new File(value.path);
        }
        else{
            file=value.file;
        }

        //log.debug('filename :'+file.getName());

        //Generate a uuid for the resource
        resource.uuid = uuid.generate();
        resource.contentType = value.contentType;
        resource.contentLength = file.getLength();
        resource.content = file;
        resource.fileName =file.getName();
        resource.tenantId = value.tenantId||'super';

        //Save the resource
        resource.save();

        return resource.uuid+'/'+file.getName();
    };
github wso2 / product-es / modules / apps / storage / modules / data / storage.js View on Github external
//value should contain the file path and content type
        var file;

        //If a path is given then use the path to create a file,otherwise
        //use the provided file.
        if(value.path){
            file=new File(value.path);
        }
        else{
            file=value.file;
        }

        log.debug('filename :'+file.getName());

        //Generate a uuid for the resource
        resource.uuid = uuid.generate();
        resource.contentType = value.contentType;
        resource.contentLength = file.getLength();
        resource.content = file;
        resource.fileName =file.getName();
        resource.tenantId = value.tenantId||'super';

        //Save the resource
        resource.save();

        return resource.uuid+'/'+file.getName();
    };