You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

17 lines
418 B

'use strict';
var alphabet = require('./alphabet');
/**
* Decode the id to get the version and worker
* Mainly for debugging and testing.
* @param id - the shortid-generated id.
*/
function decode(id) {
var characters = alphabet.shuffled();
return {
version: characters.indexOf(id.substr(0, 1)) & 0x0f,
worker: characters.indexOf(id.substr(1, 1)) & 0x0f
};
}
module.exports = decode;