bufferbase 1.0.10 → 1.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "bufferbase",
3
- "version": "1.0.10",
3
+ "version": "1.0.11",
4
4
  "description": "Buffer-to-BaseN Encoder, Decoder, Converter, and Validator",
5
5
  "type": "module",
6
6
  "types": "./dist/index.d.ts",
@@ -1 +0,0 @@
1
- export {};
@@ -1,42 +0,0 @@
1
- import { Chars, BufferEncoder } from "./bufferbase.js";
2
- import { Buffer } from "node:buffer";
3
- import test from "node:test"; // ①
4
- import assert from "node:assert";
5
- test("anybase", async (t) => {
6
- await t.test("encodes and decodes a string correctly with base58chars", () => {
7
- const encoder = new BufferEncoder(Chars.Base58);
8
- const buffer = Buffer.from("Hello, World!", "utf8");
9
- const encoded = encoder.encode(buffer);
10
- const decoded = encoder.decode(encoded);
11
- assert.strictEqual(decoded.toString("utf8"), "Hello, World!");
12
- });
13
- await t.test("handles empty buffer correctly", () => {
14
- const encoder = new BufferEncoder(Chars.Base58);
15
- const buffer = Buffer.alloc(0);
16
- const encoded = encoder.encode(buffer);
17
- const decoded = encoder.decode(encoded);
18
- assert.strictEqual(decoded.toString("utf8"), "");
19
- });
20
- await t.test("handles long buffer correctly", () => {
21
- const encoder = new BufferEncoder(Chars.Base58);
22
- const buffer = Buffer.from("Hello, World!".repeat(100), "utf8");
23
- const encoded = encoder.encode(buffer);
24
- const decoded = encoder.decode(encoded);
25
- assert.strictEqual(decoded.toString("utf8"), "Hello, World!".repeat(100));
26
- });
27
- await t.test("encode and decode various chars correctly", () => {
28
- for (const charTable of Object.values(Chars)) {
29
- const encoder = new BufferEncoder(charTable);
30
- const buffer = Buffer.from("Hello, World!", "utf8");
31
- const encoded = encoder.encode(buffer);
32
- const decoded = encoder.decode(encoded);
33
- assert.strictEqual(decoded.toString("utf8"), "Hello, World!");
34
- }
35
- });
36
- await t.test("throws error on invalid characters in decode", () => {
37
- assert.throws(() => {
38
- const encoder = new BufferEncoder(Chars.Base58);
39
- encoder.decode("InvalidString!");
40
- }, new Error("Invalid character found"));
41
- });
42
- });