function encode_baseX(data, charset, paddingChar = undefined, groupSize = undefined) {
  if (Math.log2(charset.length) % 1) throw Error(errorNotPowerOfTwo(charset.length))
  const bytes = dataToTypedArray(data, Uint8Array)
  const bitsPerCharacter = Math.ceil(Math.log2(charset.length))
  const bc = new BitConsumer(bitsPerCharacter)
  let result = ''
  bc.onIntegerReady = value => result += xFromBase10(value, charset)
  for (const byte of bytes) bc.consumeBitsFromInteger(byte, 8)
  const value = bc.integerFromRemains()
  if (value != null) result += xFromBase10(value, charset)
  if (paddingChar && groupSize) result += paddingChar.repeat((groupSize - result.length % groupSize) % groupSize)
  return result
}
/**
 * Encodes any binary data into a string of the base defined in the charset. This is only possible when the base is a power of two. An optional padding character can be applied to the output if the string length is not aligned to the supplied `groupSize`. 
 * @param {(ArrayBuffer|ArrayBufferView|Buffer|number[])} data The data to convert, an ArrayBuffer, TypedArray, DataView, Node.js Buffer or an Array with unsigned bytes.
 * @param {string} charset The charset which defines the base to use.
 * @param {string} [paddingChar] An optional padding character.
 * @param {number} [groupSize] Use the padding character if the string length is not aligned to this value.
 * @returns {string} A string where the data is converted to this base.
 */
Encodes any binary data into a string of the base defined in the charset. This is only possible when the base is a power of two. An optional padding character can be applied to the output if the string length is not aligned to the supplied `groupSize`.
@param {(ArrayBuffer|ArrayBufferView|Buffer|number[])} data The data to convert, an ArrayBuffer, TypedArray, DataView, Node.js Buffer or an Array with unsigned bytes.
@param {string} charset The charset which defines the base to use.
@param {string} [paddingChar] An optional padding character.
@param {number} [groupSize] Use the padding character if the string length is not aligned to this value.
@returns {string} A string where the data is converted to this base.
Encodes any binary data into a string of the base defined in the charset . This is only possible when the base is a power of two . An optional padding character can be applied to the output if the string length is not aligned to the supplied ` groupSize ` . @param { ( ArrayBuffer|ArrayBufferView|Buffer|number [] ) } data The data to convert an ArrayBuffer TypedArray DataView Node . js Buffer or an Array with unsigned bytes . @param { string } charset The charset which defines the base to use . @param { string } [ paddingChar ] An optional padding character . @param { number } [ groupSize ] Use the padding character if the string length is not aligned to this value . @returns { string } A string where the data is converted to this base .
function encode_baseX(data, charset, paddingChar = undefined, groupSize = undefined) {
  if (Math.log2(charset.length) % 1) throw Error(errorNotPowerOfTwo(charset.length))
  const bytes = dataToTypedArray(data, Uint8Array)
  const bitsPerCharacter = Math.ceil(Math.log2(charset.length))
  const bc = new BitConsumer(bitsPerCharacter)
  let result = ''
  bc.onIntegerReady = value => result += xFromBase10(value, charset)
  for (const byte of bytes) bc.consumeBitsFromInteger(byte, 8)
  const value = bc.integerFromRemains()
  if (value != null) result += xFromBase10(value, charset)
  if (paddingChar && groupSize) result += paddingChar.repeat((groupSize - result.length % groupSize) % groupSize)
  return result
}
function encode_baseX ( data , charset , paddingChar = undefined , groupSize = undefined ) { if ( Math . log2 ( charset . length ) % 1 ) throw Error ( errorNotPowerOfTwo ( charset . length ) ) const bytes = dataToTypedArray ( data , Uint8Array ) const bitsPerCharacter = Math . ceil ( Math . log2 ( charset . length ) ) const bc = new BitConsumer ( bitsPerCharacter ) let result = '' bc . onIntegerReady = value => result += xFromBase10 ( value , charset ) for ( const byte of bytes ) bc . consumeBitsFromInteger ( byte , 8 ) const value = bc . integerFromRemains ( ) if ( value != null ) result += xFromBase10 ( value , charset ) if ( paddingChar && groupSize ) result += paddingChar . repeat ( ( groupSize - result . length % groupSize ) % groupSize ) return result }
Encodes any binary data into a string of the base defined in the charset.
Encodes any binary data into a string of the base defined in the charset .