pythonlib 1.0.2 → 2.0.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 (133) hide show
  1. package/README.md +3 -1
  2. package/dist/base64-C_am75Sv.d.ts +165 -0
  3. package/dist/base64.d.ts +1 -0
  4. package/dist/base64.js +37 -0
  5. package/dist/chunk-2YTO24B5.js +78 -0
  6. package/dist/chunk-3CLXPGAB.js +237 -0
  7. package/dist/{chunk-7BZB2TQF.js → chunk-3M3PB4RO.js} +4 -6
  8. package/dist/chunk-5OKGPZBQ.js +1106 -0
  9. package/dist/chunk-5VAHUJNC.js +348 -0
  10. package/dist/chunk-B5AUEOAH.js +193 -0
  11. package/dist/chunk-B5LQJODJ.js +37 -0
  12. package/dist/{chunk-CUP6EPDB.js → chunk-BCMGGBWG.js} +2 -5
  13. package/dist/chunk-BCVIH2BN.js +175 -0
  14. package/dist/{chunk-QURVRHY2.js → chunk-D35YI363.js} +15 -12
  15. package/dist/{chunk-RSBRI27Z.js → chunk-ETBW6XNR.js} +3 -4
  16. package/dist/chunk-FCJ7E4OE.js +250 -0
  17. package/dist/chunk-HSTC277I.js +255 -0
  18. package/dist/chunk-IANXD4D4.js +250 -0
  19. package/dist/{chunk-G6PUQTVZ.js → chunk-JAUU3HMH.js} +1 -2
  20. package/dist/chunk-JJKTRIVO.js +262 -0
  21. package/dist/chunk-KKHKTQNN.js +361 -0
  22. package/dist/chunk-KKJHGY4C.js +551 -0
  23. package/dist/chunk-LHPQS75Z.js +192 -0
  24. package/dist/{chunk-OSX7QZAW.js → chunk-LK2L2TFG.js} +5 -6
  25. package/dist/chunk-LLZFLQS6.js +280 -0
  26. package/dist/chunk-LTXTS7RP.js +154 -0
  27. package/dist/{chunk-CEZSBJJV.js → chunk-LWYBTWBZ.js} +2 -3
  28. package/dist/{chunk-TAYRRHJ3.js → chunk-MFKIEN7N.js} +1 -2
  29. package/dist/{chunk-PZ5AY32C.js → chunk-MLKGABMK.js} +0 -1
  30. package/dist/chunk-OZRS5PC4.js +312 -0
  31. package/dist/chunk-PWA3YQZU.js +346 -0
  32. package/dist/{chunk-56DGFWIJ.js → chunk-QKJBQKPY.js} +1 -2
  33. package/dist/chunk-RB6BYCIQ.js +141 -0
  34. package/dist/chunk-U4X5DEIP.js +188 -0
  35. package/dist/chunk-UGZ5OY5Z.js +165 -0
  36. package/dist/chunk-WTZSAITC.js +82 -0
  37. package/dist/collections.js +2 -3
  38. package/dist/copy-6ZaZ__ge.d.ts +59 -0
  39. package/dist/copy.d.ts +1 -0
  40. package/dist/copy.js +9 -0
  41. package/dist/datetime.js +2 -3
  42. package/dist/functools.js +2 -3
  43. package/dist/glob.browser-B6d_YdV5.d.ts +50 -0
  44. package/dist/glob.browser.d.ts +1 -0
  45. package/dist/glob.browser.js +15 -0
  46. package/dist/glob.node-wn5ehtyM.d.ts +80 -0
  47. package/dist/glob.node.d.ts +1 -0
  48. package/dist/glob.node.js +15 -0
  49. package/dist/hashlib-vKP511NY.d.ts +205 -0
  50. package/dist/hashlib.d.ts +1 -0
  51. package/dist/hashlib.js +39 -0
  52. package/dist/index.browser.d.ts +172 -0
  53. package/dist/index.browser.js +304 -0
  54. package/dist/index.d.ts +36 -602
  55. package/dist/index.js +138 -1073
  56. package/dist/itertools.js +2 -3
  57. package/dist/json.js +2 -3
  58. package/dist/logging.browser-Dux4L5kz.d.ts +185 -0
  59. package/dist/logging.browser.d.ts +1 -0
  60. package/dist/logging.browser.js +63 -0
  61. package/dist/logging.node-CH75bVdE.d.ts +185 -0
  62. package/dist/logging.node.d.ts +1 -0
  63. package/dist/logging.node.js +61 -0
  64. package/dist/math.js +2 -3
  65. package/dist/{os-CqGKe872.d.ts → os.browser-krjSx5kF.d.ts} +32 -55
  66. package/dist/os.browser.d.ts +2 -0
  67. package/dist/{os.js → os.browser.js} +41 -16
  68. package/dist/os.node-CQjch8Ht.d.ts +124 -0
  69. package/dist/os.node.d.ts +2 -0
  70. package/dist/os.node.js +83 -0
  71. package/dist/os.shared-C3x70nhO.d.ts +59 -0
  72. package/dist/pathlib.browser-NC7kKQYe.d.ts +91 -0
  73. package/dist/pathlib.browser.d.ts +1 -0
  74. package/dist/pathlib.browser.js +17 -0
  75. package/dist/pathlib.node-CY3yUFdT.d.ts +331 -0
  76. package/dist/pathlib.node.d.ts +2 -0
  77. package/dist/pathlib.node.js +17 -0
  78. package/dist/random.js +2 -3
  79. package/dist/re.js +2 -3
  80. package/dist/set-JQbLAq8B.d.ts +592 -0
  81. package/dist/shutil.browser-Ck5oWhnP.d.ts +113 -0
  82. package/dist/shutil.browser.d.ts +1 -0
  83. package/dist/shutil.browser.js +33 -0
  84. package/dist/shutil.node-C9kwvhAf.d.ts +160 -0
  85. package/dist/shutil.node.d.ts +2 -0
  86. package/dist/shutil.node.js +33 -0
  87. package/dist/string.js +2 -3
  88. package/dist/subprocess-CZVYzQ3V.d.ts +214 -0
  89. package/dist/subprocess.d.ts +1 -0
  90. package/dist/subprocess.js +29 -0
  91. package/dist/sys-IL8LgI_W.d.ts +212 -0
  92. package/dist/sys.d.ts +1 -0
  93. package/dist/sys.js +51 -0
  94. package/dist/tempfile.browser-DciOKfNm.d.ts +78 -0
  95. package/dist/tempfile.browser.d.ts +1 -0
  96. package/dist/tempfile.browser.js +19 -0
  97. package/dist/tempfile.node-bVMY60Cu.d.ts +195 -0
  98. package/dist/tempfile.node.d.ts +2 -0
  99. package/dist/tempfile.node.js +23 -0
  100. package/dist/time-CcYhdiSu.d.ts +245 -0
  101. package/dist/time.d.ts +1 -0
  102. package/dist/time.js +49 -0
  103. package/dist/urllib-DJtkj-0f.d.ts +198 -0
  104. package/dist/urllib.d.ts +1 -0
  105. package/dist/urllib.js +37 -0
  106. package/dist/uuid-C0ypmn56.d.ts +160 -0
  107. package/dist/uuid.d.ts +1 -0
  108. package/dist/uuid.js +23 -0
  109. package/package.json +127 -5
  110. package/dist/chunk-56DGFWIJ.js.map +0 -1
  111. package/dist/chunk-5AOJFFYN.js +0 -313
  112. package/dist/chunk-5AOJFFYN.js.map +0 -1
  113. package/dist/chunk-7BZB2TQF.js.map +0 -1
  114. package/dist/chunk-CEZSBJJV.js.map +0 -1
  115. package/dist/chunk-CUP6EPDB.js.map +0 -1
  116. package/dist/chunk-G6PUQTVZ.js.map +0 -1
  117. package/dist/chunk-OSX7QZAW.js.map +0 -1
  118. package/dist/chunk-PZ5AY32C.js.map +0 -1
  119. package/dist/chunk-QURVRHY2.js.map +0 -1
  120. package/dist/chunk-RSBRI27Z.js.map +0 -1
  121. package/dist/chunk-TAYRRHJ3.js.map +0 -1
  122. package/dist/collections.js.map +0 -1
  123. package/dist/datetime.js.map +0 -1
  124. package/dist/functools.js.map +0 -1
  125. package/dist/index.js.map +0 -1
  126. package/dist/itertools.js.map +0 -1
  127. package/dist/json.js.map +0 -1
  128. package/dist/math.js.map +0 -1
  129. package/dist/os.d.ts +0 -1
  130. package/dist/os.js.map +0 -1
  131. package/dist/random.js.map +0 -1
  132. package/dist/re.js.map +0 -1
  133. package/dist/string.js.map +0 -1
