@bouko/ts 0.3.4 → 0.3.6

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.
@@ -1,4 +1,5 @@
1
1
  export declare function bufferToData(uint8: Uint8Array, mimetype?: string): string;
2
+ export declare function bufferToData(uint8: Uint8Array | undefined, mimetype?: string): string | undefined;
2
3
  export declare function base64ToBuffer(base64: string): Uint8Array;
3
4
  export declare function base64ToFile(data: string, opts?: {
4
5
  name?: string;
@@ -1,4 +1,6 @@
1
1
  export function bufferToData(uint8, mimetype) {
2
+ if (!uint8)
3
+ return;
2
4
  const len = uint8.byteLength;
3
5
  let binary = "";
4
6
  for (let i = 0; i < len; i++)
@@ -1,2 +1,3 @@
1
1
  export declare const shortenStr: (str: string) => string;
2
2
  export declare const shortenNum: (x: number) => string;
3
+ export declare const cleanStr: (str: string) => string;
@@ -10,3 +10,9 @@ export const shortenNum = (x) => {
10
10
  return `${Math.floor(x / 1000)}k`;
11
11
  return `${Math.floor(x / 1_000_000)}m`;
12
12
  };
13
+ export const cleanStr = (str) => str
14
+ .trim()
15
+ .replace(/^[^\w(]+/g, "") // leading junk
16
+ .replace(/[^\w!?.)]+$/g, "") // trailing junk
17
+ .replace(/\s+/g, " ") // collapse spaces
18
+ .trim();
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  "name": "@bouko/ts",
4
4
 
5
- "version": "0.3.4",
5
+ "version": "0.3.6",
6
6
 
7
7
  "main": "./dist/index.js",
8
8
 
@@ -36,6 +36,8 @@
36
36
 
37
37
  "dependencies": {
38
38
 
39
+ "@bouko/ts": "^0.3.5",
40
+
39
41
  "chalk": "^5.6.0",
40
42
 
41
43
  "zod": "^4.1.5"