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

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