arnaucube
arnaucube/comunicationLeapPublic Self-hosted repository
comunicationLeap/node_modules/shortid/lib/decode.js
node_modules/shortid/lib/decode.jsRaw
 1'use strict';
 2var alphabet = require('./alphabet');
 3
 4/**
 5 * Decode the id to get the version and worker
 6 * Mainly for debugging and testing.
 7 * @param id - the shortid-generated id.
 8 */
 9function decode(id) {
10    var characters = alphabet.shuffled();
11    return {
12        version: characters.indexOf(id.substr(0, 1)) & 0x0f,
13        worker: characters.indexOf(id.substr(1, 1)) & 0x0f
14    };
15}
16
17module.exports = decode;