@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 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
@@ -7,6 +7,7 @@ export * from "./utils/env";
7
7
  export * from "./utils/formatters";
8
8
  export * from "./utils/parsers";
9
9
  export * from "./utils/converters";
10
+ export * from "./utils/log";
10
11
  export const safely = (action) => {
11
12
  try {
12
13
  return action();
@@ -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;
@@ -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
+ }
@@ -0,0 +1,4 @@
1
+ type Logger = (...messages: string[]) => void;
2
+ type Config = Record<string, Logger>;
3
+ export declare const log: Config;
4
+ export {};
@@ -0,0 +1,5 @@
1
+ import chalk from "chalk";
2
+ export const log = {
3
+ info: (...msgs) => console.warn(chalk.blue.bold("[INFO]", ...msgs)),
4
+ error: (...msgs) => console.error(chalk.red.bold("[ERROR]", ...msgs))
5
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
 
3
3
  "name": "@bouko/ts",
4
- "version": "0.2.8",
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