pythonlib 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. package/README.md +183 -0
  2. package/dist/chunk-3CSEXTA7.js +376 -0
  3. package/dist/chunk-3CSEXTA7.js.map +1 -0
  4. package/dist/chunk-HA5Y7PKO.js +680 -0
  5. package/dist/chunk-HA5Y7PKO.js.map +1 -0
  6. package/dist/chunk-IVYYI2VR.js +261 -0
  7. package/dist/chunk-IVYYI2VR.js.map +1 -0
  8. package/dist/chunk-OMQNGE6T.js +245 -0
  9. package/dist/chunk-OMQNGE6T.js.map +1 -0
  10. package/dist/chunk-P3SGIF72.js +107 -0
  11. package/dist/chunk-P3SGIF72.js.map +1 -0
  12. package/dist/chunk-PZ5AY32C.js +10 -0
  13. package/dist/chunk-PZ5AY32C.js.map +1 -0
  14. package/dist/chunk-TJFGYXBJ.js +310 -0
  15. package/dist/chunk-TJFGYXBJ.js.map +1 -0
  16. package/dist/chunk-TOI6IG3T.js +337 -0
  17. package/dist/chunk-TOI6IG3T.js.map +1 -0
  18. package/dist/chunk-UFMTN4T4.js +215 -0
  19. package/dist/chunk-UFMTN4T4.js.map +1 -0
  20. package/dist/chunk-V63LKSA3.js +423 -0
  21. package/dist/chunk-V63LKSA3.js.map +1 -0
  22. package/dist/chunk-WAONBJE5.js +236 -0
  23. package/dist/chunk-WAONBJE5.js.map +1 -0
  24. package/dist/collections-xN9Gi0TA.d.ts +113 -0
  25. package/dist/collections.d.ts +1 -0
  26. package/dist/collections.js +12 -0
  27. package/dist/collections.js.map +1 -0
  28. package/dist/datetime-DRwFAiGV.d.ts +139 -0
  29. package/dist/datetime.d.ts +1 -0
  30. package/dist/datetime.js +22 -0
  31. package/dist/datetime.js.map +1 -0
  32. package/dist/functools-St5GqpKG.d.ts +125 -0
  33. package/dist/functools.d.ts +1 -0
  34. package/dist/functools.js +32 -0
  35. package/dist/functools.js.map +1 -0
  36. package/dist/index.d.ts +624 -0
  37. package/dist/index.js +1332 -0
  38. package/dist/index.js.map +1 -0
  39. package/dist/itertools-Bj8XivI6.d.ts +138 -0
  40. package/dist/itertools.d.ts +1 -0
  41. package/dist/itertools.js +44 -0
  42. package/dist/itertools.js.map +1 -0
  43. package/dist/json-Xpk0kwSd.d.ts +77 -0
  44. package/dist/json.d.ts +1 -0
  45. package/dist/json.js +14 -0
  46. package/dist/json.js.map +1 -0
  47. package/dist/math-BrT4Aw3E.d.ts +147 -0
  48. package/dist/math.d.ts +1 -0
  49. package/dist/math.js +96 -0
  50. package/dist/math.js.map +1 -0
  51. package/dist/os-FRSJbEUH.d.ts +143 -0
  52. package/dist/os.d.ts +1 -0
  53. package/dist/os.js +58 -0
  54. package/dist/os.js.map +1 -0
  55. package/dist/random-D5S5iSV3.d.ts +72 -0
  56. package/dist/random.d.ts +1 -0
  57. package/dist/random.js +42 -0
  58. package/dist/random.js.map +1 -0
  59. package/dist/re-DSxiURqN.d.ts +148 -0
  60. package/dist/re.d.ts +1 -0
  61. package/dist/re.js +52 -0
  62. package/dist/re.js.map +1 -0
  63. package/dist/string.d.ts +166 -0
  64. package/dist/string.js +30 -0
  65. package/dist/string.js.map +1 -0
  66. package/package.json +85 -0
@@ -0,0 +1,236 @@
1
+ import {
2
+ __export
3
+ } from "./chunk-PZ5AY32C.js";
4
+
5
+ // src/random.ts
6
+ var random_exports = {};
7
+ __export(random_exports, {
8
+ betavariate: () => betavariate,
9
+ choice: () => choice,
10
+ choices: () => choices,
11
+ expovariate: () => expovariate,
12
+ gammavariate: () => gammavariate,
13
+ gauss: () => gauss,
14
+ lognormvariate: () => lognormvariate,
15
+ normalvariate: () => normalvariate,
16
+ paretovariate: () => paretovariate,
17
+ randint: () => randint,
18
+ random: () => random,
19
+ randrange: () => randrange,
20
+ sample: () => sample,
21
+ shuffle: () => shuffle,
22
+ triangular: () => triangular,
23
+ uniform: () => uniform,
24
+ vonmisesvariate: () => vonmisesvariate,
25
+ weibullvariate: () => weibullvariate
26
+ });
27
+ function random() {
28
+ return Math.random();
29
+ }
30
+ function uniform(a, b) {
31
+ return a + Math.random() * (b - a);
32
+ }
33
+ function randint(a, b) {
34
+ a = Math.floor(a);
35
+ b = Math.floor(b);
36
+ return Math.floor(Math.random() * (b - a + 1)) + a;
37
+ }
38
+ function randrange(start, stop, step = 1) {
39
+ if (stop === void 0) {
40
+ stop = start;
41
+ start = 0;
42
+ }
43
+ if (step === 0) {
44
+ throw new Error("step cannot be zero");
45
+ }
46
+ const numSteps = Math.ceil((stop - start) / step);
47
+ if (numSteps <= 0) {
48
+ throw new Error("empty range for randrange()");
49
+ }
50
+ const randomStep = Math.floor(Math.random() * numSteps);
51
+ return start + randomStep * step;
52
+ }
53
+ function choice(seq) {
54
+ if (seq.length === 0) {
55
+ throw new Error("Cannot choose from an empty sequence");
56
+ }
57
+ const index = Math.floor(Math.random() * seq.length);
58
+ return seq[index];
59
+ }
60
+ function choices(population, options) {
61
+ const k = options?.k ?? 1;
62
+ const weights = options?.weights;
63
+ if (population.length === 0) {
64
+ throw new Error("Cannot choose from an empty population");
65
+ }
66
+ if (weights) {
67
+ if (weights.length !== population.length) {
68
+ throw new Error("weights and population must have the same length");
69
+ }
70
+ const cumWeights = [];
71
+ let total = 0;
72
+ for (const w of weights) {
73
+ total += w;
74
+ cumWeights.push(total);
75
+ }
76
+ const result2 = [];
77
+ for (let i = 0; i < k; i++) {
78
+ const r = Math.random() * total;
79
+ let lo = 0;
80
+ let hi = cumWeights.length;
81
+ while (lo < hi) {
82
+ const mid = Math.floor((lo + hi) / 2);
83
+ if (r > cumWeights[mid]) {
84
+ lo = mid + 1;
85
+ } else {
86
+ hi = mid;
87
+ }
88
+ }
89
+ result2.push(population[lo]);
90
+ }
91
+ return result2;
92
+ }
93
+ const result = [];
94
+ for (let i = 0; i < k; i++) {
95
+ result.push(population[Math.floor(Math.random() * population.length)]);
96
+ }
97
+ return result;
98
+ }
99
+ function sample(population, k) {
100
+ if (k > population.length) {
101
+ throw new Error("Sample larger than population");
102
+ }
103
+ if (k < 0) {
104
+ throw new Error("Sample size cannot be negative");
105
+ }
106
+ const pool = [...population];
107
+ for (let i = 0; i < k; i++) {
108
+ const j = i + Math.floor(Math.random() * (pool.length - i));
109
+ const temp = pool[i];
110
+ pool[i] = pool[j];
111
+ pool[j] = temp;
112
+ }
113
+ return pool.slice(0, k);
114
+ }
115
+ function shuffle(x) {
116
+ for (let i = x.length - 1; i > 0; i--) {
117
+ const j = Math.floor(Math.random() * (i + 1));
118
+ const temp = x[i];
119
+ x[i] = x[j];
120
+ x[j] = temp;
121
+ }
122
+ }
123
+ function gauss(mu = 0, sigma = 1) {
124
+ let u1;
125
+ let u2;
126
+ do {
127
+ u1 = Math.random();
128
+ u2 = Math.random();
129
+ } while (u1 === 0);
130
+ const z = Math.sqrt(-2 * Math.log(u1)) * Math.cos(2 * Math.PI * u2);
131
+ return mu + z * sigma;
132
+ }
133
+ var normalvariate = gauss;
134
+ function triangular(low = 0, high = 1, mode) {
135
+ if (mode === void 0) {
136
+ mode = (low + high) / 2;
137
+ }
138
+ const u = Math.random();
139
+ const c = (mode - low) / (high - low);
140
+ if (u < c) {
141
+ return low + Math.sqrt(u * (high - low) * (mode - low));
142
+ }
143
+ return high - Math.sqrt((1 - u) * (high - low) * (high - mode));
144
+ }
145
+ function betavariate(alpha, beta) {
146
+ const y = gammavariate(alpha, 1);
147
+ if (y === 0) return 0;
148
+ return y / (y + gammavariate(beta, 1));
149
+ }
150
+ function expovariate(lambd) {
151
+ return -Math.log(1 - Math.random()) / lambd;
152
+ }
153
+ function gammavariate(alpha, beta) {
154
+ if (alpha <= 0 || beta <= 0) {
155
+ throw new Error("gammavariate: alpha and beta must be > 0");
156
+ }
157
+ if (alpha > 1) {
158
+ const d = alpha - 1 / 3;
159
+ const c = 1 / Math.sqrt(9 * d);
160
+ for (; ; ) {
161
+ let x;
162
+ let v;
163
+ do {
164
+ x = gauss();
165
+ v = 1 + c * x;
166
+ } while (v <= 0);
167
+ v = v * v * v;
168
+ const u = Math.random();
169
+ if (u < 1 - 0.0331 * (x * x) * (x * x)) {
170
+ return d * v * beta;
171
+ }
172
+ if (Math.log(u) < 0.5 * x * x + d * (1 - v + Math.log(v))) {
173
+ return d * v * beta;
174
+ }
175
+ }
176
+ } else {
177
+ const u = Math.random();
178
+ return gammavariate(1 + alpha, beta) * Math.pow(u, 1 / alpha);
179
+ }
180
+ }
181
+ function lognormvariate(mu, sigma) {
182
+ return Math.exp(gauss(mu, sigma));
183
+ }
184
+ function vonmisesvariate(mu, kappa) {
185
+ if (kappa <= 1e-6) {
186
+ return 2 * Math.PI * Math.random();
187
+ }
188
+ const s = 0.5 / kappa;
189
+ const r = s + Math.sqrt(1 + s * s);
190
+ for (; ; ) {
191
+ const u1 = Math.random();
192
+ const z = Math.cos(Math.PI * u1);
193
+ const d = z / (r + z);
194
+ const u2 = Math.random();
195
+ if (u2 < 1 - d * d || u2 <= (1 - d) * Math.exp(d)) {
196
+ const q = 1 / r;
197
+ const f = (q + z) / (1 + q * z);
198
+ const u3 = Math.random();
199
+ if (u3 > 0.5) {
200
+ return (mu + Math.acos(f)) % (2 * Math.PI);
201
+ }
202
+ return (mu - Math.acos(f)) % (2 * Math.PI);
203
+ }
204
+ }
205
+ }
206
+ function paretovariate(alpha) {
207
+ const u = 1 - Math.random();
208
+ return 1 / Math.pow(u, 1 / alpha);
209
+ }
210
+ function weibullvariate(alpha, beta) {
211
+ const u = 1 - Math.random();
212
+ return alpha * Math.pow(-Math.log(u), 1 / beta);
213
+ }
214
+
215
+ export {
216
+ random,
217
+ uniform,
218
+ randint,
219
+ randrange,
220
+ choice,
221
+ choices,
222
+ sample,
223
+ shuffle,
224
+ gauss,
225
+ normalvariate,
226
+ triangular,
227
+ betavariate,
228
+ expovariate,
229
+ gammavariate,
230
+ lognormvariate,
231
+ vonmisesvariate,
232
+ paretovariate,
233
+ weibullvariate,
234
+ random_exports
235
+ };
236
+ //# sourceMappingURL=chunk-WAONBJE5.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/random.ts"],"sourcesContent":["/**\n * Python random module for TypeScript\n *\n * Provides random number generation functions matching Python's random module.\n * Uses JavaScript's Math.random() as the underlying generator.\n *\n * Note: This is NOT cryptographically secure. For security-sensitive\n * applications, use the Web Crypto API instead.\n */\n\n// ============================================================================\n// Basic random functions\n// ============================================================================\n\n/** Return a random floating point number in the range [0.0, 1.0) */\nexport function random(): number {\n return Math.random()\n}\n\n/** Return a random floating point number N such that a <= N <= b */\nexport function uniform(a: number, b: number): number {\n return a + Math.random() * (b - a)\n}\n\n/** Return a random integer N such that a <= N <= b (inclusive) */\nexport function randint(a: number, b: number): number {\n a = Math.floor(a)\n b = Math.floor(b)\n return Math.floor(Math.random() * (b - a + 1)) + a\n}\n\n/** Return a randomly selected element from range(start, stop, step) */\nexport function randrange(start: number, stop?: number, step: number = 1): number {\n if (stop === undefined) {\n stop = start\n start = 0\n }\n if (step === 0) {\n throw new Error(\"step cannot be zero\")\n }\n\n const numSteps = Math.ceil((stop - start) / step)\n if (numSteps <= 0) {\n throw new Error(\"empty range for randrange()\")\n }\n\n const randomStep = Math.floor(Math.random() * numSteps)\n return start + randomStep * step\n}\n\n// ============================================================================\n// Sequence functions\n// ============================================================================\n\n/** Return a random element from the non-empty sequence */\nexport function choice<T>(seq: T[] | string): T | string {\n if (seq.length === 0) {\n throw new Error(\"Cannot choose from an empty sequence\")\n }\n const index = Math.floor(Math.random() * seq.length)\n return seq[index] as T | string\n}\n\n/** Return a k-length list of elements chosen from the population with replacement */\nexport function choices<T>(population: T[], options?: { weights?: number[]; k?: number }): T[] {\n const k = options?.k ?? 1\n const weights = options?.weights\n\n if (population.length === 0) {\n throw new Error(\"Cannot choose from an empty population\")\n }\n\n if (weights) {\n if (weights.length !== population.length) {\n throw new Error(\"weights and population must have the same length\")\n }\n\n // Compute cumulative weights\n const cumWeights: number[] = []\n let total = 0\n for (const w of weights) {\n total += w\n cumWeights.push(total)\n }\n\n const result: T[] = []\n for (let i = 0; i < k; i++) {\n const r = Math.random() * total\n // Binary search for the index\n let lo = 0\n let hi = cumWeights.length\n while (lo < hi) {\n const mid = Math.floor((lo + hi) / 2)\n if (r > (cumWeights[mid] as number)) {\n lo = mid + 1\n } else {\n hi = mid\n }\n }\n result.push(population[lo] as T)\n }\n return result\n }\n\n const result: T[] = []\n for (let i = 0; i < k; i++) {\n result.push(population[Math.floor(Math.random() * population.length)] as T)\n }\n return result\n}\n\n/** Return a k-length list of unique elements chosen from the population (without replacement) */\nexport function sample<T>(population: T[], k: number): T[] {\n if (k > population.length) {\n throw new Error(\"Sample larger than population\")\n }\n if (k < 0) {\n throw new Error(\"Sample size cannot be negative\")\n }\n\n // Fisher-Yates shuffle on a copy, take first k elements\n const pool = [...population]\n for (let i = 0; i < k; i++) {\n const j = i + Math.floor(Math.random() * (pool.length - i))\n const temp = pool[i] as T\n pool[i] = pool[j] as T\n pool[j] = temp\n }\n return pool.slice(0, k)\n}\n\n/** Shuffle the sequence in place */\nexport function shuffle(x: unknown[]): void {\n // Fisher-Yates shuffle\n for (let i = x.length - 1; i > 0; i--) {\n const j = Math.floor(Math.random() * (i + 1))\n const temp = x[i]\n x[i] = x[j]\n x[j] = temp\n }\n}\n\n// ============================================================================\n// Real-valued distributions\n// ============================================================================\n\n/** Gaussian distribution with mean mu and standard deviation sigma */\nexport function gauss(mu: number = 0, sigma: number = 1): number {\n // Box-Muller transform\n let u1: number\n let u2: number\n do {\n u1 = Math.random()\n u2 = Math.random()\n } while (u1 === 0)\n\n const z = Math.sqrt(-2 * Math.log(u1)) * Math.cos(2 * Math.PI * u2)\n return mu + z * sigma\n}\n\n/** Normal distribution (alias for gauss) */\nexport const normalvariate = gauss\n\n/** Triangular distribution with low, high, and mode */\nexport function triangular(low: number = 0, high: number = 1, mode?: number): number {\n if (mode === undefined) {\n mode = (low + high) / 2\n }\n\n const u = Math.random()\n const c = (mode - low) / (high - low)\n\n if (u < c) {\n return low + Math.sqrt(u * (high - low) * (mode - low))\n }\n return high - Math.sqrt((1 - u) * (high - low) * (high - mode))\n}\n\n/** Beta distribution with alpha and beta parameters */\nexport function betavariate(alpha: number, beta: number): number {\n // Use the gamma method\n const y = gammavariate(alpha, 1)\n if (y === 0) return 0\n return y / (y + gammavariate(beta, 1))\n}\n\n/** Exponential distribution with mean 1/lambd */\nexport function expovariate(lambd: number): number {\n // lambd is 1.0 divided by the desired mean\n return -Math.log(1 - Math.random()) / lambd\n}\n\n/** Gamma distribution with shape alpha and scale beta */\nexport function gammavariate(alpha: number, beta: number): number {\n // Marsaglia and Tsang's method\n if (alpha <= 0 || beta <= 0) {\n throw new Error(\"gammavariate: alpha and beta must be > 0\")\n }\n\n if (alpha > 1) {\n const d = alpha - 1 / 3\n const c = 1 / Math.sqrt(9 * d)\n for (;;) {\n let x: number\n let v: number\n do {\n x = gauss()\n v = 1 + c * x\n } while (v <= 0)\n v = v * v * v\n const u = Math.random()\n if (u < 1 - 0.0331 * (x * x) * (x * x)) {\n return d * v * beta\n }\n if (Math.log(u) < 0.5 * x * x + d * (1 - v + Math.log(v))) {\n return d * v * beta\n }\n }\n } else {\n // alpha <= 1\n const u = Math.random()\n return gammavariate(1 + alpha, beta) * Math.pow(u, 1 / alpha)\n }\n}\n\n/** Log normal distribution */\nexport function lognormvariate(mu: number, sigma: number): number {\n return Math.exp(gauss(mu, sigma))\n}\n\n/** Von Mises distribution (circular data) */\nexport function vonmisesvariate(mu: number, kappa: number): number {\n if (kappa <= 1e-6) {\n return 2 * Math.PI * Math.random()\n }\n\n const s = 0.5 / kappa\n const r = s + Math.sqrt(1 + s * s)\n\n for (;;) {\n const u1 = Math.random()\n const z = Math.cos(Math.PI * u1)\n const d = z / (r + z)\n const u2 = Math.random()\n if (u2 < 1 - d * d || u2 <= (1 - d) * Math.exp(d)) {\n const q = 1 / r\n const f = (q + z) / (1 + q * z)\n const u3 = Math.random()\n if (u3 > 0.5) {\n return (mu + Math.acos(f)) % (2 * Math.PI)\n }\n return (mu - Math.acos(f)) % (2 * Math.PI)\n }\n }\n}\n\n/** Pareto distribution */\nexport function paretovariate(alpha: number): number {\n const u = 1 - Math.random()\n return 1 / Math.pow(u, 1 / alpha)\n}\n\n/** Weibull distribution */\nexport function weibullvariate(alpha: number, beta: number): number {\n const u = 1 - Math.random()\n return alpha * Math.pow(-Math.log(u), 1 / beta)\n}\n"],"mappings":";;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAeO,SAAS,SAAiB;AAC/B,SAAO,KAAK,OAAO;AACrB;AAGO,SAAS,QAAQ,GAAW,GAAmB;AACpD,SAAO,IAAI,KAAK,OAAO,KAAK,IAAI;AAClC;AAGO,SAAS,QAAQ,GAAW,GAAmB;AACpD,MAAI,KAAK,MAAM,CAAC;AAChB,MAAI,KAAK,MAAM,CAAC;AAChB,SAAO,KAAK,MAAM,KAAK,OAAO,KAAK,IAAI,IAAI,EAAE,IAAI;AACnD;AAGO,SAAS,UAAU,OAAe,MAAe,OAAe,GAAW;AAChF,MAAI,SAAS,QAAW;AACtB,WAAO;AACP,YAAQ;AAAA,EACV;AACA,MAAI,SAAS,GAAG;AACd,UAAM,IAAI,MAAM,qBAAqB;AAAA,EACvC;AAEA,QAAM,WAAW,KAAK,MAAM,OAAO,SAAS,IAAI;AAChD,MAAI,YAAY,GAAG;AACjB,UAAM,IAAI,MAAM,6BAA6B;AAAA,EAC/C;AAEA,QAAM,aAAa,KAAK,MAAM,KAAK,OAAO,IAAI,QAAQ;AACtD,SAAO,QAAQ,aAAa;AAC9B;AAOO,SAAS,OAAU,KAA+B;AACvD,MAAI,IAAI,WAAW,GAAG;AACpB,UAAM,IAAI,MAAM,sCAAsC;AAAA,EACxD;AACA,QAAM,QAAQ,KAAK,MAAM,KAAK,OAAO,IAAI,IAAI,MAAM;AACnD,SAAO,IAAI,KAAK;AAClB;AAGO,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M,IAAI,KAAK,IAAI;AACnB,UAAM,KAAK,KAAK,OAAO;AACvB,QAAI,KAAK,IAAI,IAAI,KAAK,OAAO,IAAI,KAAK,KAAK,IAAI,CAAC,GAAG;AACjD,YAAM,IAAI,IAAI;AACd,YAAM,KAAK,IAAI,MAAM,IAAI,IAAI;AAC7B,YAAM,KAAK,KAAK,OAAO;AACvB,UAAI,KAAK,KAAK;AACZ,gBAAQ,KAAK,KAAK,KAAK,CAAC,MAAM,IAAI,KAAK;AAAA,MACzC;AACA,cAAQ,KAAK,KAAK,KAAK,CAAC,MAAM,IAAI,KAAK;AAAA,IACzC;AAAA,EACF;AACF;AAGO,SAAS,cAAc,OAAuB;AACnD,QAAM,IAAI,IAAI,KAAK,OAAO;AAC1B,SAAO,IAAI,KAAK,IAAI,GAAG,IAAI,KAAK;AAClC;AAGO,SAAS,eAAe,OAAe,MAAsB;AAClE,QAAM,IAAI,IAAI,KAAK,OAAO;AAC1B,SAAO,QAAQ,KAAK,IAAI,CAAC,KAAK,IAAI,CAAC,GAAG,IAAI,IAAI;AAChD;","names":["result"]}
@@ -0,0 +1,113 @@
1
+ /**
2
+ * Python collections module for TypeScript
3
+ *
4
+ * Provides specialized container datatypes.
5
+ */
6
+ /**
7
+ * Counter: a dict subclass for counting hashable objects
8
+ *
9
+ * Elements are stored as keys and their counts are stored as values.
10
+ */
11
+ declare class Counter<T> extends Map<T, number> {
12
+ constructor(iterable?: Iterable<T>);
13
+ /**
14
+ * Increment the count for a key
15
+ */
16
+ increment(key: T, n?: number): void;
17
+ /**
18
+ * Get the count for a key (returns 0 for missing keys)
19
+ */
20
+ get(key: T): number;
21
+ /**
22
+ * List the n most common elements and their counts
23
+ * If n is undefined, list all elements from most common to least
24
+ */
25
+ mostCommon(n?: number): [T, number][];
26
+ /**
27
+ * Iterate over elements, repeating each as many times as its count
28
+ */
29
+ elements(): Generator<T>;
30
+ /**
31
+ * Subtract counts from another iterable or Counter
32
+ */
33
+ subtract(iterable: Iterable<T> | Counter<T>): void;
34
+ /**
35
+ * Add counts from another iterable or Counter
36
+ */
37
+ update(iterable: Iterable<T> | Counter<T>): void;
38
+ /**
39
+ * Return total count of all elements
40
+ */
41
+ total(): number;
42
+ }
43
+ /**
44
+ * defaultdict: a dict that provides default values for missing keys
45
+ *
46
+ * Uses a Proxy to automatically call the factory function for missing keys.
47
+ */
48
+ declare function defaultdict<K, V>(factory: () => V): Map<K, V> & {
49
+ get(key: K): V;
50
+ };
51
+ /**
52
+ * deque: double-ended queue with O(1) append and pop from both ends
53
+ */
54
+ declare class deque<T> {
55
+ private items;
56
+ private maxlen;
57
+ constructor(iterable?: Iterable<T>, maxlen?: number);
58
+ /**
59
+ * Add element to the right end
60
+ */
61
+ append(x: T): void;
62
+ /**
63
+ * Add element to the left end
64
+ */
65
+ appendleft(x: T): void;
66
+ /**
67
+ * Remove and return element from the right end
68
+ */
69
+ pop(): T | undefined;
70
+ /**
71
+ * Remove and return element from the left end
72
+ */
73
+ popleft(): T | undefined;
74
+ /**
75
+ * Extend the right side with elements from iterable
76
+ */
77
+ extend(iterable: Iterable<T>): void;
78
+ /**
79
+ * Extend the left side with elements from iterable
80
+ */
81
+ extendleft(iterable: Iterable<T>): void;
82
+ /**
83
+ * Rotate the deque n steps to the right (negative n rotates left)
84
+ */
85
+ rotate(n?: number): void;
86
+ /**
87
+ * Remove all elements
88
+ */
89
+ clear(): void;
90
+ /**
91
+ * Number of elements
92
+ */
93
+ get length(): number;
94
+ /**
95
+ * Make iterable
96
+ */
97
+ [Symbol.iterator](): Generator<T>;
98
+ /**
99
+ * Convert to array
100
+ */
101
+ toArray(): T[];
102
+ }
103
+
104
+ type collectionsModule_Counter<T> = Counter<T>;
105
+ declare const collectionsModule_Counter: typeof Counter;
106
+ declare const collectionsModule_defaultdict: typeof defaultdict;
107
+ type collectionsModule_deque<T> = deque<T>;
108
+ declare const collectionsModule_deque: typeof deque;
109
+ declare namespace collectionsModule {
110
+ export { collectionsModule_Counter as Counter, collectionsModule_defaultdict as defaultdict, collectionsModule_deque as deque };
111
+ }
112
+
113
+ export { Counter as C, deque as a, collectionsModule as c, defaultdict as d };
@@ -0,0 +1 @@
1
+ export { C as Counter, d as defaultdict, a as deque } from './collections-xN9Gi0TA.js';
@@ -0,0 +1,12 @@
1
+ import {
2
+ Counter,
3
+ defaultdict,
4
+ deque
5
+ } from "./chunk-UFMTN4T4.js";
6
+ import "./chunk-PZ5AY32C.js";
7
+ export {
8
+ Counter,
9
+ defaultdict,
10
+ deque
11
+ };
12
+ //# sourceMappingURL=collections.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,139 @@
1
+ /**
2
+ * Python datetime module for TypeScript
3
+ *
4
+ * Provides date and time handling matching Python's datetime module.
5
+ */
6
+ declare class timedelta {
7
+ readonly days: number;
8
+ readonly seconds: number;
9
+ readonly microseconds: number;
10
+ constructor(options?: {
11
+ days?: number;
12
+ seconds?: number;
13
+ microseconds?: number;
14
+ milliseconds?: number;
15
+ minutes?: number;
16
+ hours?: number;
17
+ weeks?: number;
18
+ });
19
+ total_seconds(): number;
20
+ toString(): string;
21
+ add(other: timedelta): timedelta;
22
+ subtract(other: timedelta): timedelta;
23
+ multiply(n: number): timedelta;
24
+ static min: timedelta;
25
+ static max: timedelta;
26
+ static resolution: timedelta;
27
+ }
28
+ declare class date {
29
+ readonly year: number;
30
+ readonly month: number;
31
+ readonly day: number;
32
+ constructor(year: number, month: number, day: number);
33
+ static today(): date;
34
+ static fromtimestamp(timestamp: number): date;
35
+ static fromisoformat(dateString: string): date;
36
+ static fromordinal(ordinal: number): date;
37
+ replace(options?: {
38
+ year?: number;
39
+ month?: number;
40
+ day?: number;
41
+ }): date;
42
+ toordinal(): number;
43
+ weekday(): number;
44
+ isoweekday(): number;
45
+ isocalendar(): [number, number, number];
46
+ isoformat(): string;
47
+ strftime(format: string): string;
48
+ toString(): string;
49
+ __add__(delta: timedelta): date;
50
+ __sub__(other: date | timedelta): date | timedelta;
51
+ __lt__(other: date): boolean;
52
+ __le__(other: date): boolean;
53
+ __gt__(other: date): boolean;
54
+ __ge__(other: date): boolean;
55
+ __eq__(other: date): boolean;
56
+ static min: date;
57
+ static max: date;
58
+ static resolution: timedelta;
59
+ }
60
+ declare class time {
61
+ readonly hour: number;
62
+ readonly minute: number;
63
+ readonly second: number;
64
+ readonly microsecond: number;
65
+ readonly tzinfo: null;
66
+ constructor(hour?: number, minute?: number, second?: number, microsecond?: number);
67
+ static fromisoformat(timeString: string): time;
68
+ replace(options?: {
69
+ hour?: number;
70
+ minute?: number;
71
+ second?: number;
72
+ microsecond?: number;
73
+ }): time;
74
+ isoformat(timespec?: "auto" | "hours" | "minutes" | "seconds" | "milliseconds" | "microseconds"): string;
75
+ strftime(format: string): string;
76
+ toString(): string;
77
+ static min: time;
78
+ static max: time;
79
+ static resolution: timedelta;
80
+ }
81
+ declare class datetime extends date {
82
+ readonly hour: number;
83
+ readonly minute: number;
84
+ readonly second: number;
85
+ readonly microsecond: number;
86
+ readonly tzinfo: null;
87
+ constructor(year: number, month: number, day: number, hour?: number, minute?: number, second?: number, microsecond?: number);
88
+ static today(): datetime;
89
+ static now(): datetime;
90
+ static utcnow(): datetime;
91
+ static fromtimestamp(timestamp: number): datetime;
92
+ static utcfromtimestamp(timestamp: number): datetime;
93
+ static fromisoformat(s: string): datetime;
94
+ static combine(d: date, t: time): datetime;
95
+ static strptime(dateString: string, format: string): datetime;
96
+ replace(options?: {
97
+ year?: number;
98
+ month?: number;
99
+ day?: number;
100
+ hour?: number;
101
+ minute?: number;
102
+ second?: number;
103
+ microsecond?: number;
104
+ }): datetime;
105
+ date(): date;
106
+ time(): time;
107
+ timestamp(): number;
108
+ isoformat(sep?: string, timespec?: "auto" | "hours" | "minutes" | "seconds" | "milliseconds" | "microseconds"): string;
109
+ ctime(): string;
110
+ strftime(format: string): string;
111
+ toString(): string;
112
+ __add__(delta: timedelta): datetime;
113
+ __sub__(other: datetime | date | timedelta): datetime | timedelta;
114
+ static min: datetime;
115
+ static max: datetime;
116
+ static resolution: timedelta;
117
+ }
118
+ declare function strftime(format: string, dt: datetime): string;
119
+ declare function strptime(dateString: string, format: string): datetime;
120
+ declare const MINYEAR = 1;
121
+ declare const MAXYEAR = 9999;
122
+
123
+ declare const datetimeModule_MAXYEAR: typeof MAXYEAR;
124
+ declare const datetimeModule_MINYEAR: typeof MINYEAR;
125
+ type datetimeModule_date = date;
126
+ declare const datetimeModule_date: typeof date;
127
+ type datetimeModule_datetime = datetime;
128
+ declare const datetimeModule_datetime: typeof datetime;
129
+ declare const datetimeModule_strftime: typeof strftime;
130
+ declare const datetimeModule_strptime: typeof strptime;
131
+ type datetimeModule_time = time;
132
+ declare const datetimeModule_time: typeof time;
133
+ type datetimeModule_timedelta = timedelta;
134
+ declare const datetimeModule_timedelta: typeof timedelta;
135
+ declare namespace datetimeModule {
136
+ export { datetimeModule_MAXYEAR as MAXYEAR, datetimeModule_MINYEAR as MINYEAR, datetimeModule_date as date, datetimeModule_datetime as datetime, datetimeModule_strftime as strftime, datetimeModule_strptime as strptime, datetimeModule_time as time, datetimeModule_timedelta as timedelta };
137
+ }
138
+
139
+ export { MINYEAR as M, date as a, time as b, datetime as c, datetimeModule as d, strptime as e, MAXYEAR as f, strftime as s, timedelta as t };
@@ -0,0 +1 @@
1
+ export { f as MAXYEAR, M as MINYEAR, a as date, c as datetime, s as strftime, e as strptime, b as time, t as timedelta } from './datetime-DRwFAiGV.js';
@@ -0,0 +1,22 @@
1
+ import {
2
+ MAXYEAR,
3
+ MINYEAR,
4
+ date,
5
+ datetime,
6
+ strftime,
7
+ strptime,
8
+ time,
9
+ timedelta
10
+ } from "./chunk-HA5Y7PKO.js";
11
+ import "./chunk-PZ5AY32C.js";
12
+ export {
13
+ MAXYEAR,
14
+ MINYEAR,
15
+ date,
16
+ datetime,
17
+ strftime,
18
+ strptime,
19
+ time,
20
+ timedelta
21
+ };
22
+ //# sourceMappingURL=datetime.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
@@ -0,0 +1,125 @@
1
+ /**
2
+ * Python functools module for TypeScript
3
+ *
4
+ * Provides higher-order functions and operations on callable objects.
5
+ */
6
+ /**
7
+ * Create a partial function application
8
+ * partial(func, arg1, arg2) returns a function that calls func with arg1, arg2 prepended
9
+ *
10
+ * Example:
11
+ * const add = (a: number, b: number) => a + b
12
+ * const add5 = partial(add, 5)
13
+ * add5(3) // returns 8
14
+ */
15
+ declare function partial<T extends (...args: unknown[]) => unknown>(func: T, ...partialArgs: unknown[]): (...args: unknown[]) => ReturnType<T>;
16
+ /**
17
+ * Apply a function of two arguments cumulatively to the items of an iterable
18
+ * reduce((x, y) => x + y, [1, 2, 3, 4, 5]) returns 15
19
+ * reduce((x, y) => x + y, [1, 2, 3, 4, 5], 10) returns 25
20
+ */
21
+ declare function reduce<T, U = T>(func: (acc: U, val: T) => U, iterable: Iterable<T>, initializer?: U): U;
22
+ /**
23
+ * Simple LRU cache decorator (returns a memoized version of the function)
24
+ * Note: This is a simplified implementation that caches based on JSON-stringified arguments
25
+ *
26
+ * Example:
27
+ * const fib = lru_cache((n: number): number => n <= 1 ? n : fib(n - 1) + fib(n - 2))
28
+ */
29
+ declare function lru_cache<T extends (...args: unknown[]) => unknown>(func: T, maxsize?: number): T & {
30
+ cache_info: () => {
31
+ hits: number;
32
+ misses: number;
33
+ maxsize: number;
34
+ currsize: number;
35
+ };
36
+ cache_clear: () => void;
37
+ };
38
+ /**
39
+ * Cache decorator that caches all calls (no size limit)
40
+ * Equivalent to lru_cache(maxsize=None)
41
+ */
42
+ declare function cache<T extends (...args: unknown[]) => unknown>(func: T): T;
43
+ /**
44
+ * Return a new partial object which behaves like func called with keyword arguments
45
+ * In TypeScript, we simulate this with an options object as the last argument
46
+ */
47
+ declare function partialmethod<T extends (...args: unknown[]) => unknown>(func: T, ...partialArgs: unknown[]): (...args: unknown[]) => ReturnType<T>;
48
+ /**
49
+ * Transform a function into a single-dispatch generic function
50
+ * This is a simplified version - full singledispatch would require runtime type checking
51
+ */
52
+ declare function singledispatch<T extends (...args: unknown[]) => unknown>(func: T): T & {
53
+ register: (type: string, impl: T) => void;
54
+ };
55
+ /**
56
+ * Decorator to update a wrapper function to look like the wrapped function
57
+ * In TypeScript, this just returns the wrapper as-is (metadata is handled differently)
58
+ */
59
+ declare function wraps<T extends (...args: unknown[]) => unknown>(wrapped: T): (wrapper: (...args: unknown[]) => unknown) => T;
60
+ /**
61
+ * Return a callable object that fetches attr from its operand
62
+ * attrgetter('name') returns a function that gets the 'name' attribute
63
+ */
64
+ declare function attrgetter<T>(...attrs: string[]): (obj: unknown) => T | T[];
65
+ /**
66
+ * Return a callable object that fetches item from its operand
67
+ * itemgetter(1) returns a function that gets index 1
68
+ * itemgetter('key') returns a function that gets the 'key' property
69
+ */
70
+ declare function itemgetter<T>(...items: (string | number)[]): (obj: unknown) => T | T[];
71
+ /**
72
+ * Return a callable object that calls the method name on its operand
73
+ * methodcaller('split', ' ') returns a function that calls .split(' ')
74
+ */
75
+ declare function methodcaller(name: string, ...args: unknown[]): (obj: unknown) => unknown;
76
+ /**
77
+ * Return the same object passed in (identity function)
78
+ */
79
+ declare function identity<T>(x: T): T;
80
+ /**
81
+ * Compare two objects for ordering (returns -1, 0, or 1)
82
+ * Used for sorting with a key function
83
+ */
84
+ declare function cmp_to_key<T>(mycmp: (a: T, b: T) => number): (x: T) => {
85
+ value: T;
86
+ __lt__: (other: {
87
+ value: T;
88
+ }) => boolean;
89
+ };
90
+ /**
91
+ * Return total ordering for a class that has __lt__, __le__, __gt__, or __ge__
92
+ * This is typically used as a class decorator in Python
93
+ * In TypeScript, we provide helper comparisons
94
+ */
95
+ declare function total_ordering<T extends {
96
+ __lt__?: (other: T) => boolean;
97
+ __le__?: (other: T) => boolean;
98
+ __gt__?: (other: T) => boolean;
99
+ __ge__?: (other: T) => boolean;
100
+ __eq__?: (other: T) => boolean;
101
+ }>(obj: T): T & {
102
+ __lt__: (other: T) => boolean;
103
+ __le__: (other: T) => boolean;
104
+ __gt__: (other: T) => boolean;
105
+ __ge__: (other: T) => boolean;
106
+ };
107
+
108
+ declare const functoolsModule_attrgetter: typeof attrgetter;
109
+ declare const functoolsModule_cache: typeof cache;
110
+ declare const functoolsModule_cmp_to_key: typeof cmp_to_key;
111
+ declare const functoolsModule_identity: typeof identity;
112
+ declare const functoolsModule_itemgetter: typeof itemgetter;
113
+ declare const functoolsModule_lru_cache: typeof lru_cache;
114
+ declare const functoolsModule_methodcaller: typeof methodcaller;
115
+ declare const functoolsModule_partial: typeof partial;
116
+ declare const functoolsModule_partialmethod: typeof partialmethod;
117
+ declare const functoolsModule_reduce: typeof reduce;
118
+ declare const functoolsModule_singledispatch: typeof singledispatch;
119
+ declare const functoolsModule_total_ordering: typeof total_ordering;
120
+ declare const functoolsModule_wraps: typeof wraps;
121
+ declare namespace functoolsModule {
122
+ export { functoolsModule_attrgetter as attrgetter, functoolsModule_cache as cache, functoolsModule_cmp_to_key as cmp_to_key, functoolsModule_identity as identity, functoolsModule_itemgetter as itemgetter, functoolsModule_lru_cache as lru_cache, functoolsModule_methodcaller as methodcaller, functoolsModule_partial as partial, functoolsModule_partialmethod as partialmethod, functoolsModule_reduce as reduce, functoolsModule_singledispatch as singledispatch, functoolsModule_total_ordering as total_ordering, functoolsModule_wraps as wraps };
123
+ }
124
+
125
+ export { partialmethod as a, attrgetter as b, cache as c, identity as d, cmp_to_key as e, functoolsModule as f, itemgetter as i, lru_cache as l, methodcaller as m, partial as p, reduce as r, singledispatch as s, total_ordering as t, wraps as w };