Skip to content

Commit

Permalink
1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
hiimjasmine00 committed Apr 17, 2023
1 parent 8e65f23 commit 567c7da
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 12 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
5 changes: 2 additions & 3 deletions src/base32.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 2 additions & 3 deletions src/base64.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
5 changes: 2 additions & 3 deletions src/util.ts
Original file line number Diff line number Diff line change
@@ -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;
}
}

Expand Down

0 comments on commit 567c7da

Please sign in to comment.