@xsai/shared 0.1.0-beta.2 → 0.1.0-beta.4

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
@@ -20,7 +20,23 @@ declare const objCamelToSnake: (obj: Record<string, unknown>) => {
20
20
  [k: string]: unknown;
21
21
  };
22
22
 
23
- declare const clean: <T extends Record<string, undefined | unknown> = Record<string, unknown>>(record: T) => Record<keyof T, Exclude<T[keyof T], unknown>>;
23
+ /**
24
+ * Clean all undefined values.
25
+ * @param obj object
26
+ * @returns cleaned object
27
+ *
28
+ * @example
29
+ * ```ts
30
+ * import { clean } from '@xsai/shared'
31
+ *
32
+ * // { a: 'a' }
33
+ * const obj = clean({
34
+ * a: 'a',
35
+ * b: undefined
36
+ * })
37
+ * ```
38
+ */
39
+ declare const clean: <T extends Record<string, undefined | unknown>>(obj: T) => Record<keyof T, Exclude<T[keyof T], unknown>>;
24
40
 
25
41
  declare const requestBody: (body: Record<string, unknown>) => string;
26
42
 
package/dist/index.js CHANGED
@@ -10,7 +10,9 @@ class XSAIError extends Error {
10
10
  const strCamelToSnake = (str) => str.replace(/[A-Z]/g, (s) => `_${s.toLowerCase()}`);
11
11
  const objCamelToSnake = (obj) => Object.fromEntries(Object.entries(obj).map(([k, v]) => [strCamelToSnake(k), v]));
12
12
 
13
- const clean = (record) => Object.fromEntries(Object.entries(record).filter(([, v]) => v !== undefined));
13
+ const clean = (obj) => Object.fromEntries(
14
+ Object.entries(obj).filter(([, v]) => v !== undefined)
15
+ );
14
16
 
15
17
  const requestBody = (body) => JSON.stringify(objCamelToSnake(clean({
16
18
  ...body,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@xsai/shared",
3
3
  "type": "module",
4
- "version": "0.1.0-beta.2",
4
+ "version": "0.1.0-beta.4",
5
5
  "description": "extra-small AI SDK for Browser, Node.js, Deno, Bun or Edge Runtime.",
6
6
  "author": "Moeru AI",
7
7
  "license": "MIT",