@splendidlabz/utils 1.13.0 → 1.14.0

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.
@@ -1023,8 +1023,13 @@ var queryParams = {
1023
1023
  const searchParams = new URLSearchParams(location.search);
1024
1024
  return searchParams.get(key);
1025
1025
  },
1026
+ /**
1027
+ * Converts a params object into a URL query string
1028
+ * @param {Object} params - Key-value pairs to stringify
1029
+ * @returns {string} URL-encoded query string
1030
+ */
1026
1031
  stringify(params) {
1027
- const searchParams = new URLSearchParams(location.search);
1032
+ const searchParams = new URLSearchParams(params);
1028
1033
  return searchParams.toString();
1029
1034
  }
1030
1035
  };
@@ -27,8 +27,13 @@ var queryParams = {
27
27
  const searchParams = new URLSearchParams(location.search);
28
28
  return searchParams.get(key);
29
29
  },
30
+ /**
31
+ * Converts a params object into a URL query string
32
+ * @param {Object} params - Key-value pairs to stringify
33
+ * @returns {string} URL-encoded query string
34
+ */
30
35
  stringify(params) {
31
- const searchParams = new URLSearchParams(location.search);
36
+ const searchParams = new URLSearchParams(params);
32
37
  return searchParams.toString();
33
38
  }
34
39
  };
@@ -117,7 +117,7 @@ function throttle(callback, wait2) {
117
117
 
118
118
  // src/lib/functions/timeout.js
119
119
  function timeout(wait2, callback) {
120
- setTimeout(callback, wait2);
120
+ return setTimeout(callback, wait2);
121
121
  }
122
122
  function delay(ms) {
123
123
  return new Promise((resolve) => setTimeout(resolve, ms));
@@ -25,7 +25,7 @@ __export(timeout_exports, {
25
25
  });
26
26
  module.exports = __toCommonJS(timeout_exports);
27
27
  function timeout(wait2, callback) {
28
- setTimeout(callback, wait2);
28
+ return setTimeout(callback, wait2);
29
29
  }
30
30
  function delay(ms) {
31
31
  return new Promise((resolve) => setTimeout(resolve, ms));
@@ -653,7 +653,7 @@ function throttle(callback, wait2) {
653
653
 
654
654
  // src/lib/functions/timeout.js
655
655
  function timeout(wait2, callback) {
656
- setTimeout(callback, wait2);
656
+ return setTimeout(callback, wait2);
657
657
  }
658
658
  function delay(ms2) {
659
659
  return new Promise((resolve) => setTimeout(resolve, ms2));
@@ -168,17 +168,15 @@ async function fileCache({ dir, file }) {
168
168
  async function getLastModifiedTime(globPath) {
169
169
  let files;
170
170
  if (typeof globPath === "string") {
171
- files = await (0, import_glob.glob)(removeFirstSlash(globPath));
171
+ files = await (0, import_glob.glob)(globPath);
172
172
  }
173
173
  if (Array.isArray(globPath)) {
174
- const a = await Promise.all(
175
- globPath.map((path2) => (0, import_glob.glob)(removeFirstSlash(path2)))
176
- );
174
+ const a = await Promise.all(globPath.map((path2) => (0, import_glob.glob)(path2)));
177
175
  files = a.flat();
178
176
  }
179
177
  const stats = await Promise.all(files.map((file) => import_promises.default.stat(file)));
180
178
  const timestamps = stats.map((stat) => Number(stat.mtimeMs));
181
- const sorted = sort(timestamps, { props: "mtimeMs", reverse: true });
179
+ const sorted = sort(timestamps, { reverse: true });
182
180
  return sorted[0] || 0;
183
181
  }
184
182
  async function getLatestModifiedTime(globPath) {
@@ -189,17 +189,15 @@ async function fileCache({ dir, file }) {
189
189
  async function getLastModifiedTime(globPath) {
190
190
  let files;
191
191
  if (typeof globPath === "string") {
192
- files = await (0, import_glob.glob)(removeFirstSlash(globPath));
192
+ files = await (0, import_glob.glob)(globPath);
193
193
  }
194
194
  if (Array.isArray(globPath)) {
195
- const a = await Promise.all(
196
- globPath.map((path3) => (0, import_glob.glob)(removeFirstSlash(path3)))
197
- );
195
+ const a = await Promise.all(globPath.map((path3) => (0, import_glob.glob)(path3)));
198
196
  files = a.flat();
199
197
  }
200
198
  const stats = await Promise.all(files.map((file) => import_promises.default.stat(file)));
201
199
  const timestamps = stats.map((stat) => Number(stat.mtimeMs));
202
- const sorted = sort(timestamps, { props: "mtimeMs", reverse: true });
200
+ const sorted = sort(timestamps, { reverse: true });
203
201
  return sorted[0] || 0;
204
202
  }
205
203
  async function getLatestModifiedTime(globPath) {
@@ -3,8 +3,13 @@ const queryParams = {
3
3
  const searchParams = new URLSearchParams(location.search);
4
4
  return searchParams.get(key);
5
5
  },
6
+ /**
7
+ * Converts a params object into a URL query string
8
+ * @param {Object} params - Key-value pairs to stringify
9
+ * @returns {string} URL-encoded query string
10
+ */
6
11
  stringify(params) {
7
- const searchParams = new URLSearchParams(location.search);
12
+ const searchParams = new URLSearchParams(params);
8
13
  return searchParams.toString();
9
14
  }
10
15
  };
@@ -1,5 +1,5 @@
1
1
  function timeout(wait2, callback) {
2
- setTimeout(callback, wait2);
2
+ return setTimeout(callback, wait2);
3
3
  }
4
4
  function delay(ms) {
5
5
  return new Promise((resolve) => setTimeout(resolve, ms));
@@ -90,17 +90,15 @@ async function fileCache({ dir, file }) {
90
90
  async function getLastModifiedTime(globPath) {
91
91
  let files;
92
92
  if (typeof globPath === "string") {
93
- files = await glob(removeFirstSlash(globPath));
93
+ files = await glob(globPath);
94
94
  }
95
95
  if (Array.isArray(globPath)) {
96
- const a = await Promise.all(
97
- globPath.map((path2) => glob(removeFirstSlash(path2)))
98
- );
96
+ const a = await Promise.all(globPath.map((path2) => glob(path2)));
99
97
  files = a.flat();
100
98
  }
101
99
  const stats = await Promise.all(files.map((file) => fs.stat(file)));
102
100
  const timestamps = stats.map((stat) => Number(stat.mtimeMs));
103
- const sorted = sort(timestamps, { props: "mtimeMs", reverse: true });
101
+ const sorted = sort(timestamps, { reverse: true });
104
102
  return sorted[0] || 0;
105
103
  }
106
104
  async function getLatestModifiedTime(globPath) {
@@ -1,5 +1,10 @@
1
1
  declare namespace queryParams {
2
2
  function get(key: any): string;
3
+ /**
4
+ * Converts a params object into a URL query string
5
+ * @param {Object} params - Key-value pairs to stringify
6
+ * @returns {string} URL-encoded query string
7
+ */
3
8
  function stringify(params: any): string;
4
9
  }
5
10
 
@@ -1,4 +1,4 @@
1
- declare function timeout(wait: any, callback: any): void;
1
+ declare function timeout(wait: any, callback: any): number;
2
2
  declare function delay(ms: any): Promise<any>;
3
3
  declare function wait(ms: any): Promise<any>;
4
4
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@splendidlabz/utils",
3
- "version": "1.13.0",
3
+ "version": "1.14.0",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "homepage": "https://splendidlabz.com/docs/utils",