@bouko/ts 0.2.8 → 0.3.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/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/utils/converters.d.ts +12 -0
- package/dist/utils/converters.js +7 -0
- package/dist/utils/log.d.ts +4 -0
- package/dist/utils/log.js +5 -0
- package/package.json +2 -1
package/dist/index.d.ts
CHANGED
|
@@ -8,6 +8,7 @@ export * from "./utils/env";
|
|
|
8
8
|
export * from "./utils/formatters";
|
|
9
9
|
export * from "./utils/parsers";
|
|
10
10
|
export * from "./utils/converters";
|
|
11
|
+
export * from "./utils/log";
|
|
11
12
|
export declare const safely: <T>(action: () => T) => T | undefined;
|
|
12
13
|
export declare const safelyThru: <T>(arr: T[], action: (item: T) => void) => void;
|
|
13
14
|
export declare const isJsonMap: (value: unknown) => value is JsonMap;
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,14 @@
|
|
|
1
1
|
export declare function bufferToBase64(uint8: Uint8Array): string;
|
|
2
2
|
export declare function base64ToBuffer(base64: string): Uint8Array;
|
|
3
|
+
export declare function base64ToFile(data: string, opts?: {
|
|
4
|
+
name?: string;
|
|
5
|
+
type?: string;
|
|
6
|
+
}): File;
|
|
7
|
+
export declare function base64ToFile(data: undefined, opts?: {
|
|
8
|
+
name?: string;
|
|
9
|
+
type?: string;
|
|
10
|
+
}): undefined;
|
|
11
|
+
export declare function base64ToFile(data: string | undefined, opts?: {
|
|
12
|
+
name?: string;
|
|
13
|
+
type?: string;
|
|
14
|
+
}): File | undefined;
|
package/dist/utils/converters.js
CHANGED
|
@@ -15,3 +15,10 @@ export function base64ToBuffer(base64) {
|
|
|
15
15
|
}
|
|
16
16
|
return bytes;
|
|
17
17
|
}
|
|
18
|
+
export function base64ToFile(data, opts = {}) {
|
|
19
|
+
if (!data)
|
|
20
|
+
return;
|
|
21
|
+
const { name, type } = opts;
|
|
22
|
+
const byteArray = Uint8Array.from(atob(data), c => c.charCodeAt(0));
|
|
23
|
+
return new File([byteArray], name || "file", { type });
|
|
24
|
+
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
|
|
3
3
|
"name": "@bouko/ts",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.3.0",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"types": "./dist/index.d.ts",
|
|
7
7
|
"license": "MIT",
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
},
|
|
21
21
|
|
|
22
22
|
"dependencies": {
|
|
23
|
+
"chalk": "^5.6.0",
|
|
23
24
|
"zod": "^4.1.5"
|
|
24
25
|
},
|
|
25
26
|
|