@fluixi/utils 1.0.0-alpha.83 → 1.0.0-alpha.84

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 (129) hide show
  1. package/dist/index.cjs +2858 -1
  2. package/dist/index.mjs +2838 -1
  3. package/dist/lib/array/advanced.cjs +2227 -1
  4. package/dist/lib/array/advanced.mjs +2204 -1
  5. package/dist/lib/array/array.cjs +57 -1
  6. package/dist/lib/array/array.mjs +36 -1
  7. package/dist/lib/array/index.cjs +2344 -1
  8. package/dist/lib/array/index.mjs +2322 -1
  9. package/dist/lib/array/utils.cjs +103 -1
  10. package/dist/lib/array/utils.mjs +82 -1
  11. package/dist/lib/color/color.cjs +2190 -1
  12. package/dist/lib/color/color.mjs +2167 -1
  13. package/dist/lib/color/constants.cjs +380 -1
  14. package/dist/lib/color/constants.mjs +359 -1
  15. package/dist/lib/color/conversions.cjs +629 -1
  16. package/dist/lib/color/conversions.mjs +608 -1
  17. package/dist/lib/color/helpers.cjs +2534 -1
  18. package/dist/lib/color/helpers.mjs +2511 -1
  19. package/dist/lib/color/index.cjs +2641 -1
  20. package/dist/lib/color/index.mjs +2619 -1
  21. package/dist/lib/color/types.cjs +18 -1
  22. package/dist/lib/color/utils.cjs +962 -1
  23. package/dist/lib/color/utils.mjs +939 -1
  24. package/dist/lib/compare/comparators.cjs +171 -1
  25. package/dist/lib/compare/comparators.mjs +150 -1
  26. package/dist/lib/compare/index.cjs +172 -1
  27. package/dist/lib/compare/index.mjs +152 -1
  28. package/dist/lib/crypto/hash.cjs +83 -1
  29. package/dist/lib/crypto/hash.mjs +62 -1
  30. package/dist/lib/crypto/index.cjs +85 -1
  31. package/dist/lib/crypto/index.mjs +62 -1
  32. package/dist/lib/dom/events.cjs +40 -1
  33. package/dist/lib/dom/events.mjs +19 -1
  34. package/dist/lib/dom/index.cjs +78 -1
  35. package/dist/lib/dom/index.mjs +56 -1
  36. package/dist/lib/dom/utils.cjs +57 -1
  37. package/dist/lib/dom/utils.mjs +36 -1
  38. package/dist/lib/functions/functions.cjs +366 -1
  39. package/dist/lib/functions/functions.mjs +345 -1
  40. package/dist/lib/functions/index.cjs +369 -1
  41. package/dist/lib/functions/index.mjs +347 -1
  42. package/dist/lib/functions/types.cjs +18 -1
  43. package/dist/lib/helpers.cjs +78 -1
  44. package/dist/lib/helpers.mjs +59 -1
  45. package/dist/lib/index.cjs +2857 -1
  46. package/dist/lib/index.mjs +2836 -1
  47. package/dist/lib/maths/constants.cjs +70 -1
  48. package/dist/lib/maths/constants.mjs +50 -1
  49. package/dist/lib/maths/fn/advanced.cjs +231 -1
  50. package/dist/lib/maths/fn/advanced.mjs +208 -1
  51. package/dist/lib/maths/fn/basic.cjs +212 -1
  52. package/dist/lib/maths/fn/basic.mjs +191 -1
  53. package/dist/lib/maths/fn/complex.cjs +268 -1
  54. package/dist/lib/maths/fn/complex.mjs +247 -1
  55. package/dist/lib/maths/fn/index.cjs +877 -1
  56. package/dist/lib/maths/fn/index.mjs +855 -1
  57. package/dist/lib/maths/fn/trigo.cjs +179 -1
  58. package/dist/lib/maths/fn/trigo.mjs +156 -1
  59. package/dist/lib/maths/fn/vector.cjs +728 -1
  60. package/dist/lib/maths/fn/vector.mjs +707 -1
  61. package/dist/lib/maths/formatter.cjs +61 -1
  62. package/dist/lib/maths/formatter.mjs +40 -1
  63. package/dist/lib/maths/guards.cjs +164 -1
  64. package/dist/lib/maths/guards.mjs +144 -1
  65. package/dist/lib/maths/index.cjs +1152 -1
  66. package/dist/lib/maths/index.mjs +1130 -1
  67. package/dist/lib/maths/parser.cjs +75 -1
  68. package/dist/lib/maths/parser.mjs +54 -1
  69. package/dist/lib/maths/random.cjs +49 -1
  70. package/dist/lib/maths/random.mjs +28 -1
  71. package/dist/lib/maths/types/advanced.cjs +18 -1
  72. package/dist/lib/maths/types/basic.cjs +18 -1
  73. package/dist/lib/maths/types/index.cjs +19 -1
  74. package/dist/lib/maths/types/index.mjs +1 -0
  75. package/dist/lib/maths/types/negative.cjs +18 -1
  76. package/dist/lib/maths/types/operations.cjs +18 -1
  77. package/dist/lib/object/clone.cjs +88 -1
  78. package/dist/lib/object/clone.mjs +65 -1
  79. package/dist/lib/object/diff.cjs +573 -1
  80. package/dist/lib/object/diff.mjs +550 -1
  81. package/dist/lib/object/getter-setter.cjs +2351 -1
  82. package/dist/lib/object/getter-setter.mjs +2330 -1
  83. package/dist/lib/object/index.cjs +3956 -6
  84. package/dist/lib/object/index.mjs +3936 -6
  85. package/dist/lib/object/merge.cjs +1029 -1
  86. package/dist/lib/object/merge.mjs +1006 -1
  87. package/dist/lib/object/object.cjs +280 -1
  88. package/dist/lib/object/object.mjs +257 -1
  89. package/dist/lib/object/omit.cjs +2022 -1
  90. package/dist/lib/object/omit.mjs +1999 -1
  91. package/dist/lib/object/reconcile.cjs +126 -1
  92. package/dist/lib/object/reconcile.mjs +105 -1
  93. package/dist/lib/object/selector.cjs +303 -1
  94. package/dist/lib/object/selector.mjs +282 -1
  95. package/dist/lib/object/sort.cjs +209 -1
  96. package/dist/lib/object/sort.mjs +186 -1
  97. package/dist/lib/object/transform.cjs +2211 -1
  98. package/dist/lib/object/transform.mjs +2190 -1
  99. package/dist/lib/object/types.cjs +18 -1
  100. package/dist/lib/object/utils.cjs +326 -6
  101. package/dist/lib/object/utils.mjs +305 -6
  102. package/dist/lib/primitive/boolean/boolean.cjs +407 -1
  103. package/dist/lib/primitive/boolean/boolean.mjs +386 -1
  104. package/dist/lib/primitive/boolean/index.cjs +382 -1
  105. package/dist/lib/primitive/boolean/index.mjs +359 -1
  106. package/dist/lib/primitive/boolean/types.cjs +18 -1
  107. package/dist/lib/primitive/date/date.cjs +1126 -1
  108. package/dist/lib/primitive/date/date.mjs +1105 -1
  109. package/dist/lib/primitive/date/index.cjs +1128 -1
  110. package/dist/lib/primitive/date/index.mjs +1105 -1
  111. package/dist/lib/primitive/date/types.cjs +18 -1
  112. package/dist/lib/primitive/index.cjs +2338 -5
  113. package/dist/lib/primitive/index.mjs +2316 -5
  114. package/dist/lib/primitive/string/index.cjs +875 -5
  115. package/dist/lib/primitive/string/index.mjs +852 -5
  116. package/dist/lib/primitive/string/parser-2.cjs +543 -8
  117. package/dist/lib/primitive/string/parser-2.mjs +522 -8
  118. package/dist/lib/primitive/string/parser.cjs +236 -3
  119. package/dist/lib/primitive/string/parser.mjs +215 -3
  120. package/dist/lib/primitive/string/string.cjs +926 -5
  121. package/dist/lib/primitive/string/string.mjs +903 -5
  122. package/dist/lib/primitive/string/types.cjs +18 -1
  123. package/dist/lib/primitive/types.cjs +18 -1
  124. package/dist/lib/url/index.cjs +327 -1
  125. package/dist/lib/url/index.mjs +304 -1
  126. package/dist/lib/url/parser.cjs +325 -1
  127. package/dist/lib/url/parser.mjs +304 -1
  128. package/dist/lib/url/types.cjs +18 -1
  129. package/package.json +5 -5
