@konplit-services/common 1.0.175 → 1.0.176

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.
@@ -0,0 +1,5 @@
1
+ interface QueryParams {
2
+ [key: string]: string | number | undefined;
3
+ }
4
+ export declare function generateQueryParams(params: QueryParams): string;
5
+ export {};
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateQueryParams = void 0;
4
+ function generateQueryParams(params) {
5
+ // Check if params is empty
6
+ if (Object.keys(params).length === 0) {
7
+ return "";
8
+ }
9
+ // Construct the query string
10
+ const queryString = Object.entries(params)
11
+ .filter(([_, value]) => value !== undefined) // Exclude undefined values
12
+ .map(([key, value]) => `${encodeURIComponent(key)}=${encodeURIComponent(value)}`)
13
+ .join("&");
14
+ // Combine with the base URL
15
+ const fullUrl = `?${queryString}`;
16
+ return fullUrl;
17
+ }
18
+ exports.generateQueryParams = generateQueryParams;
@@ -43,3 +43,4 @@ export * from "./date-processing";
43
43
  export * from "./timestamp";
44
44
  export * from "./keys";
45
45
  export * from "./wallet-transaction.types";
46
+ export * from "./generate-query-params";
@@ -59,3 +59,4 @@ __exportStar(require("./date-processing"), exports);
59
59
  __exportStar(require("./timestamp"), exports);
60
60
  __exportStar(require("./keys"), exports);
61
61
  __exportStar(require("./wallet-transaction.types"), exports);
62
+ __exportStar(require("./generate-query-params"), exports);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@konplit-services/common",
3
- "version": "1.0.175",
3
+ "version": "1.0.176",
4
4
  "description": "",
5
5
  "main": "./build/index.js",
6
6
  "types": "./build/index.d.ts",