Avoid needless work of converting number into its own base
authorGreg Hurrell <greg@hurrell.net>
Wed, 31 May 2017 07:30:59 +0000 (00:30 -0700)
committerGreg Hurrell <greg@hurrell.net>
Wed, 31 May 2017 07:30:59 +0000 (00:30 -0700)
src/convert.js

index 14b4562b42d4b7ae1011c20d5776528e7b9290d1..a7f80aecd48256be193f860600a9d568dfdca0b0 100644 (file)
@@ -18,6 +18,9 @@ export default function convert(
   inBase: number,
   outBase: number
 ): string {
+  if (inBase === outBase) {
+    return number;
+  }
   const digits = getDigits(number, inBase);
   let result = [0];
   let power = [1];