@md-oss/common 0.1.6 → 0.1.7
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/dist/arrays-6DA6GfsQ.mjs +2 -0
- package/dist/arrays-6DA6GfsQ.mjs.map +1 -0
- package/dist/arrays-DvPJ1GeR.d.cts +163 -0
- package/dist/arrays-DvPJ1GeR.d.mts +163 -0
- package/dist/arrays-bgbansWs.cjs +2 -0
- package/dist/arrays-bgbansWs.cjs.map +1 -0
- package/dist/constants/bytes.cjs +1 -1
- package/dist/constants/bytes.cjs.map +1 -1
- package/dist/constants/bytes.d.cts +31 -1
- package/dist/constants/bytes.d.mts +31 -1
- package/dist/constants/bytes.mjs +1 -1
- package/dist/constants/bytes.mjs.map +1 -1
- package/dist/files-DzKYei0a.mjs +2 -0
- package/dist/files-DzKYei0a.mjs.map +1 -0
- package/dist/files-m1nnj5gT.cjs +2 -0
- package/dist/files-m1nnj5gT.cjs.map +1 -0
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +10 -8
- package/dist/index.d.mts +10 -8
- package/dist/index.mjs +1 -1
- package/dist/mime-types-BmvBrrZ7.cjs.map +1 -1
- package/dist/mime-types-D_K53zgk.mjs.map +1 -1
- package/dist/{mime-types-Bjt4NvnE.d.cts → mime-types-Dajfhq2c.d.cts} +58 -1
- package/dist/{mime-types-Bjt4NvnE.d.mts → mime-types-Dajfhq2c.d.mts} +58 -1
- package/dist/numbers-B_mptknO.cjs +2 -0
- package/dist/numbers-B_mptknO.cjs.map +1 -0
- package/dist/numbers-C2680fmA.d.cts +184 -0
- package/dist/numbers-C2680fmA.d.mts +184 -0
- package/dist/numbers-lJ6gwIpk.mjs +2 -0
- package/dist/numbers-lJ6gwIpk.mjs.map +1 -0
- package/dist/objects-VXf3mqE5.mjs +2 -0
- package/dist/objects-VXf3mqE5.mjs.map +1 -0
- package/dist/objects-fiFExjsf.d.cts +116 -0
- package/dist/objects-fiFExjsf.d.mts +116 -0
- package/dist/objects-wcO6hNA8.cjs +2 -0
- package/dist/objects-wcO6hNA8.cjs.map +1 -0
- package/dist/random-668tofPV.cjs +2 -0
- package/dist/random-668tofPV.cjs.map +1 -0
- package/dist/random-BqJDZAPb.d.cts +131 -0
- package/dist/random-BqJDZAPb.d.mts +131 -0
- package/dist/random-ihslkInn.mjs +2 -0
- package/dist/random-ihslkInn.mjs.map +1 -0
- package/dist/runtime-7fkN5_oL.d.cts +206 -0
- package/dist/runtime-7fkN5_oL.d.mts +206 -0
- package/dist/runtime-Bfs-yn_-.cjs +2 -0
- package/dist/runtime-Bfs-yn_-.cjs.map +1 -0
- package/dist/runtime-CE36Va0l.mjs +2 -0
- package/dist/runtime-CE36Va0l.mjs.map +1 -0
- package/dist/strings-CrzGdnZH.mjs +3 -0
- package/dist/strings-CrzGdnZH.mjs.map +1 -0
- package/dist/strings-_1vAPvzS.cjs +3 -0
- package/dist/strings-_1vAPvzS.cjs.map +1 -0
- package/dist/strings-jE1j-qqa.d.cts +213 -0
- package/dist/strings-jE1j-qqa.d.mts +213 -0
- package/dist/time-BrLHgSth.d.mts +68 -0
- package/dist/time-DmJNWZeL.mjs.map +1 -1
- package/dist/time-ufhllID1.d.cts +68 -0
- package/dist/time-yNkQSJnQ.cjs.map +1 -1
- package/dist/utils/arrays.cjs +1 -1
- package/dist/utils/arrays.d.cts +1 -1
- package/dist/utils/arrays.d.mts +1 -1
- package/dist/utils/arrays.mjs +1 -1
- package/dist/utils/index.cjs +1 -1
- package/dist/utils/index.d.cts +187 -8
- package/dist/utils/index.d.mts +187 -8
- package/dist/utils/index.mjs +1 -1
- package/dist/utils/mime-types.d.cts +1 -1
- package/dist/utils/mime-types.d.mts +1 -1
- package/dist/utils/numbers.cjs +1 -1
- package/dist/utils/numbers.d.cts +1 -1
- package/dist/utils/numbers.d.mts +1 -1
- package/dist/utils/numbers.mjs +1 -1
- package/dist/utils/objects.cjs +1 -1
- package/dist/utils/objects.d.cts +1 -1
- package/dist/utils/objects.d.mts +1 -1
- package/dist/utils/objects.mjs +1 -1
- package/dist/utils/random.cjs +1 -1
- package/dist/utils/random.d.cts +1 -1
- package/dist/utils/random.d.mts +1 -1
- package/dist/utils/random.mjs +1 -1
- package/dist/utils/runtime.cjs +1 -1
- package/dist/utils/runtime.d.cts +1 -1
- package/dist/utils/runtime.d.mts +1 -1
- package/dist/utils/runtime.mjs +1 -1
- package/dist/utils/strings.cjs +1 -1
- package/dist/utils/strings.d.cts +1 -1
- package/dist/utils/strings.d.mts +1 -1
- package/dist/utils/strings.mjs +1 -1
- package/dist/utils/time.d.cts +1 -1
- package/dist/utils/time.d.mts +1 -1
- package/package.json +2 -2
- package/dist/arrays-BkHBzTDO.mjs +0 -2
- package/dist/arrays-BkHBzTDO.mjs.map +0 -1
- package/dist/arrays-CElcW69H.d.cts +0 -43
- package/dist/arrays-CElcW69H.d.mts +0 -43
- package/dist/arrays-DaB1Xn47.cjs +0 -2
- package/dist/arrays-DaB1Xn47.cjs.map +0 -1
- package/dist/numbers-CtAqd3eH.d.cts +0 -49
- package/dist/numbers-CtAqd3eH.d.mts +0 -49
- package/dist/numbers-D2K-8sJL.mjs +0 -2
- package/dist/numbers-D2K-8sJL.mjs.map +0 -1
- package/dist/numbers-Du__2-8Y.cjs +0 -2
- package/dist/numbers-Du__2-8Y.cjs.map +0 -1
- package/dist/objects--cO_X3EV.mjs +0 -2
- package/dist/objects--cO_X3EV.mjs.map +0 -1
- package/dist/objects-CnGoVkh6.cjs +0 -2
- package/dist/objects-CnGoVkh6.cjs.map +0 -1
- package/dist/objects-cf8j7rS8.d.cts +0 -26
- package/dist/objects-cf8j7rS8.d.mts +0 -26
- package/dist/random-D1e1NTOt.cjs +0 -2
- package/dist/random-D1e1NTOt.cjs.map +0 -1
- package/dist/random-DbidGSrQ.mjs +0 -2
- package/dist/random-DbidGSrQ.mjs.map +0 -1
- package/dist/random-DpNyGGAZ.d.cts +0 -28
- package/dist/random-DpNyGGAZ.d.mts +0 -28
- package/dist/runtime-DY-8W6Jr.mjs +0 -2
- package/dist/runtime-DY-8W6Jr.mjs.map +0 -1
- package/dist/runtime-T8Kcf7Af.d.cts +0 -28
- package/dist/runtime-T8Kcf7Af.d.mts +0 -28
- package/dist/runtime-peVFcWot.cjs +0 -2
- package/dist/runtime-peVFcWot.cjs.map +0 -1
- package/dist/strings-B0BRwNX9.mjs +0 -3
- package/dist/strings-B0BRwNX9.mjs.map +0 -1
- package/dist/strings-DV446vv-.cjs +0 -3
- package/dist/strings-DV446vv-.cjs.map +0 -1
- package/dist/strings-DhPbrpq7.d.cts +0 -47
- package/dist/strings-DhPbrpq7.d.mts +0 -47
- package/dist/time-8KLG8kBO.d.cts +0 -29
- package/dist/time-D8Wfqzu6.d.mts +0 -29
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Check if a number is an integer
|
|
3
|
+
* @param n - Number to check
|
|
4
|
+
* @returns True if number is an integer
|
|
5
|
+
* @example isInt(5) // true, isInt(5.5) // false
|
|
6
|
+
*/
|
|
7
|
+
declare const isInt: (n: number) => boolean;
|
|
8
|
+
/**
|
|
9
|
+
* Check if a number is a float (has decimal places)
|
|
10
|
+
* @param n - Number to check
|
|
11
|
+
* @returns True if number is a float
|
|
12
|
+
* @example isFloat(5.5) // true, isFloat(5) // false
|
|
13
|
+
*/
|
|
14
|
+
declare const isFloat: (n: number) => boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Check if a number is even
|
|
17
|
+
* @param n - Number to check
|
|
18
|
+
* @returns True if number is even
|
|
19
|
+
* @example isEven(4) // true, isEven(5) // false
|
|
20
|
+
*/
|
|
21
|
+
declare const isEven: (n: number) => boolean;
|
|
22
|
+
/**
|
|
23
|
+
* Check if a number is odd
|
|
24
|
+
* @param n - Number to check
|
|
25
|
+
* @returns True if number is odd
|
|
26
|
+
* @example isOdd(5) // true, isOdd(4) // false
|
|
27
|
+
*/
|
|
28
|
+
declare const isOdd: (n: number) => boolean;
|
|
29
|
+
/**
|
|
30
|
+
* Round a number to a specific number of decimal places
|
|
31
|
+
* @param value - Number to round
|
|
32
|
+
* @param decimals - Number of decimal places (default: 2)
|
|
33
|
+
* @returns Rounded number
|
|
34
|
+
* @example roundTo(3.14159, 2) // 3.14
|
|
35
|
+
*/
|
|
36
|
+
declare const roundTo: (value: number, decimals?: number) => number;
|
|
37
|
+
/**
|
|
38
|
+
* Clamp a number between min and max values
|
|
39
|
+
* @param value - Number to clamp
|
|
40
|
+
* @param min - Minimum value
|
|
41
|
+
* @param max - Maximum value
|
|
42
|
+
* @returns Clamped number
|
|
43
|
+
* @example clamp(15, 0, 10) // 10, clamp(-5, 0, 10) // 0
|
|
44
|
+
*/
|
|
45
|
+
declare const clamp: (value: number, min: number, max: number) => number;
|
|
46
|
+
/**
|
|
47
|
+
* Calculate percentage of a value relative to a total
|
|
48
|
+
* @param value - The value
|
|
49
|
+
* @param total - The total
|
|
50
|
+
* @param decimals - Number of decimal places (default: 2)
|
|
51
|
+
* @returns Percentage (0-100)
|
|
52
|
+
* @example percentage(25, 100) // 25, percentage(1, 3, 1) // 33.3
|
|
53
|
+
*/
|
|
54
|
+
declare const percentage: (value: number, total: number, decimals?: number) => number;
|
|
55
|
+
/**
|
|
56
|
+
* Calculate what value a percentage represents
|
|
57
|
+
* @param percent - Percentage (0-100)
|
|
58
|
+
* @param total - The total
|
|
59
|
+
* @returns The value
|
|
60
|
+
* @example percentageOf(25, 100) // 25, percentageOf(50, 200) // 100
|
|
61
|
+
*/
|
|
62
|
+
declare const percentageOf: (percent: number, total: number) => number;
|
|
63
|
+
/**
|
|
64
|
+
* Check if a number is within a range (inclusive)
|
|
65
|
+
* @param value - Number to check
|
|
66
|
+
* @param min - Minimum value
|
|
67
|
+
* @param max - Maximum value
|
|
68
|
+
* @returns True if value is in range
|
|
69
|
+
* @example inRange(5, 0, 10) // true, inRange(15, 0, 10) // false
|
|
70
|
+
*/
|
|
71
|
+
declare const inRange: (value: number, min: number, max: number) => boolean;
|
|
72
|
+
/**
|
|
73
|
+
* Linear interpolation between two values
|
|
74
|
+
* @param start - Start value
|
|
75
|
+
* @param end - End value
|
|
76
|
+
* @param t - Interpolation factor (0-1)
|
|
77
|
+
* @returns Interpolated value
|
|
78
|
+
* @example lerp(0, 100, 0.5) // 50, lerp(0, 100, 0.25) // 25
|
|
79
|
+
*/
|
|
80
|
+
declare const lerp: (start: number, end: number, t: number) => number;
|
|
81
|
+
/**
|
|
82
|
+
* Sum an array of numbers
|
|
83
|
+
* @param values - Numbers to sum
|
|
84
|
+
* @returns Sum of all values
|
|
85
|
+
* @example sum([1, 2, 3, 4]) // 10
|
|
86
|
+
*/
|
|
87
|
+
declare const sum: (values: number[]) => number;
|
|
88
|
+
/**
|
|
89
|
+
* Get the average (mean) of an array of numbers
|
|
90
|
+
* @param values - Numbers to average
|
|
91
|
+
* @returns Average or null if empty
|
|
92
|
+
* @example average([1, 2, 3, 4]) // 2.5
|
|
93
|
+
*/
|
|
94
|
+
declare const average: (values: number[]) => number | null;
|
|
95
|
+
declare const INT32_MAX: number;
|
|
96
|
+
declare const INT32_MIN: number;
|
|
97
|
+
declare const INT64_MAX: bigint;
|
|
98
|
+
declare const INT64_MIN: bigint;
|
|
99
|
+
/**
|
|
100
|
+
* Calculate the mean (average) of an array of numbers
|
|
101
|
+
* @param values - Numbers to calculate mean of
|
|
102
|
+
* @returns Mean or null if empty
|
|
103
|
+
* @example calculateMean([1, 2, 3, 4]) // 2.5
|
|
104
|
+
*/
|
|
105
|
+
declare const calculateMean: (values: number[]) => number | null;
|
|
106
|
+
/**
|
|
107
|
+
* Calculate the median (middle value) of an array of numbers
|
|
108
|
+
* @param values - Numbers to calculate median of
|
|
109
|
+
* @returns Median or null if empty
|
|
110
|
+
* @example calculateMedian([1, 2, 3, 4, 5]) // 3
|
|
111
|
+
*/
|
|
112
|
+
declare const calculateMedian: (values: number[]) => number | null;
|
|
113
|
+
/**
|
|
114
|
+
* Calculate the variance of an array of numbers
|
|
115
|
+
* @param values - Numbers to calculate variance of
|
|
116
|
+
* @returns Variance or null if empty
|
|
117
|
+
* @example calculateVariance([2, 4, 6, 8]) // 5
|
|
118
|
+
*/
|
|
119
|
+
declare const calculateVariance: (values: number[]) => number | null;
|
|
120
|
+
/**
|
|
121
|
+
* Calculate the standard deviation of an array of numbers
|
|
122
|
+
* @param values - Numbers to calculate standard deviation of
|
|
123
|
+
* @returns Standard deviation or null if empty
|
|
124
|
+
* @example calculateStandardDeviation([2, 4, 6, 8]) // ~2.24
|
|
125
|
+
*/
|
|
126
|
+
declare const calculateStandardDeviation: (values: number[]) => number | null;
|
|
127
|
+
/**
|
|
128
|
+
* Helper for JSON.stringify to handle BigInt serialization
|
|
129
|
+
* Converts large bigints to strings and small ones to numbers
|
|
130
|
+
* @param _ - Key (unused)
|
|
131
|
+
* @param value - Value to serialize
|
|
132
|
+
* @returns Serializable value
|
|
133
|
+
* @example JSON.stringify({big: 9007199254740992n}, bigIntSerializationHelper)
|
|
134
|
+
*/
|
|
135
|
+
declare const bigIntSerializationHelper: (_: string, value: unknown) => unknown;
|
|
136
|
+
|
|
137
|
+
declare const numbers_INT32_MAX: typeof INT32_MAX;
|
|
138
|
+
declare const numbers_INT32_MIN: typeof INT32_MIN;
|
|
139
|
+
declare const numbers_INT64_MAX: typeof INT64_MAX;
|
|
140
|
+
declare const numbers_INT64_MIN: typeof INT64_MIN;
|
|
141
|
+
declare const numbers_average: typeof average;
|
|
142
|
+
declare const numbers_bigIntSerializationHelper: typeof bigIntSerializationHelper;
|
|
143
|
+
declare const numbers_calculateMean: typeof calculateMean;
|
|
144
|
+
declare const numbers_calculateMedian: typeof calculateMedian;
|
|
145
|
+
declare const numbers_calculateStandardDeviation: typeof calculateStandardDeviation;
|
|
146
|
+
declare const numbers_calculateVariance: typeof calculateVariance;
|
|
147
|
+
declare const numbers_clamp: typeof clamp;
|
|
148
|
+
declare const numbers_inRange: typeof inRange;
|
|
149
|
+
declare const numbers_isEven: typeof isEven;
|
|
150
|
+
declare const numbers_isFloat: typeof isFloat;
|
|
151
|
+
declare const numbers_isInt: typeof isInt;
|
|
152
|
+
declare const numbers_isOdd: typeof isOdd;
|
|
153
|
+
declare const numbers_lerp: typeof lerp;
|
|
154
|
+
declare const numbers_percentage: typeof percentage;
|
|
155
|
+
declare const numbers_percentageOf: typeof percentageOf;
|
|
156
|
+
declare const numbers_roundTo: typeof roundTo;
|
|
157
|
+
declare const numbers_sum: typeof sum;
|
|
158
|
+
declare namespace numbers {
|
|
159
|
+
export {
|
|
160
|
+
numbers_INT32_MAX as INT32_MAX,
|
|
161
|
+
numbers_INT32_MIN as INT32_MIN,
|
|
162
|
+
numbers_INT64_MAX as INT64_MAX,
|
|
163
|
+
numbers_INT64_MIN as INT64_MIN,
|
|
164
|
+
numbers_average as average,
|
|
165
|
+
numbers_bigIntSerializationHelper as bigIntSerializationHelper,
|
|
166
|
+
numbers_calculateMean as calculateMean,
|
|
167
|
+
numbers_calculateMedian as calculateMedian,
|
|
168
|
+
numbers_calculateStandardDeviation as calculateStandardDeviation,
|
|
169
|
+
numbers_calculateVariance as calculateVariance,
|
|
170
|
+
numbers_clamp as clamp,
|
|
171
|
+
numbers_inRange as inRange,
|
|
172
|
+
numbers_isEven as isEven,
|
|
173
|
+
numbers_isFloat as isFloat,
|
|
174
|
+
numbers_isInt as isInt,
|
|
175
|
+
numbers_isOdd as isOdd,
|
|
176
|
+
numbers_lerp as lerp,
|
|
177
|
+
numbers_percentage as percentage,
|
|
178
|
+
numbers_percentageOf as percentageOf,
|
|
179
|
+
numbers_roundTo as roundTo,
|
|
180
|
+
numbers_sum as sum,
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export { INT32_MAX as I, isFloat as a, isEven as b, isOdd as c, clamp as d, percentageOf as e, inRange as f, average as g, INT32_MIN as h, isInt as i, INT64_MAX as j, INT64_MIN as k, lerp as l, calculateMean as m, numbers as n, calculateMedian as o, percentage as p, calculateVariance as q, roundTo as r, sum as s, calculateStandardDeviation as t, bigIntSerializationHelper as u };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var O=Object.defineProperty;var a=(n,t)=>O(n,"name",{value:t,configurable:!0});const i=a(n=>Number.isInteger(n),"isInt"),I=a(n=>!i(n),"isFloat"),u=a(n=>n%2===0,"isEven"),d=a(n=>n%2!==0,"isOdd"),l=a((n,t=2)=>{const e=10**t;return Math.round(n*e)/e},"roundTo"),m=a((n,t,e)=>Math.min(Math.max(n,t),e),"clamp"),f=a((n,t,e=2)=>t===0?0:l(n/t*100,e),"percentage"),M=a((n,t)=>n/100*t,"percentageOf"),p=a((n,t,e)=>n>=t&&n<=e,"inRange"),N=a((n,t,e)=>n+(t-n)*e,"lerp"),h=a(n=>n.reduce((t,e)=>t+e,0),"sum"),_=a(n=>s(n),"average"),b=2**31-1,T=-2147483648,E=BigInt(2)**BigInt(63)-BigInt(1),v=-(BigInt(2)**BigInt(63)),s=a(n=>n.length===0?null:n.reduce((c,r)=>c+r,0)/n.length,"calculateMean"),A=a(n=>{if(n.length===0)return null;const t=[...n].sort((r,o)=>r-o),e=Math.floor(t.length/2);if(u(t.length)){const r=t[e],o=t[e-1];return(r+o)/2}else return t.length===1?t[0]:t[e]},"calculateMedian"),g=a(n=>{if(n.length===0)return null;const t=s(n);if(typeof t!="number")return null;const e=n.map(r=>(r-t)**2);return s(e)},"calculateVariance"),B=a(n=>{const t=g(n);return typeof t!="number"?null:Math.sqrt(t)},"calculateStandardDeviation"),S=a((n,t)=>typeof t=="bigint"?t>BigInt(Number.MAX_SAFE_INTEGER)?t.toString():Number(t):t,"bigIntSerializationHelper");var X=Object.freeze({__proto__:null,INT32_MAX:b,INT32_MIN:T,INT64_MAX:E,INT64_MIN:v,average:_,bigIntSerializationHelper:S,calculateMean:s,calculateMedian:A,calculateStandardDeviation:B,calculateVariance:g,clamp:m,inRange:p,isEven:u,isFloat:I,isInt:i,isOdd:d,lerp:N,percentage:f,percentageOf:M,roundTo:l,sum:h});export{b as I,I as a,u as b,d as c,m as d,M as e,p as f,_ as g,T as h,i,E as j,v as k,N as l,s as m,X as n,A as o,f as p,g as q,l as r,h as s,B as t,S as u};
|
|
2
|
+
//# sourceMappingURL=numbers-lJ6gwIpk.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"numbers-lJ6gwIpk.mjs","sources":["../src/utils/numbers.ts"],"sourcesContent":["/**\n * Check if a number is an integer\n * @param n - Number to check\n * @returns True if number is an integer\n * @example isInt(5) // true, isInt(5.5) // false\n */\nconst isInt = (n: number): boolean => Number.isInteger(n);\n\n/**\n * Check if a number is a float (has decimal places)\n * @param n - Number to check\n * @returns True if number is a float\n * @example isFloat(5.5) // true, isFloat(5) // false\n */\nconst isFloat = (n: number): boolean => !isInt(n);\n\n/**\n * Check if a number is even\n * @param n - Number to check\n * @returns True if number is even\n * @example isEven(4) // true, isEven(5) // false\n */\nconst isEven = (n: number): boolean => n % 2 === 0;\n\n/**\n * Check if a number is odd\n * @param n - Number to check\n * @returns True if number is odd\n * @example isOdd(5) // true, isOdd(4) // false\n */\nconst isOdd = (n: number): boolean => n % 2 !== 0;\n\n/**\n * Round a number to a specific number of decimal places\n * @param value - Number to round\n * @param decimals - Number of decimal places (default: 2)\n * @returns Rounded number\n * @example roundTo(3.14159, 2) // 3.14\n */\nconst roundTo = (value: number, decimals = 2): number => {\n\tconst factor = 10 ** decimals;\n\treturn Math.round(value * factor) / factor;\n};\n\n/**\n * Clamp a number between min and max values\n * @param value - Number to clamp\n * @param min - Minimum value\n * @param max - Maximum value\n * @returns Clamped number\n * @example clamp(15, 0, 10) // 10, clamp(-5, 0, 10) // 0\n */\nconst clamp = (value: number, min: number, max: number): number => {\n\treturn Math.min(Math.max(value, min), max);\n};\n\n/**\n * Calculate percentage of a value relative to a total\n * @param value - The value\n * @param total - The total\n * @param decimals - Number of decimal places (default: 2)\n * @returns Percentage (0-100)\n * @example percentage(25, 100) // 25, percentage(1, 3, 1) // 33.3\n */\nconst percentage = (value: number, total: number, decimals = 2): number => {\n\tif (total === 0) return 0;\n\treturn roundTo((value / total) * 100, decimals);\n};\n\n/**\n * Calculate what value a percentage represents\n * @param percent - Percentage (0-100)\n * @param total - The total\n * @returns The value\n * @example percentageOf(25, 100) // 25, percentageOf(50, 200) // 100\n */\nconst percentageOf = (percent: number, total: number): number => {\n\treturn (percent / 100) * total;\n};\n\n/**\n * Check if a number is within a range (inclusive)\n * @param value - Number to check\n * @param min - Minimum value\n * @param max - Maximum value\n * @returns True if value is in range\n * @example inRange(5, 0, 10) // true, inRange(15, 0, 10) // false\n */\nconst inRange = (value: number, min: number, max: number): boolean => {\n\treturn value >= min && value <= max;\n};\n\n/**\n * Linear interpolation between two values\n * @param start - Start value\n * @param end - End value\n * @param t - Interpolation factor (0-1)\n * @returns Interpolated value\n * @example lerp(0, 100, 0.5) // 50, lerp(0, 100, 0.25) // 25\n */\nconst lerp = (start: number, end: number, t: number): number => {\n\treturn start + (end - start) * t;\n};\n\n/**\n * Sum an array of numbers\n * @param values - Numbers to sum\n * @returns Sum of all values\n * @example sum([1, 2, 3, 4]) // 10\n */\nconst sum = (values: number[]): number => {\n\treturn values.reduce((a, b) => a + b, 0);\n};\n\n/**\n * Get the average (mean) of an array of numbers\n * @param values - Numbers to average\n * @returns Average or null if empty\n * @example average([1, 2, 3, 4]) // 2.5\n */\nconst average = (values: number[]): number | null => calculateMean(values);\n\nconst INT32_MAX: number = 2 ** 31 - 1;\nconst INT32_MIN: number = -(2 ** 31);\nconst INT64_MAX: bigint = BigInt(2) ** BigInt(63) - BigInt(1);\nconst INT64_MIN: bigint = -(BigInt(2) ** BigInt(63));\n\n/**\n * Calculate the mean (average) of an array of numbers\n * @param values - Numbers to calculate mean of\n * @returns Mean or null if empty\n * @example calculateMean([1, 2, 3, 4]) // 2.5\n */\nconst calculateMean = (values: number[]): number | null => {\n\tif (values.length === 0) return null;\n\tconst sum = values.reduce((a, b) => a + b, 0);\n\tconst average = sum / values.length;\n\treturn average;\n};\n\n/**\n * Calculate the median (middle value) of an array of numbers\n * @param values - Numbers to calculate median of\n * @returns Median or null if empty\n * @example calculateMedian([1, 2, 3, 4, 5]) // 3\n */\nconst calculateMedian = (values: number[]): number | null => {\n\tif (values.length === 0) return null;\n\tconst sorted = [...values].sort((a, b) => a - b);\n\tconst middleIndex = Math.floor(sorted.length / 2);\n\tconst isEvenLength = isEven(sorted.length);\n\tif (isEvenLength) {\n\t\tconst a = sorted[middleIndex] as number;\n\t\tconst b = sorted[middleIndex - 1] as number;\n\t\tconst average = (a + b) / 2;\n\t\treturn average;\n\t} else {\n\t\tif (sorted.length === 1) return sorted[0] as number;\n\t\tconst median = sorted[middleIndex] as number;\n\t\treturn median;\n\t}\n};\n\n/**\n * Calculate the variance of an array of numbers\n * @param values - Numbers to calculate variance of\n * @returns Variance or null if empty\n * @example calculateVariance([2, 4, 6, 8]) // 5\n */\nconst calculateVariance = (values: number[]): number | null => {\n\tif (values.length === 0) return null;\n\tconst mean = calculateMean(values);\n\tif (typeof mean !== 'number') return null;\n\tconst squaredDifferences = values.map((value) => (value - mean) ** 2);\n\tconst variance = calculateMean(squaredDifferences);\n\treturn variance;\n};\n\n/**\n * Calculate the standard deviation of an array of numbers\n * @param values - Numbers to calculate standard deviation of\n * @returns Standard deviation or null if empty\n * @example calculateStandardDeviation([2, 4, 6, 8]) // ~2.24\n */\nconst calculateStandardDeviation = (values: number[]): number | null => {\n\tconst variance = calculateVariance(values);\n\tif (typeof variance !== 'number') return null;\n\treturn Math.sqrt(variance);\n};\n\n/**\n * Helper for JSON.stringify to handle BigInt serialization\n * Converts large bigints to strings and small ones to numbers\n * @param _ - Key (unused)\n * @param value - Value to serialize\n * @returns Serializable value\n * @example JSON.stringify({big: 9007199254740992n}, bigIntSerializationHelper)\n */\nconst bigIntSerializationHelper = (_: string, value: unknown): unknown =>\n\ttypeof value === 'bigint'\n\t\t? value > BigInt(Number.MAX_SAFE_INTEGER)\n\t\t\t? value.toString() // Convert large bigints to strings\n\t\t\t: Number(value) // Convert small/safe bigints to numbers\n\t\t: value; // Return other values as is\n\nexport {\n\tisInt,\n\tisFloat,\n\tisEven,\n\tisOdd,\n\troundTo,\n\tclamp,\n\tpercentage,\n\tpercentageOf,\n\tinRange,\n\tlerp,\n\tsum,\n\taverage,\n\tINT32_MAX,\n\tINT32_MIN,\n\tINT64_MAX,\n\tINT64_MIN,\n\tcalculateMean,\n\tcalculateMedian,\n\tcalculateVariance,\n\tcalculateStandardDeviation,\n\tbigIntSerializationHelper,\n};\n"],"names":["isInt","__name","isFloat","isEven","isOdd","roundTo","value","decimals","factor","clamp","min","max","percentage","total","percentageOf","percent","inRange","lerp","start","end","t","sum","values","a","b","average","calculateMean","INT32_MAX","INT32_MIN","INT64_MAX","INT64_MIN","calculateMedian","sorted","middleIndex","calculateVariance","mean","squaredDifferences","calculateStandardDeviation","variance","bigIntSerializationHelper","_"],"mappings":"+EAMA,MAAMA,EAAQC,EAAC,GAAuB,OAAO,UAAU,CAAC,EAA1C,SAQRC,EAAUD,EAAC,GAAuB,CAACD,EAAM,CAAC,EAAhC,WAQVG,EAASF,EAAC,GAAuB,EAAI,IAAM,EAAlC,UAQTG,EAAQH,EAAC,GAAuB,EAAI,IAAM,EAAlC,SASRI,EAAUJ,EAAA,CAACK,EAAeC,EAAW,IAAc,CACxD,MAAMC,EAAS,IAAMD,EACrB,OAAO,KAAK,MAAMD,EAAQE,CAAM,EAAIA,CACrC,EAHgB,WAaVC,EAAQR,EAAA,CAACK,EAAeI,EAAaC,IACnC,KAAK,IAAI,KAAK,IAAIL,EAAOI,CAAG,EAAGC,CAAG,EAD5B,SAYRC,EAAaX,EAAA,CAACK,EAAeO,EAAeN,EAAW,IACxDM,IAAU,EAAU,EACjBR,EAASC,EAAQO,EAAS,IAAKN,CAAQ,EAF5B,cAYbO,EAAeb,EAAA,CAACc,EAAiBF,IAC9BE,EAAU,IAAOF,EADL,gBAYfG,EAAUf,EAAA,CAACK,EAAeI,EAAaC,IACrCL,GAASI,GAAOJ,GAASK,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,EAAWJ,EAAkBZ,CAAM,EACzC,OAAI,OAAOgB,GAAa,SAAiB,KAClC,KAAK,KAAKA,CAAQ,CAC1B,EAJmC,8BAc7BC,EAA4BtC,EAAA,CAACuC,EAAWlC,IAC7C,OAAOA,GAAU,SACdA,EAAQ,OAAO,OAAO,gBAAgB,EACrCA,EAAM,WACN,OAAOA,CAAK,EACbA,EAL8B"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
var K=Object.defineProperty;var o=(e,n)=>K(e,"name",{value:n,configurable:!0});const a=o(e=>typeof e=="object"&&e!==null,"isObject"),O=o(e=>a(e)&&Object.keys(e).length===0,"isEmptyObject"),i=o(e=>{if(e===null||typeof e!="object")return e;if(e instanceof Date)return new Date(e.getTime());if(Array.isArray(e))return e.map(n=>i(n));if(e instanceof Object){const n={};for(const s in e)Object.hasOwn(e,s)&&(n[s]=i(e[s]));return n}return e},"deepClone"),f=o((...e)=>{const n={};for(const s of e)if(a(s))for(const t in s){if(!Object.hasOwn(s,t))continue;const c=s[t],r=n[t];a(c)&&a(r)?n[t]=f(r,c):n[t]=c}return n},"deepMerge"),p=o((e,n,s=".")=>{const t=n.split(s);let c=e;for(const r of t){if(!a(c))return;c=c[r]}return c},"getNestedValue"),k=o((e,n,s,t=".")=>{const c=n.split(t);let r=e;for(let u=0;u<c.length-1;u++){const l=c[u];a(r[l])||(r[l]={}),r=r[l]}const w=c[c.length-1];return r[w]=s,e},"setNestedValue"),d=o((e,n)=>{const s={};for(const t of n)t in e&&(s[t]=e[t]);return s},"pick"),g=o((e,n)=>{const s={...e};for(const t of n)delete s[t];return s},"omit"),y=o((e,n="")=>{const s={};for(const t in e){if(!Object.hasOwn(e,t))continue;const c=e[t],r=n?`${n}.${t}`:t;a(c)&&!Array.isArray(c)?Object.assign(s,y(c,r)):s[r]=c}return s},"flattenObject"),h=o(e=>Object.keys(e),"objectKeys"),m=o((e,n)=>{const s={};for(const t in e)Object.hasOwn(e,t)&&(s[t]=n(e[t],t));return s},"mapValues"),V=o((e,n)=>{const s={};for(const t in e)Object.hasOwn(e,t)&&(s[n(t,e[t])]=e[t]);return s},"mapKeys");var A=Object.freeze({__proto__:null,deepClone:i,deepMerge:f,flattenObject:y,getNestedValue:p,isEmptyObject:O,isObject:a,mapKeys:V,mapValues:m,objectKeys:h,omit:g,pick:d,setNestedValue:k});export{O as a,f as b,g as c,i as d,h as e,y as f,p as g,V as h,a as i,m,A as o,d as p,k as s};
|
|
2
|
+
//# sourceMappingURL=objects-VXf3mqE5.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"objects-VXf3mqE5.mjs","sources":["../src/utils/objects.ts"],"sourcesContent":["type GenericObject = Record<string, unknown>;\n\n/**\n * Check if a value is a plain object\n * @param item - Value to check\n * @returns True if value is a plain object\n * @example isObject({}) // true, isObject(null) // false\n */\nconst isObject = (item: unknown): item is GenericObject =>\n\ttypeof item === 'object' && item !== null;\n\n/**\n * Check if an object is empty (has no own properties)\n * @param item - Object to check\n * @returns True if object is empty\n * @example isEmptyObject({}) // true, isEmptyObject({a: 1}) // false\n */\nconst isEmptyObject = (item: unknown): item is GenericObject =>\n\tisObject(item) && Object.keys(item).length === 0;\n\n/**\n * Deep clone an object\n * @param obj - Object to clone\n * @returns Deep cloned copy\n * @example deepClone({a: {b: 1}}) // {a: {b: 1}} (new reference)\n */\nconst deepClone = <T>(obj: T): T => {\n\tif (obj === null || typeof obj !== 'object') return obj;\n\tif (obj instanceof Date) return new Date(obj.getTime()) as unknown as T;\n\tif (Array.isArray(obj)) {\n\t\treturn obj.map((item) => deepClone(item)) as unknown as T;\n\t}\n\tif (obj instanceof Object) {\n\t\tconst cloned = {} as T;\n\t\tfor (const key in obj) {\n\t\t\tif (Object.hasOwn(obj, key)) {\n\t\t\t\tcloned[key] = deepClone(obj[key]);\n\t\t\t}\n\t\t}\n\t\treturn cloned;\n\t}\n\treturn obj;\n};\n\n/**\n * Deep merge multiple objects\n * @param objects - Objects to merge\n * @returns Merged object\n * @example deepMerge({a: 1}, {b: 2}, {a: 3}) // {a: 3, b: 2}\n */\nconst deepMerge = <T extends GenericObject>(...objects: T[]): T => {\n\tconst result = {} as T;\n\n\tfor (const obj of objects) {\n\t\tif (!isObject(obj)) continue;\n\n\t\tfor (const key in obj) {\n\t\t\tif (!Object.hasOwn(obj, key)) continue;\n\n\t\t\tconst sourceValue = obj[key];\n\t\t\tconst targetValue = result[key];\n\n\t\t\tif (isObject(sourceValue) && isObject(targetValue)) {\n\t\t\t\tresult[key] = deepMerge(targetValue, sourceValue) as T[Extract<\n\t\t\t\t\tkeyof T,\n\t\t\t\t\tstring\n\t\t\t\t>];\n\t\t\t} else {\n\t\t\t\tresult[key] = sourceValue as T[Extract<keyof T, string>];\n\t\t\t}\n\t\t}\n\t}\n\n\treturn result;\n};\n\n/**\n * Get a nested value from an object using a path string\n * @param obj - Object to search\n * @param path - Path string (e.g., \"user.address.city\")\n * @param delimiter - Path delimiter (default: \".\")\n * @returns Value at path or undefined\n * @example getNestedValue({a: {b: {c: 1}}}, 'a.b.c') // 1\n */\nconst getNestedValue = <T = unknown>(\n\tobj: GenericObject,\n\tpath: string,\n\tdelimiter = '.'\n): T | undefined => {\n\tconst keys = path.split(delimiter);\n\tlet current: unknown = obj;\n\n\tfor (const key of keys) {\n\t\tif (!isObject(current)) return undefined;\n\t\tcurrent = current[key];\n\t}\n\n\treturn current as T;\n};\n\n/**\n * Set a nested value in an object using a path string\n * @param obj - Object to modify\n * @param path - Path string (e.g., \"user.address.city\")\n * @param value - Value to set\n * @param delimiter - Path delimiter (default: \".\")\n * @returns The modified object\n * @example setNestedValue({}, 'a.b.c', 1) // {a: {b: {c: 1}}}\n */\nconst setNestedValue = (\n\tobj: GenericObject,\n\tpath: string,\n\tvalue: unknown,\n\tdelimiter = '.'\n): GenericObject => {\n\tconst keys = path.split(delimiter);\n\tlet current: GenericObject = obj;\n\n\tfor (let i = 0; i < keys.length - 1; i++) {\n\t\tconst key = keys[i];\n\t\tif (!isObject(current[key])) {\n\t\t\tcurrent[key] = {};\n\t\t}\n\t\tcurrent = current[key] as GenericObject;\n\t}\n\n\tconst lastKey = keys[keys.length - 1];\n\tcurrent[lastKey] = value;\n\n\treturn obj;\n};\n\n/**\n * Pick specific keys from an object\n * @param obj - Source object\n * @param keys - Keys to pick\n * @returns New object with only the specified keys\n * @example pick({a: 1, b: 2, c: 3}, ['a', 'c']) // {a: 1, c: 3}\n */\nconst pick = <T extends GenericObject, K extends keyof T>(\n\tobj: T,\n\tkeys: K[]\n): Pick<T, K> => {\n\tconst result = {} as Pick<T, K>;\n\tfor (const key of keys) {\n\t\tif (key in obj) {\n\t\t\tresult[key] = obj[key];\n\t\t}\n\t}\n\treturn result;\n};\n\n/**\n * Omit specific keys from an object\n * @param obj - Source object\n * @param keys - Keys to omit\n * @returns New object without the specified keys\n * @example omit({a: 1, b: 2, c: 3}, ['b']) // {a: 1, c: 3}\n */\nconst omit = <T extends GenericObject, K extends keyof T>(\n\tobj: T,\n\tkeys: K[]\n): Omit<T, K> => {\n\tconst result = { ...obj } as T;\n\tfor (const key of keys) {\n\t\tdelete result[key];\n\t}\n\treturn result as Omit<T, K>;\n};\n\n/**\n * Flatten a nested object into a single level with dot notation keys\n * @param obj - Object to flatten\n * @param prefix - Key prefix (used internally for recursion)\n * @returns Flattened object\n * @example flattenObject({a: {b: {c: 1}}}) // {'a.b.c': 1}\n */\nconst flattenObject = (\n\tobj: GenericObject,\n\tprefix = ''\n): Record<string, unknown> => {\n\tconst result: Record<string, unknown> = {};\n\n\tfor (const key in obj) {\n\t\tif (!Object.hasOwn(obj, key)) continue;\n\n\t\tconst value = obj[key];\n\t\tconst newKey = prefix ? `${prefix}.${key}` : key;\n\n\t\tif (isObject(value) && !Array.isArray(value)) {\n\t\t\tObject.assign(result, flattenObject(value, newKey));\n\t\t} else {\n\t\t\tresult[newKey] = value;\n\t\t}\n\t}\n\n\treturn result;\n};\n\n/**\n * Get all keys from an object with proper typing\n * @param obj - Object to get keys from\n * @returns Array of keys\n * @example objectKeys({a: 1, b: 2}) // ['a', 'b'] with proper types\n */\nconst objectKeys = <T extends GenericObject>(obj: T): (keyof T)[] => {\n\treturn Object.keys(obj) as (keyof T)[];\n};\n\n/**\n * Map object values while preserving keys\n * @param obj - Object to map\n * @param fn - Mapping function\n * @returns New object with mapped values\n * @example mapValues({a: 1, b: 2}, v => v * 2) // {a: 2, b: 4}\n */\nconst mapValues = <T extends GenericObject, R>(\n\tobj: T,\n\tfn: (value: T[keyof T], key: keyof T) => R\n): Record<keyof T, R> => {\n\tconst result = {} as Record<keyof T, R>;\n\tfor (const key in obj) {\n\t\tif (Object.hasOwn(obj, key)) {\n\t\t\tresult[key] = fn(obj[key], key);\n\t\t}\n\t}\n\treturn result;\n};\n\n/**\n * Map object keys while preserving values\n * @param obj - Object to map\n * @param fn - Mapping function\n * @returns New object with mapped keys\n * @example mapKeys({a: 1, b: 2}, k => k.toUpperCase()) // {A: 1, B: 2}\n */\nconst mapKeys = <T extends GenericObject>(\n\tobj: T,\n\tfn: (key: keyof T, value: T[keyof T]) => string\n): GenericObject => {\n\tconst result: GenericObject = {};\n\tfor (const key in obj) {\n\t\tif (Object.hasOwn(obj, key)) {\n\t\t\tresult[fn(key, obj[key])] = obj[key];\n\t\t}\n\t}\n\treturn result;\n};\n\nexport {\n\tisObject,\n\tisEmptyObject,\n\tdeepClone,\n\tdeepMerge,\n\tgetNestedValue,\n\tsetNestedValue,\n\tpick,\n\tomit,\n\tflattenObject,\n\tobjectKeys,\n\tmapValues,\n\tmapKeys,\n\ttype GenericObject,\n};\n"],"names":["isObject","__name","item","isEmptyObject","deepClone","obj","cloned","key","deepMerge","objects","result","sourceValue","targetValue","getNestedValue","path","delimiter","keys","current","setNestedValue","value","i","lastKey","pick","omit","flattenObject","prefix","newKey","objectKeys","mapValues","fn","mapKeys"],"mappings":"+EAQA,MAAMA,EAAWC,EAACC,GACjB,OAAOA,GAAS,UAAYA,IAAS,KADrB,YASXC,EAAgBF,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,IACzBG,EAAOH,CAAG,EAAIsB,EAAGxB,EAAIE,CAAG,EAAGA,CAAG,GAGhC,OAAOG,CACR,EAXkB,aAoBZoB,EAAU7B,EAAA,CACfI,EACAwB,IACmB,CACnB,MAAMnB,EAAwB,CAAA,EAC9B,UAAWH,KAAOF,EACb,OAAO,OAAOA,EAAKE,CAAG,IACzBG,EAAOmB,EAAGtB,EAAKF,EAAIE,CAAG,CAAC,CAAC,EAAIF,EAAIE,CAAG,GAGrC,OAAOG,CACR,EAXgB"}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
type GenericObject = Record<string, unknown>;
|
|
2
|
+
/**
|
|
3
|
+
* Check if a value is a plain object
|
|
4
|
+
* @param item - Value to check
|
|
5
|
+
* @returns True if value is a plain object
|
|
6
|
+
* @example isObject({}) // true, isObject(null) // false
|
|
7
|
+
*/
|
|
8
|
+
declare const isObject: (item: unknown) => item is GenericObject;
|
|
9
|
+
/**
|
|
10
|
+
* Check if an object is empty (has no own properties)
|
|
11
|
+
* @param item - Object to check
|
|
12
|
+
* @returns True if object is empty
|
|
13
|
+
* @example isEmptyObject({}) // true, isEmptyObject({a: 1}) // false
|
|
14
|
+
*/
|
|
15
|
+
declare const isEmptyObject: (item: unknown) => item is GenericObject;
|
|
16
|
+
/**
|
|
17
|
+
* Deep clone an object
|
|
18
|
+
* @param obj - Object to clone
|
|
19
|
+
* @returns Deep cloned copy
|
|
20
|
+
* @example deepClone({a: {b: 1}}) // {a: {b: 1}} (new reference)
|
|
21
|
+
*/
|
|
22
|
+
declare const deepClone: <T>(obj: T) => T;
|
|
23
|
+
/**
|
|
24
|
+
* Deep merge multiple objects
|
|
25
|
+
* @param objects - Objects to merge
|
|
26
|
+
* @returns Merged object
|
|
27
|
+
* @example deepMerge({a: 1}, {b: 2}, {a: 3}) // {a: 3, b: 2}
|
|
28
|
+
*/
|
|
29
|
+
declare const deepMerge: <T extends GenericObject>(...objects: T[]) => T;
|
|
30
|
+
/**
|
|
31
|
+
* Get a nested value from an object using a path string
|
|
32
|
+
* @param obj - Object to search
|
|
33
|
+
* @param path - Path string (e.g., "user.address.city")
|
|
34
|
+
* @param delimiter - Path delimiter (default: ".")
|
|
35
|
+
* @returns Value at path or undefined
|
|
36
|
+
* @example getNestedValue({a: {b: {c: 1}}}, 'a.b.c') // 1
|
|
37
|
+
*/
|
|
38
|
+
declare const getNestedValue: <T = unknown>(obj: GenericObject, path: string, delimiter?: string) => T | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* Set a nested value in an object using a path string
|
|
41
|
+
* @param obj - Object to modify
|
|
42
|
+
* @param path - Path string (e.g., "user.address.city")
|
|
43
|
+
* @param value - Value to set
|
|
44
|
+
* @param delimiter - Path delimiter (default: ".")
|
|
45
|
+
* @returns The modified object
|
|
46
|
+
* @example setNestedValue({}, 'a.b.c', 1) // {a: {b: {c: 1}}}
|
|
47
|
+
*/
|
|
48
|
+
declare const setNestedValue: (obj: GenericObject, path: string, value: unknown, delimiter?: string) => GenericObject;
|
|
49
|
+
/**
|
|
50
|
+
* Pick specific keys from an object
|
|
51
|
+
* @param obj - Source object
|
|
52
|
+
* @param keys - Keys to pick
|
|
53
|
+
* @returns New object with only the specified keys
|
|
54
|
+
* @example pick({a: 1, b: 2, c: 3}, ['a', 'c']) // {a: 1, c: 3}
|
|
55
|
+
*/
|
|
56
|
+
declare const pick: <T extends GenericObject, K extends keyof T>(obj: T, keys: K[]) => Pick<T, K>;
|
|
57
|
+
/**
|
|
58
|
+
* Omit specific keys from an object
|
|
59
|
+
* @param obj - Source object
|
|
60
|
+
* @param keys - Keys to omit
|
|
61
|
+
* @returns New object without the specified keys
|
|
62
|
+
* @example omit({a: 1, b: 2, c: 3}, ['b']) // {a: 1, c: 3}
|
|
63
|
+
*/
|
|
64
|
+
declare const omit: <T extends GenericObject, K extends keyof T>(obj: T, keys: K[]) => Omit<T, K>;
|
|
65
|
+
/**
|
|
66
|
+
* Flatten a nested object into a single level with dot notation keys
|
|
67
|
+
* @param obj - Object to flatten
|
|
68
|
+
* @param prefix - Key prefix (used internally for recursion)
|
|
69
|
+
* @returns Flattened object
|
|
70
|
+
* @example flattenObject({a: {b: {c: 1}}}) // {'a.b.c': 1}
|
|
71
|
+
*/
|
|
72
|
+
declare const flattenObject: (obj: GenericObject, prefix?: string) => Record<string, unknown>;
|
|
73
|
+
/**
|
|
74
|
+
* Get all keys from an object with proper typing
|
|
75
|
+
* @param obj - Object to get keys from
|
|
76
|
+
* @returns Array of keys
|
|
77
|
+
* @example objectKeys({a: 1, b: 2}) // ['a', 'b'] with proper types
|
|
78
|
+
*/
|
|
79
|
+
declare const objectKeys: <T extends GenericObject>(obj: T) => (keyof T)[];
|
|
80
|
+
/**
|
|
81
|
+
* Map object values while preserving keys
|
|
82
|
+
* @param obj - Object to map
|
|
83
|
+
* @param fn - Mapping function
|
|
84
|
+
* @returns New object with mapped values
|
|
85
|
+
* @example mapValues({a: 1, b: 2}, v => v * 2) // {a: 2, b: 4}
|
|
86
|
+
*/
|
|
87
|
+
declare const mapValues: <T extends GenericObject, R>(obj: T, fn: (value: T[keyof T], key: keyof T) => R) => Record<keyof T, R>;
|
|
88
|
+
/**
|
|
89
|
+
* Map object keys while preserving values
|
|
90
|
+
* @param obj - Object to map
|
|
91
|
+
* @param fn - Mapping function
|
|
92
|
+
* @returns New object with mapped keys
|
|
93
|
+
* @example mapKeys({a: 1, b: 2}, k => k.toUpperCase()) // {A: 1, B: 2}
|
|
94
|
+
*/
|
|
95
|
+
declare const mapKeys: <T extends GenericObject>(obj: T, fn: (key: keyof T, value: T[keyof T]) => string) => GenericObject;
|
|
96
|
+
|
|
97
|
+
type objects_GenericObject = GenericObject;
|
|
98
|
+
declare const objects_deepClone: typeof deepClone;
|
|
99
|
+
declare const objects_deepMerge: typeof deepMerge;
|
|
100
|
+
declare const objects_flattenObject: typeof flattenObject;
|
|
101
|
+
declare const objects_getNestedValue: typeof getNestedValue;
|
|
102
|
+
declare const objects_isEmptyObject: typeof isEmptyObject;
|
|
103
|
+
declare const objects_isObject: typeof isObject;
|
|
104
|
+
declare const objects_mapKeys: typeof mapKeys;
|
|
105
|
+
declare const objects_mapValues: typeof mapValues;
|
|
106
|
+
declare const objects_objectKeys: typeof objectKeys;
|
|
107
|
+
declare const objects_omit: typeof omit;
|
|
108
|
+
declare const objects_pick: typeof pick;
|
|
109
|
+
declare const objects_setNestedValue: typeof setNestedValue;
|
|
110
|
+
declare namespace objects {
|
|
111
|
+
export { objects_deepClone as deepClone, objects_deepMerge as deepMerge, objects_flattenObject as flattenObject, objects_getNestedValue as getNestedValue, objects_isEmptyObject as isEmptyObject, objects_isObject as isObject, objects_mapKeys as mapKeys, objects_mapValues as mapValues, objects_objectKeys as objectKeys, objects_omit as omit, objects_pick as pick, objects_setNestedValue as setNestedValue };
|
|
112
|
+
export type { objects_GenericObject as GenericObject };
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export { isEmptyObject as a, deepMerge as b, omit as c, deepClone as d, objectKeys as e, flattenObject as f, getNestedValue as g, mapKeys as h, isObject as i, mapValues as m, objects as o, pick as p, setNestedValue as s };
|
|
116
|
+
export type { GenericObject as G };
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
type GenericObject = Record<string, unknown>;
|
|
2
|
+
/**
|
|
3
|
+
* Check if a value is a plain object
|
|
4
|
+
* @param item - Value to check
|
|
5
|
+
* @returns True if value is a plain object
|
|
6
|
+
* @example isObject({}) // true, isObject(null) // false
|
|
7
|
+
*/
|
|
8
|
+
declare const isObject: (item: unknown) => item is GenericObject;
|
|
9
|
+
/**
|
|
10
|
+
* Check if an object is empty (has no own properties)
|
|
11
|
+
* @param item - Object to check
|
|
12
|
+
* @returns True if object is empty
|
|
13
|
+
* @example isEmptyObject({}) // true, isEmptyObject({a: 1}) // false
|
|
14
|
+
*/
|
|
15
|
+
declare const isEmptyObject: (item: unknown) => item is GenericObject;
|
|
16
|
+
/**
|
|
17
|
+
* Deep clone an object
|
|
18
|
+
* @param obj - Object to clone
|
|
19
|
+
* @returns Deep cloned copy
|
|
20
|
+
* @example deepClone({a: {b: 1}}) // {a: {b: 1}} (new reference)
|
|
21
|
+
*/
|
|
22
|
+
declare const deepClone: <T>(obj: T) => T;
|
|
23
|
+
/**
|
|
24
|
+
* Deep merge multiple objects
|
|
25
|
+
* @param objects - Objects to merge
|
|
26
|
+
* @returns Merged object
|
|
27
|
+
* @example deepMerge({a: 1}, {b: 2}, {a: 3}) // {a: 3, b: 2}
|
|
28
|
+
*/
|
|
29
|
+
declare const deepMerge: <T extends GenericObject>(...objects: T[]) => T;
|
|
30
|
+
/**
|
|
31
|
+
* Get a nested value from an object using a path string
|
|
32
|
+
* @param obj - Object to search
|
|
33
|
+
* @param path - Path string (e.g., "user.address.city")
|
|
34
|
+
* @param delimiter - Path delimiter (default: ".")
|
|
35
|
+
* @returns Value at path or undefined
|
|
36
|
+
* @example getNestedValue({a: {b: {c: 1}}}, 'a.b.c') // 1
|
|
37
|
+
*/
|
|
38
|
+
declare const getNestedValue: <T = unknown>(obj: GenericObject, path: string, delimiter?: string) => T | undefined;
|
|
39
|
+
/**
|
|
40
|
+
* Set a nested value in an object using a path string
|
|
41
|
+
* @param obj - Object to modify
|
|
42
|
+
* @param path - Path string (e.g., "user.address.city")
|
|
43
|
+
* @param value - Value to set
|
|
44
|
+
* @param delimiter - Path delimiter (default: ".")
|
|
45
|
+
* @returns The modified object
|
|
46
|
+
* @example setNestedValue({}, 'a.b.c', 1) // {a: {b: {c: 1}}}
|
|
47
|
+
*/
|
|
48
|
+
declare const setNestedValue: (obj: GenericObject, path: string, value: unknown, delimiter?: string) => GenericObject;
|
|
49
|
+
/**
|
|
50
|
+
* Pick specific keys from an object
|
|
51
|
+
* @param obj - Source object
|
|
52
|
+
* @param keys - Keys to pick
|
|
53
|
+
* @returns New object with only the specified keys
|
|
54
|
+
* @example pick({a: 1, b: 2, c: 3}, ['a', 'c']) // {a: 1, c: 3}
|
|
55
|
+
*/
|
|
56
|
+
declare const pick: <T extends GenericObject, K extends keyof T>(obj: T, keys: K[]) => Pick<T, K>;
|
|
57
|
+
/**
|
|
58
|
+
* Omit specific keys from an object
|
|
59
|
+
* @param obj - Source object
|
|
60
|
+
* @param keys - Keys to omit
|
|
61
|
+
* @returns New object without the specified keys
|
|
62
|
+
* @example omit({a: 1, b: 2, c: 3}, ['b']) // {a: 1, c: 3}
|
|
63
|
+
*/
|
|
64
|
+
declare const omit: <T extends GenericObject, K extends keyof T>(obj: T, keys: K[]) => Omit<T, K>;
|
|
65
|
+
/**
|
|
66
|
+
* Flatten a nested object into a single level with dot notation keys
|
|
67
|
+
* @param obj - Object to flatten
|
|
68
|
+
* @param prefix - Key prefix (used internally for recursion)
|
|
69
|
+
* @returns Flattened object
|
|
70
|
+
* @example flattenObject({a: {b: {c: 1}}}) // {'a.b.c': 1}
|
|
71
|
+
*/
|
|
72
|
+
declare const flattenObject: (obj: GenericObject, prefix?: string) => Record<string, unknown>;
|
|
73
|
+
/**
|
|
74
|
+
* Get all keys from an object with proper typing
|
|
75
|
+
* @param obj - Object to get keys from
|
|
76
|
+
* @returns Array of keys
|
|
77
|
+
* @example objectKeys({a: 1, b: 2}) // ['a', 'b'] with proper types
|
|
78
|
+
*/
|
|
79
|
+
declare const objectKeys: <T extends GenericObject>(obj: T) => (keyof T)[];
|
|
80
|
+
/**
|
|
81
|
+
* Map object values while preserving keys
|
|
82
|
+
* @param obj - Object to map
|
|
83
|
+
* @param fn - Mapping function
|
|
84
|
+
* @returns New object with mapped values
|
|
85
|
+
* @example mapValues({a: 1, b: 2}, v => v * 2) // {a: 2, b: 4}
|
|
86
|
+
*/
|
|
87
|
+
declare const mapValues: <T extends GenericObject, R>(obj: T, fn: (value: T[keyof T], key: keyof T) => R) => Record<keyof T, R>;
|
|
88
|
+
/**
|
|
89
|
+
* Map object keys while preserving values
|
|
90
|
+
* @param obj - Object to map
|
|
91
|
+
* @param fn - Mapping function
|
|
92
|
+
* @returns New object with mapped keys
|
|
93
|
+
* @example mapKeys({a: 1, b: 2}, k => k.toUpperCase()) // {A: 1, B: 2}
|
|
94
|
+
*/
|
|
95
|
+
declare const mapKeys: <T extends GenericObject>(obj: T, fn: (key: keyof T, value: T[keyof T]) => string) => GenericObject;
|
|
96
|
+
|
|
97
|
+
type objects_GenericObject = GenericObject;
|
|
98
|
+
declare const objects_deepClone: typeof deepClone;
|
|
99
|
+
declare const objects_deepMerge: typeof deepMerge;
|
|
100
|
+
declare const objects_flattenObject: typeof flattenObject;
|
|
101
|
+
declare const objects_getNestedValue: typeof getNestedValue;
|
|
102
|
+
declare const objects_isEmptyObject: typeof isEmptyObject;
|
|
103
|
+
declare const objects_isObject: typeof isObject;
|
|
104
|
+
declare const objects_mapKeys: typeof mapKeys;
|
|
105
|
+
declare const objects_mapValues: typeof mapValues;
|
|
106
|
+
declare const objects_objectKeys: typeof objectKeys;
|
|
107
|
+
declare const objects_omit: typeof omit;
|
|
108
|
+
declare const objects_pick: typeof pick;
|
|
109
|
+
declare const objects_setNestedValue: typeof setNestedValue;
|
|
110
|
+
declare namespace objects {
|
|
111
|
+
export { objects_deepClone as deepClone, objects_deepMerge as deepMerge, objects_flattenObject as flattenObject, objects_getNestedValue as getNestedValue, objects_isEmptyObject as isEmptyObject, objects_isObject as isObject, objects_mapKeys as mapKeys, objects_mapValues as mapValues, objects_objectKeys as objectKeys, objects_omit as omit, objects_pick as pick, objects_setNestedValue as setNestedValue };
|
|
112
|
+
export type { objects_GenericObject as GenericObject };
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
export { isEmptyObject as a, deepMerge as b, omit as c, deepClone as d, objectKeys as e, flattenObject as f, getNestedValue as g, mapKeys as h, isObject as i, mapValues as m, objects as o, pick as p, setNestedValue as s };
|
|
116
|
+
export type { GenericObject as G };
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var b=Object.defineProperty;var o=(e,n)=>b(e,"name",{value:n,configurable:!0});const i=o(e=>typeof e=="object"&&e!==null,"isObject"),O=o(e=>i(e)&&Object.keys(e).length===0,"isEmptyObject"),l=o(e=>{if(e===null||typeof e!="object")return e;if(e instanceof Date)return new Date(e.getTime());if(Array.isArray(e))return e.map(n=>l(n));if(e instanceof Object){const n={};for(const s in e)Object.hasOwn(e,s)&&(n[s]=l(e[s]));return n}return e},"deepClone"),f=o((...e)=>{const n={};for(const s of e)if(i(s))for(const t in s){if(!Object.hasOwn(s,t))continue;const c=s[t],r=n[t];i(c)&&i(r)?n[t]=f(r,c):n[t]=c}return n},"deepMerge"),p=o((e,n,s=".")=>{const t=n.split(s);let c=e;for(const r of t){if(!i(c))return;c=c[r]}return c},"getNestedValue"),k=o((e,n,s,t=".")=>{const c=n.split(t);let r=e;for(let u=0;u<c.length-1;u++){const a=c[u];i(r[a])||(r[a]={}),r=r[a]}const K=c[c.length-1];return r[K]=s,e},"setNestedValue"),d=o((e,n)=>{const s={};for(const t of n)t in e&&(s[t]=e[t]);return s},"pick"),g=o((e,n)=>{const s={...e};for(const t of n)delete s[t];return s},"omit"),y=o((e,n="")=>{const s={};for(const t in e){if(!Object.hasOwn(e,t))continue;const c=e[t],r=n?`${n}.${t}`:t;i(c)&&!Array.isArray(c)?Object.assign(s,y(c,r)):s[r]=c}return s},"flattenObject"),m=o(e=>Object.keys(e),"objectKeys"),V=o((e,n)=>{const s={};for(const t in e)Object.hasOwn(e,t)&&(s[t]=n(e[t],t));return s},"mapValues"),h=o((e,n)=>{const s={};for(const t in e)Object.hasOwn(e,t)&&(s[n(t,e[t])]=e[t]);return s},"mapKeys");var j=Object.freeze({__proto__:null,deepClone:l,deepMerge:f,flattenObject:y,getNestedValue:p,isEmptyObject:O,isObject:i,mapKeys:h,mapValues:V,objectKeys:m,omit:g,pick:d,setNestedValue:k});exports.deepClone=l,exports.deepMerge=f,exports.flattenObject=y,exports.getNestedValue=p,exports.isEmptyObject=O,exports.isObject=i,exports.mapKeys=h,exports.mapValues=V,exports.objectKeys=m,exports.objects=j,exports.omit=g,exports.pick=d,exports.setNestedValue=k;
|
|
2
|
+
//# sourceMappingURL=objects-wcO6hNA8.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"objects-wcO6hNA8.cjs","sources":["../src/utils/objects.ts"],"sourcesContent":["type GenericObject = Record<string, unknown>;\n\n/**\n * Check if a value is a plain object\n * @param item - Value to check\n * @returns True if value is a plain object\n * @example isObject({}) // true, isObject(null) // false\n */\nconst isObject = (item: unknown): item is GenericObject =>\n\ttypeof item === 'object' && item !== null;\n\n/**\n * Check if an object is empty (has no own properties)\n * @param item - Object to check\n * @returns True if object is empty\n * @example isEmptyObject({}) // true, isEmptyObject({a: 1}) // false\n */\nconst isEmptyObject = (item: unknown): item is GenericObject =>\n\tisObject(item) && Object.keys(item).length === 0;\n\n/**\n * Deep clone an object\n * @param obj - Object to clone\n * @returns Deep cloned copy\n * @example deepClone({a: {b: 1}}) // {a: {b: 1}} (new reference)\n */\nconst deepClone = <T>(obj: T): T => {\n\tif (obj === null || typeof obj !== 'object') return obj;\n\tif (obj instanceof Date) return new Date(obj.getTime()) as unknown as T;\n\tif (Array.isArray(obj)) {\n\t\treturn obj.map((item) => deepClone(item)) as unknown as T;\n\t}\n\tif (obj instanceof Object) {\n\t\tconst cloned = {} as T;\n\t\tfor (const key in obj) {\n\t\t\tif (Object.hasOwn(obj, key)) {\n\t\t\t\tcloned[key] = deepClone(obj[key]);\n\t\t\t}\n\t\t}\n\t\treturn cloned;\n\t}\n\treturn obj;\n};\n\n/**\n * Deep merge multiple objects\n * @param objects - Objects to merge\n * @returns Merged object\n * @example deepMerge({a: 1}, {b: 2}, {a: 3}) // {a: 3, b: 2}\n */\nconst deepMerge = <T extends GenericObject>(...objects: T[]): T => {\n\tconst result = {} as T;\n\n\tfor (const obj of objects) {\n\t\tif (!isObject(obj)) continue;\n\n\t\tfor (const key in obj) {\n\t\t\tif (!Object.hasOwn(obj, key)) continue;\n\n\t\t\tconst sourceValue = obj[key];\n\t\t\tconst targetValue = result[key];\n\n\t\t\tif (isObject(sourceValue) && isObject(targetValue)) {\n\t\t\t\tresult[key] = deepMerge(targetValue, sourceValue) as T[Extract<\n\t\t\t\t\tkeyof T,\n\t\t\t\t\tstring\n\t\t\t\t>];\n\t\t\t} else {\n\t\t\t\tresult[key] = sourceValue as T[Extract<keyof T, string>];\n\t\t\t}\n\t\t}\n\t}\n\n\treturn result;\n};\n\n/**\n * Get a nested value from an object using a path string\n * @param obj - Object to search\n * @param path - Path string (e.g., \"user.address.city\")\n * @param delimiter - Path delimiter (default: \".\")\n * @returns Value at path or undefined\n * @example getNestedValue({a: {b: {c: 1}}}, 'a.b.c') // 1\n */\nconst getNestedValue = <T = unknown>(\n\tobj: GenericObject,\n\tpath: string,\n\tdelimiter = '.'\n): T | undefined => {\n\tconst keys = path.split(delimiter);\n\tlet current: unknown = obj;\n\n\tfor (const key of keys) {\n\t\tif (!isObject(current)) return undefined;\n\t\tcurrent = current[key];\n\t}\n\n\treturn current as T;\n};\n\n/**\n * Set a nested value in an object using a path string\n * @param obj - Object to modify\n * @param path - Path string (e.g., \"user.address.city\")\n * @param value - Value to set\n * @param delimiter - Path delimiter (default: \".\")\n * @returns The modified object\n * @example setNestedValue({}, 'a.b.c', 1) // {a: {b: {c: 1}}}\n */\nconst setNestedValue = (\n\tobj: GenericObject,\n\tpath: string,\n\tvalue: unknown,\n\tdelimiter = '.'\n): GenericObject => {\n\tconst keys = path.split(delimiter);\n\tlet current: GenericObject = obj;\n\n\tfor (let i = 0; i < keys.length - 1; i++) {\n\t\tconst key = keys[i];\n\t\tif (!isObject(current[key])) {\n\t\t\tcurrent[key] = {};\n\t\t}\n\t\tcurrent = current[key] as GenericObject;\n\t}\n\n\tconst lastKey = keys[keys.length - 1];\n\tcurrent[lastKey] = value;\n\n\treturn obj;\n};\n\n/**\n * Pick specific keys from an object\n * @param obj - Source object\n * @param keys - Keys to pick\n * @returns New object with only the specified keys\n * @example pick({a: 1, b: 2, c: 3}, ['a', 'c']) // {a: 1, c: 3}\n */\nconst pick = <T extends GenericObject, K extends keyof T>(\n\tobj: T,\n\tkeys: K[]\n): Pick<T, K> => {\n\tconst result = {} as Pick<T, K>;\n\tfor (const key of keys) {\n\t\tif (key in obj) {\n\t\t\tresult[key] = obj[key];\n\t\t}\n\t}\n\treturn result;\n};\n\n/**\n * Omit specific keys from an object\n * @param obj - Source object\n * @param keys - Keys to omit\n * @returns New object without the specified keys\n * @example omit({a: 1, b: 2, c: 3}, ['b']) // {a: 1, c: 3}\n */\nconst omit = <T extends GenericObject, K extends keyof T>(\n\tobj: T,\n\tkeys: K[]\n): Omit<T, K> => {\n\tconst result = { ...obj } as T;\n\tfor (const key of keys) {\n\t\tdelete result[key];\n\t}\n\treturn result as Omit<T, K>;\n};\n\n/**\n * Flatten a nested object into a single level with dot notation keys\n * @param obj - Object to flatten\n * @param prefix - Key prefix (used internally for recursion)\n * @returns Flattened object\n * @example flattenObject({a: {b: {c: 1}}}) // {'a.b.c': 1}\n */\nconst flattenObject = (\n\tobj: GenericObject,\n\tprefix = ''\n): Record<string, unknown> => {\n\tconst result: Record<string, unknown> = {};\n\n\tfor (const key in obj) {\n\t\tif (!Object.hasOwn(obj, key)) continue;\n\n\t\tconst value = obj[key];\n\t\tconst newKey = prefix ? `${prefix}.${key}` : key;\n\n\t\tif (isObject(value) && !Array.isArray(value)) {\n\t\t\tObject.assign(result, flattenObject(value, newKey));\n\t\t} else {\n\t\t\tresult[newKey] = value;\n\t\t}\n\t}\n\n\treturn result;\n};\n\n/**\n * Get all keys from an object with proper typing\n * @param obj - Object to get keys from\n * @returns Array of keys\n * @example objectKeys({a: 1, b: 2}) // ['a', 'b'] with proper types\n */\nconst objectKeys = <T extends GenericObject>(obj: T): (keyof T)[] => {\n\treturn Object.keys(obj) as (keyof T)[];\n};\n\n/**\n * Map object values while preserving keys\n * @param obj - Object to map\n * @param fn - Mapping function\n * @returns New object with mapped values\n * @example mapValues({a: 1, b: 2}, v => v * 2) // {a: 2, b: 4}\n */\nconst mapValues = <T extends GenericObject, R>(\n\tobj: T,\n\tfn: (value: T[keyof T], key: keyof T) => R\n): Record<keyof T, R> => {\n\tconst result = {} as Record<keyof T, R>;\n\tfor (const key in obj) {\n\t\tif (Object.hasOwn(obj, key)) {\n\t\t\tresult[key] = fn(obj[key], key);\n\t\t}\n\t}\n\treturn result;\n};\n\n/**\n * Map object keys while preserving values\n * @param obj - Object to map\n * @param fn - Mapping function\n * @returns New object with mapped keys\n * @example mapKeys({a: 1, b: 2}, k => k.toUpperCase()) // {A: 1, B: 2}\n */\nconst mapKeys = <T extends GenericObject>(\n\tobj: T,\n\tfn: (key: keyof T, value: T[keyof T]) => string\n): GenericObject => {\n\tconst result: GenericObject = {};\n\tfor (const key in obj) {\n\t\tif (Object.hasOwn(obj, key)) {\n\t\t\tresult[fn(key, obj[key])] = obj[key];\n\t\t}\n\t}\n\treturn result;\n};\n\nexport {\n\tisObject,\n\tisEmptyObject,\n\tdeepClone,\n\tdeepMerge,\n\tgetNestedValue,\n\tsetNestedValue,\n\tpick,\n\tomit,\n\tflattenObject,\n\tobjectKeys,\n\tmapValues,\n\tmapKeys,\n\ttype GenericObject,\n};\n"],"names":["isObject","__name","item","isEmptyObject","deepClone","obj","cloned","key","deepMerge","objects","result","sourceValue","targetValue","getNestedValue","path","delimiter","keys","current","setNestedValue","value","i","lastKey","pick","omit","flattenObject","prefix","newKey","objectKeys","mapValues","fn","mapKeys"],"mappings":"4FAQA,MAAMA,EAAWC,EAACC,GACjB,OAAOA,GAAS,UAAYA,IAAS,KADrB,YASXC,EAAgBF,EAACC,GACtBF,EAASE,CAAI,GAAK,OAAO,KAAKA,CAAI,EAAE,SAAW,EAD1B,iBAShBE,EAAYH,EAAII,GAAc,CACnC,GAAIA,IAAQ,MAAQ,OAAOA,GAAQ,SAAU,OAAOA,EACpD,GAAIA,aAAe,KAAM,OAAO,IAAI,KAAKA,EAAI,SAAS,EACtD,GAAI,MAAM,QAAQA,CAAG,EACpB,OAAOA,EAAI,IAAKH,GAASE,EAAUF,CA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IE,CAAG,GAGrC,OAAOG,CACR,EAXgB"}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var I=Object.defineProperty;var o=(r,n)=>I(r,"name",{value:n,configurable:!0});const s=o((r,n)=>Math.floor(Math.random()*(n-r+1))+r,"randomInt"),h=o((r,n)=>Math.random()*(n-r)+r,"randomFloat"),d=o(r=>r[Math.floor(Math.random()*r.length)],"randomItem"),u=o(r=>d(Object.keys(r)),"randomKey"),x=o(r=>d(Array.isArray(r)?r:Object.values(r)),"randomValue"),g=o(()=>Math.random()<.5,"randomBoolean"),l=o((r,n)=>{const t=typeof n=="string"?n:o((e={})=>{const m=e.useUppercase!==void 0||e.useLowercase!==void 0||e.useNumeric!==void 0;return[e.useUppercase??!m?"ABCDEFGHIJKLMNOPQRSTUVWXYZ":"",e.useLowercase??!m?"abcdefghijklmnopqrstuvwxyz":"",e.useNumeric??!m?"0123456789":""].join("")},"resolveCharactersFromOptions")(n);if(t.length===0&&r>0)throw new Error("Character set cannot be empty");return r<=0?"":Array.from({length:r}).map(()=>t.charAt(s(0,t.length-1))).join("")},"randomString"),c=o((r=16)=>l(r,"0123456789abcdef"),"randomHex"),i=o(()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,r=>{const n=Math.random()*16|0;return(r==="x"?n:n&3|8).toString(16)}),"randomUUID"),f=o((r,n)=>{if(n>r.length)throw new Error(`Cannot sample ${n} items from array of length ${r.length}`);if(n<=0)return[];const a=[],t=[...r];for(let e=0;e<n;e++){const m=s(0,t.length-1);a.push(t[m]),t.splice(m,1)}return a},"sample"),y=o((r,n)=>{if(r.length===0)return;if(r.length!==n.length)throw new Error("Items and weights arrays must have the same length");const a=n.reduce((e,m)=>e+m,0);if(a<=0)throw new Error("Total weight must be greater than 0");let t=Math.random()*a;for(let e=0;e<r.length;e++)if(t-=n[e],t<=0)return r[e];return r[r.length-1]},"weightedRandom"),p=o(r=>{const n=Object.keys(r).filter(a=>Number.isNaN(Number(a))).map(a=>r[a]);return d(n)},"randomEnum"),w=o(()=>`#${c(6)}`,"randomColor"),v=o((r,n)=>new Date(r.getTime()+Math.random()*(n.getTime()-r.getTime())),"randomDate");var M=Object.freeze({__proto__:null,randomBoolean:g,randomColor:w,randomDate:v,randomEnum:p,randomFloat:h,randomHex:c,randomInt:s,randomItem:d,randomKey:u,randomString:l,randomUUID:i,randomValue:x,sample:f,weightedRandom:y});exports.random=M,exports.randomBoolean=g,exports.randomColor=w,exports.randomDate=v,exports.randomEnum=p,exports.randomFloat=h,exports.randomHex=c,exports.randomInt=s,exports.randomItem=d,exports.randomKey=u,exports.randomString=l,exports.randomUUID=i,exports.randomValue=x,exports.sample=f,exports.weightedRandom=y;
|
|
2
|
+
//# sourceMappingURL=random-668tofPV.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"random-668tofPV.cjs","sources":["../src/utils/random.ts"],"sourcesContent":["/**\n * Generate a random integer between min and max (inclusive)\n * @param min - Minimum value\n * @param max - Maximum value\n * @returns Random integer\n * @example randomInt(1, 10) // Random integer from 1 to 10\n */\nconst randomInt = (min: number, max: number): number =>\n\tMath.floor(Math.random() * (max - min + 1)) + min;\n\n/**\n * Generate a random float between min and max\n * @param min - Minimum value\n * @param max - Maximum value\n * @returns Random float\n * @example randomFloat(1.0, 10.0) // Random float from 1.0 to 10.0\n */\nconst randomFloat = (min: number, max: number): number =>\n\tMath.random() * (max - min) + min;\n\n/**\n * Get a random item from an array\n * @param items - Array to pick from\n * @returns Random item or undefined if array is empty\n * @example randomItem([1, 2, 3]) // Could return 1, 2, or 3\n */\nconst randomItem = <T>(items: T[]): T | undefined =>\n\titems[Math.floor(Math.random() * items.length)];\n\n/**\n * Get a random key from an object or array\n * @param items - Object or array to pick from\n * @returns Random key or undefined\n * @example randomKey({a: 1, b: 2}) // Could return \"a\" or \"b\"\n */\nconst randomKey = <T>(items: Record<string, T> | T[]): string | undefined =>\n\trandomItem(Object.keys(items));\n\n/**\n * Get a random value from an object or array\n * @param items - Object or array to pick from\n * @returns Random value or undefined\n * @example randomValue({a: 1, b: 2}) // Could return 1 or 2\n */\nconst randomValue = <T>(items: Record<string, T> | T[]): T | undefined =>\n\trandomItem(Array.isArray(items) ? items : Object.values(items));\n\n/**\n * Generate a random boolean value\n * @returns Random true or false\n * @example randomBoolean() // Could return true or false with 50% probability each\n */\nconst randomBoolean = (): boolean => Math.random() < 0.5;\n\n/**\n * Generate a random string of specified length\n * @param length - Length of the string to generate\n * @param characters - Character set to use (string or options object)\n * @returns Random string\n * @example randomString(10) // Random 10-char string with uppercase, lowercase, and numbers\n * @example randomString(5, 'abc') // Random 5-char string using only 'a', 'b', 'c'\n * @example randomString(8, {useUppercase: true, useLowercase: false, useNumeric: false})\n */\nconst randomString = (\n\tlength: number,\n\tcharacters?: string | RandomStringOptions\n): string => {\n\tconst resolveCharactersFromOptions = (options: RandomStringOptions = {}) => {\n\t\t// Default to all character types if none specified\n\t\tconst hasAnyOption =\n\t\t\toptions.useUppercase !== undefined ||\n\t\t\toptions.useLowercase !== undefined ||\n\t\t\toptions.useNumeric !== undefined;\n\n\t\treturn [\n\t\t\t(options.useUppercase ?? !hasAnyOption)\n\t\t\t\t? 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'\n\t\t\t\t: '',\n\t\t\t(options.useLowercase ?? !hasAnyOption)\n\t\t\t\t? 'abcdefghijklmnopqrstuvwxyz'\n\t\t\t\t: '',\n\t\t\t(options.useNumeric ?? !hasAnyOption) ? '0123456789' : '',\n\t\t].join('');\n\t};\n\n\tconst resolvedCharacters =\n\t\ttypeof characters === 'string'\n\t\t\t? characters\n\t\t\t: resolveCharactersFromOptions(characters);\n\n\tif (resolvedCharacters.length === 0 && length > 0) {\n\t\tthrow new Error('Character set cannot be empty');\n\t}\n\n\tif (length <= 0) return '';\n\n\treturn Array.from({ length })\n\t\t.map(() =>\n\t\t\tresolvedCharacters.charAt(randomInt(0, resolvedCharacters.length - 1))\n\t\t)\n\t\t.join('');\n};\n\n/**\n * Generate a random hex string (lowercase)\n * @param length - Length of the hex string (default: 16)\n * @returns Random hex string\n * @example randomHex(8) // \"a3f5c9d1\"\n */\nconst randomHex = (length = 16): string => {\n\treturn randomString(length, '0123456789abcdef');\n};\n\n/**\n * Generate a UUID v4 (random)\n * @returns UUID string\n * @example randomUUID() // \"f47ac10b-58cc-4372-a567-0e02b2c3d479\"\n */\nconst randomUUID = (): string => {\n\treturn 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, (c) => {\n\t\tconst r = (Math.random() * 16) | 0;\n\t\tconst v = c === 'x' ? r : (r & 0x3) | 0x8;\n\t\treturn v.toString(16);\n\t});\n};\n\n/**\n * Pick N random items from an array without replacement\n * @param items - Array to sample from\n * @param count - Number of items to pick\n * @returns Array of randomly selected items\n * @example sample([1, 2, 3, 4, 5], 3) // [2, 5, 1]\n */\nconst sample = <T>(items: T[], count: number): T[] => {\n\tif (count > items.length) {\n\t\tthrow new Error(\n\t\t\t`Cannot sample ${count} items from array of length ${items.length}`\n\t\t);\n\t}\n\tif (count <= 0) return [];\n\n\tconst result: T[] = [];\n\tconst copy = [...items];\n\n\tfor (let i = 0; i < count; i++) {\n\t\tconst index = randomInt(0, copy.length - 1);\n\t\tresult.push(copy[index]);\n\t\tcopy.splice(index, 1);\n\t}\n\n\treturn result;\n};\n\n/**\n * Pick a random item with weighted probabilities\n * @param items - Array of items\n * @param weights - Array of weights (must be same length as items)\n * @returns Random item based on weights\n * @example weightedRandom(['a', 'b', 'c'], [1, 2, 3]) // 'c' is 3x more likely than 'a'\n */\nconst weightedRandom = <T>(items: T[], weights: number[]): T | undefined => {\n\tif (items.length === 0) return undefined;\n\tif (items.length !== weights.length) {\n\t\tthrow new Error('Items and weights arrays must have the same length');\n\t}\n\n\tconst totalWeight = weights.reduce((sum, weight) => sum + weight, 0);\n\tif (totalWeight <= 0) {\n\t\tthrow new Error('Total weight must be greater than 0');\n\t}\n\n\tlet random = Math.random() * totalWeight;\n\n\tfor (let i = 0; i < items.length; i++) {\n\t\trandom -= weights[i];\n\t\tif (random <= 0) {\n\t\t\treturn items[i];\n\t\t}\n\t}\n\n\t// Fallback (should never reach here)\n\treturn items[items.length - 1];\n};\n\n/**\n * Get a random enum value\n * @param enumObj - Enum object\n * @returns Random enum value\n * @example enum Color { Red, Green, Blue }; randomEnum(Color) // Color.Green\n */\nconst randomEnum = <T extends Record<string, string | number>>(\n\tenumObj: T\n): T[keyof T] => {\n\t// Filter out numeric keys (reverse mappings in numeric enums)\n\tconst enumValues = Object.keys(enumObj)\n\t\t.filter((key) => Number.isNaN(Number(key)))\n\t\t.map((key) => enumObj[key]);\n\n\treturn randomItem(enumValues as T[keyof T][]) as T[keyof T];\n};\n\n/**\n * Generate a random hex color\n * @returns Random hex color string (e.g., \"#a3f5c9\")\n * @example randomColor() // \"#a3f5c9\"\n */\nconst randomColor = (): string => {\n\treturn `#${randomHex(6)}`;\n};\n\n/**\n * Generate a random date between two dates\n * @param start - Start date\n * @param end - End date\n * @returns Random date between start and end\n * @example randomDate(new Date(2020, 0, 1), new Date(2021, 0, 1))\n */\nconst randomDate = (start: Date, end: Date): Date => {\n\treturn new Date(\n\t\tstart.getTime() + Math.random() * (end.getTime() - start.getTime())\n\t);\n};\n\ntype RandomStringOptions = {\n\tuseNumeric?: boolean;\n\tuseLowercase?: boolean;\n\tuseUppercase?: boolean;\n};\n\nexport {\n\trandomInt,\n\trandomFloat,\n\trandomItem,\n\trandomKey,\n\trandomValue,\n\trandomBoolean,\n\trandomString,\n\trandomHex,\n\trandomUUID,\n\tsample,\n\tweightedRandom,\n\trandomEnum,\n\trandomColor,\n\trandomDate,\n\ttype RandomStringOptions,\n};\n"],"names":["randomInt","__name","min","max","randomFloat","randomItem","items","randomKey","randomValue","randomBoolean","randomString","length","characters","resolvedCharacters","options","hasAnyOption","randomHex","randomUUID","c","r","sample","count","result","copy","i","index","weightedRandom","weights","totalWeight","sum","weight","random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