@cocreate/utils 1.42.0 → 1.42.2

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.
Files changed (65) hide show
  1. package/dist/cjs/ObjectId.js +54 -0
  2. package/dist/cjs/attributes.js +64 -0
  3. package/dist/cjs/checkValue.js +26 -0
  4. package/dist/cjs/clickedElement.js +48 -0
  5. package/dist/cjs/core.js +33 -0
  6. package/dist/cjs/createUpdate.js +188 -0
  7. package/dist/cjs/cssPath.js +60 -0
  8. package/dist/cjs/dataQuery.js +280 -0
  9. package/dist/cjs/dom.js +29 -0
  10. package/dist/cjs/domParser.js +44 -0
  11. package/dist/cjs/dotNotationToObject.js +103 -0
  12. package/dist/cjs/escapeHtml.js +25 -0
  13. package/dist/cjs/getRelativePath.js +39 -0
  14. package/dist/cjs/getValueFromObject.js +41 -0
  15. package/dist/cjs/index.js +112 -0
  16. package/dist/cjs/init-browser.js +4 -0
  17. package/dist/cjs/isValidDate.js +32 -0
  18. package/dist/cjs/objectToDotNotation.js +53 -0
  19. package/dist/cjs/objectToSearchParams.js +42 -0
  20. package/dist/cjs/operators copy.js +562 -0
  21. package/dist/cjs/operators.js +480 -0
  22. package/dist/cjs/parseTextToHtml.js +27 -0
  23. package/dist/cjs/queryElements.js +155 -0
  24. package/dist/cjs/safeParse.js +169 -0
  25. package/dist/cjs/uid.js +34 -0
  26. package/dist/esm/ObjectId.js +35 -0
  27. package/dist/esm/attributes.js +45 -0
  28. package/dist/esm/checkValue.js +7 -0
  29. package/dist/esm/clickedElement.js +29 -0
  30. package/dist/esm/core.js +14 -0
  31. package/dist/esm/createUpdate.js +185 -0
  32. package/dist/esm/cssPath.js +41 -0
  33. package/dist/esm/dataQuery.js +261 -0
  34. package/dist/esm/dom.js +10 -0
  35. package/dist/esm/domParser.js +25 -0
  36. package/dist/esm/dotNotationToObject.js +84 -0
  37. package/dist/esm/escapeHtml.js +6 -0
  38. package/dist/esm/getRelativePath.js +20 -0
  39. package/dist/esm/getValueFromObject.js +22 -0
  40. package/dist/esm/index.js +93 -0
  41. package/dist/esm/init-browser.js +4 -0
  42. package/dist/esm/isValidDate.js +13 -0
  43. package/dist/esm/objectToDotNotation.js +34 -0
  44. package/dist/esm/objectToSearchParams.js +23 -0
  45. package/dist/esm/operators copy.js +543 -0
  46. package/dist/esm/operators.js +461 -0
  47. package/dist/esm/package.json +3 -0
  48. package/dist/esm/parseTextToHtml.js +8 -0
  49. package/dist/esm/queryElements.js +136 -0
  50. package/dist/esm/safeParse.js +150 -0
  51. package/dist/esm/uid.js +15 -0
  52. package/package.json +9 -111
  53. package/src/index.js +3 -3
  54. package/src/operators copy.js +687 -0
  55. package/src/operators.js +407 -526
  56. package/.github/FUNDING.yml +0 -3
  57. package/.github/workflows/automated.yml +0 -44
  58. package/.github/workflows/manual.yml +0 -44
  59. package/CHANGELOG.md +0 -2075
  60. package/CoCreate.config.js +0 -23
  61. package/demo/index.html +0 -23
  62. package/docs/index.html +0 -331
  63. package/prettier.config.js +0 -16
  64. package/release.config.js +0 -22
  65. package/webpack.config.js +0 -65
