6bit-encoder.js
function encode4(n) {
  assert(0 <= n && n <= 0xffffff, ENCODE_OUTOFBOUNDS + n)
  // 24 bits -> 4 digits
  const lower = isolate(n, 0, 6)
  const aboveLower = isolate(n, 6, 6)
  const belowUpper = isolate(n, 12, 6)
  const upper = isolate(n, 18, 6)
  return encode(upper) + encode(belowUpper)
    + encode(aboveLower) + encode(lower)
}
function encode4(n) {
  assert(0 <= n && n <= 0xffffff, ENCODE_OUTOFBOUNDS + n)
  // 24 bits -> 4 digits
  const lower = isolate(n, 0, 6)
  const aboveLower = isolate(n, 6, 6)
  const belowUpper = isolate(n, 12, 6)
  const upper = isolate(n, 18, 6)
  return encode(upper) + encode(belowUpper)
    + encode(aboveLower) + encode(lower)
}
function encode4 ( n ) { assert ( 0 <= n && n <= 0xffffff , ENCODE_OUTOFBOUNDS + n ) // 24 bits -> 4 digits const lower = isolate ( n , 0 , 6 ) const aboveLower = isolate ( n , 6 , 6 ) const belowUpper = isolate ( n , 12 , 6 ) const upper = isolate ( n , 18 , 6 ) return encode ( upper ) + encode ( belowUpper ) + encode ( aboveLower ) + encode ( lower ) }
Encodes a 24 bit number into four URL safe chars

@name encode4

@param {Number} n a 24 bit number
@returns {String} the chars
Encodes a 24 bit number into four URL safe chars