import isString from '../../string/isStringPrimitive'
import isNumber from '../../number/check/isNumberPrimitive'
import toNumber from '../../number/cast/toNumber'
import fromStringToUint31 from '../../number/cast/fromStringToUint31'
import fromBinaryToPrettyBinary from './fromBinaryToPrettyBinary'
import fromNumberToBase64Binary from './fromNumberToBase64Binary'
/**
* @todo could also use toByteSize for non string|number
*
* @description convert anything to binary
*/
function toBinary(x: number | string | any): number | string | any {
if (isString(x)) {
const nummy = fromStringToUint31(x)
return fromNumberToBase64Binary(nummy)
} else if (isNumber(x)) {
return fromNumberToBase64Binary(x)
} else {
const nummy = toNumber(x)
return fromNumberToBase64Binary(nummy)
}
}
export { toBinary }
export default toBinary