@dephub/base64 1.0.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ # MIT License
2
+
3
+ Copyright (c) 2025 Estarlin R
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,76 @@
1
+ # @dephub/base64
2
+
3
+ > Encode. Decode. Simplified.
4
+
5
+ `@dephub/base64` — a utility for encoding UTF-8 strings to Base64 and decoding Base64 back to UTF-8.
6
+
7
+ [![NPM version](https://img.shields.io/npm/v/@dephub/base64.svg?style=flat)](https://npmjs.org/package/@dephub/base64)
8
+ [![ESM-only](https://img.shields.io/badge/ESM-only-brightgreen?style=flat)](https://nodejs.org/)
9
+ [![Node.js version](https://img.shields.io/badge/node-%3E%3D18.0.0-brightgreen.svg)](https://nodejs.org/)
10
+
11
+ ---
12
+
13
+ ## Features ✨
14
+
15
+ - 🔹 **Simple API**: `encode()` and `decode()` functions
16
+ - 🚀 **CLI support**: encode/decode directly from the terminal
17
+ - 🔄 **Reliable Base64 encoding/decoding** — handles all UTF-8 characters correctly
18
+ - 🌐 **Cross-environment** — works in Node.js and modern browsers
19
+ - ⚡ **Fast performance** — minimal and efficient Base64 operations
20
+
21
+ ## Installation 💿
22
+
23
+ ```bash
24
+ # Using npm
25
+ npm install @dephub/base64
26
+
27
+ # Using pnpm
28
+ pnpm add @dephub/base64
29
+
30
+ # Using yarn
31
+ yarn add @dephub/base64
32
+ ```
33
+
34
+ ## Usage 📦
35
+
36
+ ### API </>
37
+
38
+ ```ts
39
+ import { encode, decode } from '@dephub/base64';
40
+
41
+ const encoded = encode('hello');
42
+ console.log(encoded); // "aGVsbG8="
43
+
44
+ const decoded = decode(encoded);
45
+ console.log(decoded); // "hello"
46
+ ```
47
+
48
+ ### CLI 🖥️
49
+
50
+ ```bash
51
+ # Encode string
52
+ base64 encode "hello"
53
+ # Output: aGVsbG8=
54
+
55
+ # Decode string
56
+ base64 decode "aGVsbG8="
57
+ # Output: hello
58
+
59
+ # Show help
60
+ base64 --help
61
+ ```
62
+
63
+ Commands:
64
+
65
+ ```
66
+ encode <string> : Encode string to Base64
67
+ decode <base64> : Decode Base64 to string
68
+ --help : Show help message
69
+ --version : Show version
70
+ ```
71
+
72
+ ## License 📄
73
+
74
+ MIT License – see [LICENSE](LICENSE) for details.
75
+
76
+ **Author:** Estarlin R ([estarlincito.com](https://estarlincito.com))
package/dist/cli.js ADDED
@@ -0,0 +1,19 @@
1
+ #!/usr/bin/env node
2
+ import { cli as e } from "@dephub/cli";
3
+ import { decode as n } from "./core/decode.js";
4
+ import { encode as r } from "./core/encode.js";
5
+ import { name as i, version as s, description as a } from "./utils/pkg.js";
6
+ e.name(i.split("/")[1] ?? "name").version(s).description(a);
7
+ e.command("encode", "Encode string to Base64").argument("<string>", "The text string to encode into Base64 format").action(({ args: t }) => {
8
+ const o = t[0];
9
+ if (o.length === 0)
10
+ throw new Error("You must provide a string to encode.");
11
+ console.log(r(o));
12
+ });
13
+ e.command("decode", "Decode Base64 to string").argument("<base64>", "The Base64 string to decode back into text").action(({ args: t }) => {
14
+ const o = t[0];
15
+ if (o.length === 0)
16
+ throw new Error("You must provide a Base64 string to decode.");
17
+ console.log(n(o));
18
+ });
19
+ await e.run();
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Decodes a Base64 string back to UTF-8
3
+ *
4
+ * @example
5
+ * decode('aGVsbG8=') // 'hello'
6
+ */
7
+ export declare const decode: (base64: string) => string;
@@ -0,0 +1,6 @@
1
+ const d = (e) => new TextDecoder().decode(
2
+ Uint8Array.from(atob(e), (o) => o.charCodeAt(0))
3
+ );
4
+ export {
5
+ d as decode
6
+ };
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Encodes a UTF-8 string to Base64
3
+ *
4
+ * @example
5
+ * encode('hello') // 'aGVsbG8='
6
+ */
7
+ export declare const encode: (text: string) => string;
@@ -0,0 +1,4 @@
1
+ const o = (e) => btoa(String.fromCharCode(...new TextEncoder().encode(e)));
2
+ export {
3
+ o as encode
4
+ };
@@ -0,0 +1,2 @@
1
+ export { decode } from './core/decode.js';
2
+ export { encode } from './core/encode.js';
package/dist/index.js ADDED
@@ -0,0 +1,6 @@
1
+ import { decode as r } from "./core/decode.js";
2
+ import { encode as c } from "./core/encode.js";
3
+ export {
4
+ r as decode,
5
+ c as encode
6
+ };
@@ -0,0 +1,11 @@
1
+ const e = "@dephub/base64", s = "1.0.0", n = "Simple Base64 encoding and decoding utilities for Node.js and browsers", o = {
2
+ name: e,
3
+ version: s,
4
+ description: n
5
+ };
6
+ export {
7
+ o as default,
8
+ n as description,
9
+ e as name,
10
+ s as version
11
+ };
@@ -0,0 +1 @@
1
+ export declare const version: string, description: string, name: string;
@@ -0,0 +1,7 @@
1
+ import o from "../package.json.js";
2
+ const { version: e, description: i, name: n } = o ?? {};
3
+ export {
4
+ i as description,
5
+ n as name,
6
+ e as version
7
+ };
package/package.json ADDED
@@ -0,0 +1,59 @@
1
+ {
2
+ "name": "@dephub/base64",
3
+ "type": "module",
4
+ "version": "1.0.0",
5
+ "description": "Simple Base64 encoding and decoding utilities for Node.js and browsers",
6
+ "types": "./dist/index.d.ts",
7
+ "main": "./dist/index.js",
8
+ "bin": {
9
+ "base64": "./dist/cli.js"
10
+ },
11
+ "keywords": [
12
+ "base64",
13
+ "encode",
14
+ "decode",
15
+ "base64encode",
16
+ "base64decode",
17
+ "typescript",
18
+ "nodejs",
19
+ "dephub"
20
+ ],
21
+ "author": {
22
+ "name": "Estarlin R",
23
+ "email": "dev@estarlincito.com",
24
+ "url": "https://estarlincito.com"
25
+ },
26
+ "engines": {
27
+ "node": ">=18.0.0"
28
+ },
29
+ "files": [
30
+ "LICENSE",
31
+ "README.md",
32
+ "dist"
33
+ ],
34
+ "license": "MIT",
35
+ "homepage": "https://github.com/dephubjs/base64#readme",
36
+ "repository": {
37
+ "type": "git",
38
+ "url": "https://github.com/dephubjs/base64.git",
39
+ "directory": "packages/base64"
40
+ },
41
+ "bugs": {
42
+ "url": "https://github.com/dephubjs/base64/issues"
43
+ },
44
+ "publishConfig": {
45
+ "access": "public"
46
+ },
47
+ "dependencies": {
48
+ "@dephub/cli": "^1.0.0"
49
+ },
50
+ "scripts": {
51
+ "release": "pnpm publish",
52
+ "check-types": "tsc --noEmit --skipLibCheck",
53
+ "lint": "lint . --max-warnings 0",
54
+ "lint:fix": "lint . --fix",
55
+ "clean": "rm -rf dist",
56
+ "build": "vite build",
57
+ "dev": "vite build -w --mode development"
58
+ }
59
+ }