function xFromBase10(number, charset) {
  if (typeof charset != 'string' || charset.length < 2)
    throw Error('Invalid charset for base conversion: '+charset)
  const base = charset.length
  let result = '', val = number
  do {
    const res = Math.floor(val / base)
    const rem = val % base
    val = res
    result = charset[rem] + result
  } while (val > 0)
  return result
}
/**
 * Convert a base 10 number (our number system) to base X (as in any base).
 * @param {number} number The number to convert.
 * @param {string} charset The charset defining the base to use. E.g. "01" for base 2 (binary).
 * @returns {string} The number as the base defined in the charset.
 */
Convert a base 10 number (our number system) to base X (as in any base).
Convert a base 10 number ( our number system ) to base X ( as in any base ) .
function xFromBase10(number, charset) {
  if (typeof charset != 'string' || charset.length < 2)
    throw Error('Invalid charset for base conversion: '+charset)
  const base = charset.length
  let result = '', val = number
  do {
    const res = Math.floor(val / base)
    const rem = val % base
    val = res
    result = charset[rem] + result
  } while (val > 0)
  return result
}
function xFromBase10 ( number , charset ) { if ( typeof charset != 'string' || charset . length < 2 ) throw Error ( 'Invalid charset for base conversion: ' + charset ) const base = charset . length let result = '' , val = number do { const res = Math . floor ( val / base ) const rem = val % base val = res result = charset [ rem ] + result } while ( val > 0 ) return result }
Convert a base 10 number (our number system) to base X (as in any base).
Convert a base 10 number ( our number system ) to base X ( as in any base ) .