From b6a2ddc83450725d656dd37f2727d4eda2ee60bb Mon Sep 17 00:00:00 2001 From: Niklas Mollenhauer Date: Sat, 25 Jan 2025 16:53:34 +0100 Subject: [PATCH 1/6] Use `.fill` instead of loop --- src/esm/index.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/esm/index.js b/src/esm/index.js index ce48a14..8106597 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) From 7d0b4478a0bfee8b63d42cc190d04db715b1c544 Mon Sep 17 00:00:00 2001 From: Niklas Mollenhauer Date: Sat, 25 Jan 2025 16:55:14 +0100 Subject: [PATCH 2/6] Use `.fill` instead of loop --- src/cjs/index.cjs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/cjs/index.cjs b/src/cjs/index.cjs index 07524c6..98765a7 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) From d2146cb9dc6959de7e2f23e271cf72e3c107319b Mon Sep 17 00:00:00 2001 From: Niklas Mollenhauer Date: Sat, 25 Jan 2025 16:55:33 +0100 Subject: [PATCH 3/6] Use `.fill` instead of loop --- ts_src/index.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/ts_src/index.ts b/ts_src/index.ts index 5f2431a..c572821 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) From 161b830b4bf28da7c77beb3ce9ef69112e6b66d0 Mon Sep 17 00:00:00 2001 From: Niklas Mollenhauer Date: Tue, 28 Jan 2025 13:35:44 +0100 Subject: [PATCH 4/6] Format --- src/cjs/index.cjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/cjs/index.cjs b/src/cjs/index.cjs index 98765a7..a05f0b2 100644 --- a/src/cjs/index.cjs +++ b/src/cjs/index.cjs @@ -7,7 +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).fill(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) From cd07d21cd432ab41f22e721e769ff46fe2cfcbba Mon Sep 17 00:00:00 2001 From: Niklas Mollenhauer Date: Tue, 28 Jan 2025 13:36:18 +0100 Subject: [PATCH 5/6] Format --- src/esm/index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/esm/index.js b/src/esm/index.js index 8106597..b79762b 100644 --- a/src/esm/index.js +++ b/src/esm/index.js @@ -5,7 +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).fill(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) From 79700237438b1edef7c8ae264fbe7b29722deada Mon Sep 17 00:00:00 2001 From: Niklas Mollenhauer Date: Tue, 28 Jan 2025 13:36:42 +0100 Subject: [PATCH 6/6] Format --- ts_src/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ts_src/index.ts b/ts_src/index.ts index c572821..fe29b79 100644 --- a/ts_src/index.ts +++ b/ts_src/index.ts @@ -7,7 +7,7 @@ function base (ALPHABET: string): base.BaseConverter { if (ALPHABET.length >= 255) throw new TypeError('Alphabet too long') - const BASE_MAP = new Uint8Array(256).fill(255); + const BASE_MAP = new Uint8Array(256).fill(255) for (let i = 0; i < ALPHABET.length; i++) { const x = ALPHABET.charAt(i)