diff --git a/src/cjs/index.cjs b/src/cjs/index.cjs index 07524c6..a05f0b2 100644 --- a/src/cjs/index.cjs +++ b/src/cjs/index.cjs @@ -7,10 +7,7 @@ Object.defineProperty(exports, '__esModule', { value: true }) function base (ALPHABET) { if (ALPHABET.length >= 255) { throw new TypeError('Alphabet too long') } - const BASE_MAP = new Uint8Array(256) - for (let j = 0; j < BASE_MAP.length; j++) { - BASE_MAP[j] = 255 - } + const BASE_MAP = new Uint8Array(256).fill(255) for (let i = 0; i < ALPHABET.length; i++) { const x = ALPHABET.charAt(i) const xc = x.charCodeAt(0) diff --git a/src/esm/index.js b/src/esm/index.js index ce48a14..b79762b 100644 --- a/src/esm/index.js +++ b/src/esm/index.js @@ -5,10 +5,7 @@ // file LICENSE or http://www.opensource.org/licenses/mit-license.php. function base (ALPHABET) { if (ALPHABET.length >= 255) { throw new TypeError('Alphabet too long') } - const BASE_MAP = new Uint8Array(256) - for (let j = 0; j < BASE_MAP.length; j++) { - BASE_MAP[j] = 255 - } + const BASE_MAP = new Uint8Array(256).fill(255) for (let i = 0; i < ALPHABET.length; i++) { const x = ALPHABET.charAt(i) const xc = x.charCodeAt(0) diff --git a/ts_src/index.ts b/ts_src/index.ts index 5f2431a..fe29b79 100644 --- a/ts_src/index.ts +++ b/ts_src/index.ts @@ -7,10 +7,7 @@ function base (ALPHABET: string): base.BaseConverter { if (ALPHABET.length >= 255) throw new TypeError('Alphabet too long') - const BASE_MAP = new Uint8Array(256) - for (let j = 0; j < BASE_MAP.length; j++) { - BASE_MAP[j] = 255 - } + const BASE_MAP = new Uint8Array(256).fill(255) for (let i = 0; i < ALPHABET.length; i++) { const x = ALPHABET.charAt(i)