@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 +21 -0
- package/README.md +76 -0
- package/dist/cli.js +19 -0
- package/dist/core/decode.d.ts +7 -0
- package/dist/core/decode.js +6 -0
- package/dist/core/encode.d.ts +7 -0
- package/dist/core/encode.js +4 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +6 -0
- package/dist/package.json.js +11 -0
- package/dist/utils/pkg.d.ts +1 -0
- package/dist/utils/pkg.js +7 -0
- package/package.json +59 -0
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
|
+
[](https://npmjs.org/package/@dephub/base64)
|
|
8
|
+
[](https://nodejs.org/)
|
|
9
|
+
[](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();
|
package/dist/index.d.ts
ADDED
package/dist/index.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const version: string, description: string, name: string;
|
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
|
+
}
|