diff --git a/src/cjs/index.cjs b/src/cjs/index.cjs index 0124347..07524c6 100644 --- a/src/cjs/index.cjs +++ b/src/cjs/index.cjs @@ -81,7 +81,7 @@ function base (ALPHABET) { const size = (((source.length - psz) * FACTOR) + 1) >>> 0 // log(58) / log(256), rounded up. const b256 = new Uint8Array(size) // Process the characters. - while (source[psz]) { + while (psz < source.length) { // Decode character let carry = BASE_MAP[source.charCodeAt(psz)] // Invalid character diff --git a/src/esm/index.js b/src/esm/index.js index ac60db8..ce48a14 100644 --- a/src/esm/index.js +++ b/src/esm/index.js @@ -79,7 +79,7 @@ function base (ALPHABET) { const size = (((source.length - psz) * FACTOR) + 1) >>> 0 // log(58) / log(256), rounded up. const b256 = new Uint8Array(size) // Process the characters. - while (source[psz]) { + while (psz < source.length) { // Decode character let carry = BASE_MAP[source.charCodeAt(psz)] // Invalid character diff --git a/ts_src/index.ts b/ts_src/index.ts index 66e0e4b..5f2431a 100644 --- a/ts_src/index.ts +++ b/ts_src/index.ts @@ -100,7 +100,7 @@ function base (ALPHABET: string): base.BaseConverter { const b256 = new Uint8Array(size) // Process the characters. - while (source[psz]) { + while (psz < source.length) { // Decode character let carry = BASE_MAP[source.charCodeAt(psz)]