package/README.md CHANGED
@@ -2,8 +2,10 @@
2
2
 
3
3
  [![npm version](https://img.shields.io/npm/v/pythonlib.svg)](https://www.npmjs.com/package/pythonlib)
4
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)
5
+ [![Zero Dependencies](https://img.shields.io/badge/dependencies-0-brightgreen)](https://www.npmjs.com/package/pythonlib?activeTab=dependencies)
6
6
  [![TypeScript](https://img.shields.io/badge/TypeScript-5.6-blue.svg)](https://www.typescriptlang.org/)
7
+ [![Node.js](https://img.shields.io/badge/Node.js-%E2%89%A522-339933?logo=node.js&logoColor=white)](https://nodejs.org/)
8
+ [![Bun](https://img.shields.io/badge/Bun-compatible-f9f1e1?logo=bun&logoColor=black)](https://bun.sh/)
7
9
  [![License](https://img.shields.io/npm/l/pythonlib.svg)](https://github.com/sebastian-software/python2ts/blob/main/LICENSE)
8
10
 
9
11
  **Python's powerful standard library, TypeScript's familiar style** — itertools, functools,
@@ -0,0 +1,165 @@
1
+ /**
2
+ * Python base64 module for TypeScript
3
+ *
4
+ * Provides encoding and decoding using Base64 and URL-safe Base64.
5
+ *
6
+ * @see {@link https://docs.python.org/3/library/base64.html | Python base64 documentation}
7
+ * @module
8
+ */
9
+ /**
10
+ * Encode bytes-like object using Base64 and return bytes.
11
+ *
12
+ * @param s - Bytes to encode (Uint8Array or string)
13
+ * @returns Base64 encoded Uint8Array
14
+ *
15
+ * @example
16
+ * ```typescript
17
+ * const encoded = b64encode(new TextEncoder().encode("hello"))
18
+ * console.log(new TextDecoder().decode(encoded)) // "aGVsbG8="
19
+ * ```
20
+ */
21
+ declare function b64encode(s: Uint8Array | string): Uint8Array;
22
+ /**
23
+ * Decode Base64 encoded bytes-like object or ASCII string and return bytes.
24
+ *
25
+ * @param s - Base64 encoded data (Uint8Array or string)
26
+ * @returns Decoded Uint8Array
27
+ *
28
+ * @example
29
+ * ```typescript
30
+ * const decoded = b64decode("aGVsbG8=")
31
+ * console.log(new TextDecoder().decode(decoded)) // "hello"
32
+ * ```
33
+ */
34
+ declare function b64decode(s: Uint8Array | string): Uint8Array;
35
+ /**
36
+ * Encode bytes-like object using standard Base64 and return bytes.
37
+ * This is identical to b64encode().
38
+ *
39
+ * @param s - Bytes to encode
40
+ * @returns Base64 encoded Uint8Array
41
+ */
42
+ declare function standardB64encode(s: Uint8Array | string): Uint8Array;
43
+ /**
44
+ * Decode standard Base64 encoded bytes-like object and return bytes.
45
+ * This is identical to b64decode().
46
+ *
47
+ * @param s - Base64 encoded data
48
+ * @returns Decoded Uint8Array
49
+ */
50
+ declare function standardB64decode(s: Uint8Array | string): Uint8Array;
51
+ /**
52
+ * Encode bytes-like object using URL-safe Base64 and return bytes.
53
+ *
54
+ * URL-safe Base64 uses - instead of + and _ instead of /,
55
+ * and omits padding characters.
56
+ *
57
+ * @param s - Bytes to encode
58
+ * @returns URL-safe Base64 encoded Uint8Array
59
+ *
60
+ * @example
61
+ * ```typescript
62
+ * const encoded = urlsafeB64encode(new Uint8Array([255, 239]))
63
+ * // Uses - and _ instead of + and /
64
+ * ```
65
+ */
66
+ declare function urlsafeB64encode(s: Uint8Array | string): Uint8Array;
67
+ /**
68
+ * Decode URL-safe Base64 encoded bytes-like object and return bytes.
69
+ *
70
+ * @param s - URL-safe Base64 encoded data
71
+ * @returns Decoded Uint8Array
72
+ */
73
+ declare function urlsafeB64decode(s: Uint8Array | string): Uint8Array;
74
+ /**
75
+ * Encode bytes-like object using Base16 (hexadecimal) and return bytes.
76
+ *
77
+ * @param s - Bytes to encode
78
+ * @returns Hexadecimal encoded Uint8Array (uppercase)
79
+ */
80
+ declare function b16encode(s: Uint8Array | string): Uint8Array;
81
+ /**
82
+ * Decode Base16 (hexadecimal) encoded bytes-like object and return bytes.
83
+ *
84
+ * @param s - Hexadecimal encoded data
85
+ * @returns Decoded Uint8Array
86
+ */
87
+ declare function b16decode(s: Uint8Array | string): Uint8Array;
88
+ /**
89
+ * Encode bytes-like object using Base32 and return bytes.
90
+ *
91
+ * @param s - Bytes to encode
92
+ * @returns Base32 encoded Uint8Array
93
+ */
94
+ declare function b32encode(s: Uint8Array | string): Uint8Array;
95
+ /**
96
+ * Decode Base32 encoded bytes-like object and return bytes.
97
+ *
98
+ * @param s - Base32 encoded data
99
+ * @returns Decoded Uint8Array
100
+ */
101
+ declare function b32decode(s: Uint8Array | string): Uint8Array;
102
+ /**
103
+ * Encode bytes-like object using Ascii85 (also known as Base85) and return bytes.
104
+ *
105
+ * @param s - Bytes to encode
106
+ * @returns Ascii85 encoded Uint8Array
107
+ */
108
+ declare function a85encode(s: Uint8Array | string): Uint8Array;
109
+ /**
110
+ * Decode Ascii85 encoded bytes-like object and return bytes.
111
+ *
112
+ * @param s - Ascii85 encoded data
113
+ * @returns Decoded Uint8Array
114
+ */
115
+ declare function a85decode(s: Uint8Array | string): Uint8Array;
116
+ /**
117
+ * Encode bytes-like object using Base85 (same as a85encode) and return bytes.
118
+ *
119
+ * @param s - Bytes to encode
120
+ * @returns Base85 encoded Uint8Array
121
+ */
122
+ declare function b85encode(s: Uint8Array | string): Uint8Array;
123
+ /**
124
+ * Decode Base85 encoded bytes-like object and return bytes.
125
+ *
126
+ * @param s - Base85 encoded data
127
+ * @returns Decoded Uint8Array
128
+ */
129
+ declare function b85decode(s: Uint8Array | string): Uint8Array;
130
+ /**
131
+ * Encode bytes-like object using Base64 and return as ASCII string.
132
+ *
133
+ * @param s - Bytes to encode
134
+ * @returns Base64 encoded string
135
+ */
136
+ declare function encodeString(s: Uint8Array | string): string;
137
+ /**
138
+ * Decode Base64 ASCII string and return bytes.
139
+ *
140
+ * @param s - Base64 encoded string
141
+ * @returns Decoded Uint8Array
142
+ */
143
+ declare function decodeString(s: string): Uint8Array;
144
+
145
+ declare const base64Module_a85decode: typeof a85decode;
146
+ declare const base64Module_a85encode: typeof a85encode;
147
+ declare const base64Module_b16decode: typeof b16decode;
148
+ declare const base64Module_b16encode: typeof b16encode;
149
+ declare const base64Module_b32decode: typeof b32decode;
150
+ declare const base64Module_b32encode: typeof b32encode;
151
+ declare const base64Module_b64decode: typeof b64decode;
152
+ declare const base64Module_b64encode: typeof b64encode;
153
+ declare const base64Module_b85decode: typeof b85decode;
154
+ declare const base64Module_b85encode: typeof b85encode;
155
+ declare const base64Module_decodeString: typeof decodeString;
156
+ declare const base64Module_encodeString: typeof encodeString;
157
+ declare const base64Module_standardB64decode: typeof standardB64decode;
158
+ declare const base64Module_standardB64encode: typeof standardB64encode;
159
+ declare const base64Module_urlsafeB64decode: typeof urlsafeB64decode;
160
+ declare const base64Module_urlsafeB64encode: typeof urlsafeB64encode;
161
+ declare namespace base64Module {
162
+ export { base64Module_a85decode as a85decode, base64Module_a85encode as a85encode, base64Module_b16decode as b16decode, base64Module_b16encode as b16encode, base64Module_b32decode as b32decode, base64Module_b32encode as b32encode, base64Module_b64decode as b64decode, base64Module_b64encode as b64encode, base64Module_b85decode as b85decode, base64Module_b85encode as b85encode, base64Module_decodeString as decodeString, base64Module_encodeString as encodeString, base64Module_standardB64decode as standardB64decode, base64Module_standardB64encode as standardB64encode, base64Module_urlsafeB64decode as urlsafeB64decode, base64Module_urlsafeB64encode as urlsafeB64encode };
163
+ }
164
+
165
+ export { b64encode as a, base64Module as b, b64decode as c, standardB64decode as d, urlsafeB64decode as e, b16encode as f, b16decode as g, b32encode as h, b32decode as i, a85encode as j, a85decode as k, b85encode as l, b85decode as m, encodeString as n, decodeString as o, standardB64encode as s, urlsafeB64encode as u };
@@ -0,0 +1 @@
1
+ export { k as a85decode, j as a85encode, g as b16decode, f as b16encode, i as b32decode, h as b32encode, c as b64decode, a as b64encode, m as b85decode, l as b85encode, o as decodeString, n as encodeString, d as standardB64decode, s as standardB64encode, e as urlsafeB64decode, u as urlsafeB64encode } from './base64-C_am75Sv.js';
package/dist/base64.js ADDED
@@ -0,0 +1,37 @@
1
+ import {
2
+ a85decode,
3
+ a85encode,
4
+ b16decode,
5
+ b16encode,
6
+ b32decode,
7
+ b32encode,
8
+ b64decode,
9
+ b64encode,
10
+ b85decode,
11
+ b85encode,
12
+ decodeString,
13
+ encodeString,
14
+ standardB64decode,
15
+ standardB64encode,
16
+ urlsafeB64decode,
17
+ urlsafeB64encode
18
+ } from "./chunk-3CLXPGAB.js";
19
+ import "./chunk-MLKGABMK.js";
20
+ export {
21
+ a85decode,
22
+ a85encode,
23
+ b16decode,
24
+ b16encode,
25
+ b32decode,
26
+ b32encode,
27
+ b64decode,
28
+ b64encode,
29
+ b85decode,
30
+ b85encode,
31
+ decodeString,
32
+ encodeString,
33
+ standardB64decode,
34
+ standardB64encode,
35
+ urlsafeB64decode,
36
+ urlsafeB64encode
37
+ };
@@ -0,0 +1,78 @@
1
+ import {
2
+ __export
3
+ } from "./chunk-MLKGABMK.js";
4
+
5
+ // src/tempfile.browser.ts
6
+ var tempfile_browser_exports = {};
7
+ __export(tempfile_browser_exports, {
8
+ NamedTemporaryFile: () => NamedTemporaryFile,
9
+ TemporaryDirectory: () => TemporaryDirectory,
10
+ getPrefix: () => getPrefix,
11
+ getTempDir: () => getTempDir,
12
+ mkdtemp: () => mkdtemp,
13
+ mkstemp: () => mkstemp,
14
+ mktemp: () => mktemp
15
+ });
16
+ function getTempDir() {
17
+ return "/tmp";
18
+ }
19
+ function getPrefix() {
20
+ return "tmp";
21
+ }
22
+ function mktemp(suffix = "", prefix = "tmp", dir) {
23
+ const tempDir = dir ?? getTempDir();
24
+ const randomPart = Math.random().toString(36).slice(2, 10);
25
+ return `${tempDir}/${prefix}${randomPart}${suffix}`;
26
+ }
27
+ async function mkstemp(_suffix = "", _prefix = "tmp", _dir) {
28
+ throw new Error("mkstemp is not supported in browser environment");
29
+ }
30
+ async function mkdtemp(_suffix = "", _prefix = "tmp", _dir) {
31
+ throw new Error("mkdtemp is not supported in browser environment");
32
+ }
33
+ var NamedTemporaryFile = class {
34
+ name = "";
35
+ deleteOnClose = true;
36
+ constructor() {
37
+ throw new Error("NamedTemporaryFile is not supported in browser environment");
38
+ }
39
+ static async create(_options) {
40
+ throw new Error("NamedTemporaryFile is not supported in browser environment");
41
+ }
42
+ async write(_data) {
43
+ throw new Error("Not supported in browser");
44
+ }
45
+ async read(_size) {
46
+ throw new Error("Not supported in browser");
47
+ }
48
+ async flush() {
49
+ throw new Error("Not supported in browser");
50
+ }
51
+ async close() {
52
+ throw new Error("Not supported in browser");
53
+ }
54
+ };
55
+ var TemporaryDirectory = class {
56
+ name = "";
57
+ constructor() {
58
+ throw new Error("TemporaryDirectory is not supported in browser environment");
59
+ }
60
+ static async create(_options) {
61
+ throw new Error("TemporaryDirectory is not supported in browser environment");
62
+ }
63
+ async cleanup() {
64
+ throw new Error("Not supported in browser");
65
+ }
66
+ };
67
+
68
+ export {
69
+ getTempDir,
70
+ getPrefix,
71
+ mktemp,
72
+ mkstemp,
73
+ mkdtemp,
74
+ NamedTemporaryFile,
75
+ TemporaryDirectory,
76
+ tempfile_browser_exports
77
+ };
78
+ /* v8 ignore start -- browser stubs @preserve */
@@ -0,0 +1,237 @@
1
+ import {
2
+ __export
3
+ } from "./chunk-MLKGABMK.js";
4
+
5
+ // src/base64.ts
6
+ var base64_exports = {};
7
+ __export(base64_exports, {
8
+ a85decode: () => a85decode,
9
+ a85encode: () => a85encode,
10
+ b16decode: () => b16decode,
11
+ b16encode: () => b16encode,
12
+ b32decode: () => b32decode,
13
+ b32encode: () => b32encode,
14
+ b64decode: () => b64decode,
15
+ b64encode: () => b64encode,
16
+ b85decode: () => b85decode,
17
+ b85encode: () => b85encode,
18
+ decodeString: () => decodeString,
19
+ encodeString: () => encodeString,
20
+ standardB64decode: () => standardB64decode,
21
+ standardB64encode: () => standardB64encode,
22
+ urlsafeB64decode: () => urlsafeB64decode,
23
+ urlsafeB64encode: () => urlsafeB64encode
24
+ });
25
+ function uint8ArrayToBase64(bytes) {
26
+ if (typeof Buffer !== "undefined") {
27
+ return Buffer.from(bytes).toString("base64");
28
+ }
29
+ let binary = "";
30
+ for (const byte of bytes) {
31
+ binary += String.fromCharCode(byte);
32
+ }
33
+ return btoa(binary);
34
+ }
35
+ function base64ToUint8Array(base64) {
36
+ if (typeof Buffer !== "undefined") {
37
+ return new Uint8Array(Buffer.from(base64, "base64"));
38
+ }
39
+ const binary = atob(base64);
40
+ const bytes = new Uint8Array(binary.length);
41
+ for (let i = 0; i < binary.length; i++) {
42
+ bytes[i] = binary.charCodeAt(i);
43
+ }
44
+ return bytes;
45
+ }
46
+ function b64encode(s) {
47
+ const bytes = typeof s === "string" ? new TextEncoder().encode(s) : s;
48
+ const base64String = uint8ArrayToBase64(bytes);
49
+ return new TextEncoder().encode(base64String);
50
+ }
51
+ function b64decode(s) {
52
+ const base64String = typeof s === "string" ? s : new TextDecoder().decode(s);
53
+ const cleaned = base64String.replace(/\s/g, "");
54
+ return base64ToUint8Array(cleaned);
55
+ }
56
+ function standardB64encode(s) {
57
+ return b64encode(s);
58
+ }
59
+ function standardB64decode(s) {
60
+ return b64decode(s);
61
+ }
62
+ function urlsafeB64encode(s) {
63
+ const bytes = typeof s === "string" ? new TextEncoder().encode(s) : s;
64
+ const base64String = uint8ArrayToBase64(bytes);
65
+ const urlSafe = base64String.replace(/\+/g, "-").replace(/\//g, "_");
66
+ return new TextEncoder().encode(urlSafe);
67
+ }
68
+ function urlsafeB64decode(s) {
69
+ const base64String = typeof s === "string" ? s : new TextDecoder().decode(s);
70
+ const cleaned = base64String.replace(/\s/g, "").replace(/-/g, "+").replace(/_/g, "/");
71
+ const padding = (4 - cleaned.length % 4) % 4;
72
+ const padded = cleaned + "=".repeat(padding);
73
+ return base64ToUint8Array(padded);
74
+ }
75
+ function b16encode(s) {
76
+ const bytes = typeof s === "string" ? new TextEncoder().encode(s) : s;
77
+ let hex = "";
78
+ for (const byte of bytes) {
79
+ hex += byte.toString(16).padStart(2, "0").toUpperCase();
80
+ }
81
+ return new TextEncoder().encode(hex);
82
+ }
83
+ function b16decode(s) {
84
+ const hexString = typeof s === "string" ? s : new TextDecoder().decode(s);
85
+ const cleaned = hexString.replace(/\s/g, "");
86
+ if (cleaned.length % 2 !== 0) {
87
+ throw new Error("Non-hexadecimal digit found");
88
+ }
89
+ const bytes = new Uint8Array(cleaned.length / 2);
90
+ for (let i = 0; i < cleaned.length; i += 2) {
91
+ const byte = parseInt(cleaned.substring(i, i + 2), 16);
92
+ if (isNaN(byte)) {
93
+ throw new Error("Non-hexadecimal digit found");
94
+ }
95
+ bytes[i / 2] = byte;
96
+ }
97
+ return bytes;
98
+ }
99
+ function b32encode(s) {
100
+ const bytes = typeof s === "string" ? new TextEncoder().encode(s) : s;
101
+ const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
102
+ let result = "";
103
+ let bits = 0;
104
+ let value = 0;
105
+ for (const byte of bytes) {
106
+ value = value << 8 | byte;
107
+ bits += 8;
108
+ while (bits >= 5) {
109
+ bits -= 5;
110
+ const idx = value >> bits & 31;
111
+ result += alphabet[idx] ?? "";
112
+ }
113
+ }
114
+ if (bits > 0) {
115
+ const idx = value << 5 - bits & 31;
116
+ result += alphabet[idx] ?? "";
117
+ }
118
+ while (result.length % 8 !== 0) {
119
+ result += "=";
120
+ }
121
+ return new TextEncoder().encode(result);
122
+ }
123
+ function b32decode(s) {
124
+ const base32String = typeof s === "string" ? s : new TextDecoder().decode(s);
125
+ const alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567";
126
+ const cleaned = base32String.replace(/=+$/, "").replace(/\s/g, "").toUpperCase();
127
+ let bits = 0;
128
+ let value = 0;
129
+ const result = [];
130
+ for (const char of cleaned) {
131
+ const idx = alphabet.indexOf(char);
132
+ if (idx === -1) {
133
+ throw new Error("Invalid Base32 character");
134
+ }
135
+ value = value << 5 | idx;
136
+ bits += 5;
137
+ if (bits >= 8) {
138
+ bits -= 8;
139
+ result.push(value >> bits & 255);
140
+ }
141
+ }
142
+ return new Uint8Array(result);
143
+ }
144
+ function a85encode(s) {
145
+ const bytes = typeof s === "string" ? new TextEncoder().encode(s) : s;
146
+ let result = "";
147
+ for (let i = 0; i < bytes.length; i += 4) {
148
+ const chunk = bytes.slice(i, i + 4);
149
+ let value = 0;
150
+ for (const byte of chunk) {
151
+ value = value * 256 + byte;
152
+ }
153
+ for (let j = chunk.length; j < 4; j++) {
154
+ value = value * 256;
155
+ }
156
+ if (value === 0 && chunk.length === 4) {
157
+ result += "z";
158
+ } else {
159
+ const chars = [];
160
+ for (let j = 0; j < 5; j++) {
161
+ chars.unshift(String.fromCharCode(value % 85 + 33));
162
+ value = Math.floor(value / 85);
163
+ }
164
+ const outputLen = chunk.length + 1;
165
+ result += chars.slice(0, outputLen).join("");
166
+ }
167
+ }
168
+ return new TextEncoder().encode(result);
169
+ }
170
+ function a85decode(s) {
171
+ const ascii85String = typeof s === "string" ? s : new TextDecoder().decode(s);
172
+ const cleaned = ascii85String.replace(/\s/g, "");
173
+ const result = [];
174
+ let i = 0;
175
+ while (i < cleaned.length) {
176
+ if (cleaned[i] === "z") {
177
+ result.push(0, 0, 0, 0);
178
+ i++;
179
+ } else {
180
+ let chunk = cleaned.slice(i, i + 5);
181
+ const chunkLen = chunk.length;
182
+ while (chunk.length < 5) {
183
+ chunk += "u";
184
+ }
185
+ let value = 0;
186
+ for (let j = 0; j < 5; j++) {
187
+ const charCode = chunk.charCodeAt(j) - 33;
188
+ if (charCode < 0 || charCode > 84) {
189
+ throw new Error("Invalid Ascii85 character");
190
+ }
191
+ value = value * 85 + charCode;
192
+ }
193
+ const bytes = [];
194
+ for (let j = 0; j < 4; j++) {
195
+ bytes.unshift(value & 255);
196
+ value = Math.floor(value / 256);
197
+ }
198
+ const outputLen = chunkLen - 1;
199
+ result.push(...bytes.slice(0, outputLen));
200
+ i += chunkLen;
201
+ }
202
+ }
203
+ return new Uint8Array(result);
204
+ }
205
+ function b85encode(s) {
206
+ return a85encode(s);
207
+ }
208
+ function b85decode(s) {
209
+ return a85decode(s);
210
+ }
211
+ function encodeString(s) {
212
+ const bytes = typeof s === "string" ? new TextEncoder().encode(s) : s;
213
+ return uint8ArrayToBase64(bytes);
214
+ }
215
+ function decodeString(s) {
216
+ return base64ToUint8Array(s);
217
+ }
218
+
219
+ export {
220
+ b64encode,
221
+ b64decode,
222
+ standardB64encode,
223
+ standardB64decode,
224
+ urlsafeB64encode,
225
+ urlsafeB64decode,
226
+ b16encode,
227
+ b16decode,
228
+ b32encode,
229
+ b32decode,
230
+ a85encode,
231
+ a85decode,
232
+ b85encode,
233
+ b85decode,
234
+ encodeString,
235
+ decodeString,
236
+ base64_exports
237
+ };
@@ -1,6 +1,6 @@
1
1
  import {
2
2
  __export
3
- } from "./chunk-PZ5AY32C.js";
3
+ } from "./chunk-MLKGABMK.js";
4
4
 
5
5
  // src/random.ts
6
6
  var random_exports = {};
@@ -80,7 +80,8 @@ function choices(population, options) {
80
80
  let hi = cumWeights.length;
81
81
  while (lo < hi) {
82
82
  const mid = Math.floor((lo + hi) / 2);
83
- if (r > cumWeights[mid]) {
83
+ const midWeight = cumWeights[mid];
84
+ if (midWeight !== void 0 && r > midWeight) {
84
85
  lo = mid + 1;
85
86
  } else {
86
87
  hi = mid;
@@ -132,9 +133,7 @@ function gauss(mu = 0, sigma = 1) {
132
133
  }
133
134
  var normalVariate = gauss;
134
135
  function triangular(low = 0, high = 1, mode) {
135
- if (mode === void 0) {
136
- mode = (low + high) / 2;
137
- }
136
+ mode ??= (low + high) / 2;
138
137
  const u = Math.random();
139
138
  const c = (mode - low) / (high - low);
140
139
  if (u < c) {
@@ -233,4 +232,3 @@ export {
233
232
  weibullVariate,
234
233
  random_exports
235
234
  };
236
- //# sourceMappingURL=chunk-7BZB2TQF.js.map