@lucid-softworks/base64 0.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 +15 -0
- package/dist/browser.d.ts +5 -0
- package/dist/browser.d.ts.map +1 -0
- package/dist/browser.js +13 -0
- package/dist/browser.js.map +1 -0
- package/dist/node.d.ts +5 -0
- package/dist/node.d.ts.map +1 -0
- package/dist/node.js +10 -0
- package/dist/node.js.map +1 -0
- package/package.json +68 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Lucid Softworks
|
|
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,15 @@
|
|
|
1
|
+
# `@lucid-softworks/base64`
|
|
2
|
+
|
|
3
|
+
Byte-oriented base64 with explicit browser and Node entry points. Keeping text
|
|
4
|
+
encoding outside this package avoids implicit Latin-1 versus UTF-8 behavior.
|
|
5
|
+
|
|
6
|
+
```ts
|
|
7
|
+
import { encodeBase64, decodeBase64 } from "@lucid-softworks/base64/browser";
|
|
8
|
+
|
|
9
|
+
const encoded = encodeBase64(new TextEncoder().encode("hello"));
|
|
10
|
+
const bytes = decodeBase64(encoded);
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
Node applications import the same API from `@lucid-softworks/base64/node`,
|
|
14
|
+
where it is implemented with `Buffer`. Both entry points accept and return
|
|
15
|
+
`Uint8Array`.
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Encode arbitrary bytes as base64 using browser platform primitives. */
|
|
2
|
+
export declare function encodeBase64(input: Uint8Array): string;
|
|
3
|
+
/** Decode base64 to bytes using browser platform primitives. */
|
|
4
|
+
export declare function decodeBase64(input: string): Uint8Array;
|
|
5
|
+
//# sourceMappingURL=browser.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAQtD;AAED,gEAAgE;AAChE,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,CAEtD"}
|
package/dist/browser.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Encode arbitrary bytes as base64 using browser platform primitives. */
|
|
2
|
+
export function encodeBase64(input) {
|
|
3
|
+
let binary = "";
|
|
4
|
+
for (const byte of input) {
|
|
5
|
+
binary += String.fromCodePoint(byte);
|
|
6
|
+
}
|
|
7
|
+
return btoa(binary);
|
|
8
|
+
}
|
|
9
|
+
/** Decode base64 to bytes using browser platform primitives. */
|
|
10
|
+
export function decodeBase64(input) {
|
|
11
|
+
return Uint8Array.from(atob(input), (character) => character.charCodeAt(0));
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=browser.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"browser.js","sourceRoot":"","sources":["../src/browser.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,MAAM,UAAU,YAAY,CAAC,KAAiB;IAC5C,IAAI,MAAM,GAAG,EAAE,CAAC;IAEhB,KAAK,MAAM,IAAI,IAAI,KAAK,EAAE,CAAC;QACzB,MAAM,IAAI,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,CAAC;IACvC,CAAC;IAED,OAAO,IAAI,CAAC,MAAM,CAAC,CAAC;AACtB,CAAC;AAED,gEAAgE;AAChE,MAAM,UAAU,YAAY,CAAC,KAAa;IACxC,OAAO,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,SAAS,EAAE,EAAE,CAAC,SAAS,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;AAC9E,CAAC"}
|
package/dist/node.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/** Encode arbitrary bytes as base64 using Node's `Buffer`. */
|
|
2
|
+
export declare function encodeBase64(input: Uint8Array): string;
|
|
3
|
+
/** Decode base64 to bytes using Node's `Buffer`. */
|
|
4
|
+
export declare function decodeBase64(input: string): Uint8Array;
|
|
5
|
+
//# sourceMappingURL=node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAEA,8DAA8D;AAC9D,wBAAgB,YAAY,CAAC,KAAK,EAAE,UAAU,GAAG,MAAM,CAEtD;AAED,oDAAoD;AACpD,wBAAgB,YAAY,CAAC,KAAK,EAAE,MAAM,GAAG,UAAU,CAEtD"}
|
package/dist/node.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Buffer } from "node:buffer";
|
|
2
|
+
/** Encode arbitrary bytes as base64 using Node's `Buffer`. */
|
|
3
|
+
export function encodeBase64(input) {
|
|
4
|
+
return Buffer.from(input).toString("base64");
|
|
5
|
+
}
|
|
6
|
+
/** Decode base64 to bytes using Node's `Buffer`. */
|
|
7
|
+
export function decodeBase64(input) {
|
|
8
|
+
return new Uint8Array(Buffer.from(input, "base64"));
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=node.js.map
|
package/dist/node.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.js","sourceRoot":"","sources":["../src/node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AAErC,8DAA8D;AAC9D,MAAM,UAAU,YAAY,CAAC,KAAiB;IAC5C,OAAO,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;AAC/C,CAAC;AAED,oDAAoD;AACpD,MAAM,UAAU,YAAY,CAAC,KAAa;IACxC,OAAO,IAAI,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,EAAE,QAAQ,CAAC,CAAC,CAAC;AACtD,CAAC"}
|
package/package.json
ADDED
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@lucid-softworks/base64",
|
|
3
|
+
"version": "0.0.0",
|
|
4
|
+
"description": "Portable byte-oriented base64 with explicit browser and Node entry points.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"base64",
|
|
7
|
+
"javascript",
|
|
8
|
+
"typescript",
|
|
9
|
+
"utility"
|
|
10
|
+
],
|
|
11
|
+
"homepage": "https://github.com/lucid-softworks/base64#readme",
|
|
12
|
+
"bugs": {
|
|
13
|
+
"url": "https://github.com/lucid-softworks/base64/issues"
|
|
14
|
+
},
|
|
15
|
+
"license": "MIT",
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "git+https://github.com/lucid-softworks/base64.git"
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist"
|
|
22
|
+
],
|
|
23
|
+
"type": "module",
|
|
24
|
+
"sideEffects": false,
|
|
25
|
+
"exports": {
|
|
26
|
+
"./browser": {
|
|
27
|
+
"types": "./dist/browser.d.ts",
|
|
28
|
+
"import": "./dist/browser.js"
|
|
29
|
+
},
|
|
30
|
+
"./node": {
|
|
31
|
+
"types": "./dist/node.d.ts",
|
|
32
|
+
"import": "./dist/node.js"
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
"publishConfig": {
|
|
36
|
+
"access": "public",
|
|
37
|
+
"provenance": true
|
|
38
|
+
},
|
|
39
|
+
"scripts": {
|
|
40
|
+
"bench": "vitest bench --run",
|
|
41
|
+
"bench:smoke": "VITEST_BENCHMARK_SMOKE=1 vitest bench --run",
|
|
42
|
+
"build": "tsc -p tsconfig.build.json",
|
|
43
|
+
"check": "oxfmt --check . && oxlint . && tsc -p tsconfig.json && tsc -p tsconfig.build.json && vitest run --coverage && publint && VITEST_BENCHMARK_SMOKE=1 vitest bench --run",
|
|
44
|
+
"format": "oxfmt --write .",
|
|
45
|
+
"format:check": "oxfmt --check .",
|
|
46
|
+
"lint": "oxlint .",
|
|
47
|
+
"pack:check": "publint",
|
|
48
|
+
"test": "vitest run --coverage",
|
|
49
|
+
"typecheck": "tsc -p tsconfig.json"
|
|
50
|
+
},
|
|
51
|
+
"devDependencies": {
|
|
52
|
+
"@lucid-softworks/oxfmt-config": "^0.1.1",
|
|
53
|
+
"@lucid-softworks/oxlint-config": "^0.1.0",
|
|
54
|
+
"@lucid-softworks/tsconfig": "^0.1.0",
|
|
55
|
+
"@lucid-softworks/vitest-config": "^0.1.1",
|
|
56
|
+
"@types/node": "26.1.1",
|
|
57
|
+
"@vitest/coverage-v8": "4.1.10",
|
|
58
|
+
"oxfmt": "0.60.0",
|
|
59
|
+
"oxlint": "1.75.0",
|
|
60
|
+
"publint": "0.3.22",
|
|
61
|
+
"typescript": "7.0.2",
|
|
62
|
+
"vitest": "4.1.10"
|
|
63
|
+
},
|
|
64
|
+
"engines": {
|
|
65
|
+
"node": ">=22"
|
|
66
|
+
},
|
|
67
|
+
"packageManager": "pnpm@11.16.0"
|
|
68
|
+
}
|