From 567c7daefa186ae6d5f344798c2d2b9aeb9f2588 Mon Sep 17 00:00:00 2001 From: Justin Pridgen Date: Sun, 16 Apr 2023 22:07:09 -0400 Subject: [PATCH] 1.0.1 --- README.md | 4 ++-- package.json | 2 +- src/base32.ts | 5 ++--- src/base64.ts | 5 ++--- src/util.ts | 5 ++--- 5 files changed, 9 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index b0d48ac..2097eb5 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,7 @@ dencodeme.base(5).decode("0404040104130413042101120441034204130413"); // hello y ``` ## Documentation -The documentation can be found [here](https://crack-a-bottle.github.io/dencodeme). +The documentation can be found [here](https://crackabottle.js.org/dencodeme). ## License -[MIT](./LICENSE) +This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details. diff --git a/package.json b/package.json index 0d567be..1e4aaa3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "dencodeme", - "version": "1.0.0", + "version": "1.0.1", "description": "Encode/Decode data using various encoding schemes.", "main": "dist/index.js", "module": "dist/index.mjs", diff --git a/src/base32.ts b/src/base32.ts index da80b33..1154287 100644 --- a/src/base32.ts +++ b/src/base32.ts @@ -12,9 +12,8 @@ const pads = util.quickMap(5, x => (8 - Math.ceil(x * 8 / 5)) % 8, false); // 0, export function encode(data: string | Buffer, encoding: BufferEncoding = "utf8") { let padding = 0; return Buffer.from(data.toString(encoding), encoding).reduce((a, x, i, r) => { - const y = x * bits[i % 5]; - if (i % 5 == 0) a.push(y); - else a[a.length - 1] += y; + if (i % 5 == 0) a.push(0); + a[a.length - 1] += x * bits[i % 5]; if ((i + 1) >= r.length) padding = pads[r.length % 5]; return a; diff --git a/src/base64.ts b/src/base64.ts index 807bddc..9c616a5 100644 --- a/src/base64.ts +++ b/src/base64.ts @@ -12,9 +12,8 @@ const pads = util.quickMap(3, x => (4 - Math.ceil(x * 4 / 3)) % 4, false); // 0, export function encode(data: string | Buffer, encoding: BufferEncoding = "utf8") { let padding = 0; return Buffer.from(data.toString(encoding), encoding).reduce((a, x, i, r) => { - const y = x * bits[i % 3]; - if (i % 3 == 0) a.push(y); - else a[a.length - 1] += y; + if (i % 3 == 0) a.push(0); + a[a.length - 1] += x * bits[i % 3]; if ((i + 1) >= r.length) padding = pads[r.length % 3]; return a; diff --git a/src/util.ts b/src/util.ts index e8adbe6..a25b072 100644 --- a/src/util.ts +++ b/src/util.ts @@ -1,9 +1,8 @@ // Returns a mapper function to split a string into an array of strings of the given length. function getMapper(length: number) { return (a: string[], x: string, i: number) => { - if (i % length == 0) a.push(x); - else a[a.length - 1] += x; - return a; + if (i % length == 0) a.push(""); + return a[a.length - 1] += x, a; } }