index.js
function setDefaults() {
    // sequence: generate a random 3-byte integer initial value for the sequence counter
    if (seq === undefined)
        seq = ~~(Math.random() * 0xffffff)

    // processId: 2-byte integer derived from the PID assigned by the OS
    if (pid === undefined)
        pid = process.pid % 0xffff

    // machineId: first three bytes of the md5 hash calculated from OS hostname
    if (mid === undefined)
        mid = crypto.createHash('md5')
                    .update(os.hostname())
                    .digest()
                    .slice(0, 3)
                    .readUIntBE(0, 3)

    // reset the counter
    // (if `mid` or `pid` changes then previously allocated ids in the current second are freed)
    ctr = 0

    // `unique` is the fixed-length composition of `mid` and `pid`
    unique = pad(mid, 6, 16) + pad(pid, 4, 16)

    // calculate the initial sequence prefix
    seqpref = pad(~~(seq / 16), 5, 16)
}
function setDefaults() {
    // sequence: generate a random 3-byte integer initial value for the sequence counter
    if (seq === undefined)
        seq = ~~(Math.random() * 0xffffff)

    // processId: 2-byte integer derived from the PID assigned by the OS
    if (pid === undefined)
        pid = process.pid % 0xffff

    // machineId: first three bytes of the md5 hash calculated from OS hostname
    if (mid === undefined)
        mid = crypto.createHash('md5')
                    .update(os.hostname())
                    .digest()
                    .slice(0, 3)
                    .readUIntBE(0, 3)

    // reset the counter
    // (if `mid` or `pid` changes then previously allocated ids in the current second are freed)
    ctr = 0

    // `unique` is the fixed-length composition of `mid` and `pid`
    unique = pad(mid, 6, 16) + pad(pid, 4, 16)

    // calculate the initial sequence prefix
    seqpref = pad(~~(seq / 16), 5, 16)
}
Initialize values for calculations.