@minto-ai/tools 1.0.36 → 1.0.38

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.js CHANGED
@@ -158,7 +158,7 @@ function getFileSuffix(filePath) {
158
158
  }
159
159
  function getFileTitle(filePath) {
160
160
  const matchResult = filePath.match(filePathRegex);
161
- return matchResult ? matchResult[3] : "";
161
+ return matchResult ? matchResult[2] : "";
162
162
  }
163
163
  function getFileName(filePath) {
164
164
  const fileTitle = getFileTitle(filePath);
@@ -438,6 +438,11 @@ function chunkString(str, chunkSize = str.length) {
438
438
  }
439
439
  return chunks;
440
440
  }
441
+ function objectToQueryString(obj) {
442
+ return Object.entries(obj).map(([key, value]) => {
443
+ return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
444
+ }).join("&");
445
+ }
441
446
  function getUuid() {
442
447
  return window.crypto.getRandomValues(new Uint32Array(1))[0].toString(36);
443
448
  }
@@ -512,6 +517,7 @@ export {
512
517
  isVideoFilePath,
513
518
  isWebSocketSupported,
514
519
  multiply,
520
+ objectToQueryString,
515
521
  pickObject,
516
522
  singleDownloadFile,
517
523
  subtract,
@@ -1,2 +1,3 @@
1
1
  import { default as chunkString } from './chunk-string';
2
- export { chunkString };
2
+ import { default as objectToQueryString } from './object-to-query-string';
3
+ export { chunkString, objectToQueryString };
@@ -0,0 +1,12 @@
1
+ /**
2
+ * 将对象转换为 URL 查询字符串。
3
+ *
4
+ * 该函数会遍历对象的键值对,将每个键和值进行 URL 编码,
5
+ * 然后以 "key=value" 的形式拼接成字符串,并用 "&" 符号连接。
6
+ *
7
+ * @param obj - 需要转换的对象,对象的键为字符串,值为任意类型。
8
+ * @returns 转换后的 URL 查询字符串。
9
+ *
10
+ */
11
+ declare function objectToQueryString(obj: Record<string, any>): string;
12
+ export default objectToQueryString;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@minto-ai/tools",
3
3
  "type": "module",
4
- "version": "1.0.36",
4
+ "version": "1.0.38",
5
5
  "description": "明途公共工具库",
6
6
  "author": "hcc",
7
7
  "license": "ISC",