index.js
function uuidNamed(hashFunc, version, arg1, arg2) {

    var options = arg1 || {};
    var callback = typeof arg1 === "function" ? arg1 : arg2;

    var namespace = options.namespace;
    var name = options.name;

    var hash = crypto.createHash(hashFunc);

    if (typeof namespace === "string") {
        if (!check(namespace)) {
            return error(invalidNamespace, callback);
        }
        namespace = parse(namespace);
    } else if (namespace instanceof UUID) {
        namespace = namespace.toBuffer();
    } else if (!(namespace instanceof Buffer) || namespace.length !== 16) {
        return error(invalidNamespace, callback);
    }

    var nameIsNotAString = typeof name !== "string";
    if (nameIsNotAString && !(name instanceof Buffer)) {
        return error(invalidName, callback);
    }

    hash.update(namespace);
    hash.update(options.name, nameIsNotAString ? "binary" : "utf8");

    var buffer = hash.digest();

    var result;
    switch (options.encoding && options.encoding[0]) {
        case "b":
        case "B":
            buffer[6] = (buffer[6] & 0x0f) | version;
            buffer[8] = (buffer[8] & 0x3f) | 0x80;
            result = buffer;
            break;
        case "o":
        case "U":
            buffer[6] = (buffer[6] & 0x0f) | version;
            buffer[8] = (buffer[8] & 0x3f) | 0x80;
            result = new UUID(buffer);
            break;
        default:
            result = byte2hex[buffer[0]] + byte2hex[buffer[1]] +
                     byte2hex[buffer[2]] + byte2hex[buffer[3]] + "-" +
                     byte2hex[buffer[4]] + byte2hex[buffer[5]] + "-" +
                     byte2hex[(buffer[6] & 0x0f) | version] +
                     byte2hex[buffer[7]] + "-" +
                     byte2hex[(buffer[8] & 0x3f) | 0x80] +
                     byte2hex[buffer[9]] + "-" +
                     byte2hex[buffer[10]] + byte2hex[buffer[11]] +
                     byte2hex[buffer[12]] + byte2hex[buffer[13]] +
                     byte2hex[buffer[14]] + byte2hex[buffer[15]];
            break;
    }
    if (callback) {
        setImmediate(function () {
            callback(null, result);
        });
    } else {
        return result;
    }
}
function uuidNamed(hashFunc, version, arg1, arg2) {

    var options = arg1 || {};
    var callback = typeof arg1 === "function" ? arg1 : arg2;

    var namespace = options.namespace;
    var name = options.name;

    var hash = crypto.createHash(hashFunc);

    if (typeof namespace === "string") {
        if (!check(namespace)) {
            return error(invalidNamespace, callback);
        }
        namespace = parse(namespace);
    } else if (namespace instanceof UUID) {
        namespace = namespace.toBuffer();
    } else if (!(namespace instanceof Buffer) || namespace.length !== 16) {
        return error(invalidNamespace, callback);
    }

    var nameIsNotAString = typeof name !== "string";
    if (nameIsNotAString && !(name instanceof Buffer)) {
        return error(invalidName, callback);
    }

    hash.update(namespace);
    hash.update(options.name, nameIsNotAString ? "binary" : "utf8");

    var buffer = hash.digest();

    var result;
    switch (options.encoding && options.encoding[0]) {
        case "b":
        case "B":
            buffer[6] = (buffer[6] & 0x0f) | version;
            buffer[8] = (buffer[8] & 0x3f) | 0x80;
            result = buffer;
            break;
        case "o":
        case "U":
            buffer[6] = (buffer[6] & 0x0f) | version;
            buffer[8] = (buffer[8] & 0x3f) | 0x80;
            result = new UUID(buffer);
            break;
        default:
            result = byte2hex[buffer[0]] + byte2hex[buffer[1]] +
                     byte2hex[buffer[2]] + byte2hex[buffer[3]] + "-" +
                     byte2hex[buffer[4]] + byte2hex[buffer[5]] + "-" +
                     byte2hex[(buffer[6] & 0x0f) | version] +
                     byte2hex[buffer[7]] + "-" +
                     byte2hex[(buffer[8] & 0x3f) | 0x80] +
                     byte2hex[buffer[9]] + "-" +
                     byte2hex[buffer[10]] + byte2hex[buffer[11]] +
                     byte2hex[buffer[12]] + byte2hex[buffer[13]] +
                     byte2hex[buffer[14]] + byte2hex[buffer[15]];
            break;
    }
    if (callback) {
        setImmediate(function () {
            callback(null, result);
        });
    } else {
        return result;
    }
}
function uuidNamed ( hashFunc , version , arg1 , arg2 ) { var options = arg1 || { } ; var callback = typeof arg1 === "function" ? arg1 : arg2 ; var namespace = options . namespace ; var name = options . name ; var hash = crypto . createHash ( hashFunc ) ; if ( typeof namespace === "string" ) { if ( ! check ( namespace ) ) { return error ( invalidNamespace , callback ) ; } namespace = parse ( namespace ) ; } else if ( namespace instanceof UUID ) { namespace = namespace . toBuffer ( ) ; } else if ( ! ( namespace instanceof Buffer ) || namespace . length !== 16 ) { return error ( invalidNamespace , callback ) ; } var nameIsNotAString = typeof name !== "string" ; if ( nameIsNotAString && ! ( name instanceof Buffer ) ) { return error ( invalidName , callback ) ; } hash . update ( namespace ) ; hash . update ( options . name , nameIsNotAString ? "binary" : "utf8" ) ; var buffer = hash . digest ( ) ; var result ; switch ( options . encoding && options . encoding [ 0 ] ) { case "b" : case "B" : buffer [ 6 ] = ( buffer [ 6 ] & 0x0f ) | version ; buffer [ 8 ] = ( buffer [ 8 ] & 0x3f ) | 0x80 ; result = buffer ; break ; case "o" : case "U" : buffer [ 6 ] = ( buffer [ 6 ] & 0x0f ) | version ; buffer [ 8 ] = ( buffer [ 8 ] & 0x3f ) | 0x80 ; result = new UUID ( buffer ) ; break ; default : result = byte2hex [ buffer [ 0 ] ] + byte2hex [ buffer [ 1 ] ] + byte2hex [ buffer [ 2 ] ] + byte2hex [ buffer [ 3 ] ] + "-" + byte2hex [ buffer [ 4 ] ] + byte2hex [ buffer [ 5 ] ] + "-" + byte2hex [ ( buffer [ 6 ] & 0x0f ) | version ] + byte2hex [ buffer [ 7 ] ] + "-" + byte2hex [ ( buffer [ 8 ] & 0x3f ) | 0x80 ] + byte2hex [ buffer [ 9 ] ] + "-" + byte2hex [ buffer [ 10 ] ] + byte2hex [ buffer [ 11 ] ] + byte2hex [ buffer [ 12 ] ] + byte2hex [ buffer [ 13 ] ] + byte2hex [ buffer [ 14 ] ] + byte2hex [ buffer [ 15 ] ] ; break ; } if ( callback ) { setImmediate ( function ( ) { callback ( null , result ) ; } ) ; } else { return result ; } }
v3 + v5
v3 + v5