@vope/utils 1.4.24 → 1.4.25

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/cjs/index.js CHANGED
@@ -1266,9 +1266,9 @@ var FlexTable = class {
1266
1266
 
1267
1267
  // src/union.ts
1268
1268
  var Union = class {
1269
- constructor(key, formatter) {
1269
+ constructor(key, formatter2) {
1270
1270
  this.key = key;
1271
- this.formatter = formatter;
1271
+ this.formatter = formatter2;
1272
1272
  }
1273
1273
  #data = {};
1274
1274
  #options = {};
@@ -1320,9 +1320,8 @@ var joinPaths = (...list) => {
1320
1320
  };
1321
1321
 
1322
1322
  // src/url/params.ts
1323
- var connectURLParams = (url, params, isOpenType) => {
1324
- if (!params)
1325
- return url;
1323
+ var import_lodash_es6 = require("lodash-es");
1324
+ var formatter = (params, isOpenType) => {
1326
1325
  const list = [];
1327
1326
  for (const key in params) {
1328
1327
  const value = params[key];
@@ -1336,11 +1335,16 @@ var connectURLParams = (url, params, isOpenType) => {
1336
1335
  list.push(key + "=" + (isOpenType ? JSON.stringify(value) : value.toString()));
1337
1336
  }
1338
1337
  }
1339
- if (!list.length)
1340
- return url;
1341
- const caches = list.join("&");
1342
- return url.includes("?") ? url + "&" + caches : url + "?" + caches;
1338
+ return list.join("&");
1343
1339
  };
1340
+ function connectURLParams(url, params, serializes) {
1341
+ if (!params)
1342
+ return url;
1343
+ const query = serializes === void 0 || (0, import_lodash_es6.isBoolean)(serializes) ? formatter(params, serializes) : flatURLParams(params, serializes);
1344
+ if (!query)
1345
+ return url;
1346
+ return url.includes("?") ? url + "&" + query : url + "?" + query;
1347
+ }
1344
1348
 
1345
1349
  // src/wait.ts
1346
1350
  var wait = (delay = 0) => new Promise((resolve) => setTimeout(resolve, delay));
package/lib/url/params.js CHANGED
@@ -1,6 +1,6 @@
1
- const connectURLParams = (url, params, isOpenType) => {
2
- if (!params)
3
- return url;
1
+ import { isBoolean } from "lodash-es";
2
+ import { flatURLParams } from "../serialize/url-params";
3
+ const formatter = (params, isOpenType) => {
4
4
  const list = [];
5
5
  for (const key in params) {
6
6
  const value = params[key];
@@ -14,11 +14,16 @@ const connectURLParams = (url, params, isOpenType) => {
14
14
  list.push(key + "=" + (isOpenType ? JSON.stringify(value) : value.toString()));
15
15
  }
16
16
  }
17
- if (!list.length)
18
- return url;
19
- const caches = list.join("&");
20
- return url.includes("?") ? url + "&" + caches : url + "?" + caches;
17
+ return list.join("&");
21
18
  };
19
+ function connectURLParams(url, params, serializes) {
20
+ if (!params)
21
+ return url;
22
+ const query = serializes === void 0 || isBoolean(serializes) ? formatter(params, serializes) : flatURLParams(params, serializes);
23
+ if (!query)
24
+ return url;
25
+ return url.includes("?") ? url + "&" + query : url + "?" + query;
26
+ }
22
27
  export {
23
28
  connectURLParams
24
29
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@vope/utils",
3
- "version": "1.4.24",
3
+ "version": "1.4.25",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "publishConfig": {
@@ -1,11 +1,12 @@
1
+ import { URLParamsFlats, URLParamsValues } from '../serialize/url-params';
1
2
  type Param = string | number | boolean | undefined;
2
3
  type Params = Param | Param[];
3
4
  /**
4
5
  * url拼接参数
5
6
  * @param url
6
7
  * @param params 需要让url携带的参数
7
- * @param isOpenType 是否开启类型处理
8
- * @description 开始类型处理的情况下,undefined会被转成null
8
+ * @param serializes 泛型对象(转换套件),boolean或缺省(是否将undefined会被转成null)
9
9
  */
10
- export declare const connectURLParams: (url: string, params?: Record<string, Params>, isOpenType?: boolean) => string;
10
+ export declare function connectURLParams<T extends URLParamsValues>(url: string, params: URLParamsFlats<T>, serializes: T): string;
11
+ export declare function connectURLParams(url: string, params?: Record<string, Params>, serializes?: boolean): string;
11
12
  export {};