Blame view

node_modules/shortid/lib/decode.js 418 Bytes
f7563de62   Palak Handa   first commit
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
  '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;