pythonlib 0.1.0 → 0.2.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +41 -138
- package/dist/{chunk-P3SGIF72.js → chunk-4KYJT3DR.js} +8 -6
- package/dist/chunk-4KYJT3DR.js.map +1 -0
- package/dist/{chunk-3CSEXTA7.js → chunk-4QG3772L.js} +53 -53
- package/dist/chunk-4QG3772L.js.map +1 -0
- package/dist/{chunk-IVYYI2VR.js → chunk-6POEDI34.js} +1 -1
- package/dist/chunk-6POEDI34.js.map +1 -0
- package/dist/{chunk-UFMTN4T4.js → chunk-6ZAJ37MR.js} +6 -5
- package/dist/chunk-6ZAJ37MR.js.map +1 -0
- package/dist/{chunk-V63LKSA3.js → chunk-7TH4FCVQ.js} +24 -24
- package/dist/chunk-7TH4FCVQ.js.map +1 -0
- package/dist/{chunk-TJFGYXBJ.js → chunk-CXKGPD5D.js} +64 -61
- package/dist/chunk-CXKGPD5D.js.map +1 -0
- package/dist/{chunk-OMQNGE6T.js → chunk-EE7SK2GV.js} +33 -27
- package/dist/chunk-EE7SK2GV.js.map +1 -0
- package/dist/{chunk-WAONBJE5.js → chunk-H76SKASU.js} +36 -36
- package/dist/chunk-H76SKASU.js.map +1 -0
- package/dist/{chunk-TOI6IG3T.js → chunk-HQ42WNKZ.js} +43 -16
- package/dist/chunk-HQ42WNKZ.js.map +1 -0
- package/dist/{chunk-HA5Y7PKO.js → chunk-LWO6BIAD.js} +36 -35
- package/dist/chunk-LWO6BIAD.js.map +1 -0
- package/dist/{collections-xN9Gi0TA.d.ts → collections-CJur5Wg-.d.ts} +5 -3
- package/dist/collections.d.ts +1 -1
- package/dist/collections.js +1 -1
- package/dist/{datetime-DRwFAiGV.d.ts → datetime-Bpce8gG2.d.ts} +17 -15
- package/dist/datetime.d.ts +1 -1
- package/dist/datetime.js +1 -1
- package/dist/{functools-St5GqpKG.d.ts → functools-NrsZAqJk.d.ts} +42 -26
- package/dist/functools.d.ts +1 -1
- package/dist/functools.js +19 -17
- package/dist/index.d.ts +56 -158
- package/dist/index.js +47 -137
- package/dist/index.js.map +1 -1
- package/dist/{itertools-Bj8XivI6.d.ts → itertools-Sjl1LB_0.d.ts} +35 -17
- package/dist/itertools.d.ts +1 -1
- package/dist/itertools.js +15 -11
- package/dist/{json-Xpk0kwSd.d.ts → json-DAlvCadU.d.ts} +7 -5
- package/dist/json.d.ts +1 -1
- package/dist/json.js +1 -1
- package/dist/{math-BrT4Aw3E.d.ts → math-DwEGjjQ-.d.ts} +2 -0
- package/dist/math.d.ts +1 -1
- package/dist/math.js +1 -1
- package/dist/{os-FRSJbEUH.d.ts → os-C6Nt7Ijx.d.ts} +45 -42
- package/dist/os.d.ts +1 -1
- package/dist/os.js +23 -23
- package/dist/{random-D5S5iSV3.d.ts → random-BJv_rSpL.d.ts} +24 -22
- package/dist/random.d.ts +1 -1
- package/dist/random.js +21 -21
- package/dist/{re-DSxiURqN.d.ts → re-B1CHCgyr.d.ts} +17 -15
- package/dist/re.d.ts +1 -1
- package/dist/re.js +7 -7
- package/dist/string.d.ts +51 -48
- package/dist/string.js +13 -13
- package/package.json +30 -11
- package/dist/chunk-3CSEXTA7.js.map +0 -1
- package/dist/chunk-HA5Y7PKO.js.map +0 -1
- package/dist/chunk-IVYYI2VR.js.map +0 -1
- package/dist/chunk-OMQNGE6T.js.map +0 -1
- package/dist/chunk-P3SGIF72.js.map +0 -1
- package/dist/chunk-TJFGYXBJ.js.map +0 -1
- package/dist/chunk-TOI6IG3T.js.map +0 -1
- package/dist/chunk-UFMTN4T4.js.map +0 -1
- package/dist/chunk-V63LKSA3.js.map +0 -1
- package/dist/chunk-WAONBJE5.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,51 +1,48 @@
|
|
|
1
1
|
import {
|
|
2
2
|
random_exports
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-H76SKASU.js";
|
|
4
4
|
import {
|
|
5
5
|
re_exports
|
|
6
|
-
} from "./chunk-
|
|
6
|
+
} from "./chunk-7TH4FCVQ.js";
|
|
7
7
|
import {
|
|
8
8
|
Template,
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
asciiLetters,
|
|
10
|
+
asciiLowercase,
|
|
11
|
+
asciiUppercase,
|
|
12
|
+
capWords,
|
|
13
13
|
digits,
|
|
14
|
-
|
|
15
|
-
|
|
14
|
+
hexDigits,
|
|
15
|
+
octDigits,
|
|
16
16
|
printable,
|
|
17
17
|
punctuation,
|
|
18
18
|
string,
|
|
19
19
|
whitespace
|
|
20
|
-
} from "./chunk-
|
|
20
|
+
} from "./chunk-4QG3772L.js";
|
|
21
21
|
import {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
defaultdict,
|
|
25
|
-
deque
|
|
26
|
-
} from "./chunk-UFMTN4T4.js";
|
|
22
|
+
collections_exports
|
|
23
|
+
} from "./chunk-6ZAJ37MR.js";
|
|
27
24
|
import {
|
|
28
25
|
datetime_exports
|
|
29
|
-
} from "./chunk-
|
|
26
|
+
} from "./chunk-LWO6BIAD.js";
|
|
30
27
|
import {
|
|
31
28
|
functools_exports
|
|
32
|
-
} from "./chunk-
|
|
29
|
+
} from "./chunk-EE7SK2GV.js";
|
|
33
30
|
import {
|
|
34
31
|
itertools_exports
|
|
35
|
-
} from "./chunk-
|
|
32
|
+
} from "./chunk-HQ42WNKZ.js";
|
|
36
33
|
import {
|
|
37
34
|
json_exports
|
|
38
|
-
} from "./chunk-
|
|
35
|
+
} from "./chunk-4KYJT3DR.js";
|
|
39
36
|
import {
|
|
40
37
|
math_exports
|
|
41
|
-
} from "./chunk-
|
|
38
|
+
} from "./chunk-6POEDI34.js";
|
|
42
39
|
import {
|
|
43
40
|
os_exports
|
|
44
|
-
} from "./chunk-
|
|
41
|
+
} from "./chunk-CXKGPD5D.js";
|
|
45
42
|
import "./chunk-PZ5AY32C.js";
|
|
46
43
|
|
|
47
44
|
// src/core.ts
|
|
48
|
-
function
|
|
45
|
+
function floorDiv(a, b) {
|
|
49
46
|
return Math.floor(a / b);
|
|
50
47
|
}
|
|
51
48
|
function pow(base, exp) {
|
|
@@ -54,8 +51,8 @@ function pow(base, exp) {
|
|
|
54
51
|
function mod(a, b) {
|
|
55
52
|
return (a % b + b) % b;
|
|
56
53
|
}
|
|
57
|
-
function
|
|
58
|
-
return [
|
|
54
|
+
function divMod(a, b) {
|
|
55
|
+
return [floorDiv(a, b), mod(a, b)];
|
|
59
56
|
}
|
|
60
57
|
function sprintf(template, args) {
|
|
61
58
|
const values = Array.isArray(args) ? args : [args];
|
|
@@ -90,6 +87,7 @@ function sprintf(template, args) {
|
|
|
90
87
|
return Number(value).toExponential();
|
|
91
88
|
case "c":
|
|
92
89
|
return String.fromCharCode(Number(value));
|
|
90
|
+
/* v8 ignore next 2 -- unreachable: regex only matches handled cases @preserve */
|
|
93
91
|
default:
|
|
94
92
|
return String(value);
|
|
95
93
|
}
|
|
@@ -206,10 +204,6 @@ function is(a, b) {
|
|
|
206
204
|
}
|
|
207
205
|
|
|
208
206
|
// src/builtins.ts
|
|
209
|
-
var py;
|
|
210
|
-
function _setPyRef(pyRef) {
|
|
211
|
-
py = pyRef;
|
|
212
|
-
}
|
|
213
207
|
function range(startOrStop, stop, step) {
|
|
214
208
|
let start;
|
|
215
209
|
let end;
|
|
@@ -466,17 +460,17 @@ function str(x) {
|
|
|
466
460
|
return x ? "True" : "False";
|
|
467
461
|
}
|
|
468
462
|
if (Array.isArray(x)) {
|
|
469
|
-
return "[" + x.map((item) =>
|
|
463
|
+
return "[" + x.map((item) => repr(item)).join(", ") + "]";
|
|
470
464
|
}
|
|
471
465
|
if (x instanceof Map) {
|
|
472
|
-
const entries = Array.from(x.entries()).map(([k, v]) => `${
|
|
466
|
+
const entries = Array.from(x.entries()).map(([k, v]) => `${repr(k)}: ${repr(v)}`).join(", ");
|
|
473
467
|
return "{" + entries + "}";
|
|
474
468
|
}
|
|
475
469
|
if (x instanceof Set) {
|
|
476
470
|
if (x.size === 0) {
|
|
477
471
|
return "set()";
|
|
478
472
|
}
|
|
479
|
-
return "{" + Array.from(x).map((item) =>
|
|
473
|
+
return "{" + Array.from(x).map((item) => repr(item)).join(", ") + "}";
|
|
480
474
|
}
|
|
481
475
|
return String(x);
|
|
482
476
|
}
|
|
@@ -857,9 +851,9 @@ var dict2 = {
|
|
|
857
851
|
return key in obj ? obj[key] : defaultValue;
|
|
858
852
|
},
|
|
859
853
|
/**
|
|
860
|
-
* Python dict.
|
|
854
|
+
* Python dict.setDefault() - get value or set default
|
|
861
855
|
*/
|
|
862
|
-
|
|
856
|
+
setDefault(obj, key, defaultValue) {
|
|
863
857
|
if (!(key in obj)) {
|
|
864
858
|
obj[key] = defaultValue;
|
|
865
859
|
}
|
|
@@ -880,9 +874,9 @@ var dict2 = {
|
|
|
880
874
|
throw new Error("KeyError");
|
|
881
875
|
},
|
|
882
876
|
/**
|
|
883
|
-
* Python dict.
|
|
877
|
+
* Python dict.popItem() - remove and return last item
|
|
884
878
|
*/
|
|
885
|
-
|
|
879
|
+
popItem(obj) {
|
|
886
880
|
const keys = Object.keys(obj);
|
|
887
881
|
if (keys.length === 0) {
|
|
888
882
|
throw new Error("dictionary is empty");
|
|
@@ -937,9 +931,9 @@ var dict2 = {
|
|
|
937
931
|
return Object.entries(obj);
|
|
938
932
|
},
|
|
939
933
|
/**
|
|
940
|
-
* Python dict.
|
|
934
|
+
* Python dict.fromKeys() - create dict from keys
|
|
941
935
|
*/
|
|
942
|
-
|
|
936
|
+
fromKeys(keys, value) {
|
|
943
937
|
const result = {};
|
|
944
938
|
for (const key of keys) {
|
|
945
939
|
result[key] = value;
|
|
@@ -1081,27 +1075,27 @@ var set2 = {
|
|
|
1081
1075
|
for (const item of toAdd) a.add(item);
|
|
1082
1076
|
},
|
|
1083
1077
|
/**
|
|
1084
|
-
* Python set.
|
|
1078
|
+
* Python set.isSubset() - test if all elements are in other
|
|
1085
1079
|
*/
|
|
1086
|
-
|
|
1080
|
+
isSubset(a, b) {
|
|
1087
1081
|
for (const item of a) {
|
|
1088
1082
|
if (!b.has(item)) return false;
|
|
1089
1083
|
}
|
|
1090
1084
|
return true;
|
|
1091
1085
|
},
|
|
1092
1086
|
/**
|
|
1093
|
-
* Python set.
|
|
1087
|
+
* Python set.isSuperset() - test if all other elements are in this set
|
|
1094
1088
|
*/
|
|
1095
|
-
|
|
1089
|
+
isSuperset(a, b) {
|
|
1096
1090
|
for (const item of b) {
|
|
1097
1091
|
if (!a.has(item)) return false;
|
|
1098
1092
|
}
|
|
1099
1093
|
return true;
|
|
1100
1094
|
},
|
|
1101
1095
|
/**
|
|
1102
|
-
* Python set.
|
|
1096
|
+
* Python set.isDisjoint() - test if no common elements
|
|
1103
1097
|
*/
|
|
1104
|
-
|
|
1098
|
+
isDisjoint(a, b) {
|
|
1105
1099
|
for (const item of a) {
|
|
1106
1100
|
if (b.has(item)) return false;
|
|
1107
1101
|
}
|
|
@@ -1121,16 +1115,16 @@ var datetime = datetime_exports;
|
|
|
1121
1115
|
var re = re_exports;
|
|
1122
1116
|
var string2 = {
|
|
1123
1117
|
...string,
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1118
|
+
asciiLowercase,
|
|
1119
|
+
asciiUppercase,
|
|
1120
|
+
asciiLetters,
|
|
1127
1121
|
digits,
|
|
1128
|
-
|
|
1129
|
-
|
|
1122
|
+
hexDigits,
|
|
1123
|
+
octDigits,
|
|
1130
1124
|
punctuation,
|
|
1131
1125
|
whitespace,
|
|
1132
1126
|
printable,
|
|
1133
|
-
|
|
1127
|
+
capWords,
|
|
1134
1128
|
Template
|
|
1135
1129
|
};
|
|
1136
1130
|
var list3 = Object.assign(
|
|
@@ -1145,9 +1139,9 @@ var set3 = Object.assign(
|
|
|
1145
1139
|
(iterable) => set(iterable),
|
|
1146
1140
|
set2
|
|
1147
1141
|
);
|
|
1148
|
-
var
|
|
1142
|
+
var floorDiv2 = floorDiv;
|
|
1149
1143
|
var mod2 = mod;
|
|
1150
|
-
var
|
|
1144
|
+
var divMod2 = divMod;
|
|
1151
1145
|
var sprintf2 = sprintf;
|
|
1152
1146
|
var strFormat2 = strFormat;
|
|
1153
1147
|
var slice2 = slice;
|
|
@@ -1186,89 +1180,6 @@ var isinstance2 = isinstance;
|
|
|
1186
1180
|
var type2 = type;
|
|
1187
1181
|
var input2 = input;
|
|
1188
1182
|
var format2 = format;
|
|
1189
|
-
var py2 = {
|
|
1190
|
-
// Namespaced methods
|
|
1191
|
-
string,
|
|
1192
|
-
list: list3,
|
|
1193
|
-
dict: dict3,
|
|
1194
|
-
set: set3,
|
|
1195
|
-
// Core operations
|
|
1196
|
-
floordiv,
|
|
1197
|
-
pow,
|
|
1198
|
-
mod,
|
|
1199
|
-
divmod,
|
|
1200
|
-
sprintf,
|
|
1201
|
-
strFormat,
|
|
1202
|
-
slice,
|
|
1203
|
-
at,
|
|
1204
|
-
repeat,
|
|
1205
|
-
in: contains,
|
|
1206
|
-
is,
|
|
1207
|
-
// Iterables
|
|
1208
|
-
range,
|
|
1209
|
-
enumerate,
|
|
1210
|
-
zip,
|
|
1211
|
-
iter,
|
|
1212
|
-
reversed,
|
|
1213
|
-
sorted,
|
|
1214
|
-
map,
|
|
1215
|
-
filter,
|
|
1216
|
-
// Collection constructors
|
|
1217
|
-
tuple,
|
|
1218
|
-
// Built-in functions
|
|
1219
|
-
len,
|
|
1220
|
-
abs,
|
|
1221
|
-
min,
|
|
1222
|
-
max,
|
|
1223
|
-
sum,
|
|
1224
|
-
all,
|
|
1225
|
-
any,
|
|
1226
|
-
round,
|
|
1227
|
-
ord,
|
|
1228
|
-
chr,
|
|
1229
|
-
hex,
|
|
1230
|
-
oct,
|
|
1231
|
-
bin,
|
|
1232
|
-
// Type conversions
|
|
1233
|
-
int,
|
|
1234
|
-
float,
|
|
1235
|
-
str,
|
|
1236
|
-
repr,
|
|
1237
|
-
bool,
|
|
1238
|
-
ascii,
|
|
1239
|
-
// Type checking
|
|
1240
|
-
isinstance,
|
|
1241
|
-
type,
|
|
1242
|
-
input,
|
|
1243
|
-
format,
|
|
1244
|
-
// Modules
|
|
1245
|
-
itertools: itertools_exports,
|
|
1246
|
-
functools: functools_exports,
|
|
1247
|
-
math: math_exports,
|
|
1248
|
-
random: random_exports,
|
|
1249
|
-
json: json_exports,
|
|
1250
|
-
os: os_exports,
|
|
1251
|
-
datetime: datetime_exports,
|
|
1252
|
-
re: re_exports,
|
|
1253
|
-
// collections
|
|
1254
|
-
Counter,
|
|
1255
|
-
defaultdict,
|
|
1256
|
-
deque,
|
|
1257
|
-
// string module
|
|
1258
|
-
Template,
|
|
1259
|
-
ascii_lowercase,
|
|
1260
|
-
ascii_uppercase,
|
|
1261
|
-
ascii_letters,
|
|
1262
|
-
digits,
|
|
1263
|
-
hexdigits,
|
|
1264
|
-
octdigits,
|
|
1265
|
-
punctuation,
|
|
1266
|
-
whitespace,
|
|
1267
|
-
printable,
|
|
1268
|
-
capwords
|
|
1269
|
-
};
|
|
1270
|
-
_setPyRef(py2);
|
|
1271
|
-
var index_default = py2;
|
|
1272
1183
|
export {
|
|
1273
1184
|
abs2 as abs,
|
|
1274
1185
|
all2 as all,
|
|
@@ -1281,13 +1192,12 @@ export {
|
|
|
1281
1192
|
collections,
|
|
1282
1193
|
contains2 as contains,
|
|
1283
1194
|
datetime,
|
|
1284
|
-
index_default as default,
|
|
1285
1195
|
dict3 as dict,
|
|
1286
|
-
|
|
1196
|
+
divMod2 as divMod,
|
|
1287
1197
|
enumerate2 as enumerate,
|
|
1288
1198
|
filter2 as filter,
|
|
1289
1199
|
float2 as float,
|
|
1290
|
-
|
|
1200
|
+
floorDiv2 as floorDiv,
|
|
1291
1201
|
format2 as format,
|
|
1292
1202
|
functools,
|
|
1293
1203
|
hex2 as hex,
|
|
@@ -1309,7 +1219,6 @@ export {
|
|
|
1309
1219
|
ord2 as ord,
|
|
1310
1220
|
os,
|
|
1311
1221
|
pow,
|
|
1312
|
-
py2 as py,
|
|
1313
1222
|
random,
|
|
1314
1223
|
range2 as range,
|
|
1315
1224
|
re,
|
|
@@ -1329,4 +1238,5 @@ export {
|
|
|
1329
1238
|
type2 as type,
|
|
1330
1239
|
zip2 as zip
|
|
1331
1240
|
};
|
|
1241
|
+
/* v8 ignore next -- fallback for unrecognized format types @preserve */
|
|
1332
1242
|
//# sourceMappingURL=index.js.map
|