code: function intArray(val) {
      var array = [], encVal = val, bytes;
  
      if (val === 0) {
          array.push(0);
      } else {
          if (val < 0) {
              bytes = Math.floor(1 + Math.log(-val) / LOG256);
              // Encode negatives as 32-bit two's complement. Let's hope that fits.
              encVal += Math.pow(2, 8 * bytes);
          }
          while (encVal > 0) {
              array.push(encVal % 256);
              encVal = parseInt(encVal / 256, 10);
          }
      }
  
      // Do not produce integers that look negative (high bit
      // of first byte set).
      if (val > 0 && array[array.length - 1] >= 0x80) {
          array.push(0);
      }
  
      return array.reverse();
  }
docs: Divide an integer into base-256 bytes. Most significant byte first.