@xsai/shared 0.0.6 → 0.0.8

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
@@ -1,4 +1,5 @@
1
1
  interface CommonRequestOptions<T extends string> {
2
+ abortSingal?: AbortSignal;
2
3
  /** @default `http://localhost:11434/v1` */
3
4
  base?: string;
4
5
  /** @default `undefined` */
@@ -6,10 +7,15 @@ interface CommonRequestOptions<T extends string> {
6
7
  path?: ({} & string) | T;
7
8
  }
8
9
 
10
+ declare const strCamelToSnake: (str: string) => string;
11
+ declare const objCamelToSnake: (obj: Record<string, unknown>) => {
12
+ [k: string]: unknown;
13
+ };
14
+
9
15
  declare const clean: (record: Record<string, undefined | unknown>) => {
10
16
  [k: string]: unknown;
11
17
  };
12
18
 
13
19
  declare const requestUrl: (path: string, base?: string | URL) => URL;
14
20
 
15
- export { type CommonRequestOptions, clean, requestUrl };
21
+ export { type CommonRequestOptions, clean, objCamelToSnake, requestUrl, strCamelToSnake };
package/dist/index.js CHANGED
@@ -1,5 +1,8 @@
1
+ const strCamelToSnake = (str) => str.replace(/[A-Z]/g, (s) => `_${s.toLowerCase()}`);
2
+ const objCamelToSnake = (obj) => Object.fromEntries(Object.entries(obj).map(([k, v]) => [strCamelToSnake(k), v]));
3
+
1
4
  const clean = (record) => Object.fromEntries(Object.entries(record).filter(([, v]) => !!v));
2
5
 
3
6
  const requestUrl = (path, base = "http://localhost:11434/v1/") => new URL(path, base);
4
7
 
5
- export { clean, requestUrl };
8
+ export { clean, objCamelToSnake, requestUrl, strCamelToSnake };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xsai/shared",
3
- "version": "0.0.6",
3
+ "version": "0.0.8",
4
4
  "type": "module",
5
5
  "author": "藍+85CD",
6
6
  "license": "MIT",
@@ -24,8 +24,6 @@
24
24
  ],
25
25
  "scripts": {
26
26
  "build": "pkgroll",
27
- "build:watch": "pkgroll --watch",
28
- "test": "vitest run",
29
- "test:watch": "vitest"
27
+ "build:watch": "pkgroll --watch"
30
28
  }
31
29
  }