@@ -1 +1,18 @@
1
- "use strict";var s=Object.defineProperty;var d=Object.getOwnPropertyDescriptor;var x=Object.getOwnPropertyNames;var o=Object.prototype.hasOwnProperty;var i=(t,e,a,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of x(e))!o.call(t,n)&&n!==a&&s(t,n,{get:()=>e[n],enumerable:!(r=d(e,n))||r.enumerable});return t};var y=t=>i(s({},"__esModule",{value:!0}),t);var l={};module.exports=y(l);
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __copyProps = (to, from, except, desc) => {
7
+ if (from && typeof from === "object" || typeof from === "function") {
8
+ for (let key of __getOwnPropNames(from))
9
+ if (!__hasOwnProp.call(to, key) && key !== except)
10
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
11
+ }
12
+ return to;
13
+ };
14
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
15
+
16
+ // src/lib/object/types.ts
17
+ var types_exports = {};
18
+ module.exports = __toCommonJS(types_exports);
@@ -1,6 +1,326 @@
1
- "use strict";var A=Object.defineProperty;var k=Object.getOwnPropertyDescriptor;var O=Object.getOwnPropertyNames;var R=Object.prototype.hasOwnProperty;var p=(e,i)=>{for(var o in i)A(e,o,{get:i[o],enumerable:!0})},$=(e,i,o,a)=>{if(i&&typeof i=="object"||typeof i=="function")for(let f of O(i))!R.call(e,f)&&f!==o&&A(e,f,{get:()=>i[f],enumerable:!(a=k(i,f))||a.enumerable});return e};var w=e=>$(A({},"__esModule",{value:!0}),e);var T={};p(T,{isClass:()=>h,isEmptyObject:()=>C,isObject:()=>S,isPlainObject:()=>m,toJSONString:()=>E,traverseStructure:()=>c});module.exports=w(T);var S=e=>e==null||Array.isArray(e)||typeof e=="function"||e instanceof Date||e instanceof RegExp||e instanceof Map||e instanceof Set||e instanceof Error?!1:typeof e=="object";function m(e){if(typeof e!="object"||e===null)return!1;let i=Object.getPrototypeOf(e);return i===Object.prototype||i===null}function h(e){return typeof e=="function"&&/^class\s/.test(Function.prototype.toString.call(e))}var C=e=>S(e)?Object.keys(e).length===0:!1,c=(e,i,o,a)=>{if(o>a)return;if(i.length===0)return e;let f=i[0],l=i.slice(1);if(f.type==="descendant"){let s=c(e,l,o+1,a);if(s!==void 0)return s;if(e&&typeof e=="object")if(Array.isArray(e)){let t=[];for(let n=0;n<e.length;n++){let r=c(e[n],i,o+1,a);r!==void 0&&(t[n]=r)}return t.length>0?t:void 0}else{let t={};for(let n in e)if(e.hasOwnProperty(n)){let r=c(e[n],i,o+1,a);r!==void 0&&(t[n]=r)}return Object.keys(t).length>0?t:void 0}return}switch(f.type){case"property":if(S(e)&&f.value&&String(f.value)in e){let s=e[String(f.value)],t=c(s,l,o+1,a);if(t!==void 0)return{[String(f.value)]:t}}break;case"index":if(Array.isArray(e)){let s=f.value;if(s>=0&&s<e.length){let t=c(e[s],l,o+1,a);if(t!==void 0){let n=new Array(e.length).filter(r=>r!==void 0);return n[s]=t,n}}}else if(e&&typeof e=="object"){let s=String(f.value);if(s in e){let t=c(e[s],l,o+1,a);if(t!==void 0)return{[s]:t}}}break;case"wildcard":if(e&&typeof e=="object")if(Array.isArray(e)){let s=[],t=!1;for(let n=0;n<e.length;n++){let r=c(e[n],l,o+1,a);r!==void 0&&(s[n]=r,t=!0)}return t?s:void 0}else{let s={},t=!1;for(let n in e)if(e.hasOwnProperty(n)){let r=c(e[n],l,o+1,a);r!==void 0&&(s[n]=r,t=!0)}return t?s:void 0}break;case"slice":if(Array.isArray(e)){let[s,t]=f.value,n=Math.max(0,s),r=Math.min(e.length,t===1/0?e.length:t),u=[],b=!1;for(let d=n;d<r;d++){let y=c(e[d],l,o+1,a);y!==void 0&&(u[d]=y,b=!0)}return b?u:void 0}break;case"union":if(Array.isArray(e)){let s=f.value,t=[],n=!1;for(let r of s)if(r>=0&&r<e.length){let u=c(e[r],l,o+1,a);u!==void 0&&(t[r]=u,n=!0)}return n?t:void 0}break;case"filter":if(Array.isArray(e)){let s=f.value,t=[],n=!1;for(let r=0;r<e.length;r++)if(s(e[r])){let u=c(e[r],l,o+1,a);u!==void 0&&(t[r]=u,n=!0)}return n?t:void 0}break}};function E(e,i=0){let o=new WeakSet,a=n=>i?" ".repeat(n):"",f=n=>i?`
2
- ${" ".repeat(n)}`:"",l=n=>n.replace(/[\u0000-\u001F"\\]/g,r=>{switch(r){case'"':return'\\"';case"\\":return"\\\\";case"\b":return"\\b";case"\f":return"\\f";case`
3
- `:return"\\n";case"\r":return"\\r";case" ":return"\\t";default:return`\\u${r.charCodeAt(0).toString(16).padStart(4,"0")}`}}),s=(n,r)=>{if(n===null)return"null";let u=typeof n;if(u==="number")return Number.isFinite(n)?String(n):"null";if(u==="boolean")return n?"true":"false";if(u==="bigint")return`"${String(n)}"`;if(!(u==="function"||u==="undefined"||u==="symbol")){if(Array.isArray(n)){if(o.has(n))throw new TypeError("Converting circular structure to JSON");o.add(n);let b=r+i,d=n.map(y=>{let g=s(y,b);return g===void 0?"null":g});return o.delete(n),i?`[${f(b)}${d.join(`,${f(b)}`)}${f(r)}]`:`[${d.join(",")}]`}if(u==="object"){if(o.has(n))throw new TypeError("Converting circular structure to JSON");o.add(n);let b=Object.keys(n),d=r+i,y=[];for(let g of b){let j=s(n[g],d);j!==void 0&&(i?y.push(`${a(d)}"${l(g)}": ${j}`):y.push(`"${l(g)}":${j}`))}return o.delete(n),i?`{
4
- ${y.join(`,
5
- `)}
6
- ${a(r)}}`:`{${y.join(",")}}`}}},t=s(e,0);return t===void 0?void 0:t}
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/lib/object/utils.ts
21
+ var utils_exports = {};
22
+ __export(utils_exports, {
23
+ isClass: () => isClass,
24
+ isEmptyObject: () => isEmptyObject,
25
+ isObject: () => isObject,
26
+ isPlainObject: () => isPlainObject,
27
+ toJSONString: () => toJSONString,
28
+ traverseStructure: () => traverseStructure
29
+ });
30
+ module.exports = __toCommonJS(utils_exports);
31
+ var isObject = (value) => {
32
+ if (value == null) return false;
33
+ if (Array.isArray(value)) return false;
34
+ if (typeof value === "function") return false;
35
+ if (value instanceof Date) return false;
36
+ if (value instanceof RegExp) return false;
37
+ if (value instanceof Map) return false;
38
+ if (value instanceof Set) return false;
39
+ if (value instanceof Error) return false;
40
+ return typeof value === "object";
41
+ };
42
+ function isPlainObject(v) {
43
+ if (typeof v !== "object" || v === null) return false;
44
+ const proto = Object.getPrototypeOf(v);
45
+ return proto === Object.prototype || proto === null;
46
+ }
47
+ function isClass(obj) {
48
+ return typeof obj === "function" && /^class\s/.test(Function.prototype.toString.call(obj));
49
+ }
50
+ var isEmptyObject = (value) => {
51
+ if (!isObject(value)) return false;
52
+ return Object.keys(value).length === 0;
53
+ };
54
+ var traverseStructure = (current, segments, depth, maxDepth) => {
55
+ if (depth > maxDepth) return void 0;
56
+ if (segments.length === 0) return current;
57
+ const segment = segments[0];
58
+ const remaining = segments.slice(1);
59
+ if (segment.type === "descendant") {
60
+ const result = traverseStructure(current, remaining, depth + 1, maxDepth);
61
+ if (result !== void 0) {
62
+ return result;
63
+ }
64
+ if (current && typeof current === "object") {
65
+ if (Array.isArray(current)) {
66
+ const arrResult = [];
67
+ for (let i = 0; i < current.length; i++) {
68
+ const itemResult = traverseStructure(
69
+ current[i],
70
+ segments,
71
+ depth + 1,
72
+ maxDepth
73
+ );
74
+ if (itemResult !== void 0) {
75
+ arrResult[i] = itemResult;
76
+ }
77
+ }
78
+ return arrResult.length > 0 ? arrResult : void 0;
79
+ } else {
80
+ const objResult = {};
81
+ for (const key in current) {
82
+ if (current.hasOwnProperty(key)) {
83
+ const itemResult = traverseStructure(
84
+ current[key],
85
+ segments,
86
+ depth + 1,
87
+ maxDepth
88
+ );
89
+ if (itemResult !== void 0) {
90
+ objResult[key] = itemResult;
91
+ }
92
+ }
93
+ }
94
+ return Object.keys(objResult).length > 0 ? objResult : void 0;
95
+ }
96
+ }
97
+ return void 0;
98
+ }
99
+ switch (segment.type) {
100
+ case "property":
101
+ if (isObject(current) && segment.value && String(segment.value) in current) {
102
+ const next = current[String(segment.value)];
103
+ const result = traverseStructure(next, remaining, depth + 1, maxDepth);
104
+ if (result !== void 0) {
105
+ return { [String(segment.value)]: result };
106
+ }
107
+ }
108
+ break;
109
+ case "index":
110
+ if (Array.isArray(current)) {
111
+ const index = segment.value;
112
+ if (index >= 0 && index < current.length) {
113
+ const result = traverseStructure(
114
+ current[index],
115
+ remaining,
116
+ depth + 1,
117
+ maxDepth
118
+ );
119
+ if (result !== void 0) {
120
+ const arr = new Array(current.length).filter(
121
+ (a) => a !== void 0
122
+ );
123
+ arr[index] = result;
124
+ return arr;
125
+ }
126
+ }
127
+ } else if (current && typeof current === "object") {
128
+ const key = String(segment.value);
129
+ if (key in current) {
130
+ const result = traverseStructure(
131
+ current[key],
132
+ remaining,
133
+ depth + 1,
134
+ maxDepth
135
+ );
136
+ if (result !== void 0) {
137
+ return { [key]: result };
138
+ }
139
+ }
140
+ }
141
+ break;
142
+ case "wildcard":
143
+ if (current && typeof current === "object") {
144
+ if (Array.isArray(current)) {
145
+ const arrResult = [];
146
+ let hasResults = false;
147
+ for (let i = 0; i < current.length; i++) {
148
+ const result = traverseStructure(
149
+ current[i],
150
+ remaining,
151
+ depth + 1,
152
+ maxDepth
153
+ );
154
+ if (result !== void 0) {
155
+ arrResult[i] = result;
156
+ hasResults = true;
157
+ }
158
+ }
159
+ return hasResults ? arrResult : void 0;
160
+ } else {
161
+ const objResult = {};
162
+ let hasResults = false;
163
+ for (const key in current) {
164
+ if (current.hasOwnProperty(key)) {
165
+ const result = traverseStructure(
166
+ current[key],
167
+ remaining,
168
+ depth + 1,
169
+ maxDepth
170
+ );
171
+ if (result !== void 0) {
172
+ objResult[key] = result;
173
+ hasResults = true;
174
+ }
175
+ }
176
+ }
177
+ return hasResults ? objResult : void 0;
178
+ }
179
+ }
180
+ break;
181
+ case "slice":
182
+ if (Array.isArray(current)) {
183
+ const [start, end] = segment.value;
184
+ const actualStart = Math.max(0, start);
185
+ const actualEnd = Math.min(
186
+ current.length,
187
+ end === Infinity ? current.length : end
188
+ );
189
+ const arrResult = [];
190
+ let hasResults = false;
191
+ for (let i = actualStart; i < actualEnd; i++) {
192
+ const result = traverseStructure(
193
+ current[i],
194
+ remaining,
195
+ depth + 1,
196
+ maxDepth
197
+ );
198
+ if (result !== void 0) {
199
+ arrResult[i] = result;
200
+ hasResults = true;
201
+ }
202
+ }
203
+ return hasResults ? arrResult : void 0;
204
+ }
205
+ break;
206
+ case "union":
207
+ if (Array.isArray(current)) {
208
+ const indices = segment.value;
209
+ const arrResult = [];
210
+ let hasResults = false;
211
+ for (const index of indices) {
212
+ if (index >= 0 && index < current.length) {
213
+ const result = traverseStructure(
214
+ current[index],
215
+ remaining,
216
+ depth + 1,
217
+ maxDepth
218
+ );
219
+ if (result !== void 0) {
220
+ arrResult[index] = result;
221
+ hasResults = true;
222
+ }
223
+ }
224
+ }
225
+ return hasResults ? arrResult : void 0;
226
+ }
227
+ break;
228
+ case "filter":
229
+ if (Array.isArray(current)) {
230
+ const filterFn = segment.value;
231
+ const arrResult = [];
232
+ let hasResults = false;
233
+ for (let i = 0; i < current.length; i++) {
234
+ if (filterFn(current[i])) {
235
+ const result = traverseStructure(
236
+ current[i],
237
+ remaining,
238
+ depth + 1,
239
+ maxDepth
240
+ );
241
+ if (result !== void 0) {
242
+ arrResult[i] = result;
243
+ hasResults = true;
244
+ }
245
+ }
246
+ }
247
+ return hasResults ? arrResult : void 0;
248
+ }
249
+ break;
250
+ }
251
+ return void 0;
252
+ };
253
+ function toJSONString(value, space = 0) {
254
+ const seen = /* @__PURE__ */ new WeakSet();
255
+ const gap = (n) => space ? " ".repeat(n) : "";
256
+ const nl = (n) => space ? `
257
+ ${" ".repeat(n)}` : "";
258
+ const esc = (s) => s.replace(/[\u0000-\u001F"\\]/g, (c) => {
259
+ switch (c) {
260
+ case '"':
261
+ return '\\"';
262
+ case "\\":
263
+ return "\\\\";
264
+ case "\b":
265
+ return "\\b";
266
+ case "\f":
267
+ return "\\f";
268
+ case "\n":
269
+ return "\\n";
270
+ case "\r":
271
+ return "\\r";
272
+ case " ":
273
+ return "\\t";
274
+ default:
275
+ const code = c.charCodeAt(0).toString(16).padStart(4, "0");
276
+ return `\\u${code}`;
277
+ }
278
+ });
279
+ const ser = (v, indent) => {
280
+ if (v === null) return "null";
281
+ const t = typeof v;
282
+ if (t === "number") return Number.isFinite(v) ? String(v) : "null";
283
+ if (t === "boolean") return v ? "true" : "false";
284
+ if (t === "string") {
285
+ }
286
+ if (t === "bigint") return `"${String(v)}"`;
287
+ if (t === "function" || t === "undefined" || t === "symbol")
288
+ return void 0;
289
+ if (Array.isArray(v)) {
290
+ if (seen.has(v))
291
+ throw new TypeError("Converting circular structure to JSON");
292
+ seen.add(v);
293
+ const next = indent + space;
294
+ const parts = v.map((x) => {
295
+ const s = ser(x, next);
296
+ return s === void 0 ? "null" : s;
297
+ });
298
+ seen.delete(v);
299
+ if (!space) return `[${parts.join(",")}]`;
300
+ return `[${nl(next)}${parts.join(`,${nl(next)}`)}${nl(indent)}]`;
301
+ }
302
+ if (t === "object") {
303
+ if (seen.has(v))
304
+ throw new TypeError("Converting circular structure to JSON");
305
+ seen.add(v);
306
+ const keys = Object.keys(v);
307
+ const next = indent + space;
308
+ const parts = [];
309
+ for (const k of keys) {
310
+ const s = ser(v[k], next);
311
+ if (s !== void 0) {
312
+ if (!space) parts.push(`"${esc(k)}":${s}`);
313
+ else parts.push(`${gap(next)}"${esc(k)}": ${s}`);
314
+ }
315
+ }
316
+ seen.delete(v);
317
+ if (!space) return `{${parts.join(",")}}`;
318
+ return `{
319
+ ${parts.join(",\n")}
320
+ ${gap(indent)}}`;
321
+ }
322
+ return void 0;
323
+ };
324
+ const out = ser(value, 0);
325
+ return out === void 0 ? void 0 : out;
326
+ }
@@ -1,6 +1,305 @@
1
- var A=e=>e==null||Array.isArray(e)||typeof e=="function"||e instanceof Date||e instanceof RegExp||e instanceof Map||e instanceof Set||e instanceof Error?!1:typeof e=="object";function S(e){if(typeof e!="object"||e===null)return!1;let f=Object.getPrototypeOf(e);return f===Object.prototype||f===null}function k(e){return typeof e=="function"&&/^class\s/.test(Function.prototype.toString.call(e))}var O=e=>A(e)?Object.keys(e).length===0:!1,c=(e,f,i,a)=>{if(i>a)return;if(f.length===0)return e;let u=f[0],l=f.slice(1);if(u.type==="descendant"){let s=c(e,l,i+1,a);if(s!==void 0)return s;if(e&&typeof e=="object")if(Array.isArray(e)){let t=[];for(let n=0;n<e.length;n++){let r=c(e[n],f,i+1,a);r!==void 0&&(t[n]=r)}return t.length>0?t:void 0}else{let t={};for(let n in e)if(e.hasOwnProperty(n)){let r=c(e[n],f,i+1,a);r!==void 0&&(t[n]=r)}return Object.keys(t).length>0?t:void 0}return}switch(u.type){case"property":if(A(e)&&u.value&&String(u.value)in e){let s=e[String(u.value)],t=c(s,l,i+1,a);if(t!==void 0)return{[String(u.value)]:t}}break;case"index":if(Array.isArray(e)){let s=u.value;if(s>=0&&s<e.length){let t=c(e[s],l,i+1,a);if(t!==void 0){let n=new Array(e.length).filter(r=>r!==void 0);return n[s]=t,n}}}else if(e&&typeof e=="object"){let s=String(u.value);if(s in e){let t=c(e[s],l,i+1,a);if(t!==void 0)return{[s]:t}}}break;case"wildcard":if(e&&typeof e=="object")if(Array.isArray(e)){let s=[],t=!1;for(let n=0;n<e.length;n++){let r=c(e[n],l,i+1,a);r!==void 0&&(s[n]=r,t=!0)}return t?s:void 0}else{let s={},t=!1;for(let n in e)if(e.hasOwnProperty(n)){let r=c(e[n],l,i+1,a);r!==void 0&&(s[n]=r,t=!0)}return t?s:void 0}break;case"slice":if(Array.isArray(e)){let[s,t]=u.value,n=Math.max(0,s),r=Math.min(e.length,t===1/0?e.length:t),o=[],b=!1;for(let d=n;d<r;d++){let y=c(e[d],l,i+1,a);y!==void 0&&(o[d]=y,b=!0)}return b?o:void 0}break;case"union":if(Array.isArray(e)){let s=u.value,t=[],n=!1;for(let r of s)if(r>=0&&r<e.length){let o=c(e[r],l,i+1,a);o!==void 0&&(t[r]=o,n=!0)}return n?t:void 0}break;case"filter":if(Array.isArray(e)){let s=u.value,t=[],n=!1;for(let r=0;r<e.length;r++)if(s(e[r])){let o=c(e[r],l,i+1,a);o!==void 0&&(t[r]=o,n=!0)}return n?t:void 0}break}};function R(e,f=0){let i=new WeakSet,a=n=>f?" ".repeat(n):"",u=n=>f?`
2
- ${" ".repeat(n)}`:"",l=n=>n.replace(/[\u0000-\u001F"\\]/g,r=>{switch(r){case'"':return'\\"';case"\\":return"\\\\";case"\b":return"\\b";case"\f":return"\\f";case`
3
- `:return"\\n";case"\r":return"\\r";case" ":return"\\t";default:return`\\u${r.charCodeAt(0).toString(16).padStart(4,"0")}`}}),s=(n,r)=>{if(n===null)return"null";let o=typeof n;if(o==="number")return Number.isFinite(n)?String(n):"null";if(o==="boolean")return n?"true":"false";if(o==="bigint")return`"${String(n)}"`;if(!(o==="function"||o==="undefined"||o==="symbol")){if(Array.isArray(n)){if(i.has(n))throw new TypeError("Converting circular structure to JSON");i.add(n);let b=r+f,d=n.map(y=>{let g=s(y,b);return g===void 0?"null":g});return i.delete(n),f?`[${u(b)}${d.join(`,${u(b)}`)}${u(r)}]`:`[${d.join(",")}]`}if(o==="object"){if(i.has(n))throw new TypeError("Converting circular structure to JSON");i.add(n);let b=Object.keys(n),d=r+f,y=[];for(let g of b){let j=s(n[g],d);j!==void 0&&(f?y.push(`${a(d)}"${l(g)}": ${j}`):y.push(`"${l(g)}":${j}`))}return i.delete(n),f?`{
4
- ${y.join(`,
5
- `)}
6
- ${a(r)}}`:`{${y.join(",")}}`}}},t=s(e,0);return t===void 0?void 0:t}export{k as isClass,O as isEmptyObject,A as isObject,S as isPlainObject,R as toJSONString,c as traverseStructure};
1
+ // src/lib/object/utils.ts
2
+ var isObject = (value) => {
3
+ if (value == null) return false;
4
+ if (Array.isArray(value)) return false;
5
+ if (typeof value === "function") return false;
6
+ if (value instanceof Date) return false;
7
+ if (value instanceof RegExp) return false;
8
+ if (value instanceof Map) return false;
9
+ if (value instanceof Set) return false;
10
+ if (value instanceof Error) return false;
11
+ return typeof value === "object";
12
+ };
13
+ function isPlainObject(v) {
14
+ if (typeof v !== "object" || v === null) return false;
15
+ const proto = Object.getPrototypeOf(v);
16
+ return proto === Object.prototype || proto === null;
17
+ }
18
+ function isClass(obj) {
19
+ return typeof obj === "function" && /^class\s/.test(Function.prototype.toString.call(obj));
20
+ }
21
+ var isEmptyObject = (value) => {
22
+ if (!isObject(value)) return false;
23
+ return Object.keys(value).length === 0;
24
+ };
25
+ var traverseStructure = (current, segments, depth, maxDepth) => {
26
+ if (depth > maxDepth) return void 0;
27
+ if (segments.length === 0) return current;
28
+ const segment = segments[0];
29
+ const remaining = segments.slice(1);
30
+ if (segment.type === "descendant") {
31
+ const result = traverseStructure(current, remaining, depth + 1, maxDepth);
32
+ if (result !== void 0) {
33
+ return result;
34
+ }
35
+ if (current && typeof current === "object") {
36
+ if (Array.isArray(current)) {
37
+ const arrResult = [];
38
+ for (let i = 0; i < current.length; i++) {
39
+ const itemResult = traverseStructure(
40
+ current[i],
41
+ segments,
42
+ depth + 1,
43
+ maxDepth
44
+ );
45
+ if (itemResult !== void 0) {
46
+ arrResult[i] = itemResult;
47
+ }
48
+ }
49
+ return arrResult.length > 0 ? arrResult : void 0;
50
+ } else {
51
+ const objResult = {};
52
+ for (const key in current) {
53
+ if (current.hasOwnProperty(key)) {
54
+ const itemResult = traverseStructure(
55
+ current[key],
56
+ segments,
57
+ depth + 1,
58
+ maxDepth
59
+ );
60
+ if (itemResult !== void 0) {
61
+ objResult[key] = itemResult;
62
+ }
63
+ }
64
+ }
65
+ return Object.keys(objResult).length > 0 ? objResult : void 0;
66
+ }
67
+ }
68
+ return void 0;
69
+ }
70
+ switch (segment.type) {
71
+ case "property":
72
+ if (isObject(current) && segment.value && String(segment.value) in current) {
73
+ const next = current[String(segment.value)];
74
+ const result = traverseStructure(next, remaining, depth + 1, maxDepth);
75
+ if (result !== void 0) {
76
+ return { [String(segment.value)]: result };
77
+ }
78
+ }
79
+ break;
80
+ case "index":
81
+ if (Array.isArray(current)) {
82
+ const index = segment.value;
83
+ if (index >= 0 && index < current.length) {
84
+ const result = traverseStructure(
85
+ current[index],
86
+ remaining,
87
+ depth + 1,
88
+ maxDepth
89
+ );
90
+ if (result !== void 0) {
91
+ const arr = new Array(current.length).filter(
92
+ (a) => a !== void 0
93
+ );
94
+ arr[index] = result;
95
+ return arr;
96
+ }
97
+ }
98
+ } else if (current && typeof current === "object") {
99
+ const key = String(segment.value);
100
+ if (key in current) {
101
+ const result = traverseStructure(
102
+ current[key],
103
+ remaining,
104
+ depth + 1,
105
+ maxDepth
106
+ );
107
+ if (result !== void 0) {
108
+ return { [key]: result };
109
+ }
110
+ }
111
+ }
112
+ break;
113
+ case "wildcard":
114
+ if (current && typeof current === "object") {
115
+ if (Array.isArray(current)) {
116
+ const arrResult = [];
117
+ let hasResults = false;
118
+ for (let i = 0; i < current.length; i++) {
119
+ const result = traverseStructure(
120
+ current[i],
121
+ remaining,
122
+ depth + 1,
123
+ maxDepth
124
+ );
125
+ if (result !== void 0) {
126
+ arrResult[i] = result;
127
+ hasResults = true;
128
+ }
129
+ }
130
+ return hasResults ? arrResult : void 0;
131
+ } else {
132
+ const objResult = {};
133
+ let hasResults = false;
134
+ for (const key in current) {
135
+ if (current.hasOwnProperty(key)) {
136
+ const result = traverseStructure(
137
+ current[key],
138
+ remaining,
139
+ depth + 1,
140
+ maxDepth
141
+ );
142
+ if (result !== void 0) {
143
+ objResult[key] = result;
144
+ hasResults = true;
145
+ }
146
+ }
147
+ }
148
+ return hasResults ? objResult : void 0;
149
+ }
150
+ }
151
+ break;
152
+ case "slice":
153
+ if (Array.isArray(current)) {
154
+ const [start, end] = segment.value;
155
+ const actualStart = Math.max(0, start);
156
+ const actualEnd = Math.min(
157
+ current.length,
158
+ end === Infinity ? current.length : end
159
+ );
160
+ const arrResult = [];
161
+ let hasResults = false;
162
+ for (let i = actualStart; i < actualEnd; i++) {
163
+ const result = traverseStructure(
164
+ current[i],
165
+ remaining,
166
+ depth + 1,
167
+ maxDepth
168
+ );
169
+ if (result !== void 0) {
170
+ arrResult[i] = result;
171
+ hasResults = true;
172
+ }
173
+ }
174
+ return hasResults ? arrResult : void 0;
175
+ }
176
+ break;
177
+ case "union":
178
+ if (Array.isArray(current)) {
179
+ const indices = segment.value;
180
+ const arrResult = [];
181
+ let hasResults = false;
182
+ for (const index of indices) {
183
+ if (index >= 0 && index < current.length) {
184
+ const result = traverseStructure(
185
+ current[index],
186
+ remaining,
187
+ depth + 1,
188
+ maxDepth
189
+ );
190
+ if (result !== void 0) {
191
+ arrResult[index] = result;
192
+ hasResults = true;
193
+ }
194
+ }
195
+ }
196
+ return hasResults ? arrResult : void 0;
197
+ }
198
+ break;
199
+ case "filter":
200
+ if (Array.isArray(current)) {
201
+ const filterFn = segment.value;
202
+ const arrResult = [];
203
+ let hasResults = false;
204
+ for (let i = 0; i < current.length; i++) {
205
+ if (filterFn(current[i])) {
206
+ const result = traverseStructure(
207
+ current[i],
208
+ remaining,
209
+ depth + 1,
210
+ maxDepth
211
+ );
212
+ if (result !== void 0) {
213
+ arrResult[i] = result;
214
+ hasResults = true;
215
+ }
216
+ }
217
+ }
218
+ return hasResults ? arrResult : void 0;
219
+ }
220
+ break;
221
+ }
222
+ return void 0;
223
+ };
224
+ function toJSONString(value, space = 0) {
225
+ const seen = /* @__PURE__ */ new WeakSet();
226
+ const gap = (n) => space ? " ".repeat(n) : "";
227
+ const nl = (n) => space ? `
228
+ ${" ".repeat(n)}` : "";
229
+ const esc = (s) => s.replace(/[\u0000-\u001F"\\]/g, (c) => {
230
+ switch (c) {
231
+ case '"':
232
+ return '\\"';
233
+ case "\\":
234
+ return "\\\\";
235
+ case "\b":
236
+ return "\\b";
237
+ case "\f":
238
+ return "\\f";
239
+ case "\n":
240
+ return "\\n";
241
+ case "\r":
242
+ return "\\r";
243
+ case " ":
244
+ return "\\t";
245
+ default:
246
+ const code = c.charCodeAt(0).toString(16).padStart(4, "0");
247
+ return `\\u${code}`;
248
+ }
249
+ });
250
+ const ser = (v, indent) => {
251
+ if (v === null) return "null";
252
+ const t = typeof v;
253
+ if (t === "number") return Number.isFinite(v) ? String(v) : "null";
254
+ if (t === "boolean") return v ? "true" : "false";
255
+ if (t === "string") {
256
+ }
257
+ if (t === "bigint") return `"${String(v)}"`;
258
+ if (t === "function" || t === "undefined" || t === "symbol")
259
+ return void 0;
260
+ if (Array.isArray(v)) {
261
+ if (seen.has(v))
262
+ throw new TypeError("Converting circular structure to JSON");
263
+ seen.add(v);
264
+ const next = indent + space;
265
+ const parts = v.map((x) => {
266
+ const s = ser(x, next);
267
+ return s === void 0 ? "null" : s;
268
+ });
269
+ seen.delete(v);
270
+ if (!space) return `[${parts.join(",")}]`;
271
+ return `[${nl(next)}${parts.join(`,${nl(next)}`)}${nl(indent)}]`;
272
+ }
273
+ if (t === "object") {
274
+ if (seen.has(v))
275
+ throw new TypeError("Converting circular structure to JSON");
276
+ seen.add(v);
277
+ const keys = Object.keys(v);
278
+ const next = indent + space;
279
+ const parts = [];
280
+ for (const k of keys) {
281
+ const s = ser(v[k], next);
282
+ if (s !== void 0) {
283
+ if (!space) parts.push(`"${esc(k)}":${s}`);
284
+ else parts.push(`${gap(next)}"${esc(k)}": ${s}`);
285
+ }
286
+ }
287
+ seen.delete(v);
288
+ if (!space) return `{${parts.join(",")}}`;
289
+ return `{
290
+ ${parts.join(",\n")}
291
+ ${gap(indent)}}`;
292
+ }
293
+ return void 0;
294
+ };
295
+ const out = ser(value, 0);
296
+ return out === void 0 ? void 0 : out;
297
+ }
298
+ export {
299
+ isClass,
300
+ isEmptyObject,
301
+ isObject,
302
+ isPlainObject,
303
+ toJSONString,
304
+ traverseStructure
305
+ };