@@ -0,0 +1,261 @@
1
+ import { getValueFromObject } from "./getValueFromObject.js";
2
+ import { isValidDate } from "./isValidDate.js";
3
+ function isEqualArray(arr1, arr2) {
4
+ if (arr1.length !== arr2.length) {
5
+ return false;
6
+ }
7
+ for (let i = 0; i < arr1.length; i++) {
8
+ if (!isEqualObject(arr1[i], arr2[i])) {
9
+ return false;
10
+ }
11
+ }
12
+ return true;
13
+ }
14
+ function isEqualObject(obj1, obj2) {
15
+ const keys1 = Object.keys(obj1);
16
+ const keys2 = Object.keys(obj2);
17
+ if (keys1.length !== keys2.length) {
18
+ return false;
19
+ }
20
+ for (const key of keys1) {
21
+ if (obj1[key] !== obj2[key]) {
22
+ return false;
23
+ }
24
+ }
25
+ return true;
26
+ }
27
+ function queryMatch(data, query) {
28
+ for (let key of Object.keys(query)) {
29
+ let dataValue;
30
+ try {
31
+ dataValue = getValueFromObject(data, key, true);
32
+ } catch (error) {
33
+ return false;
34
+ }
35
+ if (typeof query[key] === "string" || typeof query[key] === "number" || typeof query[key] === "boolean") {
36
+ if (Array.isArray(dataValue)) return dataValue.includes(query[key]);
37
+ else return dataValue === query[key];
38
+ } else if (Array.isArray(query[key])) {
39
+ if (Array.isArray(dataValue)) {
40
+ return isEqualArray(dataValue, query[key]);
41
+ } else {
42
+ return false;
43
+ }
44
+ } else {
45
+ for (let property of Object.keys(query[key])) {
46
+ if (property === "$options") continue;
47
+ if (!property.startsWith("$")) {
48
+ if (typeof dataValue !== "object") {
49
+ return false;
50
+ } else
51
+ return queryMatch(
52
+ { [property]: getValueFromObject(dataValue, property) },
53
+ { [property]: query[key][property] }
54
+ );
55
+ } else {
56
+ let queryValue = query[key][property];
57
+ if (isValidDate(queryValue) && isValidDate(dataValue)) {
58
+ queryValue = new Date(queryValue);
59
+ dataValue = new Date(dataValue);
60
+ }
61
+ let queryStatus = false;
62
+ switch (property) {
63
+ case "$eq":
64
+ if (Array.isArray(dataValue) && Array.isArray(queryValue)) {
65
+ queryStatus = isEqualArray(dataValue, queryValue);
66
+ } else {
67
+ queryStatus = dataValue === queryValue;
68
+ }
69
+ break;
70
+ case "$ne":
71
+ if (Array.isArray(dataValue) && Array.isArray(queryValue)) {
72
+ queryStatus = !isEqualArray(dataValue, queryValue);
73
+ } else {
74
+ queryStatus = dataValue !== queryValue;
75
+ }
76
+ break;
77
+ case "$not":
78
+ queryStatus = !queryMatch(data, {
79
+ [key]: query[key]["$not"]
80
+ });
81
+ break;
82
+ case "$lt":
83
+ queryStatus = dataValue < queryValue;
84
+ break;
85
+ case "$lte":
86
+ queryStatus = dataValue <= queryValue;
87
+ break;
88
+ case "$gt":
89
+ queryStatus = dataValue > queryValue;
90
+ break;
91
+ case "$gte":
92
+ queryStatus = dataValue >= queryValue;
93
+ break;
94
+ case "$in":
95
+ if (Array.isArray(dataValue)) {
96
+ queryStatus = dataValue.some(
97
+ (element) => queryValue.includes(element)
98
+ );
99
+ } else {
100
+ queryStatus = queryValue.includes(dataValue);
101
+ }
102
+ break;
103
+ case "$nin":
104
+ if (Array.isArray(dataValue)) {
105
+ queryStatus = !dataValue.some(
106
+ (element) => queryValue.includes(element)
107
+ );
108
+ } else {
109
+ queryStatus = !queryValue.includes(dataValue);
110
+ }
111
+ break;
112
+ case "$all":
113
+ if (Array.isArray(dataValue) && Array.isArray(queryValue)) {
114
+ queryStatus = queryValue.every(
115
+ (element) => dataValue.includes(element)
116
+ );
117
+ }
118
+ break;
119
+ case "$elemMatch":
120
+ if (Array.isArray(data[key])) {
121
+ queryStatus = data[key].some(
122
+ (element) => queryMatch(element, query[key][property])
123
+ );
124
+ }
125
+ break;
126
+ case "$size":
127
+ if (Array.isArray(dataValue)) {
128
+ queryStatus = dataValue.length === queryValue;
129
+ }
130
+ break;
131
+ case "$exists":
132
+ queryStatus = queryValue ? data.hasOwnProperty(key) : !data.hasOwnProperty(key);
133
+ break;
134
+ case "$regex":
135
+ if (typeof dataValue === "string") {
136
+ let regexFlag = query[key]["$options"] || "";
137
+ let regex = new RegExp(queryValue, regexFlag);
138
+ queryStatus = regex.test(dataValue);
139
+ }
140
+ break;
141
+ case "$type":
142
+ let dataType = typeof dataValue;
143
+ if (Array.isArray(dataValue)) {
144
+ dataType = "array";
145
+ }
146
+ queryStatus = dataType === queryValue;
147
+ break;
148
+ case "$mod":
149
+ if (typeof dataValue === "number" && Array.isArray(queryValue) && queryValue.length === 2) {
150
+ const [divisor, remainder] = queryValue;
151
+ queryStatus = dataValue % divisor === remainder;
152
+ }
153
+ break;
154
+ case "$where":
155
+ if (typeof queryValue === "function") {
156
+ try {
157
+ } catch (error) {
158
+ console.error(
159
+ "Error in queryData $where function:",
160
+ error
161
+ );
162
+ }
163
+ }
164
+ break;
165
+ default:
166
+ console.log("unknown operator");
167
+ break;
168
+ }
169
+ if (!queryStatus) return false;
170
+ }
171
+ }
172
+ return true;
173
+ }
174
+ }
175
+ }
176
+ function queryData(data, query) {
177
+ if (query.$and) {
178
+ for (let i = 0; i < query.$and.length; i++) {
179
+ if (!queryData(data, query.$and[i])) return false;
180
+ }
181
+ }
182
+ if (query.$nor) {
183
+ for (let i = 0; i < query.$nor.length; i++) {
184
+ if (queryData(data, query.$nor[i])) return false;
185
+ }
186
+ }
187
+ for (let key of Object.keys(query)) {
188
+ if (key === "$and" || key === "$or") continue;
189
+ if (!queryMatch(data, { [key]: query[key] })) return false;
190
+ }
191
+ if (query.$or) {
192
+ for (let i = 0; i < query.$or.length; i++) {
193
+ if (queryData(data, query.$or[i])) return true;
194
+ }
195
+ }
196
+ return true;
197
+ }
198
+ function searchData(data, search) {
199
+ if (!search) return true;
200
+ if (!Array.isArray(search)) search = [search];
201
+ for (let i = 0; i < search.length; i++) {
202
+ let searchValue = search[i].value;
203
+ if (!Array.isArray(searchValue)) searchValue = [searchValue];
204
+ for (let key in data) {
205
+ let value = data[key];
206
+ let status = false;
207
+ switch (typeof value) {
208
+ case "number":
209
+ value = value.toString();
210
+ break;
211
+ case "object":
212
+ value = JSON.stringify(value);
213
+ break;
214
+ case "function":
215
+ value = value.toString();
216
+ break;
217
+ }
218
+ if (search[i].caseSensitive != "true" || search[i].caseSensitive != true)
219
+ value = value.toLowerCase();
220
+ for (let i2 = 0; i2 < searchValue.length; i2++) {
221
+ let searchString = searchValue[i2];
222
+ if (search[i2].caseSensitive != "true" || search[i2].caseSensitive != true)
223
+ searchString = searchString.toLowerCase();
224
+ if (searchString === "" && search[i2].operator === "and") {
225
+ if (value !== "") return false;
226
+ }
227
+ if (value.indexOf(searchString) > -1) status = true;
228
+ if (status) return true;
229
+ else if (search[i2].operator == "and") return false;
230
+ }
231
+ }
232
+ if (search[i].value.length && search[i].operator == "or") return false;
233
+ }
234
+ return true;
235
+ }
236
+ function sortData(data, sort) {
237
+ return data.sort((a, b) => {
238
+ for (let i = 0; i < sort.length; i++) {
239
+ let key = sort[i].key;
240
+ if (a[key] == null && b[key] == null) continue;
241
+ if (a[key] == null) return sort[i].direction === "desc" ? -1 : 1;
242
+ if (b[key] == null) return sort[i].direction === "desc" ? 1 : -1;
243
+ if (typeof a[key] !== typeof b[key]) {
244
+ return typeof a[key] < typeof b[key] ? -1 : 1;
245
+ }
246
+ if (a[key] !== b[key]) {
247
+ if (typeof a[key] === "string") {
248
+ return sort[i].direction === "desc" ? b[key].localeCompare(a[key]) : a[key].localeCompare(b[key]);
249
+ } else {
250
+ return sort[i].direction === "desc" ? b[key] - a[key] : a[key] - b[key];
251
+ }
252
+ }
253
+ }
254
+ return 0;
255
+ });
256
+ }
257
+ export {
258
+ queryData,
259
+ searchData,
260
+ sortData
261
+ };
@@ -0,0 +1,10 @@
1
+ import { domParser } from "./domParser.js";
2
+ import { parseTextToHtml } from "./parseTextToHtml.js";
3
+ import { escapeHtml } from "./escapeHtml.js";
4
+ import { cssPath } from "./cssPath.js";
5
+ export {
6
+ cssPath,
7
+ domParser,
8
+ escapeHtml,
9
+ parseTextToHtml
10
+ };
@@ -0,0 +1,25 @@
1
+ function domParser(str) {
2
+ try {
3
+ var mainTag = str.match(new RegExp("\\<(?<tag>[a-z0-9]+)(.*?)?\\>")).groups.tag;
4
+ } catch (e) {
5
+ }
6
+ let doc;
7
+ switch (mainTag) {
8
+ case "html":
9
+ doc = new DOMParser().parseFromString(str, "text/html");
10
+ return doc.documentElement;
11
+ case "body":
12
+ doc = new DOMParser().parseFromString(str, "text/html");
13
+ return doc.body;
14
+ case "head":
15
+ doc = new DOMParser().parseFromString(str, "text/html");
16
+ return doc.head;
17
+ default:
18
+ let con = document.createElement("dom-parser");
19
+ con.innerHTML = str;
20
+ return con;
21
+ }
22
+ }
23
+ export {
24
+ domParser
25
+ };
@@ -0,0 +1,84 @@
1
+ function dotNotationToObject(data, obj = {}) {
2
+ try {
3
+ let arrayGroup = {};
4
+ for (const key of Object.keys(data)) {
5
+ let value = data[key];
6
+ let newObject = obj;
7
+ let oldObject = new Object(obj);
8
+ let keys = key.split(".");
9
+ let length = keys.length - 1;
10
+ for (let i = 0; i < keys.length; i++) {
11
+ if (keys[i].endsWith("]")) {
12
+ if (keys[i].endsWith("[]")) {
13
+ let baseKey = keys[i].slice(0, -2);
14
+ if (!Array.isArray(newObject[baseKey])) {
15
+ newObject[baseKey] = [];
16
+ }
17
+ if (length == i) {
18
+ if (Array.isArray(value)) {
19
+ newObject[baseKey].push(...value);
20
+ } else {
21
+ newObject[baseKey].push(value);
22
+ }
23
+ }
24
+ } else if (/\[([0-9]+)\]/g.test(keys[i])) {
25
+ let [k, index] = keys[i].split("[");
26
+ index = index.slice(0, -1);
27
+ if (!Array.isArray(newObject[k])) {
28
+ newObject[k] = [];
29
+ }
30
+ if (length == i) {
31
+ if (value === void 0) {
32
+ newObject[k].splice(index, 1);
33
+ } else {
34
+ newObject[k][index] = value;
35
+ }
36
+ } else {
37
+ newObject[k][index] = oldObject[k][index] || {};
38
+ newObject = newObject[k][index];
39
+ oldObject = oldObject[k][index];
40
+ }
41
+ } else if (/\[\w\]/g.test(keys[i])) {
42
+ let [k, group] = keys[i].split("[");
43
+ group = group.slice(0, -1);
44
+ if (!Array.isArray(newObject[k])) {
45
+ newObject[k] = [];
46
+ }
47
+ let index;
48
+ if (arrayGroup[keys.slice(0, i + 1).join(".")]) {
49
+ index = arrayGroup[keys.slice(0, i + 1).join(".")];
50
+ } else {
51
+ index = newObject[k].length;
52
+ arrayGroup[keys.slice(0, i + 1).join(".")] = index;
53
+ newObject[k][index] = {};
54
+ }
55
+ if (length == i) {
56
+ newObject[k][index] = value;
57
+ } else {
58
+ newObject = newObject[k][index];
59
+ }
60
+ }
61
+ } else {
62
+ if (length == i) {
63
+ if (value === void 0) {
64
+ delete newObject[keys[i]];
65
+ } else {
66
+ newObject[keys[i]] = value;
67
+ }
68
+ } else {
69
+ newObject[keys[i]] = oldObject[keys[i]] || {};
70
+ newObject = newObject[keys[i]];
71
+ oldObject = oldObject[keys[i]];
72
+ }
73
+ }
74
+ }
75
+ }
76
+ return obj;
77
+ } catch (error) {
78
+ console.log("Error converting dot notation to object", error);
79
+ return false;
80
+ }
81
+ }
82
+ export {
83
+ dotNotationToObject
84
+ };
@@ -0,0 +1,6 @@
1
+ function escapeHtml(html) {
2
+ return html.replaceAll("&", "&amp").replaceAll("<", "&lt").replaceAll(">", "&gt;").replaceAll("'", "&#39;").replaceAll('"', "&quot;");
3
+ }
4
+ export {
5
+ escapeHtml
6
+ };
@@ -0,0 +1,20 @@
1
+ function getRelativePath(path) {
2
+ const isBrowser = typeof window !== "undefined";
3
+ if (!path && isBrowser) {
4
+ path = window.location.pathname.replace(/\/[^\/]*$/, "");
5
+ }
6
+ if (isBrowser && (location.hostname === "localhost" || location.hostname === "127.0.0.1")) {
7
+ const srcIndex = path.indexOf("/src");
8
+ if (srcIndex !== -1) {
9
+ path = path.slice(srcIndex + 4);
10
+ }
11
+ }
12
+ if (!path.endsWith("/")) {
13
+ path += "/";
14
+ }
15
+ let depth = path.split("/").filter(Boolean).length;
16
+ return depth > 0 ? "../".repeat(depth) : "./";
17
+ }
18
+ export {
19
+ getRelativePath
20
+ };
@@ -0,0 +1,22 @@
1
+ function getValueFromObject(object = {}, path = "", throwError = false) {
2
+ try {
3
+ if (!Array.isArray(object) && !Object.keys(object).length || !path) {
4
+ if (throwError) throw new Error("Invalid input to getValueFromObject");
5
+ return;
6
+ }
7
+ path = path.replace(/\[(\d+)\]/g, ".$1").replace(/^\./, "");
8
+ let data = object, subpath = path.split(".");
9
+ for (let i = 0; i < subpath.length; i++) {
10
+ if (throwError && !(subpath[i] in data))
11
+ throw new Error("Key not found in object: " + subpath[i]);
12
+ data = data[subpath[i]];
13
+ if (!data) break;
14
+ }
15
+ return data;
16
+ } catch (error) {
17
+ if (throwError) throw error;
18
+ }
19
+ }
20
+ export {
21
+ getValueFromObject
22
+ };
@@ -0,0 +1,93 @@
1
+ import { getRelativePath } from "./getRelativePath.js";
2
+ import { ObjectId } from "./ObjectId.js";
3
+ import { uid } from "./uid.js";
4
+ import { checkValue } from "./checkValue.js";
5
+ import { isValidDate } from "./isValidDate.js";
6
+ import { objectToSearchParams } from "./objectToSearchParams.js";
7
+ import { dotNotationToObject } from "./dotNotationToObject.js";
8
+ import { objectToDotNotation } from "./objectToDotNotation.js";
9
+ import { getValueFromObject } from "./getValueFromObject.js";
10
+ import { createUpdate } from "./createUpdate.js";
11
+ import { domParser } from "./domParser.js";
12
+ import { parseTextToHtml } from "./parseTextToHtml.js";
13
+ import { escapeHtml } from "./escapeHtml.js";
14
+ import { cssPath } from "./cssPath.js";
15
+ import { queryElements, checkMediaQueries } from "./queryElements.js";
16
+ import { queryData, searchData, sortData } from "./dataQuery.js";
17
+ import { getAttributes, getAttributeNames, setAttributeNames } from "./attributes.js";
18
+ import { clickedElement } from "./clickedElement.js";
19
+ import { processOperators, processOperatorsAsync } from "./operators.js";
20
+ import { getRelativePath as getRelativePath2 } from "./getRelativePath.js";
21
+ import { ObjectId as ObjectId2 } from "./ObjectId.js";
22
+ import { uid as uid2 } from "./uid.js";
23
+ import { checkValue as checkValue2 } from "./checkValue.js";
24
+ import { isValidDate as isValidDate2 } from "./isValidDate.js";
25
+ import { objectToSearchParams as objectToSearchParams2 } from "./objectToSearchParams.js";
26
+ import { dotNotationToObject as dotNotationToObject2 } from "./dotNotationToObject.js";
27
+ import { objectToDotNotation as objectToDotNotation2 } from "./objectToDotNotation.js";
28
+ import { getValueFromObject as getValueFromObject2 } from "./getValueFromObject.js";
29
+ import { createUpdate as createUpdate2 } from "./createUpdate.js";
30
+ import { domParser as domParser2 } from "./domParser.js";
31
+ import { parseTextToHtml as parseTextToHtml2 } from "./parseTextToHtml.js";
32
+ import { escapeHtml as escapeHtml2 } from "./escapeHtml.js";
33
+ import { cssPath as cssPath2 } from "./cssPath.js";
34
+ import { queryElements as queryElements2, checkMediaQueries as checkMediaQueries2 } from "./queryElements.js";
35
+ import { queryData as queryData2, searchData as searchData2, sortData as sortData2 } from "./dataQuery.js";
36
+ import { getAttributes as getAttributes2, getAttributeNames as getAttributeNames2, setAttributeNames as setAttributeNames2 } from "./attributes.js";
37
+ import { processOperators as processOperators2, processOperatorsAsync as processOperatorsAsync2 } from "./operators.js";
38
+ const utils = {
39
+ getRelativePath: getRelativePath2,
40
+ ObjectId: ObjectId2,
41
+ uid: uid2,
42
+ checkValue: checkValue2,
43
+ isValidDate: isValidDate2,
44
+ dotNotationToObject: dotNotationToObject2,
45
+ objectToDotNotation: objectToDotNotation2,
46
+ getValueFromObject: getValueFromObject2,
47
+ objectToSearchParams: objectToSearchParams2,
48
+ domParser: domParser2,
49
+ parseTextToHtml: parseTextToHtml2,
50
+ escapeHtml: escapeHtml2,
51
+ cssPath: cssPath2,
52
+ queryElements: queryElements2,
53
+ checkMediaQueries: checkMediaQueries2,
54
+ queryData: queryData2,
55
+ searchData: searchData2,
56
+ sortData: sortData2,
57
+ createUpdate: createUpdate2,
58
+ getAttributes: getAttributes2,
59
+ setAttributeNames: setAttributeNames2,
60
+ getAttributeNames: getAttributeNames2,
61
+ // safeParse,
62
+ processOperators: processOperators2,
63
+ processOperatorsAsync: processOperatorsAsync2
64
+ };
65
+ var index_default = utils;
66
+ export {
67
+ ObjectId,
68
+ checkMediaQueries,
69
+ checkValue,
70
+ clickedElement,
71
+ createUpdate,
72
+ cssPath,
73
+ index_default as default,
74
+ domParser,
75
+ dotNotationToObject,
76
+ escapeHtml,
77
+ getAttributeNames,
78
+ getAttributes,
79
+ getRelativePath,
80
+ getValueFromObject,
81
+ isValidDate,
82
+ objectToDotNotation,
83
+ objectToSearchParams,
84
+ parseTextToHtml,
85
+ processOperators,
86
+ processOperatorsAsync,
87
+ queryData,
88
+ queryElements,
89
+ searchData,
90
+ setAttributeNames,
91
+ sortData,
92
+ uid
93
+ };
@@ -0,0 +1,4 @@
1
+ import { clickedElement } from "./clickedElement.js";
2
+ if (typeof window !== "undefined" && typeof document !== "undefined") {
3
+ clickedElement();
4
+ }
@@ -0,0 +1,13 @@
1
+ function isValidDate(value) {
2
+ if (typeof value === "string" && value.length >= 20 && value.length <= 24) {
3
+ if (/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d{3})?([-+]\d{2}:\d{2}|Z)?$/i.test(
4
+ value
5
+ )) {
6
+ return true;
7
+ }
8
+ }
9
+ return false;
10
+ }
11
+ export {
12
+ isValidDate
13
+ };
@@ -0,0 +1,34 @@
1
+ function objectToDotNotation(input) {
2
+ const results = {};
3
+ function traverse(currentValue, path) {
4
+ if (typeof currentValue !== "object" || currentValue === null) {
5
+ if (path !== void 0 && path !== null && path !== "") {
6
+ results[path] = currentValue;
7
+ }
8
+ return;
9
+ }
10
+ if (Array.isArray(currentValue)) {
11
+ if (currentValue.length > 0) {
12
+ currentValue.forEach((item, index) => {
13
+ const nextPath = `${path}[${index}]`;
14
+ traverse(item, nextPath);
15
+ });
16
+ } else if (path) {
17
+ }
18
+ } else {
19
+ const keys = Object.keys(currentValue);
20
+ if (keys.length > 0) {
21
+ keys.forEach((key) => {
22
+ const nextPath = path ? `${path}.${key}` : key;
23
+ traverse(currentValue[key], nextPath);
24
+ });
25
+ } else if (path) {
26
+ }
27
+ }
28
+ }
29
+ traverse(input, "");
30
+ return results;
31
+ }
32
+ export {
33
+ objectToDotNotation
34
+ };
@@ -0,0 +1,23 @@
1
+ function objectToSearchParams(paramsObj) {
2
+ if (!paramsObj || typeof paramsObj !== "object" || Array.isArray(paramsObj)) {
3
+ return "";
4
+ }
5
+ const filteredObj = {};
6
+ for (const key in paramsObj) {
7
+ if (Object.hasOwn(paramsObj, key)) {
8
+ const value = paramsObj[key];
9
+ if (value !== null && value !== void 0) {
10
+ filteredObj[key] = value;
11
+ }
12
+ }
13
+ }
14
+ if (Object.keys(filteredObj).length === 0) {
15
+ return "";
16
+ }
17
+ const searchParams = new URLSearchParams(filteredObj);
18
+ const queryString = searchParams.toString();
19
+ return queryString ? `?${queryString}` : "";
20
+ }
21
+ export {
22
+ objectToSearchParams
23
+ };