this function is what hex-to-binary package uses. since it does not have types file and even declaring in decs.t.ts does not work, i tried to implement in typescript: