pythonlib 0.1.0 → 0.2.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 (64) hide show
  1. package/README.md +41 -138
  2. package/dist/{chunk-3CSEXTA7.js → chunk-4QG3772L.js} +53 -53
  3. package/dist/chunk-4QG3772L.js.map +1 -0
  4. package/dist/{chunk-OMQNGE6T.js → chunk-4SZT4HJI.js} +32 -27
  5. package/dist/chunk-4SZT4HJI.js.map +1 -0
  6. package/dist/{chunk-IVYYI2VR.js → chunk-6POEDI34.js} +1 -1
  7. package/dist/chunk-6POEDI34.js.map +1 -0
  8. package/dist/{chunk-P3SGIF72.js → chunk-6VQ7ITWO.js} +6 -6
  9. package/dist/chunk-6VQ7ITWO.js.map +1 -0
  10. package/dist/{chunk-V63LKSA3.js → chunk-7TH4FCVQ.js} +24 -24
  11. package/dist/chunk-7TH4FCVQ.js.map +1 -0
  12. package/dist/{chunk-TJFGYXBJ.js → chunk-BDBX5BG4.js} +63 -61
  13. package/dist/chunk-BDBX5BG4.js.map +1 -0
  14. package/dist/{chunk-WAONBJE5.js → chunk-H76SKASU.js} +36 -36
  15. package/dist/chunk-H76SKASU.js.map +1 -0
  16. package/dist/{chunk-TOI6IG3T.js → chunk-HQ42WNKZ.js} +43 -16
  17. package/dist/chunk-HQ42WNKZ.js.map +1 -0
  18. package/dist/{chunk-HA5Y7PKO.js → chunk-KRRY534Q.js} +36 -35
  19. package/dist/chunk-KRRY534Q.js.map +1 -0
  20. package/dist/{chunk-UFMTN4T4.js → chunk-XGT3VOIZ.js} +5 -5
  21. package/dist/chunk-XGT3VOIZ.js.map +1 -0
  22. package/dist/{collections-xN9Gi0TA.d.ts → collections-CJur5Wg-.d.ts} +5 -3
  23. package/dist/collections.d.ts +1 -1
  24. package/dist/collections.js +1 -1
  25. package/dist/{datetime-DRwFAiGV.d.ts → datetime-Bpce8gG2.d.ts} +17 -15
  26. package/dist/datetime.d.ts +1 -1
  27. package/dist/datetime.js +1 -1
  28. package/dist/{functools-St5GqpKG.d.ts → functools-NrsZAqJk.d.ts} +42 -26
  29. package/dist/functools.d.ts +1 -1
  30. package/dist/functools.js +19 -17
  31. package/dist/index.d.ts +56 -158
  32. package/dist/index.js +45 -137
  33. package/dist/index.js.map +1 -1
  34. package/dist/{itertools-Bj8XivI6.d.ts → itertools-Sjl1LB_0.d.ts} +35 -17
  35. package/dist/itertools.d.ts +1 -1
  36. package/dist/itertools.js +15 -11
  37. package/dist/{json-Xpk0kwSd.d.ts → json-DAlvCadU.d.ts} +7 -5
  38. package/dist/json.d.ts +1 -1
  39. package/dist/json.js +1 -1
  40. package/dist/{math-BrT4Aw3E.d.ts → math-DwEGjjQ-.d.ts} +2 -0
  41. package/dist/math.d.ts +1 -1
  42. package/dist/math.js +1 -1
  43. package/dist/{os-FRSJbEUH.d.ts → os-C6Nt7Ijx.d.ts} +45 -42
  44. package/dist/os.d.ts +1 -1
  45. package/dist/os.js +23 -23
  46. package/dist/{random-D5S5iSV3.d.ts → random-BJv_rSpL.d.ts} +24 -22
  47. package/dist/random.d.ts +1 -1
  48. package/dist/random.js +21 -21
  49. package/dist/{re-DSxiURqN.d.ts → re-B1CHCgyr.d.ts} +17 -15
  50. package/dist/re.d.ts +1 -1
  51. package/dist/re.js +7 -7
  52. package/dist/string.d.ts +51 -48
  53. package/dist/string.js +13 -13
  54. package/package.json +20 -3
  55. package/dist/chunk-3CSEXTA7.js.map +0 -1
  56. package/dist/chunk-HA5Y7PKO.js.map +0 -1
  57. package/dist/chunk-IVYYI2VR.js.map +0 -1
  58. package/dist/chunk-OMQNGE6T.js.map +0 -1
  59. package/dist/chunk-P3SGIF72.js.map +0 -1
  60. package/dist/chunk-TJFGYXBJ.js.map +0 -1
  61. package/dist/chunk-TOI6IG3T.js.map +0 -1
  62. package/dist/chunk-UFMTN4T4.js.map +0 -1
  63. package/dist/chunk-V63LKSA3.js.map +0 -1
  64. package/dist/chunk-WAONBJE5.js.map +0 -1
package/README.md CHANGED
@@ -1,24 +1,28 @@
1
1
  # pythonlib
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/pythonlib.svg)](https://www.npmjs.com/package/pythonlib)
4
+ [![npm downloads](https://img.shields.io/npm/dm/pythonlib.svg)](https://www.npmjs.com/package/pythonlib)
5
+ [![Bundle Size](https://img.shields.io/bundlephobia/minzip/pythonlib)](https://bundlephobia.com/package/pythonlib)
6
+ [![TypeScript](https://img.shields.io/badge/TypeScript-5.6-blue.svg)](https://www.typescriptlang.org/)
4
7
  [![License](https://img.shields.io/npm/l/pythonlib.svg)](https://github.com/sebastian-software/python2ts/blob/main/LICENSE)
5
8
 
6
- **Python standard library for TypeScript** — itertools, functools, collections, and more.
9
+ **Python's powerful standard library, TypeScript's familiar style** — itertools, functools,
10
+ collections, and more.
7
11
 
8
- Zero dependencies. Full TypeScript support. Tree-shakeable.
12
+ > Zero dependencies · Full TypeScript support · Tree-shakeable · camelCase API · Works everywhere JS
13
+ > runs
9
14
 
10
- ## Installation
15
+ ## Quick Start
11
16
 
12
17
  ```bash
13
18
  npm install pythonlib
14
19
  ```
15
20
 
16
- ## Quick Start
17
-
18
21
  ```typescript
19
- import { range, enumerate, sorted, len } from "pythonlib"
22
+ import { range, enumerate, sorted } from "pythonlib"
20
23
  import { combinations } from "pythonlib/itertools"
21
24
  import { Counter } from "pythonlib/collections"
25
+ import { lruCache } from "pythonlib/functools"
22
26
 
23
27
  // Python-style iteration
24
28
  for (const i of range(10)) {
@@ -32,152 +36,51 @@ for (const combo of combinations([1, 2, 3], 2)) {
32
36
 
33
37
  // Count occurrences
34
38
  const counter = new Counter("mississippi")
35
- console.log(counter.mostCommon(2)) // [["i", 4], ["s", 4]]
36
- ```
37
-
38
- ## Import Structure
39
-
40
- pythonlib uses subpath exports for tree-shakeable imports:
41
-
42
- | Import Path | Contents |
43
- | ----------------------- | -------------------------------------------------- |
44
- | `pythonlib` | Builtins: `len`, `range`, `sorted`, `enumerate` |
45
- | `pythonlib/itertools` | `chain`, `combinations`, `permutations`, `product` |
46
- | `pythonlib/functools` | `partial`, `reduce`, `lru_cache`, `cache` |
47
- | `pythonlib/collections` | `Counter`, `defaultdict`, `deque` |
48
- | `pythonlib/math` | `sqrt`, `floor`, `ceil`, `factorial`, `pi`, `e` |
49
- | `pythonlib/random` | `randint`, `choice`, `shuffle`, `sample` |
50
- | `pythonlib/datetime` | `datetime`, `date`, `time`, `timedelta` |
51
- | `pythonlib/json` | `loads`, `dumps`, `load`, `dump` |
52
- | `pythonlib/re` | `search`, `match`, `findall`, `sub`, `compile` |
53
- | `pythonlib/os` | `path`, `getcwd`, `sep` |
54
- | `pythonlib/string` | `Template`, `capwords`, `ascii_lowercase` |
55
-
56
- ## Modules
57
-
58
- ### Builtins
59
-
60
- ```typescript
61
- import { range, enumerate, zip, len, sorted, reversed, sum, min, max } from "pythonlib"
62
-
63
- for (const i of range(5)) {
64
- } // 0, 1, 2, 3, 4
65
- for (const i of range(1, 5)) {
66
- } // 1, 2, 3, 4
67
- for (const i of range(0, 10, 2)) {
68
- } // 0, 2, 4, 6, 8
69
-
70
- for (const [i, v] of enumerate(["a", "b", "c"])) {
71
- } // [0,"a"], [1,"b"], [2,"c"]
72
- for (const [a, b] of zip([1, 2], ["x", "y"])) {
73
- } // [1,"x"], [2,"y"]
74
-
75
- len([1, 2, 3]) // 3
76
- sorted([3, 1, 2]) // [1, 2, 3]
77
- reversed([1, 2, 3]) // [3, 2, 1]
78
- sum([1, 2, 3]) // 6
79
- min([1, 2, 3]) // 1
80
- max([1, 2, 3]) // 3
81
- ```
82
-
83
- ### itertools
84
-
85
- ```typescript
86
- import { chain, combinations, permutations, product, groupby } from "pythonlib/itertools"
39
+ counter.mostCommon(2) // [["i", 4], ["s", 4]]
87
40
 
88
- chain([1, 2], [3, 4]) // [1, 2, 3, 4]
89
- combinations([1, 2, 3], 2) // [[1,2], [1,3], [2,3]]
90
- permutations([1, 2, 3], 2) // [[1,2], [1,3], [2,1], [2,3], [3,1], [3,2]]
91
- product([1, 2], ["a", "b"]) // [[1,"a"], [1,"b"], [2,"a"], [2,"b"]]
41
+ // Memoization
42
+ const fib = lruCache((n: number): number => (n <= 1 ? n : fib(n - 1) + fib(n - 2)))
92
43
  ```
93
44
 
94
- ### functools
45
+ ## Available Modules
95
46
 
96
- ```typescript
97
- import { partial, reduce, lru_cache } from "pythonlib/functools"
47
+ | Import Path | Contents | API Docs |
48
+ | ----------------------- | -------------------------------------------------- | ------------------------------------------------------------------------ |
49
+ | `pythonlib` | Builtins: `len`, `range`, `sorted`, `enumerate`... | [→](https://sebastian-software.github.io/python2ts/docs/api/index) |
50
+ | `pythonlib/itertools` | `chain`, `combinations`, `zipLongest`, `takeWhile` | [→](https://sebastian-software.github.io/python2ts/docs/api/itertools) |
51
+ | `pythonlib/functools` | `partial`, `reduce`, `lruCache`, `pipe` | [→](https://sebastian-software.github.io/python2ts/docs/api/functools) |
52
+ | `pythonlib/collections` | `Counter`, `defaultdict`, `deque` | [→](https://sebastian-software.github.io/python2ts/docs/api/collections) |
53
+ | `pythonlib/math` | `sqrt`, `floor`, `ceil`, `factorial`, `pi`, `e` | [→](https://sebastian-software.github.io/python2ts/docs/api/math) |
54
+ | `pythonlib/random` | `randInt`, `choice`, `shuffle`, `sample` | [→](https://sebastian-software.github.io/python2ts/docs/api/random) |
55
+ | `pythonlib/datetime` | `datetime`, `date`, `time`, `timedelta` | [→](https://sebastian-software.github.io/python2ts/docs/api/datetime) |
56
+ | `pythonlib/json` | `loads`, `dumps` | [→](https://sebastian-software.github.io/python2ts/docs/api/json) |
57
+ | `pythonlib/re` | `search`, `match`, `findAll`, `sub`, `compile` | [→](https://sebastian-software.github.io/python2ts/docs/api/re) |
58
+ | `pythonlib/string` | `Template`, `capWords`, `asciiLowercase` | [→](https://sebastian-software.github.io/python2ts/docs/api/string) |
98
59
 
99
- const add5 = partial((a, b) => a + b, 5)
100
- add5(3) // 8
60
+ > All function names use **camelCase** to feel native in TypeScript.
101
61
 
102
- reduce((a, b) => a + b, [1, 2, 3, 4, 5]) // 15
62
+ ## Documentation
103
63
 
104
- const cached = lru_cache((n: number) => expensiveComputation(n))
105
- cached(5) // computes
106
- cached(5) // returns cached result
107
- ```
64
+ **[📚 View Full Documentation](https://sebastian-software.github.io/python2ts/)**
108
65
 
109
- ### collections
66
+ | Resource | Description |
67
+ | ------------------------------------------------------------------------------ | ------------------------------------------- |
68
+ | [Homepage](https://sebastian-software.github.io/python2ts/) | Project overview, features, and quick start |
69
+ | [Runtime Guide](https://sebastian-software.github.io/python2ts/docs/runtime) | How to use pythonlib in your projects |
70
+ | [API Reference](https://sebastian-software.github.io/python2ts/docs/api) | Complete API documentation for all modules |
71
+ | [Syntax Reference](https://sebastian-software.github.io/python2ts/docs/syntax) | Python → TypeScript transformation rules |
110
72
 
111
- ```typescript
112
- import { Counter, defaultdict, deque } from "pythonlib/collections"
113
-
114
- const counter = new Counter("abracadabra")
115
- counter.get("a") // 5
116
- counter.mostCommon(2) // [["a", 5], ["b", 2]]
117
-
118
- const dd = defaultdict(() => [])
119
- dd.get("key").push(1) // auto-creates array
120
-
121
- const d = new deque([1, 2, 3])
122
- d.appendleft(0) // [0, 1, 2, 3]
123
- d.pop() // 3
124
- ```
73
+ ## Runtime Support
125
74
 
126
- ### datetime
75
+ Tested on every commit: **Node.js** (v22, v24) · **Bun** · **Deno** · **Browsers**
127
76
 
128
- ```typescript
129
- import { datetime, date, timedelta } from "pythonlib/datetime"
130
-
131
- const now = datetime.now()
132
- now.strftime("%Y-%m-%d %H:%M:%S")
133
-
134
- const d = new date(2024, 6, 15)
135
- d.isoformat() // "2024-06-15"
136
-
137
- const delta = new timedelta({ days: 7 })
138
- delta.total_seconds() // 604800
139
- ```
140
-
141
- ### re
142
-
143
- ```typescript
144
- import { search, findall, sub, compile } from "pythonlib/re"
145
-
146
- const m = search("(?P<name>\\w+)@(?P<domain>\\w+)", "user@example")
147
- m?.group("name") // "user"
148
- m?.groupdict() // { name: "user", domain: "example" }
149
-
150
- findall("\\d+", "a1b2c3") // ["1", "2", "3"]
151
- sub("\\d", "X", "a1b2") // "aXbX"
152
- ```
153
-
154
- ### math
155
-
156
- ```typescript
157
- import { sqrt, factorial, gcd, lcm, pi, e } from "pythonlib/math"
158
-
159
- sqrt(16) // 4
160
- factorial(5) // 120
161
- gcd(12, 8) // 4
162
- lcm(4, 6) // 12
163
- ```
164
-
165
- ### random
166
-
167
- ```typescript
168
- import { randint, choice, shuffle, sample } from "pythonlib/random"
169
-
170
- randint(1, 10) // random integer 1-10
171
- choice(["a", "b", "c"]) // random element
172
- shuffle([1, 2, 3]) // shuffles in place
173
- sample([1, 2, 3, 4, 5], 3) // 3 unique random elements
174
- ```
77
+ Also works in Cloudflare Workers, AWS Lambda, and other JS environments.
175
78
 
176
79
  ## Related
177
80
 
178
- - [python2ts](https://www.npmjs.com/package/python2ts) — Transpile Python to TypeScript (uses
179
- pythonlib as runtime)
81
+ - [**python2ts**](https://www.npmjs.com/package/python2ts) — Transpile Python to TypeScript
82
+ - [**GitHub**](https://github.com/sebastian-software/python2ts) — Source code and issue tracker
180
83
 
181
84
  ## License
182
85
 
183
- MIT
86
+ MIT © [Sebastian Software GmbH](https://sebastian-software.de)
@@ -2,15 +2,15 @@
2
2
  function escapeRegex(str) {
3
3
  return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
4
4
  }
5
- var ascii_lowercase = "abcdefghijklmnopqrstuvwxyz";
6
- var ascii_uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
7
- var ascii_letters = ascii_lowercase + ascii_uppercase;
5
+ var asciiLowercase = "abcdefghijklmnopqrstuvwxyz";
6
+ var asciiUppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
7
+ var asciiLetters = asciiLowercase + asciiUppercase;
8
8
  var digits = "0123456789";
9
- var hexdigits = "0123456789abcdefABCDEF";
10
- var octdigits = "01234567";
9
+ var hexDigits = "0123456789abcdefABCDEF";
10
+ var octDigits = "01234567";
11
11
  var punctuation = "!\"#$%&'()*+,-./:;<=>?@[\\]^_`{|}~";
12
12
  var whitespace = " \n\r\v\f";
13
- var printable = digits + ascii_letters + punctuation + whitespace;
13
+ var printable = digits + asciiLetters + punctuation + whitespace;
14
14
  var Template = class {
15
15
  template;
16
16
  constructor(template) {
@@ -32,7 +32,7 @@ var Template = class {
32
32
  );
33
33
  }
34
34
  /** Perform substitution, returning original placeholder for missing keys */
35
- safe_substitute(mapping) {
35
+ safeSubstitute(mapping) {
36
36
  const combined = { ...mapping };
37
37
  return this.template.replace(
38
38
  /\$\$|\$(\w+)|\$\{(\w+)\}/g,
@@ -47,7 +47,7 @@ var Template = class {
47
47
  );
48
48
  }
49
49
  /** Get identifiers in template */
50
- get_identifiers() {
50
+ getIdentifiers() {
51
51
  const identifiers = [];
52
52
  const regex = /\$(\w+)|\$\{(\w+)\}/g;
53
53
  let match;
@@ -60,7 +60,7 @@ var Template = class {
60
60
  return identifiers;
61
61
  }
62
62
  };
63
- function capwords(s, sep) {
63
+ function capWords(s, sep) {
64
64
  const separator = sep ?? " ";
65
65
  return s.split(separator).map((word) => {
66
66
  if (!word) return "";
@@ -102,9 +102,9 @@ var string = {
102
102
  return s.split(sep);
103
103
  },
104
104
  /**
105
- * Python str.rsplit()
105
+ * Python str.rSplit()
106
106
  */
107
- rsplit(s, sep, maxsplit) {
107
+ rSplit(s, sep, maxsplit) {
108
108
  if (sep === void 0) {
109
109
  const parts2 = s.trim().split(/\s+/);
110
110
  if (maxsplit === void 0) return parts2;
@@ -131,9 +131,9 @@ var string = {
131
131
  return s.replace(regex, "");
132
132
  },
133
133
  /**
134
- * Python str.lstrip()
134
+ * Python str.lStrip()
135
135
  */
136
- lstrip(s, chars) {
136
+ lStrip(s, chars) {
137
137
  if (chars === void 0) {
138
138
  return s.trimStart();
139
139
  }
@@ -141,9 +141,9 @@ var string = {
141
141
  return s.replace(regex, "");
142
142
  },
143
143
  /**
144
- * Python str.rstrip()
144
+ * Python str.rStrip()
145
145
  */
146
- rstrip(s, chars) {
146
+ rStrip(s, chars) {
147
147
  if (chars === void 0) {
148
148
  return s.trimEnd();
149
149
  }
@@ -176,22 +176,22 @@ var string = {
176
176
  return s.replace(/\b\w/g, (c) => c.toUpperCase());
177
177
  },
178
178
  /**
179
- * Python str.swapcase()
179
+ * Python str.swapCase()
180
180
  */
181
- swapcase(s) {
181
+ swapCase(s) {
182
182
  return s.split("").map((c) => c === c.toUpperCase() ? c.toLowerCase() : c.toUpperCase()).join("");
183
183
  },
184
184
  /**
185
- * Python str.startswith()
185
+ * Python str.startsWith()
186
186
  */
187
- startswith(s, prefix, start, end) {
187
+ startsWith(s, prefix, start, end) {
188
188
  const substr = s.slice(start, end);
189
189
  return substr.startsWith(prefix);
190
190
  },
191
191
  /**
192
- * Python str.endswith()
192
+ * Python str.endsWith()
193
193
  */
194
- endswith(s, suffix, start, end) {
194
+ endsWith(s, suffix, start, end) {
195
195
  const substr = s.slice(start, end);
196
196
  return substr.endsWith(suffix);
197
197
  },
@@ -205,9 +205,9 @@ var string = {
205
205
  return (start ?? 0) + index;
206
206
  },
207
207
  /**
208
- * Python str.rfind()
208
+ * Python str.rFind()
209
209
  */
210
- rfind(s, sub, start, end) {
210
+ rFind(s, sub, start, end) {
211
211
  const substr = s.slice(start, end);
212
212
  const index = substr.lastIndexOf(sub);
213
213
  if (index === -1) return -1;
@@ -224,10 +224,10 @@ var string = {
224
224
  return result;
225
225
  },
226
226
  /**
227
- * Python str.rindex() - raises error if not found
227
+ * Python str.rIndex() - raises error if not found
228
228
  */
229
- rindex(s, sub, start, end) {
230
- const result = string.rfind(s, sub, start, end);
229
+ rIndex(s, sub, start, end) {
230
+ const result = string.rFind(s, sub, start, end);
231
231
  if (result === -1) {
232
232
  throw new Error("substring not found");
233
233
  }
@@ -263,9 +263,9 @@ var string = {
263
263
  return result;
264
264
  },
265
265
  /**
266
- * Python str.zfill()
266
+ * Python str.zFill()
267
267
  */
268
- zfill(s, width) {
268
+ zFill(s, width) {
269
269
  if (s.length >= width) return s;
270
270
  const sign = s[0] === "-" || s[0] === "+" ? s[0] : "";
271
271
  const digits2 = sign ? s.slice(1) : s;
@@ -282,16 +282,16 @@ var string = {
282
282
  return fillchar.repeat(left) + s + fillchar.repeat(right);
283
283
  },
284
284
  /**
285
- * Python str.ljust()
285
+ * Python str.lJust()
286
286
  */
287
- ljust(s, width, fillchar = " ") {
287
+ lJust(s, width, fillchar = " ") {
288
288
  if (s.length >= width) return s;
289
289
  return s + fillchar.repeat(width - s.length);
290
290
  },
291
291
  /**
292
- * Python str.rjust()
292
+ * Python str.rJust()
293
293
  */
294
- rjust(s, width, fillchar = " ") {
294
+ rJust(s, width, fillchar = " ") {
295
295
  if (s.length >= width) return s;
296
296
  return fillchar.repeat(width - s.length) + s;
297
297
  },
@@ -304,47 +304,47 @@ var string = {
304
304
  return [s.slice(0, index), sep, s.slice(index + sep.length)];
305
305
  },
306
306
  /**
307
- * Python str.rpartition()
307
+ * Python str.rPartition()
308
308
  */
309
- rpartition(s, sep) {
309
+ rPartition(s, sep) {
310
310
  const index = s.lastIndexOf(sep);
311
311
  if (index === -1) return ["", "", s];
312
312
  return [s.slice(0, index), sep, s.slice(index + sep.length)];
313
313
  },
314
314
  /**
315
- * Python str.isalpha()
315
+ * Python str.isAlpha()
316
316
  */
317
- isalpha(s) {
317
+ isAlpha(s) {
318
318
  return s.length > 0 && /^[a-zA-Z]+$/.test(s);
319
319
  },
320
320
  /**
321
- * Python str.isdigit()
321
+ * Python str.isDigit()
322
322
  */
323
- isdigit(s) {
323
+ isDigit(s) {
324
324
  return s.length > 0 && /^[0-9]+$/.test(s);
325
325
  },
326
326
  /**
327
- * Python str.isalnum()
327
+ * Python str.isAlnum()
328
328
  */
329
- isalnum(s) {
329
+ isAlnum(s) {
330
330
  return s.length > 0 && /^[a-zA-Z0-9]+$/.test(s);
331
331
  },
332
332
  /**
333
- * Python str.isspace()
333
+ * Python str.isSpace()
334
334
  */
335
- isspace(s) {
335
+ isSpace(s) {
336
336
  return s.length > 0 && /^\s+$/.test(s);
337
337
  },
338
338
  /**
339
- * Python str.isupper()
339
+ * Python str.isUpper()
340
340
  */
341
- isupper(s) {
341
+ isUpper(s) {
342
342
  return s.length > 0 && s === s.toUpperCase() && s !== s.toLowerCase();
343
343
  },
344
344
  /**
345
- * Python str.islower()
345
+ * Python str.isLower()
346
346
  */
347
- islower(s) {
347
+ isLower(s) {
348
348
  return s.length > 0 && s === s.toLowerCase() && s !== s.toUpperCase();
349
349
  },
350
350
  /**
@@ -360,17 +360,17 @@ var string = {
360
360
  };
361
361
 
362
362
  export {
363
- ascii_lowercase,
364
- ascii_uppercase,
365
- ascii_letters,
363
+ asciiLowercase,
364
+ asciiUppercase,
365
+ asciiLetters,
366
366
  digits,
367
- hexdigits,
368
- octdigits,
367
+ hexDigits,
368
+ octDigits,
369
369
  punctuation,
370
370
  whitespace,
371
371
  printable,
372
372
  Template,
373
- capwords,
373
+ capWords,
374
374
  string
375
375
  };
376
- //# sourceMappingURL=chunk-3CSEXTA7.js.map
376
+ //# sourceMappingURL=chunk-4QG3772L.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/string.ts"],"sourcesContent":["/**\n * Python string module for TypeScript\n *\n * Provides string constants and utility classes matching Python's string module.\n *\n * @see {@link https://docs.python.org/3/library/string.html | Python string documentation}\n */\n\nfunction escapeRegex(str: string): string {\n return str.replace(/[.*+?^${}()|[\\]\\\\]/g, \"\\\\$&\")\n}\n\n// ============================================================================\n// String constants (Python string module)\n// ============================================================================\n\n/** The lowercase letters 'abcdefghijklmnopqrstuvwxyz' */\nexport const asciiLowercase = \"abcdefghijklmnopqrstuvwxyz\"\n\n/** The uppercase letters 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' */\nexport const asciiUppercase = \"ABCDEFGHIJKLMNOPQRSTUVWXYZ\"\n\n/** The concatenation of asciiLowercase and asciiUppercase */\nexport const asciiLetters = asciiLowercase + asciiUppercase\n\n/** The string '0123456789' */\nexport const digits = \"0123456789\"\n\n/** The string '0123456789abcdefABCDEF' */\nexport const hexDigits = \"0123456789abcdefABCDEF\"\n\n/** The string '01234567' */\nexport const octDigits = \"01234567\"\n\n/** String of ASCII characters which are considered punctuation */\nexport const punctuation = \"!\\\"#$%&'()*+,-./:;<=>?@[\\\\]^_`{|}~\"\n\n/** String of ASCII characters which are considered whitespace */\nexport const whitespace = \" \\t\\n\\r\\x0b\\x0c\"\n\n/** String of ASCII characters which are considered printable */\nexport const printable = digits + asciiLetters + punctuation + whitespace\n\n// ============================================================================\n// Template class\n// ============================================================================\n\nexport class Template {\n readonly template: string\n\n constructor(template: string) {\n this.template = template\n }\n\n /** Perform substitution, raising KeyError for missing keys */\n substitute(mapping?: Record<string, unknown>): string {\n const combined = { ...mapping }\n return this.template.replace(\n /\\$\\$|\\$(\\w+)|\\$\\{(\\w+)\\}/g,\n (match, name1: string, name2: string) => {\n if (match === \"$$\") return \"$\"\n const name = name1 || name2\n if (!(name in combined)) {\n throw new Error(`KeyError: '${name}'`)\n }\n return String(combined[name])\n }\n )\n }\n\n /** Perform substitution, returning original placeholder for missing keys */\n safeSubstitute(mapping?: Record<string, unknown>): string {\n const combined = { ...mapping }\n return this.template.replace(\n /\\$\\$|\\$(\\w+)|\\$\\{(\\w+)\\}/g,\n (match, name1: string, name2: string) => {\n if (match === \"$$\") return \"$\"\n const name = name1 || name2\n if (!(name in combined)) {\n return match\n }\n return String(combined[name])\n }\n )\n }\n\n /** Get identifiers in template */\n getIdentifiers(): string[] {\n const identifiers: string[] = []\n const regex = /\\$(\\w+)|\\$\\{(\\w+)\\}/g\n let match: RegExpExecArray | null\n while ((match = regex.exec(this.template)) !== null) {\n const name = match[1] || match[2]\n if (name && !identifiers.includes(name)) {\n identifiers.push(name)\n }\n }\n return identifiers\n }\n}\n\n/** Capitalize words in string */\nexport function capWords(s: string, sep?: string): string {\n const separator = sep ?? \" \"\n return s\n .split(separator)\n .map((word) => {\n if (!word) return \"\"\n const first = word[0]\n return first ? first.toUpperCase() + word.slice(1).toLowerCase() : word\n })\n .join(separator)\n}\n\nexport const string = {\n /**\n * Python str.join()\n */\n join(sep: string, iterable: Iterable<string>): string {\n return Array.from(iterable).join(sep)\n },\n\n /**\n * Python str.split()\n */\n split(s: string, sep?: string, maxsplit?: number): string[] {\n if (sep === undefined) {\n // Split on whitespace\n const result = s.trim().split(/\\s+/)\n if (maxsplit !== undefined && maxsplit >= 0) {\n if (result.length > maxsplit + 1) {\n const limited = result.slice(0, maxsplit)\n limited.push(result.slice(maxsplit).join(\" \"))\n return limited\n }\n }\n return result\n }\n\n if (maxsplit !== undefined && maxsplit >= 0) {\n const parts = s.split(sep)\n if (parts.length > maxsplit + 1) {\n const limited = parts.slice(0, maxsplit)\n limited.push(parts.slice(maxsplit).join(sep))\n return limited\n }\n return parts\n }\n\n return s.split(sep)\n },\n\n /**\n * Python str.rSplit()\n */\n rSplit(s: string, sep?: string, maxsplit?: number): string[] {\n if (sep === undefined) {\n const parts = s.trim().split(/\\s+/)\n if (maxsplit === undefined) return parts\n if (maxsplit <= 0) return [s]\n if (parts.length <= maxsplit + 1) return parts\n const keep = parts.slice(-maxsplit)\n const rest = parts.slice(0, parts.length - maxsplit).join(\" \")\n return [rest, ...keep]\n }\n\n const parts = s.split(sep)\n if (maxsplit === undefined || parts.length <= maxsplit + 1) return parts\n const keep = parts.slice(-maxsplit)\n const rest = parts.slice(0, parts.length - maxsplit).join(sep)\n return [rest, ...keep]\n },\n\n /**\n * Python str.strip()\n */\n strip(s: string, chars?: string): string {\n if (chars === undefined) {\n return s.trim()\n }\n const regex = new RegExp(`^[${escapeRegex(chars)}]+|[${escapeRegex(chars)}]+$`, \"g\")\n return s.replace(regex, \"\")\n },\n\n /**\n * Python str.lStrip()\n */\n lStrip(s: string, chars?: string): string {\n if (chars === undefined) {\n return s.trimStart()\n }\n const regex = new RegExp(`^[${escapeRegex(chars)}]+`)\n return s.replace(regex, \"\")\n },\n\n /**\n * Python str.rStrip()\n */\n rStrip(s: string, chars?: string): string {\n if (chars === undefined) {\n return s.trimEnd()\n }\n const regex = new RegExp(`[${escapeRegex(chars)}]+$`)\n return s.replace(regex, \"\")\n },\n\n /**\n * Python str.upper()\n */\n upper(s: string): string {\n return s.toUpperCase()\n },\n\n /**\n * Python str.lower()\n */\n lower(s: string): string {\n return s.toLowerCase()\n },\n\n /**\n * Python str.capitalize()\n */\n capitalize(s: string): string {\n if (s.length === 0) return s\n return s.charAt(0).toUpperCase() + s.slice(1).toLowerCase()\n },\n\n /**\n * Python str.title()\n */\n title(s: string): string {\n return s.replace(/\\b\\w/g, (c) => c.toUpperCase())\n },\n\n /**\n * Python str.swapCase()\n */\n swapCase(s: string): string {\n return s\n .split(\"\")\n .map((c) => (c === c.toUpperCase() ? c.toLowerCase() : c.toUpperCase()))\n .join(\"\")\n },\n\n /**\n * Python str.startsWith()\n */\n startsWith(s: string, prefix: string, start?: number, end?: number): boolean {\n const substr = s.slice(start, end)\n return substr.startsWith(prefix)\n },\n\n /**\n * Python str.endsWith()\n */\n endsWith(s: string, suffix: string, start?: number, end?: number): boolean {\n const substr = s.slice(start, end)\n return substr.endsWith(suffix)\n },\n\n /**\n * Python str.find()\n */\n find(s: string, sub: string, start?: number, end?: number): number {\n const substr = s.slice(start, end)\n const index = substr.indexOf(sub)\n if (index === -1) return -1\n return (start ?? 0) + index\n },\n\n /**\n * Python str.rFind()\n */\n rFind(s: string, sub: string, start?: number, end?: number): number {\n const substr = s.slice(start, end)\n const index = substr.lastIndexOf(sub)\n if (index === -1) return -1\n return (start ?? 0) + index\n },\n\n /**\n * Python str.index() - raises error if not found\n */\n index(s: string, sub: string, start?: number, end?: number): number {\n const result = string.find(s, sub, start, end)\n if (result === -1) {\n throw new Error(\"substring not found\")\n }\n return result\n },\n\n /**\n * Python str.rIndex() - raises error if not found\n */\n rIndex(s: string, sub: string, start?: number, end?: number): number {\n const result = string.rFind(s, sub, start, end)\n if (result === -1) {\n throw new Error(\"substring not found\")\n }\n return result\n },\n\n /**\n * Python str.count()\n */\n count(s: string, sub: string, start?: number, end?: number): number {\n const substr = s.slice(start, end)\n if (sub.length === 0) return substr.length + 1\n let count = 0\n let pos = 0\n while ((pos = substr.indexOf(sub, pos)) !== -1) {\n count++\n pos += sub.length\n }\n return count\n },\n\n /**\n * Python str.replace()\n */\n replace(s: string, old: string, newStr: string, count?: number): string {\n if (count === undefined || count < 0) {\n return s.split(old).join(newStr)\n }\n\n let result = s\n for (let i = 0; i < count; i++) {\n const index = result.indexOf(old)\n if (index === -1) break\n result = result.slice(0, index) + newStr + result.slice(index + old.length)\n }\n return result\n },\n\n /**\n * Python str.zFill()\n */\n zFill(s: string, width: number): string {\n if (s.length >= width) return s\n const sign = s[0] === \"-\" || s[0] === \"+\" ? s[0] : \"\"\n const digits = sign ? s.slice(1) : s\n return sign + digits.padStart(width - sign.length, \"0\")\n },\n\n /**\n * Python str.center()\n */\n center(s: string, width: number, fillchar = \" \"): string {\n if (s.length >= width) return s\n const total = width - s.length\n const left = Math.floor(total / 2)\n const right = total - left\n return fillchar.repeat(left) + s + fillchar.repeat(right)\n },\n\n /**\n * Python str.lJust()\n */\n lJust(s: string, width: number, fillchar = \" \"): string {\n if (s.length >= width) return s\n return s + fillchar.repeat(width - s.length)\n },\n\n /**\n * Python str.rJust()\n */\n rJust(s: string, width: number, fillchar = \" \"): string {\n if (s.length >= width) return s\n return fillchar.repeat(width - s.length) + s\n },\n\n /**\n * Python str.partition()\n */\n partition(s: string, sep: string): [string, string, string] {\n const index = s.indexOf(sep)\n if (index === -1) return [s, \"\", \"\"]\n return [s.slice(0, index), sep, s.slice(index + sep.length)]\n },\n\n /**\n * Python str.rPartition()\n */\n rPartition(s: string, sep: string): [string, string, string] {\n const index = s.lastIndexOf(sep)\n if (index === -1) return [\"\", \"\", s]\n return [s.slice(0, index), sep, s.slice(index + sep.length)]\n },\n\n /**\n * Python str.isAlpha()\n */\n isAlpha(s: string): boolean {\n return s.length > 0 && /^[a-zA-Z]+$/.test(s)\n },\n\n /**\n * Python str.isDigit()\n */\n isDigit(s: string): boolean {\n return s.length > 0 && /^[0-9]+$/.test(s)\n },\n\n /**\n * Python str.isAlnum()\n */\n isAlnum(s: string): boolean {\n return s.length > 0 && /^[a-zA-Z0-9]+$/.test(s)\n },\n\n /**\n * Python str.isSpace()\n */\n isSpace(s: string): boolean {\n return s.length > 0 && /^\\s+$/.test(s)\n },\n\n /**\n * Python str.isUpper()\n */\n isUpper(s: string): boolean {\n return s.length > 0 && s === s.toUpperCase() && s !== s.toLowerCase()\n },\n\n /**\n * Python str.isLower()\n */\n isLower(s: string): boolean {\n return s.length > 0 && s === s.toLowerCase() && s !== s.toUpperCase()\n },\n\n /**\n * Python str.format() - basic implementation\n */\n format(s: string, ...args: unknown[]): string {\n let index = 0\n return s.replace(/\\{(\\d*)\\}/g, (_, num: string) => {\n const i = num === \"\" ? index++ : parseInt(num, 10)\n return String(args[i])\n })\n }\n}\n"],"mappings":";AAQA,SAAS,YAAY,KAAqB;AACxC,SAAO,IAAI,QAAQ,uBAAuB,MAAM;AAClD;AAOO,IAAM,iBAAiB;AAGvB,IAAM,iBAAiB;AAGvB,IAAM,eAAe,iBAAiB;AAGtC,IAAM,SAAS;AAGf,IAAM,YAAY;AAGlB,IAAM,YAAY;AAGlB,IAAM,cAAc;AAGpB,IAAM,aAAa;AAGnB,IAAM,YAAY,SAAS,eAAe,cAAc;AAMxD,IAAM,WAAN,MAAe;AAAA,EACX;AAAA,EAET,YAAY,UAAkB;AAC5B,SAAK,WAAW;AAAA,EAClB;AAAA;AAAA,EAGA,WAAW,SAA2C;AACpD,UAAM,WAAW,EAAE,GAAG,QAAQ;AAC9B,WAAO,KAAK,SAAS;AAAA,MACnB;AAAA,MACA,CAAC,OAAO,OAAe,UAAkB;AACvC,YAAI,UAAU,KAAM,QAAO;AAC3B,cAAM,OAAO,SAAS;AACtB,YAAI,EAAE,QAAQ,WAAW;AACvB,gBAAM,IAAI,MAAM,cAAc,IAAI,GAAG;AAAA,QACvC;AACA,eAA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AE,SAAS,KAAK,QAAQ,KAAK,CAAC;AAAA,EACvC;AAAA;AAAA;AAAA;AAAA,EAKA,QAAQ,GAAoB;AAC1B,WAAO,EAAE,SAAS,KAAK,MAAM,EAAE,YAAY,KAAK,MAAM,EAAE,YAAY;AAAA,EACtE;AAAA;AAAA;AAAA;AAAA,EAKA,QAAQ,GAAoB;AAC1B,WAAO,EAAE,SAAS,KAAK,MAAM,EAAE,YAAY,KAAK,MAAM,EAAE,YAAY;AAAA,EACtE;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,MAAc,MAAyB;AAC5C,QAAI,QAAQ;AACZ,WAAO,EAAE,QAAQ,cAAc,CAAC,GAAG,QAAgB;AACjD,YAAM,IAAI,QAAQ,KAAK,UAAU,SAAS,KAAK,EAAE;AACjD,aAAO,OAAO,KAAK,CAAC,CAAC;AAAA,IACvB,CAAC;AAAA,EACH;AACF;","names":["parts","keep","rest","digits"]}
@@ -5,18 +5,19 @@ import {
5
5
  // src/functools.ts
6
6
  var functools_exports = {};
7
7
  __export(functools_exports, {
8
- attrgetter: () => attrgetter,
8
+ attrGetter: () => attrGetter,
9
9
  cache: () => cache,
10
- cmp_to_key: () => cmp_to_key,
10
+ cmpToKey: () => cmpToKey,
11
11
  identity: () => identity,
12
- itemgetter: () => itemgetter,
13
- lru_cache: () => lru_cache,
14
- methodcaller: () => methodcaller,
12
+ itemGetter: () => itemGetter,
13
+ lruCache: () => lruCache,
14
+ methodCaller: () => methodCaller,
15
15
  partial: () => partial,
16
- partialmethod: () => partialmethod,
16
+ partialMethod: () => partialMethod,
17
+ pipe: () => pipe,
17
18
  reduce: () => reduce,
18
- singledispatch: () => singledispatch,
19
- total_ordering: () => total_ordering,
19
+ singleDispatch: () => singleDispatch,
20
+ totalOrdering: () => totalOrdering,
20
21
  wraps: () => wraps
21
22
  });
22
23
  function partial(func, ...partialArgs) {
@@ -46,7 +47,7 @@ function reduce(func, iterable, initializer) {
46
47
  }
47
48
  return acc;
48
49
  }
49
- function lru_cache(func, maxsize = 128) {
50
+ function lruCache(func, maxsize = 128) {
50
51
  const cache2 = /* @__PURE__ */ new Map();
51
52
  const order = [];
52
53
  let hits = 0;
@@ -74,13 +75,13 @@ function lru_cache(func, maxsize = 128) {
74
75
  order.push(key);
75
76
  return result;
76
77
  });
77
- cached.cache_info = () => ({
78
+ cached.cacheInfo = () => ({
78
79
  hits,
79
80
  misses,
80
81
  maxsize,
81
82
  currsize: cache2.size
82
83
  });
83
- cached.cache_clear = () => {
84
+ cached.cacheClear = () => {
84
85
  cache2.clear();
85
86
  order.length = 0;
86
87
  hits = 0;
@@ -100,10 +101,10 @@ function cache(func) {
100
101
  return result;
101
102
  });
102
103
  }
103
- function partialmethod(func, ...partialArgs) {
104
+ function partialMethod(func, ...partialArgs) {
104
105
  return partial(func, ...partialArgs);
105
106
  }
106
- function singledispatch(func) {
107
+ function singleDispatch(func) {
107
108
  const registry = /* @__PURE__ */ new Map();
108
109
  registry.set("object", func);
109
110
  const dispatcher = ((...args) => {
@@ -133,7 +134,7 @@ function wraps(wrapped) {
133
134
  return wrapper;
134
135
  };
135
136
  }
136
- function attrgetter(...attrs) {
137
+ function attrGetter(...attrs) {
137
138
  if (attrs.length === 1) {
138
139
  const attr = attrs[0];
139
140
  const parts = attr.split(".");
@@ -156,7 +157,7 @@ function attrgetter(...attrs) {
156
157
  });
157
158
  };
158
159
  }
159
- function itemgetter(...items) {
160
+ function itemGetter(...items) {
160
161
  if (items.length === 1) {
161
162
  const item = items[0];
162
163
  return (obj) => {
@@ -175,7 +176,7 @@ function itemgetter(...items) {
175
176
  });
176
177
  };
177
178
  }
178
- function methodcaller(name, ...args) {
179
+ function methodCaller(name, ...args) {
179
180
  return (obj) => {
180
181
  const method = obj[name];
181
182
  if (typeof method !== "function") {
@@ -187,7 +188,7 @@ function methodcaller(name, ...args) {
187
188
  function identity(x) {
188
189
  return x;
189
190
  }
190
- function cmp_to_key(mycmp) {
191
+ function cmpToKey(mycmp) {
191
192
  return (x) => ({
192
193
  value: x,
193
194
  __lt__(other) {
@@ -195,7 +196,7 @@ function cmp_to_key(mycmp) {
195
196
  }
196
197
  });
197
198
  }
198
- function total_ordering(obj) {
199
+ function totalOrdering(obj) {
199
200
  const lt = obj.__lt__?.bind(obj);
200
201
  const le = obj.__le__?.bind(obj);
201
202
  const gt = obj.__gt__?.bind(obj);
@@ -225,21 +226,25 @@ function total_ordering(obj) {
225
226
  }
226
227
  return result;
227
228
  }
229
+ function pipe(value, ...fns) {
230
+ return fns.reduce((acc, fn) => fn(acc), value);
231
+ }
228
232
 
229
233
  export {
230
234
  partial,
231
235
  reduce,
232
- lru_cache,
236
+ lruCache,
233
237
  cache,
234
- partialmethod,
235
- singledispatch,
238
+ partialMethod,
239
+ singleDispatch,
236
240
  wraps,
237
- attrgetter,
238
- itemgetter,
239
- methodcaller,
241
+ attrGetter,
242
+ itemGetter,
243
+ methodCaller,
240
244
  identity,
241
- cmp_to_key,
242
- total_ordering,
245
+ cmpToKey,
246
+ totalOrdering,
247
+ pipe,
243
248
  functools_exports
244
249
  };
245
- //# sourceMappingURL=chunk-OMQNGE6T.js.map
250
+ //# sourceMappingURL=chunk-4SZT4HJI.js.map