@jrc03c/make-key 0.0.35 → 0.0.37
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/.prettierrc.json +10 -0
- package/dist/make-key.js +161 -266
- package/dist/make-key.min.js +5 -5
- package/package.json +3 -3
package/.prettierrc.json
ADDED
package/dist/make-key.js
CHANGED
|
@@ -32,8 +32,7 @@
|
|
|
32
32
|
|
|
33
33
|
// node_modules/@jrc03c/js-math-tools/src/assert.mjs
|
|
34
34
|
function assert(isTrue, message) {
|
|
35
|
-
if (!isTrue)
|
|
36
|
-
throw new MathError(message);
|
|
35
|
+
if (!isTrue) throw new MathError(message);
|
|
37
36
|
}
|
|
38
37
|
|
|
39
38
|
// node_modules/@jrc03c/js-math-tools/src/helpers/array-types.mjs
|
|
@@ -240,8 +239,7 @@
|
|
|
240
239
|
}
|
|
241
240
|
}
|
|
242
241
|
if (typeof x2 === "object") {
|
|
243
|
-
if (x2 === null)
|
|
244
|
-
return null;
|
|
242
|
+
if (x2 === null) return null;
|
|
245
243
|
checked.push(x2);
|
|
246
244
|
if (isArray(x2)) {
|
|
247
245
|
if (typeof x2.constructor !== "undefined" && x2.constructor.name !== "Array") {
|
|
@@ -290,12 +288,9 @@
|
|
|
290
288
|
const bType = typeof b2;
|
|
291
289
|
if (aType !== bType && !numberTypes.includes(aType) && !numberTypes.includes(bType))
|
|
292
290
|
return false;
|
|
293
|
-
if (aType === "undefined" && bType === "undefined")
|
|
294
|
-
|
|
295
|
-
if (aType === "
|
|
296
|
-
return a2 === b2;
|
|
297
|
-
if (aType === "symbol")
|
|
298
|
-
return a2 === b2;
|
|
291
|
+
if (aType === "undefined" && bType === "undefined") return true;
|
|
292
|
+
if (aType === "boolean") return a2 === b2;
|
|
293
|
+
if (aType === "symbol") return a2 === b2;
|
|
299
294
|
if (aType === "number" || aType === "bigint") {
|
|
300
295
|
try {
|
|
301
296
|
const aString = a2.toString();
|
|
@@ -305,10 +300,8 @@
|
|
|
305
300
|
return false;
|
|
306
301
|
}
|
|
307
302
|
}
|
|
308
|
-
if (aType === "string")
|
|
309
|
-
|
|
310
|
-
if (aType === "function")
|
|
311
|
-
return a2 === b2;
|
|
303
|
+
if (aType === "string") return a2 === b2;
|
|
304
|
+
if (aType === "function") return a2 === b2;
|
|
312
305
|
if (aType === "object") {
|
|
313
306
|
if (a2 === null || b2 === null) {
|
|
314
307
|
return a2 === null && b2 === null;
|
|
@@ -330,12 +323,10 @@
|
|
|
330
323
|
}
|
|
331
324
|
const aKeys = Object.keys(a2).concat(Object.getOwnPropertySymbols(a2));
|
|
332
325
|
const bKeys = Object.keys(b2).concat(Object.getOwnPropertySymbols(b2));
|
|
333
|
-
if (aKeys.length !== bKeys.length)
|
|
334
|
-
return false;
|
|
326
|
+
if (aKeys.length !== bKeys.length) return false;
|
|
335
327
|
for (let i = 0; i < aKeys.length; i++) {
|
|
336
328
|
const key = aKeys[i];
|
|
337
|
-
if (!helper4(a2[key], b2[key]))
|
|
338
|
-
return false;
|
|
329
|
+
if (!helper4(a2[key], b2[key])) return false;
|
|
339
330
|
}
|
|
340
331
|
return true;
|
|
341
332
|
}
|
|
@@ -352,8 +343,7 @@
|
|
|
352
343
|
function makeKey(n) {
|
|
353
344
|
const alpha = "abcdefg1234567890";
|
|
354
345
|
let out = "";
|
|
355
|
-
while (out.length < n)
|
|
356
|
-
out += alpha[Math.floor(Math.random() * alpha.length)];
|
|
346
|
+
while (out.length < n) out += alpha[Math.floor(Math.random() * alpha.length)];
|
|
357
347
|
return out;
|
|
358
348
|
}
|
|
359
349
|
var NULL_KEY = makeKey(16);
|
|
@@ -636,13 +626,11 @@
|
|
|
636
626
|
var error = "You must pass a natural number or a one-dimensional array of natural numbers into the `ndarray` function!";
|
|
637
627
|
function ndarray(shape2) {
|
|
638
628
|
assert(!isUndefined(shape2), error);
|
|
639
|
-
if (!isArray(shape2))
|
|
640
|
-
shape2 = [shape2];
|
|
629
|
+
if (!isArray(shape2)) shape2 = [shape2];
|
|
641
630
|
assert(!isNested(shape2), error);
|
|
642
631
|
assert(shape2.length > 0, error);
|
|
643
632
|
let s2 = shape2[0];
|
|
644
|
-
if (typeof s2 === "bigint")
|
|
645
|
-
s2 = Number(s2);
|
|
633
|
+
if (typeof s2 === "bigint") s2 = Number(s2);
|
|
646
634
|
assert(isNumber(s2), error);
|
|
647
635
|
assert(s2 >= 0, error);
|
|
648
636
|
assert(Math.floor(s2) === s2, error);
|
|
@@ -652,8 +640,7 @@
|
|
|
652
640
|
);
|
|
653
641
|
if (shape2.length === 1) {
|
|
654
642
|
const out = [];
|
|
655
|
-
for (let i = 0; i < s2; i++)
|
|
656
|
-
out.push(void 0);
|
|
643
|
+
for (let i = 0; i < s2; i++) out.push(void 0);
|
|
657
644
|
return out;
|
|
658
645
|
} else {
|
|
659
646
|
const out = [];
|
|
@@ -677,8 +664,7 @@
|
|
|
677
664
|
"The `reverse` function only works on arrays, Series, and DataFrames!"
|
|
678
665
|
);
|
|
679
666
|
const out = [];
|
|
680
|
-
for (let i = arr.length - 1; i >= 0; i--)
|
|
681
|
-
out.push(arr[i]);
|
|
667
|
+
for (let i = arr.length - 1; i >= 0; i--) out.push(arr[i]);
|
|
682
668
|
return out;
|
|
683
669
|
}
|
|
684
670
|
|
|
@@ -719,8 +705,7 @@
|
|
|
719
705
|
out.push(i);
|
|
720
706
|
}
|
|
721
707
|
}
|
|
722
|
-
if (shouldReverse)
|
|
723
|
-
out = reverse(out);
|
|
708
|
+
if (shouldReverse) out = reverse(out);
|
|
724
709
|
return out;
|
|
725
710
|
}
|
|
726
711
|
|
|
@@ -728,8 +713,7 @@
|
|
|
728
713
|
function makeKey2(n) {
|
|
729
714
|
const alpha = "abcdefg1234567890";
|
|
730
715
|
let out = "";
|
|
731
|
-
while (out.length < n)
|
|
732
|
-
out += alpha[Math.floor(Math.random() * alpha.length)];
|
|
716
|
+
while (out.length < n) out += alpha[Math.floor(Math.random() * alpha.length)];
|
|
733
717
|
return out;
|
|
734
718
|
}
|
|
735
719
|
var NULL_KEY2 = makeKey2(256);
|
|
@@ -749,8 +733,7 @@
|
|
|
749
733
|
const temp = {};
|
|
750
734
|
flatten(arr).forEach((item) => {
|
|
751
735
|
const key = typeof item === "object" && item === null ? NULL_KEY2 : isUndefined(item) ? UNDEFINED_KEY2 : isFunction(item) ? item.toString() : typeof item === "symbol" ? item.toString() + " - " + SYMBOL_KEY2 : item === Infinity ? INFINITY_KEY2 : item === -Infinity ? MINUS_INFINITY_KEY2 : typeof item === "bigint" ? item.toString() : isDataFrame(item) ? item.toJSONString() : isSeries(item) ? JSON.stringify(item.toObject()) : JSON.stringify(item);
|
|
752
|
-
if (!temp[key])
|
|
753
|
-
out.push(item);
|
|
736
|
+
if (!temp[key]) out.push(item);
|
|
754
737
|
temp[key] = true;
|
|
755
738
|
});
|
|
756
739
|
return out;
|
|
@@ -1025,24 +1008,37 @@
|
|
|
1025
1008
|
isArray(p2) && !isJagged(p2) && shape(p2).length === 1,
|
|
1026
1009
|
"If passing two arguments into the `assign` method, then the second argument must be a 1-dimensional array!"
|
|
1027
1010
|
);
|
|
1028
|
-
const out = df.
|
|
1029
|
-
out.columns
|
|
1030
|
-
|
|
1011
|
+
const out = df.copy();
|
|
1012
|
+
if (out.columns.includes(p1)) {
|
|
1013
|
+
const index = out.columns.indexOf(p1);
|
|
1014
|
+
out.columns[index] = p1;
|
|
1015
|
+
out.values.forEach((v, i) => v[index] = p2[i]);
|
|
1016
|
+
return out;
|
|
1017
|
+
} else {
|
|
1018
|
+
out._columns.push(p1);
|
|
1019
|
+
out._values.forEach((v, i) => v.push(p2[i]));
|
|
1020
|
+
return out;
|
|
1021
|
+
}
|
|
1031
1022
|
} else {
|
|
1032
1023
|
if (isDataFrame2(p1)) {
|
|
1033
|
-
|
|
1024
|
+
const out = df.copy();
|
|
1025
|
+
const outShape = out.shape;
|
|
1026
|
+
const p1Shape = p1.shape;
|
|
1027
|
+
for (let j = 0; j < p1Shape[1]; j++) {
|
|
1028
|
+
const col = p1.columns[j];
|
|
1029
|
+
const colNewIndex = out.columns.includes(col) ? out.columns.indexOf(col) : out.columns.length;
|
|
1030
|
+
if (!out.columns.includes(col)) {
|
|
1031
|
+
out._columns.push(col);
|
|
1032
|
+
}
|
|
1033
|
+
for (let i = 0; i < outShape[0]; i++) {
|
|
1034
|
+
out._values[i][colNewIndex] = p1._values[i][j];
|
|
1035
|
+
}
|
|
1036
|
+
}
|
|
1037
|
+
return out;
|
|
1034
1038
|
} else if (isSeries2(p1)) {
|
|
1035
|
-
return df.
|
|
1039
|
+
return df.assign(p1.name, p1.values);
|
|
1036
1040
|
} else if (isObject(p1)) {
|
|
1037
|
-
|
|
1038
|
-
...Object.keys(p1).concat(Object.getOwnPropertySymbols(p1)).map((key) => p1[key].length)
|
|
1039
|
-
);
|
|
1040
|
-
Object.keys(p1).concat(Object.getOwnPropertySymbols(p1)).forEach((key) => {
|
|
1041
|
-
while (p1[key].length < maxColumnLength) {
|
|
1042
|
-
p1[key].push(void 0);
|
|
1043
|
-
}
|
|
1044
|
-
});
|
|
1045
|
-
return df.append(new DataFrame2(p1), 1);
|
|
1041
|
+
return df.assign(new DataFrame2(p1));
|
|
1046
1042
|
} else {
|
|
1047
1043
|
throw new MathError(
|
|
1048
1044
|
"You must pass a DataFrame, Series, or object into the `assign` method!"
|
|
@@ -1053,8 +1049,7 @@
|
|
|
1053
1049
|
|
|
1054
1050
|
// node_modules/@jrc03c/js-math-tools/src/dataframe/df-copy.mjs
|
|
1055
1051
|
function dfCopy(DataFrame2, df) {
|
|
1056
|
-
if (df.isEmpty)
|
|
1057
|
-
return new DataFrame2();
|
|
1052
|
+
if (df.isEmpty) return new DataFrame2();
|
|
1058
1053
|
const out = new DataFrame2(copy(df.values));
|
|
1059
1054
|
out.columns = df.columns.slice();
|
|
1060
1055
|
out.index = df.index.slice();
|
|
@@ -1063,14 +1058,10 @@
|
|
|
1063
1058
|
|
|
1064
1059
|
// node_modules/@jrc03c/js-math-tools/src/dataframe/df-drop.mjs
|
|
1065
1060
|
function dfDrop(DataFrame2, Series2, df, rows, cols) {
|
|
1066
|
-
if (isUndefined(rows))
|
|
1067
|
-
|
|
1068
|
-
if (
|
|
1069
|
-
|
|
1070
|
-
if (isString(rows) || isNumber(rows))
|
|
1071
|
-
rows = [rows];
|
|
1072
|
-
if (isString(cols) || isNumber(cols))
|
|
1073
|
-
cols = [cols];
|
|
1061
|
+
if (isUndefined(rows)) rows = [];
|
|
1062
|
+
if (isUndefined(cols)) cols = [];
|
|
1063
|
+
if (isString(rows) || isNumber(rows)) rows = [rows];
|
|
1064
|
+
if (isString(cols) || isNumber(cols)) cols = [cols];
|
|
1074
1065
|
assert(
|
|
1075
1066
|
isArray(rows),
|
|
1076
1067
|
"The `drop` method only works on 1-dimensional arrays of numerical indices and/or strings."
|
|
@@ -1090,15 +1081,13 @@
|
|
|
1090
1081
|
let outIndex, outColumns;
|
|
1091
1082
|
df.index.forEach((row, i) => {
|
|
1092
1083
|
if (rows.indexOf(row) < 0 && rows.indexOf(i) < 0) {
|
|
1093
|
-
if (!outIndex)
|
|
1094
|
-
outIndex = [];
|
|
1084
|
+
if (!outIndex) outIndex = [];
|
|
1095
1085
|
outIndex.push(row);
|
|
1096
1086
|
}
|
|
1097
1087
|
});
|
|
1098
1088
|
df.columns.forEach((col, i) => {
|
|
1099
1089
|
if (cols.indexOf(col) < 0 && cols.indexOf(i) < 0) {
|
|
1100
|
-
if (!outColumns)
|
|
1101
|
-
outColumns = [];
|
|
1090
|
+
if (!outColumns) outColumns = [];
|
|
1102
1091
|
outColumns.push(col);
|
|
1103
1092
|
}
|
|
1104
1093
|
});
|
|
@@ -1106,8 +1095,7 @@
|
|
|
1106
1095
|
if (out instanceof Series2) {
|
|
1107
1096
|
let temp = new DataFrame2();
|
|
1108
1097
|
temp = temp.assign(out);
|
|
1109
|
-
if (df.index.indexOf(out.name) > -1)
|
|
1110
|
-
temp = temp.transpose();
|
|
1098
|
+
if (df.index.indexOf(out.name) > -1) temp = temp.transpose();
|
|
1111
1099
|
out = temp;
|
|
1112
1100
|
}
|
|
1113
1101
|
return out;
|
|
@@ -1145,22 +1133,18 @@
|
|
|
1145
1133
|
let count2 = 0;
|
|
1146
1134
|
for (let i = 0; i < values.length; i++) {
|
|
1147
1135
|
const value = values[i];
|
|
1148
|
-
if (isUndefined(value))
|
|
1149
|
-
|
|
1150
|
-
if (count2 >= threshold)
|
|
1151
|
-
return [];
|
|
1136
|
+
if (isUndefined(value)) count2++;
|
|
1137
|
+
if (count2 >= threshold) return [];
|
|
1152
1138
|
}
|
|
1153
1139
|
} else if (condition === "any") {
|
|
1154
1140
|
for (let i = 0; i < values.length; i++) {
|
|
1155
1141
|
const value = values[i];
|
|
1156
|
-
if (isUndefined(value))
|
|
1157
|
-
return [];
|
|
1142
|
+
if (isUndefined(value)) return [];
|
|
1158
1143
|
}
|
|
1159
1144
|
} else if (condition === "all") {
|
|
1160
1145
|
for (let i = 0; i < values.length; i++) {
|
|
1161
1146
|
const value = values[i];
|
|
1162
|
-
if (!isUndefined(value))
|
|
1163
|
-
return values;
|
|
1147
|
+
if (!isUndefined(value)) return values;
|
|
1164
1148
|
}
|
|
1165
1149
|
return [];
|
|
1166
1150
|
}
|
|
@@ -1171,16 +1155,12 @@
|
|
|
1171
1155
|
if (axis === 0) {
|
|
1172
1156
|
out = out.assign(tempID, out.index);
|
|
1173
1157
|
const newValues = out.values.map(helper4).filter((row) => row.length > 0);
|
|
1174
|
-
if (shape(newValues).length < 2)
|
|
1175
|
-
return new DataFrame2();
|
|
1158
|
+
if (shape(newValues).length < 2) return new DataFrame2();
|
|
1176
1159
|
out.values = newValues;
|
|
1177
1160
|
let newIndex = out.get(null, tempID);
|
|
1178
|
-
if (isUndefined(newIndex))
|
|
1179
|
-
|
|
1180
|
-
if (
|
|
1181
|
-
newIndex = [newIndex];
|
|
1182
|
-
if (newIndex instanceof Series2)
|
|
1183
|
-
newIndex = newIndex.values;
|
|
1161
|
+
if (isUndefined(newIndex)) return new DataFrame2();
|
|
1162
|
+
if (isString(newIndex)) newIndex = [newIndex];
|
|
1163
|
+
if (newIndex instanceof Series2) newIndex = newIndex.values;
|
|
1184
1164
|
out.index = newIndex;
|
|
1185
1165
|
out = out.drop(null, tempID);
|
|
1186
1166
|
} else if (axis === 1) {
|
|
@@ -1243,12 +1223,9 @@
|
|
|
1243
1223
|
);
|
|
1244
1224
|
function helper4(values) {
|
|
1245
1225
|
const numericalValues = dropNaN(values);
|
|
1246
|
-
if (threshold > 0)
|
|
1247
|
-
|
|
1248
|
-
if (condition === "
|
|
1249
|
-
return numericalValues.length === values.length;
|
|
1250
|
-
if (condition === "all")
|
|
1251
|
-
return numericalValues.length > 0;
|
|
1226
|
+
if (threshold > 0) return values.length - numericalValues.length < threshold;
|
|
1227
|
+
if (condition === "any") return numericalValues.length === values.length;
|
|
1228
|
+
if (condition === "all") return numericalValues.length > 0;
|
|
1252
1229
|
return true;
|
|
1253
1230
|
}
|
|
1254
1231
|
const out = df.copy();
|
|
@@ -1257,19 +1234,15 @@
|
|
|
1257
1234
|
const values = out.get(row, null).values;
|
|
1258
1235
|
return helper4(values);
|
|
1259
1236
|
});
|
|
1260
|
-
if (rowsToKeep.length > 0)
|
|
1261
|
-
|
|
1262
|
-
else
|
|
1263
|
-
return new DataFrame2();
|
|
1237
|
+
if (rowsToKeep.length > 0) return out.get(rowsToKeep, null);
|
|
1238
|
+
else return new DataFrame2();
|
|
1264
1239
|
} else if (axis === 1) {
|
|
1265
1240
|
const colsToKeep = out.columns.filter((col) => {
|
|
1266
1241
|
const values = out.get(null, col).values;
|
|
1267
1242
|
return helper4(values);
|
|
1268
1243
|
});
|
|
1269
|
-
if (colsToKeep.length > 0)
|
|
1270
|
-
|
|
1271
|
-
else
|
|
1272
|
-
return new DataFrame2();
|
|
1244
|
+
if (colsToKeep.length > 0) return out.get(null, colsToKeep);
|
|
1245
|
+
else return new DataFrame2();
|
|
1273
1246
|
}
|
|
1274
1247
|
return out;
|
|
1275
1248
|
}
|
|
@@ -1290,15 +1263,13 @@
|
|
|
1290
1263
|
isFunction(fn),
|
|
1291
1264
|
"The `filter` method takes a single parameter: a function that is used to filter the values."
|
|
1292
1265
|
);
|
|
1293
|
-
if (isUndefined(axis))
|
|
1294
|
-
axis = 0;
|
|
1266
|
+
if (isUndefined(axis)) axis = 0;
|
|
1295
1267
|
assert(
|
|
1296
1268
|
axis === 0 || axis === 1,
|
|
1297
1269
|
"The `axis` parameter to the `filter` method must be 0 or 1."
|
|
1298
1270
|
);
|
|
1299
1271
|
let out = df.copy();
|
|
1300
|
-
if (out.isEmpty)
|
|
1301
|
-
return out;
|
|
1272
|
+
if (out.isEmpty) return out;
|
|
1302
1273
|
const index = arrayToObject(out.index);
|
|
1303
1274
|
const columns = arrayToObject(out.columns);
|
|
1304
1275
|
if (axis === 0) {
|
|
@@ -1359,10 +1330,8 @@
|
|
|
1359
1330
|
|
|
1360
1331
|
// node_modules/@jrc03c/js-math-tools/src/dataframe/df-get.mjs
|
|
1361
1332
|
function dfGet(df, rows, cols) {
|
|
1362
|
-
if (isString(rows) || isNumber(rows))
|
|
1363
|
-
|
|
1364
|
-
if (isString(cols) || isNumber(cols))
|
|
1365
|
-
cols = [cols];
|
|
1333
|
+
if (isString(rows) || isNumber(rows)) rows = [rows];
|
|
1334
|
+
if (isString(cols) || isNumber(cols)) cols = [cols];
|
|
1366
1335
|
for (const i in rows) {
|
|
1367
1336
|
if (typeof rows[i] === "bigint") {
|
|
1368
1337
|
rows[i] = Number(rows[i]);
|
|
@@ -1428,24 +1397,19 @@
|
|
|
1428
1397
|
// node_modules/@jrc03c/js-math-tools/src/sort.mjs
|
|
1429
1398
|
function alphaSort(a, b) {
|
|
1430
1399
|
try {
|
|
1431
|
-
if (a < b)
|
|
1432
|
-
|
|
1433
|
-
if (a > b)
|
|
1434
|
-
return 1;
|
|
1400
|
+
if (a < b) return -1;
|
|
1401
|
+
if (a > b) return 1;
|
|
1435
1402
|
return 0;
|
|
1436
1403
|
} catch (e) {
|
|
1437
1404
|
a = typeof a === "object" && a !== null ? JSON.stringify(a) : a.toString();
|
|
1438
1405
|
b = typeof b === "object" && b !== null ? JSON.stringify(b) : b.toString();
|
|
1439
|
-
if (a < b)
|
|
1440
|
-
|
|
1441
|
-
if (a > b)
|
|
1442
|
-
return 1;
|
|
1406
|
+
if (a < b) return -1;
|
|
1407
|
+
if (a > b) return 1;
|
|
1443
1408
|
return 0;
|
|
1444
1409
|
}
|
|
1445
1410
|
}
|
|
1446
1411
|
function sort(arr, fn) {
|
|
1447
|
-
if (isUndefined(fn))
|
|
1448
|
-
fn = alphaSort;
|
|
1412
|
+
if (isUndefined(fn)) fn = alphaSort;
|
|
1449
1413
|
if (isDataFrame(arr) || isSeries(arr)) {
|
|
1450
1414
|
return arr.sort(...Object.values(arguments).slice(1));
|
|
1451
1415
|
}
|
|
@@ -1518,14 +1482,10 @@
|
|
|
1518
1482
|
// node_modules/@jrc03c/js-math-tools/src/dataframe/df-get-subset-by-indices.mjs
|
|
1519
1483
|
function dfGetSubsetByIndices(df, rowIndices, colIndices) {
|
|
1520
1484
|
const dataShape = df.shape;
|
|
1521
|
-
if (isUndefined(rowIndices))
|
|
1522
|
-
|
|
1523
|
-
if (
|
|
1524
|
-
|
|
1525
|
-
if (isNumber(rowIndices))
|
|
1526
|
-
rowIndices = [rowIndices];
|
|
1527
|
-
if (isNumber(colIndices))
|
|
1528
|
-
colIndices = [colIndices];
|
|
1485
|
+
if (isUndefined(rowIndices)) rowIndices = range(0, dataShape[0]);
|
|
1486
|
+
if (isUndefined(colIndices)) colIndices = range(0, dataShape[1]);
|
|
1487
|
+
if (isNumber(rowIndices)) rowIndices = [rowIndices];
|
|
1488
|
+
if (isNumber(colIndices)) colIndices = [colIndices];
|
|
1529
1489
|
assert(
|
|
1530
1490
|
isArray(rowIndices) && isArray(colIndices),
|
|
1531
1491
|
"The `rowIndices` and `colIndices` parameters must be 1-dimensional arrays of whole numbers."
|
|
@@ -1569,14 +1529,10 @@
|
|
|
1569
1529
|
|
|
1570
1530
|
// node_modules/@jrc03c/js-math-tools/src/dataframe/df-get-subset-by-names.mjs
|
|
1571
1531
|
function dfGetSubsetByNames(DataFrame2, Series2, df, rows, cols) {
|
|
1572
|
-
if (isUndefined(rows))
|
|
1573
|
-
|
|
1574
|
-
if (
|
|
1575
|
-
|
|
1576
|
-
if (isString(rows))
|
|
1577
|
-
rows = [rows];
|
|
1578
|
-
if (isString(cols))
|
|
1579
|
-
cols = [cols];
|
|
1532
|
+
if (isUndefined(rows)) rows = df.index;
|
|
1533
|
+
if (isUndefined(cols)) cols = df.columns;
|
|
1534
|
+
if (isString(rows)) rows = [rows];
|
|
1535
|
+
if (isString(cols)) cols = [cols];
|
|
1580
1536
|
assert(
|
|
1581
1537
|
isArray(rows) && isArray(cols),
|
|
1582
1538
|
"The `rows` and `cols` parameters must be 1-dimensional arrays of strings."
|
|
@@ -1659,7 +1615,7 @@
|
|
|
1659
1615
|
}
|
|
1660
1616
|
const maxRows = typeof window === "undefined" ? 20 : 10;
|
|
1661
1617
|
const halfMaxRows = Math.floor(maxRows / 2);
|
|
1662
|
-
const maxColumns =
|
|
1618
|
+
const maxColumns = 4;
|
|
1663
1619
|
const halfMaxColumns = Math.floor(maxColumns / 2);
|
|
1664
1620
|
const tempRows = maxRows > df.index.length ? null : range(0, halfMaxRows).concat(
|
|
1665
1621
|
range(df.index.length - halfMaxRows, df.index.length)
|
|
@@ -1715,8 +1671,7 @@
|
|
|
1715
1671
|
function leftPad(x, maxLength) {
|
|
1716
1672
|
assert(isNumber(x), "The `leftPad` function only works on numbers!");
|
|
1717
1673
|
let out = x.toString();
|
|
1718
|
-
while (out.length < maxLength)
|
|
1719
|
-
out = "0" + out;
|
|
1674
|
+
while (out.length < maxLength) out = "0" + out;
|
|
1720
1675
|
return out;
|
|
1721
1676
|
}
|
|
1722
1677
|
|
|
@@ -1739,8 +1694,7 @@
|
|
|
1739
1694
|
"The `product` function only works on arrays, Series, and DataFrames!"
|
|
1740
1695
|
);
|
|
1741
1696
|
try {
|
|
1742
|
-
if (arr.length === 0)
|
|
1743
|
-
return NaN;
|
|
1697
|
+
if (arr.length === 0) return NaN;
|
|
1744
1698
|
const temp = flatten(arr);
|
|
1745
1699
|
let resultShouldBeABigInt = false;
|
|
1746
1700
|
let out = 1;
|
|
@@ -1784,8 +1738,7 @@
|
|
|
1784
1738
|
isArray(x),
|
|
1785
1739
|
"The first argument passed into the `reshape` function must be an array!"
|
|
1786
1740
|
);
|
|
1787
|
-
if (isNumber(newShape))
|
|
1788
|
-
newShape = [newShape];
|
|
1741
|
+
if (isNumber(newShape)) newShape = [newShape];
|
|
1789
1742
|
assert(
|
|
1790
1743
|
isArray(newShape),
|
|
1791
1744
|
"The second argument passed into the `reshape` function must be a whole number or a one-dimensional array of whole numbers!"
|
|
@@ -1838,8 +1791,7 @@
|
|
|
1838
1791
|
return z ^ z >> BigInt(31);
|
|
1839
1792
|
}
|
|
1840
1793
|
const out = [];
|
|
1841
|
-
for (let i = 0; i < n; i++)
|
|
1842
|
-
out.push(helper4());
|
|
1794
|
+
for (let i = 0; i < n; i++) out.push(helper4());
|
|
1843
1795
|
return out;
|
|
1844
1796
|
}
|
|
1845
1797
|
function uint(x) {
|
|
@@ -1880,10 +1832,8 @@
|
|
|
1880
1832
|
return Math.floor(Number(result)) / MAX;
|
|
1881
1833
|
}
|
|
1882
1834
|
function random(shape2) {
|
|
1883
|
-
if (isUndefined(shape2))
|
|
1884
|
-
|
|
1885
|
-
if (!isArray(shape2))
|
|
1886
|
-
shape2 = [shape2];
|
|
1835
|
+
if (isUndefined(shape2)) return next();
|
|
1836
|
+
if (!isArray(shape2)) shape2 = [shape2];
|
|
1887
1837
|
return reshape(ndarray(product(shape2)).map(next), shape2);
|
|
1888
1838
|
}
|
|
1889
1839
|
|
|
@@ -1907,8 +1857,7 @@
|
|
|
1907
1857
|
|
|
1908
1858
|
// node_modules/@jrc03c/js-math-tools/src/dataframe/df-shuffle.mjs
|
|
1909
1859
|
function dfShuffle(df, axis) {
|
|
1910
|
-
if (isUndefined(axis))
|
|
1911
|
-
axis = 0;
|
|
1860
|
+
if (isUndefined(axis)) axis = 0;
|
|
1912
1861
|
assert(
|
|
1913
1862
|
axis === 0 || axis === 1,
|
|
1914
1863
|
"The `axis` parameter to the `shuffle` must be 0, 1, or undefined."
|
|
@@ -1964,8 +1913,7 @@
|
|
|
1964
1913
|
}
|
|
1965
1914
|
if (isNumber(cols) || isString(cols)) {
|
|
1966
1915
|
cols = [cols];
|
|
1967
|
-
if (isBoolean(directions) || isString(directions))
|
|
1968
|
-
directions = [directions];
|
|
1916
|
+
if (isBoolean(directions) || isString(directions)) directions = [directions];
|
|
1969
1917
|
}
|
|
1970
1918
|
assert(
|
|
1971
1919
|
isArray(cols),
|
|
@@ -2028,12 +1976,9 @@
|
|
|
2028
1976
|
counter++;
|
|
2029
1977
|
}
|
|
2030
1978
|
const isAscending = directions[counter];
|
|
2031
|
-
if (a[cols[counter]] === b[cols[counter]])
|
|
2032
|
-
|
|
2033
|
-
if (a[cols[counter]]
|
|
2034
|
-
return isAscending ? -1 : 1;
|
|
2035
|
-
if (a[cols[counter]] > b[cols[counter]])
|
|
2036
|
-
return isAscending ? 1 : -1;
|
|
1979
|
+
if (a[cols[counter]] === b[cols[counter]]) return 0;
|
|
1980
|
+
if (a[cols[counter]] < b[cols[counter]]) return isAscending ? -1 : 1;
|
|
1981
|
+
if (a[cols[counter]] > b[cols[counter]]) return isAscending ? 1 : -1;
|
|
2037
1982
|
});
|
|
2038
1983
|
const indexNumber = out.columns.indexOf(indexID);
|
|
2039
1984
|
out.index = out.values.map((row) => row[indexNumber]);
|
|
@@ -2189,8 +2134,7 @@
|
|
|
2189
2134
|
const indicesToRemove = [];
|
|
2190
2135
|
const newValues = out.values.filter((value, i) => {
|
|
2191
2136
|
const shouldKeep = fn(value, i, out.values);
|
|
2192
|
-
if (!shouldKeep)
|
|
2193
|
-
indicesToRemove.push(out.index[i]);
|
|
2137
|
+
if (!shouldKeep) indicesToRemove.push(out.index[i]);
|
|
2194
2138
|
return shouldKeep;
|
|
2195
2139
|
});
|
|
2196
2140
|
indicesToRemove.forEach((i) => {
|
|
@@ -2208,8 +2152,7 @@
|
|
|
2208
2152
|
|
|
2209
2153
|
// node_modules/@jrc03c/js-math-tools/src/series/series-get.mjs
|
|
2210
2154
|
function seriesGet(series, indices) {
|
|
2211
|
-
if (isString(indices) || isNumber(indices))
|
|
2212
|
-
indices = [indices];
|
|
2155
|
+
if (isString(indices) || isNumber(indices)) indices = [indices];
|
|
2213
2156
|
for (const i in indices) {
|
|
2214
2157
|
if (typeof indices[i] === "bigint") {
|
|
2215
2158
|
indices[i] = Number(indices[i]);
|
|
@@ -2256,8 +2199,7 @@
|
|
|
2256
2199
|
// node_modules/@jrc03c/js-math-tools/src/series/series-get-subset-by-indices.mjs
|
|
2257
2200
|
function seriesGetSubsetByIndices(series, indices) {
|
|
2258
2201
|
const dataShape = series.shape;
|
|
2259
|
-
if (isUndefined(indices))
|
|
2260
|
-
indices = range(0, dataShape[0]);
|
|
2202
|
+
if (isUndefined(indices)) indices = range(0, dataShape[0]);
|
|
2261
2203
|
assert(
|
|
2262
2204
|
isArray(indices),
|
|
2263
2205
|
"The `indices` array must be 1-dimensional array of whole numbers."
|
|
@@ -2286,8 +2228,7 @@
|
|
|
2286
2228
|
|
|
2287
2229
|
// node_modules/@jrc03c/js-math-tools/src/series/series-get-subset-by-names.mjs
|
|
2288
2230
|
function seriesGetSubsetByNames(Series2, series, indices) {
|
|
2289
|
-
if (isUndefined(indices))
|
|
2290
|
-
indices = series.index;
|
|
2231
|
+
if (isUndefined(indices)) indices = series.index;
|
|
2291
2232
|
assert(
|
|
2292
2233
|
isArray(indices),
|
|
2293
2234
|
"The `indices` array must be a 1-dimensional array of strings."
|
|
@@ -2310,8 +2251,7 @@
|
|
|
2310
2251
|
const values = indices.map((name) => {
|
|
2311
2252
|
return series.values[series.index.indexOf(name)];
|
|
2312
2253
|
});
|
|
2313
|
-
if (values.length === 1)
|
|
2314
|
-
return values[0];
|
|
2254
|
+
if (values.length === 1) return values[0];
|
|
2315
2255
|
const out = new Series2(values);
|
|
2316
2256
|
out.index = indices;
|
|
2317
2257
|
out.name = series.name;
|
|
@@ -2380,12 +2320,9 @@
|
|
|
2380
2320
|
let temp = transpose([series.values, series.index]);
|
|
2381
2321
|
temp = transpose(
|
|
2382
2322
|
sort(temp, (a, b) => {
|
|
2383
|
-
if (a[1] === b[1])
|
|
2384
|
-
|
|
2385
|
-
if (a[1]
|
|
2386
|
-
return -1;
|
|
2387
|
-
if (a[1] > b[1])
|
|
2388
|
-
return 1;
|
|
2323
|
+
if (a[1] === b[1]) return 0;
|
|
2324
|
+
if (a[1] < b[1]) return -1;
|
|
2325
|
+
if (a[1] > b[1]) return 1;
|
|
2389
2326
|
})
|
|
2390
2327
|
);
|
|
2391
2328
|
const out = new Series2(temp[0]);
|
|
@@ -2625,11 +2562,10 @@
|
|
|
2625
2562
|
function makeKey3(n) {
|
|
2626
2563
|
const alpha = "abcdefghijklmnopqrstuvwxyz1234567890";
|
|
2627
2564
|
let out = "";
|
|
2628
|
-
for (let i = 0; i < n; i++)
|
|
2629
|
-
out += alpha[Math.floor(random() * alpha.length)];
|
|
2565
|
+
for (let i = 0; i < n; i++) out += alpha[Math.floor(random() * alpha.length)];
|
|
2630
2566
|
return out;
|
|
2631
2567
|
}
|
|
2632
|
-
var DataFrame = class {
|
|
2568
|
+
var DataFrame = class _DataFrame {
|
|
2633
2569
|
static [Symbol.hasInstance](x) {
|
|
2634
2570
|
try {
|
|
2635
2571
|
return !!x._symbol && x._symbol === DATAFRAME_SYMBOL;
|
|
@@ -2794,7 +2730,7 @@
|
|
|
2794
2730
|
"The `data` passed into the constructor of a DataFrame must be either (1) an object where the key-value pairs are (respectively) column names and 1-dimensional arrays of values, or (2) a 2-dimensional array of values."
|
|
2795
2731
|
);
|
|
2796
2732
|
if (data) {
|
|
2797
|
-
if (data instanceof
|
|
2733
|
+
if (data instanceof _DataFrame) {
|
|
2798
2734
|
this.values = copy(data.values);
|
|
2799
2735
|
this.columns = copy(data.columns);
|
|
2800
2736
|
this.index = copy(data.index);
|
|
@@ -2854,7 +2790,7 @@
|
|
|
2854
2790
|
return this.values.length === 0 || this.values.every((row) => row.length === 0);
|
|
2855
2791
|
}
|
|
2856
2792
|
clear() {
|
|
2857
|
-
const out = new
|
|
2793
|
+
const out = new _DataFrame(ndarray(this.shape));
|
|
2858
2794
|
out.columns = this.columns.slice();
|
|
2859
2795
|
out.index = this.index.slice();
|
|
2860
2796
|
return out;
|
|
@@ -2873,19 +2809,19 @@
|
|
|
2873
2809
|
return dfGet(this, rows, cols);
|
|
2874
2810
|
}
|
|
2875
2811
|
getSubsetByNames(rows, cols) {
|
|
2876
|
-
return dfGetSubsetByNames(
|
|
2812
|
+
return dfGetSubsetByNames(_DataFrame, Series, this, rows, cols);
|
|
2877
2813
|
}
|
|
2878
2814
|
getSubsetByIndices(rowIndices, colIndices) {
|
|
2879
2815
|
return dfGetSubsetByIndices(this, rowIndices, colIndices);
|
|
2880
2816
|
}
|
|
2881
2817
|
getDummies(columns) {
|
|
2882
|
-
return dfGetDummies(
|
|
2818
|
+
return dfGetDummies(_DataFrame, this, columns);
|
|
2883
2819
|
}
|
|
2884
2820
|
oneHotEncode(columns) {
|
|
2885
|
-
return dfGetDummies(
|
|
2821
|
+
return dfGetDummies(_DataFrame, this, columns);
|
|
2886
2822
|
}
|
|
2887
2823
|
transpose() {
|
|
2888
|
-
const out = new
|
|
2824
|
+
const out = new _DataFrame(transpose(this.values));
|
|
2889
2825
|
out.columns = this.index.slice();
|
|
2890
2826
|
out.index = this.columns.slice();
|
|
2891
2827
|
return out;
|
|
@@ -2897,22 +2833,22 @@
|
|
|
2897
2833
|
return dfResetIndex(this, shouldSkipCopying);
|
|
2898
2834
|
}
|
|
2899
2835
|
copy() {
|
|
2900
|
-
return dfCopy(
|
|
2836
|
+
return dfCopy(_DataFrame, this);
|
|
2901
2837
|
}
|
|
2902
2838
|
assign(p1, p2) {
|
|
2903
|
-
return dfAssign(
|
|
2839
|
+
return dfAssign(_DataFrame, Series, this, p1, p2);
|
|
2904
2840
|
}
|
|
2905
2841
|
apply(fn, axis) {
|
|
2906
|
-
return dfApply(
|
|
2842
|
+
return dfApply(_DataFrame, Series, this, fn, axis);
|
|
2907
2843
|
}
|
|
2908
2844
|
dropMissing(axis, condition, threshold) {
|
|
2909
|
-
return dfDropMissing(
|
|
2845
|
+
return dfDropMissing(_DataFrame, Series, this, axis, condition, threshold);
|
|
2910
2846
|
}
|
|
2911
2847
|
dropNaN(axis, condition, threshold) {
|
|
2912
|
-
return dfDropNaN(
|
|
2848
|
+
return dfDropNaN(_DataFrame, this, axis, condition, threshold);
|
|
2913
2849
|
}
|
|
2914
2850
|
drop(rows, cols) {
|
|
2915
|
-
return dfDrop(
|
|
2851
|
+
return dfDrop(_DataFrame, Series, this, rows, cols);
|
|
2916
2852
|
}
|
|
2917
2853
|
dropColumns(columns) {
|
|
2918
2854
|
return this.drop(null, columns);
|
|
@@ -2933,7 +2869,7 @@
|
|
|
2933
2869
|
return dfToJSON(this, filename, axis);
|
|
2934
2870
|
}
|
|
2935
2871
|
print() {
|
|
2936
|
-
return dfPrint(
|
|
2872
|
+
return dfPrint(_DataFrame, Series, this);
|
|
2937
2873
|
}
|
|
2938
2874
|
sort(cols, directions) {
|
|
2939
2875
|
return dfSort(this, cols, directions);
|
|
@@ -2942,7 +2878,7 @@
|
|
|
2942
2878
|
return this.sort();
|
|
2943
2879
|
}
|
|
2944
2880
|
filter(fn, axis) {
|
|
2945
|
-
return dfFilter(
|
|
2881
|
+
return dfFilter(_DataFrame, Series, this, fn, axis);
|
|
2946
2882
|
}
|
|
2947
2883
|
shuffle(axis) {
|
|
2948
2884
|
return dfShuffle(this, axis);
|
|
@@ -3058,8 +2994,7 @@
|
|
|
3058
2994
|
// node_modules/@jrc03c/js-math-tools/src/abs.mjs
|
|
3059
2995
|
function abs(x) {
|
|
3060
2996
|
try {
|
|
3061
|
-
if (!isNumber(x))
|
|
3062
|
-
return NaN;
|
|
2997
|
+
if (!isNumber(x)) return NaN;
|
|
3063
2998
|
if (typeof x === "bigint") {
|
|
3064
2999
|
return x < 0 ? -x : x;
|
|
3065
3000
|
} else {
|
|
@@ -3078,8 +3013,7 @@
|
|
|
3078
3013
|
let resultShouldBeABigInt = false;
|
|
3079
3014
|
const x = Object.values(arguments);
|
|
3080
3015
|
for (let v of x) {
|
|
3081
|
-
if (!isNumber(v))
|
|
3082
|
-
return NaN;
|
|
3016
|
+
if (!isNumber(v)) return NaN;
|
|
3083
3017
|
if (typeof v === "bigint") {
|
|
3084
3018
|
resultShouldBeABigInt = true;
|
|
3085
3019
|
v = Number(v);
|
|
@@ -3112,8 +3046,7 @@
|
|
|
3112
3046
|
// node_modules/@jrc03c/js-math-tools/src/arccos.mjs
|
|
3113
3047
|
function arccos(x) {
|
|
3114
3048
|
try {
|
|
3115
|
-
if (!isNumber(x))
|
|
3116
|
-
return NaN;
|
|
3049
|
+
if (!isNumber(x)) return NaN;
|
|
3117
3050
|
if (typeof x === "bigint") {
|
|
3118
3051
|
x = Number(x);
|
|
3119
3052
|
}
|
|
@@ -3127,8 +3060,7 @@
|
|
|
3127
3060
|
// node_modules/@jrc03c/js-math-tools/src/arcsin.mjs
|
|
3128
3061
|
function arcsin(x) {
|
|
3129
3062
|
try {
|
|
3130
|
-
if (!isNumber(x))
|
|
3131
|
-
return NaN;
|
|
3063
|
+
if (!isNumber(x)) return NaN;
|
|
3132
3064
|
if (typeof x === "bigint") {
|
|
3133
3065
|
x = Number(x);
|
|
3134
3066
|
}
|
|
@@ -3142,8 +3074,7 @@
|
|
|
3142
3074
|
// node_modules/@jrc03c/js-math-tools/src/arctan.mjs
|
|
3143
3075
|
function arctan(x) {
|
|
3144
3076
|
try {
|
|
3145
|
-
if (!isNumber(x))
|
|
3146
|
-
return NaN;
|
|
3077
|
+
if (!isNumber(x)) return NaN;
|
|
3147
3078
|
if (typeof x === "bigint") {
|
|
3148
3079
|
x = Number(x);
|
|
3149
3080
|
}
|
|
@@ -3157,10 +3088,8 @@
|
|
|
3157
3088
|
// node_modules/@jrc03c/js-math-tools/src/ceil.mjs
|
|
3158
3089
|
function ceil(x) {
|
|
3159
3090
|
try {
|
|
3160
|
-
if (!isNumber(x))
|
|
3161
|
-
|
|
3162
|
-
if (typeof x === "bigint")
|
|
3163
|
-
return x;
|
|
3091
|
+
if (!isNumber(x)) return NaN;
|
|
3092
|
+
if (typeof x === "bigint") return x;
|
|
3164
3093
|
return Math.ceil(x);
|
|
3165
3094
|
} catch (e) {
|
|
3166
3095
|
return NaN;
|
|
@@ -3171,10 +3100,8 @@
|
|
|
3171
3100
|
// node_modules/@jrc03c/js-math-tools/src/chop.mjs
|
|
3172
3101
|
function chop(x, threshold) {
|
|
3173
3102
|
try {
|
|
3174
|
-
if (!isNumber(x))
|
|
3175
|
-
|
|
3176
|
-
if (typeof x === "bigint")
|
|
3177
|
-
return x;
|
|
3103
|
+
if (!isNumber(x)) return NaN;
|
|
3104
|
+
if (typeof x === "bigint") return x;
|
|
3178
3105
|
if (isUndefined(threshold)) {
|
|
3179
3106
|
threshold = 1e-10;
|
|
3180
3107
|
} else if (!isNumber(threshold)) {
|
|
@@ -3213,19 +3140,14 @@
|
|
|
3213
3140
|
// node_modules/@jrc03c/js-math-tools/src/clamp.mjs
|
|
3214
3141
|
function clamp(x, a, b) {
|
|
3215
3142
|
try {
|
|
3216
|
-
if (!isNumber(x))
|
|
3217
|
-
|
|
3218
|
-
if (!isNumber(
|
|
3219
|
-
return NaN;
|
|
3220
|
-
if (!isNumber(b))
|
|
3221
|
-
return NaN;
|
|
3143
|
+
if (!isNumber(x)) return NaN;
|
|
3144
|
+
if (!isNumber(a)) return NaN;
|
|
3145
|
+
if (!isNumber(b)) return NaN;
|
|
3222
3146
|
if (typeof x === "bigint") {
|
|
3223
3147
|
return BigInt(clamp(vint(x), a, b));
|
|
3224
3148
|
}
|
|
3225
|
-
if (x < a)
|
|
3226
|
-
|
|
3227
|
-
if (x > b)
|
|
3228
|
-
return b;
|
|
3149
|
+
if (x < a) return a;
|
|
3150
|
+
if (x > b) return b;
|
|
3229
3151
|
return x;
|
|
3230
3152
|
} catch (e) {
|
|
3231
3153
|
return NaN;
|
|
@@ -3236,8 +3158,7 @@
|
|
|
3236
3158
|
// node_modules/@jrc03c/js-math-tools/src/cos.mjs
|
|
3237
3159
|
function cos(x) {
|
|
3238
3160
|
try {
|
|
3239
|
-
if (!isNumber(x))
|
|
3240
|
-
return NaN;
|
|
3161
|
+
if (!isNumber(x)) return NaN;
|
|
3241
3162
|
if (typeof x === "bigint") {
|
|
3242
3163
|
x = Number(x);
|
|
3243
3164
|
}
|
|
@@ -3261,10 +3182,8 @@
|
|
|
3261
3182
|
// node_modules/@jrc03c/js-math-tools/src/pow.mjs
|
|
3262
3183
|
function pow(x, p) {
|
|
3263
3184
|
try {
|
|
3264
|
-
if (!isNumber(x))
|
|
3265
|
-
|
|
3266
|
-
if (!isNumber(p))
|
|
3267
|
-
return NaN;
|
|
3185
|
+
if (!isNumber(x)) return NaN;
|
|
3186
|
+
if (!isNumber(p)) return NaN;
|
|
3268
3187
|
if (typeof x === "bigint" || typeof p === "bigint") {
|
|
3269
3188
|
const out = pow(Number(x), Number(p));
|
|
3270
3189
|
try {
|
|
@@ -3283,8 +3202,7 @@
|
|
|
3283
3202
|
// node_modules/@jrc03c/js-math-tools/src/sqrt.mjs
|
|
3284
3203
|
function sqrt(x) {
|
|
3285
3204
|
try {
|
|
3286
|
-
if (!isNumber(x))
|
|
3287
|
-
return NaN;
|
|
3205
|
+
if (!isNumber(x)) return NaN;
|
|
3288
3206
|
if (typeof x === "bigint") {
|
|
3289
3207
|
const out = sqrt(Number(x));
|
|
3290
3208
|
try {
|
|
@@ -3304,13 +3222,11 @@
|
|
|
3304
3222
|
function multiply() {
|
|
3305
3223
|
try {
|
|
3306
3224
|
const x = Object.values(arguments);
|
|
3307
|
-
if (x.length === 0)
|
|
3308
|
-
return NaN;
|
|
3225
|
+
if (x.length === 0) return NaN;
|
|
3309
3226
|
let resultShouldBeABigInt = false;
|
|
3310
3227
|
let out = 1;
|
|
3311
3228
|
for (let v of x) {
|
|
3312
|
-
if (!isNumber(v))
|
|
3313
|
-
return NaN;
|
|
3229
|
+
if (!isNumber(v)) return NaN;
|
|
3314
3230
|
if (typeof v === "bigint") {
|
|
3315
3231
|
resultShouldBeABigInt = true;
|
|
3316
3232
|
v = Number(v);
|
|
@@ -3333,8 +3249,7 @@
|
|
|
3333
3249
|
// node_modules/@jrc03c/js-math-tools/src/exp.mjs
|
|
3334
3250
|
function exp(x) {
|
|
3335
3251
|
try {
|
|
3336
|
-
if (!isNumber(x))
|
|
3337
|
-
return NaN;
|
|
3252
|
+
if (!isNumber(x)) return NaN;
|
|
3338
3253
|
if (typeof x === "bigint") {
|
|
3339
3254
|
if (x === 0n) {
|
|
3340
3255
|
return 1n;
|
|
@@ -3355,10 +3270,8 @@
|
|
|
3355
3270
|
if (typeof n === "bigint") {
|
|
3356
3271
|
return BigInt(factorial(vint(n)));
|
|
3357
3272
|
}
|
|
3358
|
-
if (n !== vint(n))
|
|
3359
|
-
|
|
3360
|
-
if (n <= 1)
|
|
3361
|
-
return 1;
|
|
3273
|
+
if (n !== vint(n)) return NaN;
|
|
3274
|
+
if (n <= 1) return 1;
|
|
3362
3275
|
return n * factorial(n - 1);
|
|
3363
3276
|
} catch (e) {
|
|
3364
3277
|
return NaN;
|
|
@@ -3376,8 +3289,7 @@
|
|
|
3376
3289
|
return -Infinity;
|
|
3377
3290
|
}
|
|
3378
3291
|
const out = JSON.parse(x);
|
|
3379
|
-
if (isNumber(out))
|
|
3380
|
-
return out;
|
|
3292
|
+
if (isNumber(out)) return out;
|
|
3381
3293
|
return NaN;
|
|
3382
3294
|
} catch (e) {
|
|
3383
3295
|
return NaN;
|
|
@@ -3388,8 +3300,7 @@
|
|
|
3388
3300
|
// node_modules/@jrc03c/js-math-tools/src/floor.mjs
|
|
3389
3301
|
function floor(x) {
|
|
3390
3302
|
try {
|
|
3391
|
-
if (!isNumber(x))
|
|
3392
|
-
return NaN;
|
|
3303
|
+
if (!isNumber(x)) return NaN;
|
|
3393
3304
|
if (typeof x === "bigint") {
|
|
3394
3305
|
return x;
|
|
3395
3306
|
}
|
|
@@ -3403,12 +3314,9 @@
|
|
|
3403
3314
|
// node_modules/@jrc03c/js-math-tools/src/lerp.mjs
|
|
3404
3315
|
function lerp(a, b, f) {
|
|
3405
3316
|
try {
|
|
3406
|
-
if (!isNumber(a))
|
|
3407
|
-
|
|
3408
|
-
if (!isNumber(
|
|
3409
|
-
return NaN;
|
|
3410
|
-
if (!isNumber(f))
|
|
3411
|
-
return NaN;
|
|
3317
|
+
if (!isNumber(a)) return NaN;
|
|
3318
|
+
if (!isNumber(b)) return NaN;
|
|
3319
|
+
if (!isNumber(f)) return NaN;
|
|
3412
3320
|
if (typeof a === "bigint" || typeof b === "bigint") {
|
|
3413
3321
|
const out = lerp(Number(a), Number(b), f);
|
|
3414
3322
|
try {
|
|
@@ -3428,10 +3336,8 @@
|
|
|
3428
3336
|
function log(x, base) {
|
|
3429
3337
|
try {
|
|
3430
3338
|
base = isUndefined(base) ? Math.E : base;
|
|
3431
|
-
if (!isNumber(x))
|
|
3432
|
-
|
|
3433
|
-
if (!isNumber(base))
|
|
3434
|
-
return NaN;
|
|
3339
|
+
if (!isNumber(x)) return NaN;
|
|
3340
|
+
if (!isNumber(base)) return NaN;
|
|
3435
3341
|
if (typeof x === "bigint" || typeof base === "bigint") {
|
|
3436
3342
|
const out = log(Number(x), Number(base));
|
|
3437
3343
|
try {
|
|
@@ -3450,10 +3356,8 @@
|
|
|
3450
3356
|
// node_modules/@jrc03c/js-math-tools/src/mod.mjs
|
|
3451
3357
|
function mod(a, b) {
|
|
3452
3358
|
try {
|
|
3453
|
-
if (!isNumber(a))
|
|
3454
|
-
|
|
3455
|
-
if (!isNumber(b))
|
|
3456
|
-
return NaN;
|
|
3359
|
+
if (!isNumber(a)) return NaN;
|
|
3360
|
+
if (!isNumber(b)) return NaN;
|
|
3457
3361
|
if (typeof a === "bigint" || typeof b === "bigint") {
|
|
3458
3362
|
const out = mod(Number(a), Number(b));
|
|
3459
3363
|
try {
|
|
@@ -3490,8 +3394,7 @@
|
|
|
3490
3394
|
}
|
|
3491
3395
|
const num = (d - c) * (x - a);
|
|
3492
3396
|
const den = b - a;
|
|
3493
|
-
if (den === 0)
|
|
3494
|
-
return NaN;
|
|
3397
|
+
if (den === 0) return NaN;
|
|
3495
3398
|
const out = num / den + c;
|
|
3496
3399
|
if (resultShouldBeABigInt) {
|
|
3497
3400
|
try {
|
|
@@ -3508,10 +3411,8 @@
|
|
|
3508
3411
|
// node_modules/@jrc03c/js-math-tools/src/round.mjs
|
|
3509
3412
|
function round(x) {
|
|
3510
3413
|
try {
|
|
3511
|
-
if (!isNumber(x))
|
|
3512
|
-
|
|
3513
|
-
if (typeof x === "bigint")
|
|
3514
|
-
return x;
|
|
3414
|
+
if (!isNumber(x)) return NaN;
|
|
3415
|
+
if (typeof x === "bigint") return x;
|
|
3515
3416
|
return Math.round(x);
|
|
3516
3417
|
} catch (e) {
|
|
3517
3418
|
return NaN;
|
|
@@ -3522,14 +3423,10 @@
|
|
|
3522
3423
|
// node_modules/@jrc03c/js-math-tools/src/sign.mjs
|
|
3523
3424
|
function sign(x) {
|
|
3524
3425
|
try {
|
|
3525
|
-
if (!isNumber(x))
|
|
3526
|
-
|
|
3527
|
-
if (
|
|
3528
|
-
|
|
3529
|
-
if (x < 0)
|
|
3530
|
-
return -1;
|
|
3531
|
-
if (x > 0)
|
|
3532
|
-
return 1;
|
|
3426
|
+
if (!isNumber(x)) return NaN;
|
|
3427
|
+
if (typeof x === "bigint") return BigInt(sign(Number(x)));
|
|
3428
|
+
if (x < 0) return -1;
|
|
3429
|
+
if (x > 0) return 1;
|
|
3533
3430
|
return 0;
|
|
3534
3431
|
} catch (e) {
|
|
3535
3432
|
return NaN;
|
|
@@ -3540,8 +3437,7 @@
|
|
|
3540
3437
|
// node_modules/@jrc03c/js-math-tools/src/sin.mjs
|
|
3541
3438
|
function sin(x) {
|
|
3542
3439
|
try {
|
|
3543
|
-
if (!isNumber(x))
|
|
3544
|
-
return NaN;
|
|
3440
|
+
if (!isNumber(x)) return NaN;
|
|
3545
3441
|
if (typeof x === "bigint") {
|
|
3546
3442
|
x = Number(x);
|
|
3547
3443
|
}
|
|
@@ -3555,8 +3451,7 @@
|
|
|
3555
3451
|
// node_modules/@jrc03c/js-math-tools/src/tan.mjs
|
|
3556
3452
|
function tan(x) {
|
|
3557
3453
|
try {
|
|
3558
|
-
if (!isNumber(x))
|
|
3559
|
-
return NaN;
|
|
3454
|
+
if (!isNumber(x)) return NaN;
|
|
3560
3455
|
if (typeof x === "bigint") {
|
|
3561
3456
|
x = Number(x);
|
|
3562
3457
|
}
|
package/dist/make-key.min.js
CHANGED
|
@@ -8,10 +8,10 @@
|
|
|
8
8
|
} catch(e){}
|
|
9
9
|
|
|
10
10
|
return false
|
|
11
|
-
`);var
|
|
11
|
+
`);var R=class extends Error{constructor(t){gt()?super(t):super(`
|
|
12
12
|
|
|
13
13
|
\x1B[31m`+t+`
|
|
14
|
-
\x1B[0m`)}};function s(e,t){if(!e)throw new Y(t)}var yt=[Array,ArrayBuffer,BigInt64Array,BigUint64Array,Float32Array,Float64Array,Int16Array,Int32Array,Int8Array,Uint16Array,Uint32Array,Uint8Array,Uint8ClampedArray];function h(e){return e===null||typeof e>"u"}var Oe=yt.map(e=>e.name);function l(e){try{return e instanceof Array?!0:h(e.constructor)?!1:yt.indexOf(e.constructor)>-1||Oe.indexOf(e.constructor.name)>-1}catch{return!1}}function y(e){try{return!!e._symbol&&e._symbol===Symbol.for("@jrc03c/js-math-tools/dataframe")}catch{return!1}}function O(e){return typeof e=="function"}function k(e){return typeof e=="object"&&!h(e)&&!l(e)}function g(e){try{return!!e._symbol&&e._symbol===Symbol.for("@jrc03c/js-math-tools/series")}catch{return!1}}function V(e,t){if(y(e)){let i=V(e.values,t);return i.length>0&&f(i[0])&&i[0]>=0&&i[0]<e.index.length&&(i[0]=e.index[i[0]]),i.length>1&&f(i[1])&&i[1]>=0&&i[1]<e.columns.length&&(i[1]=e.columns[i[1]]),i}if(g(e)){let i=V(e.values,t);return i.length>0&&f(i[0])&&i[0]>=0&&i[0]<e.index.length&&(i[0]=e.index[i[0]]),i}if(s(k(e)||l(e),"You must pass (1) an object, array, Series, or DataFrame and (2) a function or value into the `indexOf` function!"),!O(t)){let i=t;t=m=>m===i}function n(i,m,a){if(a=a||[],a.indexOf(i)>-1)return null;if(k(i)){a.push(i);let u=Object.keys(i).concat(Object.getOwnPropertySymbols(i));for(let p=0;p<u.length;p++){let c=u[p],d=i[c];if(m(d))return[c];let v=n(d,m,a);if(v&&v.length>0)return[c].concat(v)}}else if(l(i)){a.push(i);for(let u=0;u<i.length;u++){let p=i[u];if(m(p))return[u];let c=n(p,m,a);if(c&&c.length>0)return[u].concat(c)}}else if(m(i))return[];return null}function r(i){try{return t(i)}catch{return!1}}let o=n(e,r);return o&&o.length>0?o:null}function I(e){function t(n){if(typeof n=="object"){if(n===null)return null;if(l(n))return n instanceof Array?n.map(o=>I(o)):n.slice();if(g(n)){let o=n.copy();return o.values=I(o.values),o}if(y(n)){let o=n.copy();return o.values=I(n.values),o}if(n instanceof Date)return new Date(n.getTime());n=L(n);let r={};return Object.keys(n).concat(Object.getOwnPropertySymbols(n)).forEach(o=>{r[o]=I(n[o])}),r}else return n}return t(L(e))}function L(e){function t(o,i,m){if(i=i||[],m=m||"",i.indexOf(o)>-1){let a=m.split("/").slice(m.startsWith("/")?1:0);if(a.some((p,c)=>{let d=a.slice(0,a.length-c-1),v=n;return d.forEach(D=>{v=v[D]}),v===o}))return`<reference to "${n===o?"/":"/"+V(n,o).join("/")}">`}return typeof o=="object"?o===null?null:(i.push(o),l(o)?typeof o.constructor<"u"&&o.constructor.name!=="Array"?o.slice():o.map((a,u)=>t(a,i,m+"/"+u)):(Object.keys(o).concat(Object.getOwnPropertySymbols(o)).forEach(a=>{o[a]=t(o[a],i,m+"/"+a.toString())}),o)):o}let n=e,r=t(n);if(y(e)){let o=e.copy();o._values=r.values,o._columns=r.columns,o._index=r.index,r=o}if(g(e)){let o=e.copy();o.name=r.name,o._values=r.values,o._index=r.index,r=o}return r}function G(e){return e instanceof Date&&e.toString()!=="Invalid Date"}var Dt=["number","int","float","bigint"];function z(e,t){function n(r,o){let i=typeof r,m=typeof o;if(i!==m&&!Dt.includes(i)&&!Dt.includes(m))return!1;if(i==="undefined"&&m==="undefined")return!0;if(i==="boolean"||i==="symbol")return r===o;if(i==="number"||i==="bigint")try{let a=r.toString(),u=o.toString();return a===u}catch{return!1}if(i==="string"||i==="function")return r===o;if(i==="object"){if(r===null||o===null)return r===null&&o===null;{if(G(r))return G(o)?r.getTime()===o.getTime():!1;if(G(o))return!1;if(r instanceof RegExp&&o instanceof RegExp)return r.toString()===o.toString();if(l(r)!==l(o))return!1;let a=Object.keys(r).concat(Object.getOwnPropertySymbols(r)),u=Object.keys(o).concat(Object.getOwnPropertySymbols(o));if(a.length!==u.length)return!1;for(let p=0;p<a.length;p++){let c=a[p];if(!n(r[c],o[c]))return!1}return!0}}}try{return n(e,t)}catch{return n(L(e),L(t))}}function rt(e){let t="abcdefg1234567890",n="";for(;n.length<e;)n+=t[Math.floor(Math.random()*t.length)];return n}var Te=rt(16),_e=rt(16),De=rt(16),Ie=rt(16),xe=rt(16),mt=class{constructor(){this.clear()}get counts(){return this.values.map(t=>this.get(t))}get values(){return Object.values(this.valuesDict)}clear(){return this.countsDict={},this.valuesDict={},this}count(t){for(let n of t)l(n)?this.count(n):this.increment(n);return this}delete(t){let n=this.getStandardizedKey(t);return delete this.countsDict[n],delete this.valuesDict[n],this}get(t){return this.countsDict[this.getStandardizedKey(t)]||0}getStandardizedKey(t){return typeof t=="object"&&t===null?Te:h(t)?_e:O(t)?t.toString():typeof t=="symbol"?t.toString()+" - "+xe:t===1/0?De:t===-1/0?Ie:typeof t=="bigint"?t.toString():y(t)?t.toJSONString():g(t)?JSON.stringify(t.toObject()):JSON.stringify(t)}has(t){return!h(this.countsDict[this.getStandardizedKey(t)])}increment(t){return this.set(t,this.get(t)+1)}set(t,n){let r=this.getStandardizedKey(t);return this.countsDict[r]=n,this.valuesDict[r]=t,this}toArray(){return this.values.map(t=>({value:t,count:this.get(t)}))}toObject(){let t={};return this.values.forEach(n=>{t[n]=this.get(n)}),t}};function x(e){if(y(e)||g(e))return x(e.values);s(l(e),"The `flatten` function only works on arrays, Series, and DataFrames!");function t(n){let r=[];return n.forEach(o=>{l(o)?r=r.concat(t(o)):r.push(o)}),r}return t(e)}function E(e,t){t=t||{};let n=new mt,r={},o=x(e),i=[],m=-1/0,a=1/0,u=!1,p=0;for(let d of o){if(typeof d=="bigint"&&(u=!0),!t.shouldDropNaNs||f(d))try{d>m&&(m=d),d<a&&(a=d),p+=Number(d),i.push(d)}catch{m=NaN,a=NaN,p=NaN}n.increment(d)}let c=p/i.length;if(r.counts=n,r.max=m,r.mean=c,r.min=a,r.n=o.length,r.sum=p,isNaN(r.mean)&&(r.max=NaN,r.min=NaN),t.shouldDropNaNs&&(r.nWithoutNaNs=i.length),t.mode){let d=Array.from(n.values.map(F=>[F,n.get(F)])).toSorted((F,st)=>st[1]-F[1]),v=d[0][1],D=[];for(let F of d)if(F[1]==v)D.push(F[0]);else break;r.mode=D.toSorted()}if(t.median)if(isNaN(c))r.median=NaN;else{let d=i.toSorted((D,F)=>Number(D)-Number(F)),v=Math.floor(d.length/2);if(d.length%2===0){let D=d[v-1],F=d[v];if(r.median=(Number(D)+Number(F))/2,u&&typeof D=="bigint"&&typeof F=="bigint")try{r.median=BigInt(r.median)}catch{}}else r.median=d[v]}if(t.stdev||t.variance){let d=0;for(let D of i)d+=Math.pow(Number(D)-c,2);d/=i.length;let v=Math.sqrt(d);r.stdev=v,r.variance=d}if(u){try{r.sum=BigInt(r.sum)}catch{}try{r.mean=BigInt(r.mean)}catch{}t.mode&&(r.mode=r.mode.map(d=>{try{return BigInt(d)}catch{return d}}))}return r}function nt(e,t){let{counts:n}=E(e);return h(t)||(O(t)?n.values.forEach(r=>{t(r)||n.delete(r)}):n.values.forEach(r=>{z(r,t)||n.delete(r)})),n}function bt(e){if(y(e)||g(e))return bt(e.values);if(l(e)){let t=!1,n=!1,r=null;for(let o of e){if(bt(o))return!0;if(l(o)){if(r===null)r=o.length;else if(o.length!==r)return!0;t=!0}else n=!0;if(t&&n)return!0}}return!1}function q(e){return bt(L(e))}function H(e){if(y(e)||g(e))return H(e.values);s(l(e),"The `isNested` function only works on arrays, Series, and DataFrames!");for(let t=0;t<e.length;t++)if(l(e[t]))return!0;return!1}var X="You must pass a natural number or a one-dimensional array of natural numbers into the `ndarray` function!";function j(e){s(!h(e),X),l(e)||(e=[e]),s(!H(e),X),s(e.length>0,X);let t=e[0];if(typeof t=="bigint"&&(t=Number(t)),s(f(t),X),s(t>=0,X),s(Math.floor(t)===t,X),s(t!==1/0,"We can't create an array containing an infinite number of values!"),e.length===1){let n=[];for(let r=0;r<t;r++)n.push(void 0);return n}else{let n=[];for(let r=0;r<t;r++)n.push(j(e.slice(1)));return n}}function U(e){if(y(e)||g(e)){let n=e.copy();return n.values=U(n.values),n.index=U(n.index),n}s(l(e),"The `reverse` function only works on arrays, Series, and DataFrames!");let t=[];for(let n=e.length-1;n>=0;n--)t.push(e[n]);return t}function S(e,t,n=1){s(!h(e)&&!h(t)&&!h(n),"You must pass two numbers and optionally a step value to the `range` function!"),s(f(e)&&f(t)&&f(n),"You must pass two numbers and optionally a step value to the `range` function!"),s(n>0,"The step value must be greater than 0! (NOTE: The step value is a magnitude; it does not indicate direction.)");let r=!1,o=typeof e=="bigint"||typeof t=="bigint"||typeof n=="bigint";if(e=Number(e),t=Number(t),n=Number(n),e>t){r=!0;let m=e;e=t+n,t=m+n}let i=[];for(let m=e;m<t;m+=n)if(o)try{i.push(BigInt(m))}catch{i.push(m)}else i.push(m);return r&&(i=U(i)),i}function ot(e){let t="abcdefg1234567890",n="";for(;n.length<e;)n+=t[Math.floor(Math.random()*t.length)];return n}var Ae=ot(256),Fe=ot(256),je=ot(256),Ee=ot(256),Me=ot(256);function P(e){if(y(e)||g(e))return P(e.values);s(l(e),"The `set` function only works on arrays, Series, and DataFrames!");let t=[],n={};return x(e).forEach(r=>{let o=typeof r=="object"&&r===null?Ae:h(r)?Fe:O(r)?r.toString():typeof r=="symbol"?r.toString()+" - "+Me:r===1/0?je:r===-1/0?Ee:typeof r=="bigint"?r.toString():y(r)?r.toJSONString():g(r)?JSON.stringify(r.toObject()):JSON.stringify(r);n[o]||t.push(r),n[o]=!0}),t}function It(e){if(l(e)){let t=It(e[0]);return[e.length].concat(t||[])}else return}function b(e){return y(e)||g(e)?b(e.values):(s(l(e),"The `shape` function only works on arrays, Series, and DataFrames!"),It(e))}function Nt(e,t,n){if(h(n)&&(n=0),s(n===0||n===1||n==="vertical"||n==="horizontal",'The only valid axis values for use when appending data to a DataFrame are 0, 1, "vertical", and "horizontal". Note that 0 == "horizontal" and 1 == "vertical".'),l(t)){s(!q(t),"The array of data you're trying to append to this DataFrame is jagged!");let r=b(t);if(r.length===1)if(n===0){let o=e.copy();o._values.push(t);let i=Math.max(e.shape[1],r[0]);for(o._values.forEach(m=>{for(;m.length<i;)m.push(void 0)});o._index.length<o._values.length;)o._index.push("row"+o._index.length);for(;o._columns.length<i;)o._columns.push("col"+o._columns.length);return o}else{let o=Math.max(e.shape[0],r[0]),i=e.copy();for(S(0,o).forEach(m=>{m>=i._values.length&&i._values.push(j(e.shape[1])),i._values[m].push(t[m])});i._index.length<i._values.length;)i._index.push("row"+i._index.length);for(;i._columns.length<i._values[0].length;)i._columns.push("col"+i._columns.length);return i}else if(r.length===2)if(n===0){let o=Math.max(...t.map(m=>m.length).concat([e.shape[1]])),i=e.copy();for(i._values=i._values.concat(t).map(m=>{for(;m.length<o;)m.push(void 0);return m});i._index.length<i._values.length;)i._index.push("row"+i._index.length);for(;i._columns.length<o;)i._columns.push("col"+i._columns.length);return i}else{let o=Math.max(...t.map(a=>a.length))+e.shape[1],i=Math.max(e.shape[0],r[0]),m=e.copy();for(S(0,i).forEach(a=>{for(a>=m._values.length&&m._values.push(j(e.shape[1])),m._values[a]=m._values[a].concat(t[a]);m._values[a].length<o;)m._values[a].push(void 0)});m._index.length<m._values.length;)m._index.push("row"+m._index.length);for(;m._columns.length<o;)m._columns.push("col"+m._columns.length);return m}else throw new Y("Only 1- and 2-dimensional arrays can be appended to a DataFrame!")}else if(g(t)){let r=Nt(e,t.values,n);return n===0?r.index[r.index.length-1]=r.index.indexOf(t.name)>-1?t.name+" (2)":t.name:r.columns[r.columns.length-1]=r.columns.indexOf(t.name)>-1?t.name+" (2)":t.name,r}else if(y(t))if(n===0){let r=e.copy(),o=P(r._columns.concat(t._columns)).length;for(r._values.forEach(i=>{for(;i.length<o;)i.push(void 0)}),t.apply(i=>{let m=i.copy(),a=[];r._columns.forEach(u=>{let p=m._index.indexOf(u);p>-1?(a.push(m._values[p]),m._values.splice(p,1),m._index.splice(p,1)):a.push(void 0)}),r._values.push(a.concat(m._values))},1),r._columns=r._columns.concat(t._columns.filter(i=>r._columns.indexOf(i)<0));r._index.length<r._values.length;){let i="row"+r._index.length;r._index.push(i+(e._index.indexOf(i)>-1?" (2)":""))}return r}else{let r=e.copy();return r._index.forEach((o,i)=>{let m=t._index.indexOf(o);m>-1?r._values[i]=r._values[i].concat(t._values[m]):r._values[i]=r._values[i].concat(j(t.shape[1]))}),t._index.forEach((o,i)=>{r._index.indexOf(o)<0&&(r._index.push(o),r._values.push(j(r._columns.length).concat(t._values[i])))}),r._columns=r._columns.concat(t._columns.map(o=>o+(r._columns.indexOf(o)>-1?" (2)":""))),r}else throw new Y("Only 1- or 2-dimensional arrays, Series, and DataFrames can be appended to a DataFrame!")}function xt(e,t,n,r,o){if(o=o||0,s(O(r),"The first parameter to the `apply` method must be a function."),s(o===0||o===1,"The second parameter to the `apply` method (the `axis`) must be 0 or 1."),o===0){let i={},m;if(n.columns.forEach((a,u)=>{let p=new t(n.values.map(d=>d[u]));p.name=a,p.index=n.index;let c=r(p,u,n);c instanceof t?i[a]=c.values:i[a]=c,h(m)&&(m=c instanceof t||l(c))}),m){let a=new e(i);return a.index=n.index,a}else{let a=new t(n.columns.map(u=>i[u]));return a.index=n.columns,a}}else if(o===1){let i,m=n.values.map((a,u)=>{let p=new t(a);p.name=n.index[u],p.index=n.columns;let c=r(p,u,n);return h(i)&&(i=c instanceof t||l(c)),c instanceof t?c.values:c});if(i){let a=new e(m);return a.index=n.index,a.columns=n.columns,a}else{let a=new t(m);return a.index=n.index,a}}}function w(e){return typeof e=="string"}function At(e,t,n,r,o){let i=a=>a instanceof e,m=a=>a instanceof t;if(h(o)){if(i(r))return n.append(r,1);if(m(r))return n.append(r,1);if(k(r)){let a=Math.max(...Object.keys(r).concat(Object.getOwnPropertySymbols(r)).map(u=>r[u].length));return Object.keys(r).concat(Object.getOwnPropertySymbols(r)).forEach(u=>{for(;r[u].length<a;)r[u].push(void 0)}),n.append(new e(r),1)}else throw new Y("You must pass a DataFrame, Series, or object into the `assign` method!")}else{s(w(r),"If passing two arguments into the `assign` method, then the first argument must be a string name!"),s(l(o)&&!q(o)&&b(o).length===1,"If passing two arguments into the `assign` method, then the second argument must be a 1-dimensional array!");let a=n.append(o,1);return a.columns[a.columns.length-1]=r,a}}function Ft(e,t){if(t.isEmpty)return new e;let n=new e(I(t.values));return n.columns=t.columns.slice(),n.index=t.index.slice(),n}function jt(e,t,n,r,o){h(r)&&(r=[]),h(o)&&(o=[]),(w(r)||f(r))&&(r=[r]),(w(o)||f(o))&&(o=[o]),s(l(r),"The `drop` method only works on 1-dimensional arrays of numerical indices and/or strings."),s(l(o),"The `drop` method only works on 1-dimensional arrays of numerical indices and/or strings."),s(b(r).length===1,"The `drop` method only works on 1-dimensional arrays of numerical indices and/or strings."),s(b(o).length===1,"The `drop` method only works on 1-dimensional arrays of numerical indices and/or strings.");let i,m;n.index.forEach((u,p)=>{r.indexOf(u)<0&&r.indexOf(p)<0&&(i||(i=[]),i.push(u))}),n.columns.forEach((u,p)=>{o.indexOf(u)<0&&o.indexOf(p)<0&&(m||(m=[]),m.push(u))});let a=n.get(i,m);if(a instanceof t){let u=new e;u=u.assign(a),n.index.indexOf(a.name)>-1&&(u=u.transpose()),a=u}return a}function at(e){return f(e)&&(e>=0?Math.floor(e)===e:Math.ceil(e)===e)}function J(e){return at(e)&&e>=0}function Et(e,t,n,r,o,i){r=r||0,s(r===0||r===1,"The first parameter of the `dropMissing` method (the `axis`) must be 0 or 1."),i=i||0,s(J(i),"The third parameter of the `dropMissing` method (the `threshold`) should be a whole number (meaning that data should be dropped if it contains more than `threshold` null values)."),o=i>0?"none":o||"any",s(o==="any"||o==="all"||o==="none","The second parameter of the `dropMissing` method (the `condition` parameter, which indicates the condition under which data should be dropped) should be 'any' or 'all' (meaning that if 'any' of the data contains null values, then it should be dropped; or that if 'all' of the data contains null values, then it should be dropped).");function m(p){if(i>0){let c=0;for(let d=0;d<p.length;d++){let v=p[d];if(h(v)&&c++,c>=i)return[]}}else if(o==="any")for(let c=0;c<p.length;c++){let d=p[c];if(h(d))return[]}else if(o==="all"){for(let c=0;c<p.length;c++){let d=p[c];if(!h(d))return p}return[]}return p}let a=n.copy(),u=Math.random().toString();if(r===0){a=a.assign(u,a.index);let p=a.values.map(m).filter(d=>d.length>0);if(b(p).length<2)return new e;a.values=p;let c=a.get(null,u);if(h(c))return new e;w(c)&&(c=[c]),c instanceof t&&(c=c.values),a.index=c,a=a.drop(null,u)}else if(r===1){let p={};if(a.columns.forEach((d,v)=>{let D=a.values.map(st=>st[v]),F=m(D);F.length>0&&(p[d]=F)}),Object.keys(p).length+Object.getOwnPropertySymbols(p).length===0)return new e;let c=new e(p);return c.index=a.index,c}return a}function ut(e){if(y(e)||g(e))return e.dropNaN(...Object.values(arguments).slice(1));s(l(e),"The `dropNaN` function only works on arrays, Series, and DataFrames!");let t=[];return e.forEach(n=>{try{return t.push(ut(n))}catch{if(f(n))return t.push(n)}}),t}function Mt(e,t,n,r,o){n=n||0,s(n===0||n===1,"The first parameter of the `dropNaN` method (the `axis`) must be 0 or 1."),o=o||0,s(J(o),"The third parameter of the `dropNaN` method (the `threshold`) should be a whole number (meaning that data should be dropped if it contains more than `threshold` NaN values)."),r=o>0?"none":r||"any",s(r==="any"||r==="all"||r==="none","The second parameter of the `dropNaN` method (the `condition` parameter, which indicates the condition under which data should be dropped) should be 'any' or 'all' (meaning that if 'any' of the data contains NaN values, then it should be dropped; or that if 'all' of the data contains NaN values, then it should be dropped).");function i(a){let u=ut(a);return o>0?a.length-u.length<o:r==="any"?u.length===a.length:r==="all"?u.length>0:!0}let m=t.copy();if(n===0){let a=m.index.filter(u=>{let p=m.get(u,null).values;return i(p)});return a.length>0?m.get(a,null):new e}else if(n===1){let a=m.columns.filter(u=>{let p=m.get(null,u).values;return i(p)});return a.length>0?m.get(null,a):new e}return m}function Bt(e){let t={};return x(e).forEach((n,r)=>{t[n]=r}),t}function Q(e){return Object.keys(e).concat(Object.getOwnPropertySymbols(e)).sort((t,n)=>e[t]-e[n])}function Ut(e,t,n,r,o){s(O(r),"The `filter` method takes a single parameter: a function that is used to filter the values."),h(o)&&(o=0),s(o===0||o===1,"The `axis` parameter to the `filter` method must be 0 or 1.");let i=n.copy();if(i.isEmpty)return i;let m=Bt(i.index),a=Bt(i.columns);if(o===0){let u=0,p=i.values.filter((c,d)=>{let v=new t(c);v.name=n.index[d],v.index=n.columns;let D=r(v,d,n);return D?u++:delete m[i.index[d]],D});if(u===0)return new e;if(u===1){let c=new t(p[0]);return c.name=Q(m)[0],c.index=Q(a),c}i.values=p,i.index=Q(m)}else if(o===1){i=i.transpose();let u=0,p=i.values.filter((c,d)=>{let v=new t(c);v.name=n.columns[d],v.index=n.index;let D=r(v,d,n);return D?u++:delete a[i.index[d]],D});if(u===0)return new e;if(u===1){let c=new t(p[0]);return c.name=Q(a)[0],c.index=Q(m),c}i.values=p,i.index=Q(a),i=i.transpose()}return i}function Pt(e,t,n){(w(t)||f(t))&&(t=[t]),(w(n)||f(n))&&(n=[n]);for(let o in t)typeof t[o]=="bigint"&&(t[o]=Number(t[o]));for(let o in n)typeof n[o]=="bigint"&&(n[o]=Number(n[o]));let r=P((t||[]).concat(n||[]).map(o=>typeof o));return s(r.length<=2,"Only whole numbers and/or strings are allowed in `get` arrays!"),r.length===1&&s(r[0]==="string"||r[0]==="number","Only whole numbers and/or strings are allowed in `get` arrays!"),r.length===2&&(s(r.indexOf("string")>-1,"Only whole numbers and/or strings are allowed in `get` arrays!"),s(r.indexOf("number")>-1,"Only whole numbers and/or strings are allowed in `get` arrays!")),h(t)||(t=t.map(o=>{if(w(o))return s(e.index.indexOf(o)>-1,`Row "${o}" does not exist!`),o;if(f(o))return s(o>=0,`Index ${o} is out of bounds!`),s(Math.floor(o)===o,"Row numbers must be integers!"),s(o<e.index.length,`Index ${o} is out of bounds!`),e.index[o]})),h(n)||(n=n.map(o=>{if(w(o))return s(e.columns.indexOf(o)>-1,`Column "${o}" does not exist!`),o;if(f(o))return s(o>=0,`Column ${o} is out of bounds!`),s(Math.floor(o)===o,"Column numbers must be integers!"),s(o<e.columns.length,`Column ${o} is out of bounds!`),e.columns[o]})),e.getSubsetByNames(t,n)}function Be(e,t){try{return e<t?-1:e>t?1:0}catch{return e=typeof e=="object"&&e!==null?JSON.stringify(e):e.toString(),t=typeof t=="object"&&t!==null?JSON.stringify(t):t.toString(),e<t?-1:e>t?1:0}}function R(e,t){if(h(t)&&(t=Be),y(e)||g(e))return e.sort(...Object.values(arguments).slice(1));s(l(e),"The `sort` function only works on arrays, Series, and DataFrames!"),s(O(t),"The second parameter of the `sort` function must be a comparison function!");let n=e.slice();return n.sort(t),n}function Ue(e){let t=e.toLowerCase(),n="";for(let o=0;o<t.length;o++){let i=t[o];i.match(/[a-z0-9]/g)?n+=i:n+=" "}let r=n.split(" ").filter(o=>o.length>0);return r[0]+r.slice(1).map(o=>o[0].toUpperCase()+o.substring(1)).join("")}function vt(e,t,n){h(n)?n=t.columns:w(n)&&(n=[n]);let r={};n.forEach(i=>{s(w(i),"You must pass either a string or a one-dimensional array of strings into the `getDummies` (AKA `oneHotEncode`) method!");let m=t.columns.indexOf(i);s(m>-1,`The given DataFrame does not have a column called "${i}"!`);let a=t.values.map(p=>p[m]),u=R(P(a));a.forEach(p=>{u.forEach(c=>{let d=i+"_"+Ue(c.toString());r[d]||(r[d]=[]),p===c?r[d].push(1):r[d].push(0)})})});let o=new e(r);return o.index=t.index,o}function zt(e,t,n){let r=e.shape;h(t)&&(t=S(0,r[0])),h(n)&&(n=S(0,r[1])),f(t)&&(t=[t]),f(n)&&(n=[n]),s(l(t)&&l(n),"The `rowIndices` and `colIndices` parameters must be 1-dimensional arrays of whole numbers."),s(b(t).length===1&&b(n).length===1,"The `rowIndices` and `colIndices` parameters must be 1-dimensional arrays of whole numbers."),s(t.length>0,"The `rowIndices` array must contain at least one index."),s(n.length>0,"The `colIndices` array must contain at least one index."),t.forEach(m=>{s(J(m),"The `rowIndices` and `colIndices` parameters must be 1-dimensional arrays of whole numbers."),s(m<e.index.length,`The row index ${m} is out of bounds.`)}),n.forEach(m=>{s(J(m),"The `rowIndices` and `colIndices` parameters must be 1-dimensional arrays of whole numbers."),s(m<e.columns.length,`The column index ${m} is out of bounds.`)});let o=t.map(m=>e.index[m]),i=n.map(m=>e.columns[m]);return e.getSubsetByNames(o,i)}function Ct(e,t,n,r,o){h(r)&&(r=n.index),h(o)&&(o=n.columns),w(r)&&(r=[r]),w(o)&&(o=[o]),s(l(r)&&l(o),"The `rows` and `cols` parameters must be 1-dimensional arrays of strings."),s(b(r).length===1&&b(o).length===1,"The `rows` and `cols` parameters must be 1-dimensional arrays of strings."),s(r.length>0,"The `rows` array must contain at least one row name."),s(o.length>0,"The `cols` array must contain at least one column name."),r.forEach(a=>{s(w(a),"The `rows` and `cols` parameters must be 1-dimensional arrays of strings."),s(n.index.indexOf(a)>-1,`The row name "${a}" does not exist in the list of rows.`)}),o.forEach(a=>{s(w(a),"The `rows` and `cols` parameters must be 1-dimensional arrays of strings."),s(n.columns.indexOf(a)>-1,`The column name "${a}" does not exist in the list of columns.`)});let i=r.map(a=>o.map(u=>n.values[n.index.indexOf(a)][n.columns.indexOf(u)]));if(r.length===1&&o.length===1)return i[0][0];if(r.length===1){let a=new t(i[0]);return a.name=r[0],a.index=o,a}if(o.length===1){let a=new t(i.map(u=>u[0]));return a.name=o[0],a.index=r,a}let m=new e(i);return m.columns=o,m.index=r,m}function kt(e,t,n){function r(v,D){return w(v)&&v.length>D?v.substring(0,D-3)+"...":v}if(n.isEmpty)return console.table({}),console.log("Shape:",[0,0],`
|
|
15
|
-
`),n;let o=typeof window>"u"?20:10,i=Math.floor(o/2),m=
|
|
16
|
-
`),n}function $(e,t){s(f(e),"The `leftPad` function only works on numbers!");let n=e.toString();for(;n.length<t;)n="0"+n;return n}function Jt(e,t){let n=t?e:e.copy();return n.index=S(0,e.shape[0]).map(r=>"row"+$(r,(n.index.length-1).toString().length)),n}function W(e,t){if(y(e)||g(e))return W(e.values,t);s(l(e),"The `product` function only works on arrays, Series, and DataFrames!");try{if(e.length===0)return NaN;let n=x(e),r=!1,o=1;for(let i of n){if(!f(i))if(t)i=1;else return NaN;typeof i=="bigint"&&(r=!0,i=Number(i)),o*=i}if(r)try{return BigInt(o)}catch{}return o}catch{return NaN}}function Rt(e){return at(e)&&e>0}function Z(e,t){if(y(e)||g(e))return Z(e.values,t);if(s(l(e),"The first argument passed into the `reshape` function must be an array!"),f(t)&&(t=[t]),s(l(t),"The second argument passed into the `reshape` function must be a whole number or a one-dimensional array of whole numbers!"),s(b(t).length===1,"The first argument passed into the `reshape` function must be a whole number or a one-dimensional array of whole numbers!"),t=t.map(i=>(typeof i=="bigint"&&(i=Number(i)),s(Rt(i),"The first argument passed into the `reshape` function must be a whole number or a one-dimensional array of whole numbers!"),Number(i))),t.length===0)return x(e);let n=x(e);if(t.length===1&&t[0]===n.length)return n;s(W(t)===n.length,"The new shape doesn't match the number of values available in `x` (the first argument passed into the `reshape` function)!");let r=[],o=Math.floor(n.length/t[0]);for(let i=0;i<t[0];i++){let m=n.slice(i*o,(i+1)*o);r.push(Z(m,t.slice(1)))}return r}var $t=Math.pow(2,64),T=[];ft(Math.floor(Math.random()*$t));function Pe(e,t){e=A(e);function n(){e+=A("0x9e3779b97f4a7c15");let o=I(e);return o=(o^o>>BigInt(30))*A("0xbf58476d1ce4e5b9"),o=(o^o>>BigInt(27))*A("0x94d049bb133111eb"),o^o>>BigInt(31)}let r=[];for(let o=0;o<t;o++)r.push(n());return r}function A(e){return BigInt.asUintN(64,BigInt(e))}function Yt(e,t){return e=A(e),t=BigInt(t),A(A(e<<t)|A(e>>A(BigInt(64)-t)))}function ft(e){if(typeof e=="bigint"&&(e=Number(e)),h(e))return I(T);{s(f(e),"If passing a value into the `seed` function, then that value must be an integer!");let t=Pe(Math.floor(e),4);T[0]=t[0],T[1]=t[1],T[2]=t[2],T[3]=t[3]}}function Kt(){let e=A(Yt(T[0]+T[3],23)+T[0]),t=A(T[1]<<BigInt(17));return T[2]=A(T[2]^T[0]),T[3]=A(T[3]^T[1]),T[1]=A(T[1]^T[2]),T[0]=A(T[0]^T[3]),T[2]=A(T[2]^t),T[3]=Yt(T[3],45),Math.floor(Number(e))/$t}function K(e){return h(e)?Kt():(l(e)||(e=[e]),Z(j(W(e)).map(Kt),e))}function tt(e){if(y(e)||g(e))return e.shuffle(...Object.values(arguments).slice(1));s(l(e),"The `shuffle` function only works on arrays, Series, and DataFrames!");let t=[],n=e.slice();for(let r=0;r<e.length;r++){let o=Math.floor(K()*n.length);t.push(n.splice(o,1)[0])}return t}function Lt(e,t){return h(t)&&(t=0),s(t===0||t===1,"The `axis` parameter to the `shuffle` must be 0, 1, or undefined."),e.get(t===0?tt(e.index):null,t===1?tt(e.columns):null)}function et(e){return typeof e=="boolean"}function qt(e,t,n){return O(t)?ze(e,t,n):Ce(e,t,n)}function ze(e,t,n){if(n=h(n)?0:n,s(O(t),"When sorting a DataFrame using a function, the first argument to the `sort` method must be a function!"),s(f(n),"When sorting a DataFrame using a function, the second argument to the `sort` method must be null, undefined, 0, or 1 to indicate the axis along which the data should be sorted! An axis of 0 means that the rows will be sorted relative to each other, whereas an axis of 1 means that the columns will be sorted relative to each other."),n===0){let r=R(e.index,(o,i)=>t(e.get(o,null),e.get(i,null)));return e.get(r,null)}else{let r=R(e.columns,(o,i)=>t(e.get(null,o),e.get(null,i)));return e.get(null,r)}}function Ce(e,t,n){let r=e.copy(),o=K().toString();r=r.assign(o,r.index),h(t)&&(t=[o],n=[!0]),(f(t)||w(t))&&(t=[t],(et(n)||w(n))&&(n=[n])),s(l(t),"The first parameter of the `sort` method must be (1) a string or index representing a column name or index, respectively; (2) a 1-dimensional array of strings and/or indices; or (3) null."),s(b(t).length===1,"The first parameter of the `sort` method must be (1) a string or index representing a column name or index, respectively; (2) a 1-dimensional array of strings and/or indices; or (3) null."),h(n)&&(n=S(0,t.length).map(()=>!0)),s(l(n),"The second parameter of the `sort` method must be (1) a string or boolean representing the sort direction ('ascending' / 'descending', or true / false); (2) a 1-dimensional array of strings and/or booleans; or (3) null."),s(b(n).length===1,"The second parameter of the `sort` method must be (1) a string or boolean representing the sort direction ('ascending' / 'descending', or true / false); (2) a 1-dimensional array of strings and/or booleans; or (3) null."),s(t.length===n.length,"The arrays passed into the `sort` method must be equal in length."),t=t.map(m=>{if(s(w(m)||f(m),"Column references can either be column names (as strings) or column indices (as whole numbers)."),w(m)){let a=r.columns.indexOf(m);return s(a>-1,`The column "${m}" does not exist!`),a}if(f(m))return s(J(m),"Column indices must be whole numbers!"),s(m<r.columns.length,`The index ${m} is out of bounds!`),m}),n=n.map(m=>{if(s(w(m)||et(m),"Direction references can either be strings ('ascending' or 'descending') or booleans (true or false)."),w(m)){let a=m.trim().toLowerCase();return s(a==="ascending"||a==="descending","Direction references can either be strings ('ascending' or 'descending') or booleans (true or false)."),a==="ascending"}if(et(m))return m}),r.values=R(r.values,(m,a)=>{let u=0;for(;m[t[u]]===a[t[u]]&&u<t.length;)u++;let p=n[u];if(m[t[u]]===a[t[u]])return 0;if(m[t[u]]<a[t[u]])return p?-1:1;if(m[t[u]]>a[t[u]])return p?1:-1});let i=r.columns.indexOf(o);return r.index=r.values.map(m=>m[i]),r=r.dropColumns(o),r}function Vt(e,t){h(t)?t=0:s(t===0||t===1,"The axis parameter of the `toDetailedObject` method must be undefined, 0, or 1. An axis of 0 indicates that the returned object should be organized first by rows and then by columns. An axis of 1 indicates that the returned object should be organized first by columns and then by rows.");let n={};return t===0?e.index.forEach((r,o)=>{let i={};e.columns.forEach((m,a)=>{i[m]=e.values[o][a]}),n[r]=i}):e.columns.forEach((r,o)=>{let i={};e.index.forEach((m,a)=>{i[m]=e.values[a][o]}),n[r]=i}),n}function lt(e,t){return JSON.stringify(e.toObject(t))}async function Gt(e,t){return JSON.parse(lt(e,t))}function Wt(e){let t={};return e.columns.forEach(n=>{t[n]=e.get(n).values}),t}function C(e){if(y(e)||g(e))return e.transpose();s(l(e),"The `transpose` function only works on arrays, Series, and DataFrames!");let t=b(e);if(s(t.length<=2,"I'm not smart enough to know how to transpose arrays that have more than 2 dimensions. Sorry for the inconvenience! Please only pass 1- or 2-dimensional arrays into the `transpose` function!"),t.length===1)return U(e);if(t.length===2){let n=j(U(t));for(let r=0;r<t[0];r++)for(let o=0;o<t[1];o++)n[o][r]=e[r][o];return n}}function wt(e,t,n){if(g(n))return new e(t.values.concat(n.values));if(l(n)){let r=b(n);s(r.length===1&&!H(r),"Only vectors can be appended to Series!");let o=t.copy();return n.forEach((i,m)=>{o._values.push(i),o._index.push("item"+(t.values.length+m))}),o}return wt(t,[n])}function Ht(e,t){s(O(t),"The parameter to the `apply` method must be a function.");let n=e.copy();return n._values=n._values.map((r,o)=>t(r,o)),n}function Xt(e){let t=e.copy(),n=[];return t._values=t.values.filter((r,o)=>h(r)?!1:(n.push(t.index[o]),!0)),t._index=n,t}function Qt(e,t){let n=[],r=[];t.values.forEach((i,m)=>{f(i)&&(r.push(i),n.push(t.index[m]))});let o=new e(r);return o.name=t.name,o.index=n,o}function Zt(e,t,n){let r=t.copy(),o=I(r.index),i=[],m=r.values.filter((a,u)=>{let p=n(a,u,r.values);return p||i.push(r.index[u]),p});return i.forEach(a=>{o.splice(o.indexOf(a),1)}),m.length===0?(r=new e,r.name=t.name,r):(r.values=m,r.index=o,r)}function te(e,t){(w(t)||f(t))&&(t=[t]);for(let r in t)typeof t[r]=="bigint"&&(t[r]=Number(t[r]));let n=P((t||[]).map(r=>typeof r));return s(n.length<=2,"Only whole numbers and/or strings are allowed in `get` arrays!"),n.length===1&&s(n[0]==="string"||n[0]==="number","Only whole numbers and/or strings are allowed in `get` arrays!"),n.length===2&&(s(n.indexOf("string")>-1,"Only whole numbers and/or strings are allowed in `get` arrays!"),s(n.indexOf("number")>-1,"Only whole numbers and/or strings are allowed in `get` arrays!")),h(t)||(t=t.map(r=>{if(typeof r=="string")return s(e.index.indexOf(r)>-1,`Index "${r}" does not exist!`),r;if(typeof r=="number")return s(r>=0,`Index ${r} is out of bounds!`),s(Math.floor(r)===r,"Indices must be integers!"),s(r<e.index.length,`Index ${r} is out of bounds!`),e.index[r]})),e.getSubsetByNames(t)}function ee(e,t){let n=e.shape;h(t)&&(t=S(0,n[0])),s(l(t),"The `indices` array must be 1-dimensional array of whole numbers."),s(b(t).length===1,"The `indices` array must be a 1-dimensional array of whole numbers."),s(t.length>0,"The `indices` array must contain at least one index."),t.forEach(o=>{s(J(o),"The `indices` array must be a 1-dimensional array of whole numbers."),s(o<e.index.length,`The row index ${o} is out of bounds.`)});let r=t.map(o=>e.index[o]);return e.getSubsetByNames(r)}function re(e,t,n){h(n)&&(n=t.index),s(l(n),"The `indices` array must be a 1-dimensional array of strings."),s(b(n).length===1,"The `indices` array must be a 1-dimensional array of strings."),s(n.length>0,"The `indices` array must contain at least one index name."),n.forEach(i=>{s(w(i),"The `indices` array must contain only strings."),s(t.index.indexOf(i)>-1,`The name "${i}" does not exist in the index.`)});let r=n.map(i=>t.values[t.index.indexOf(i)]);if(r.length===1)return r[0];let o=new e(r);return o.index=n,o.name=t.name,o}function ne(e){let t=e.copy(),n=typeof window>"u"?20:10;if(t.index.length>n){t=t.get(S(0,n/2).concat(S(t.index.length-n/2,t.index.length)));let o=I(t.index);o.splice(Math.floor(o.length/2),0,"..."),t.values.push("..."),t.index.push("..."),t=t.get(o)}let r={};return t.values.forEach((o,i)=>{let m={};m[t.name]=o,r[t.index[i]]=m}),console.table(r),console.log("Shape:",e.shape,`
|
|
17
|
-
`),e}function oe(e){let t=e.copy();return t.get(tt(t.index))}function ie(e,t,n){n=n||((u,p)=>u<p?-1:1),s(h(n)||O(n),"You must pass undefined, null, or a comparison function as the second argument to the `sort` method!");let r=C([t.values,t.index]),o=R(r,(u,p)=>n(u[0],p[0])),i=[],m=[];o.forEach(u=>{i.push(u[0]),m.push(u[1])});let a=new e;return a._values=i,a._index=m,a.name=t.name,a}function se(e,t){let n=C([t.values,t.index]);n=C(R(n,(o,i)=>{if(o[1]===i[1])return 0;if(o[1]<i[1])return-1;if(o[1]>i[1])return 1}));let r=new e(n[0]);return r.index=n[1],r.name=t.name,r}function me(e){let t={};return t[e.name]={},e.index.forEach((n,r)=>{t[e.name][n]=e.values[r]}),t}var ae=Symbol.for("@jrc03c/js-math-tools/series");function ue(e){class t{static[Symbol.hasInstance](r){try{return!!r._symbol&&r._symbol===ae}catch{return!1}}constructor(r){if(this.name="data",Object.defineProperty(this,"_symbol",{configurable:!1,enumerable:!1,writable:!1,value:ae}),Object.defineProperty(this,"_values",{value:[],configurable:!0,enumerable:!1,writable:!0}),Object.defineProperty(this,"values",{configurable:!0,enumerable:!0,get(){return this._values},set(o){s(l(o),"The new values must be a 1-dimensional array!");let i=b(o);s(i.length===1,"The new array of values must be 1-dimensional!"),i[0]<this._index.length?this._index=this._index.slice(0,i[0]):i[0]>this._index.length&&(this._index=this._index.concat(S(this._index.length,i[0]).map(m=>"item"+$(m,(o.length-1).toString().length)))),this._values=o}}),Object.defineProperty(this,"_index",{value:[],configurable:!0,enumerable:!1,writable:!0}),Object.defineProperty(this,"index",{configurable:!0,enumerable:!0,get(){return this._index},set(o){s(l(o),"The new index must be a 1-dimensional array of strings!"),s(o.length===this.shape[0],"The new index must be the same length as the old index!"),s(b(o).length===1,"The new index must be a 1-dimensional array of strings!"),o.forEach(i=>{s(w(i),"All of the row names must be strings!")}),this._index=o}}),r){if(r instanceof t)this.name=r.name,this.values=I(r.values),this.index=I(r.index);else if(l(r)){let o=b(r);s(o.length===1,"When passing an array into the constructor of a Series, the array must be 1-dimensional!"),this.values=r}else if(r instanceof Object){let o=Object.keys(r).concat(Object.getOwnPropertySymbols(r)).map(a=>a.toString());s(o.length===1,"When passing an object into the constructor of a Series, the object must have only 1 key-value pair, where the key is the name of the data and the value is the 1-dimensional array of values!");let i=o[0],m=r[i];s(b(m).length===1,"When passing an object into the constructor of a Series, the object must have only 1 key-value pair, where the key is the name of the data and the value is the 1-dimensional array of values!"),this.name=i,this.values=m.slice()}}}get shape(){return b(this.values)}get length(){return this.shape[0]}get isEmpty(){return this.values.filter(r=>!h(r)).length===0}clear(){let r=this.copy();return r.values.forEach((o,i)=>{r.values[i]=void 0}),r}get(r){return te(this,r)}getSubsetByNames(r){return re(t,this,r)}getSubsetByIndices(r){return ee(this,r)}loc(r){return this.getSubsetByNames(r)}iloc(r){return this.getSubsetByIndices(r)}reverse(){let r=new t(U(this.values));return r.index=U(this.index),r.name=this.name,r}resetIndex(){let r=this.copy();return r.index=S(0,this.shape[0]).map(o=>"item"+$(o,(r.index.length-1).toString().length)),r}copy(){let r=new t;return r._values=I(this.values),r._index=I(this.index),r.name=this.name,r}append(r){return wt(t,this,r)}apply(r){return Ht(this,r)}concat(r){return this.append(r)}dropMissing(r,o){return Xt(this,r,o)}dropNaN(){return Qt(t,this)}toObject(){return me(this)}print(){return ne(this)}shuffle(){return oe(this)}sort(r){return ie(t,this,r)}sortByIndex(){return se(t,this)}filter(r){return Zt(t,this,r)}toDataFrame(){let r=new e(C([this.values]));return r.columns=[this.name],r.index=this.index,r}transpose(){let r=this.copy();return r.values=U(r.values),r.index=U(r.index),r}getDummies(){return this.toDataFrame().getDummies()}oneHotEncode(){return this.getDummies()}}return t}var fe=Symbol.for("@jrc03c/js-math-tools/dataframe");function pt(e){let t="abcdefghijklmnopqrstuvwxyz1234567890",n="";for(let r=0;r<e;r++)n+=t[Math.floor(K()*t.length)];return n}var _=class{static[Symbol.hasInstance](t){try{return!!t._symbol&&t._symbol===fe}catch{return!1}}constructor(t){if(Object.defineProperty(this,"_symbol",{configurable:!1,enumerable:!1,writable:!1,value:fe}),Object.defineProperty(this,"_values",{value:[],configurable:!0,enumerable:!1,writable:!0}),Object.defineProperty(this,"values",{configurable:!0,enumerable:!0,get(){return this._values.length===0||!h(this._values[0])&&this._values[0].length===0?[[]]:this._values},set(n){s(l(n),"The new values must be a 2-dimensional array!");let r=b(n);s(r.length===2,"The new array of values must be 2-dimensional!"),r[0]<this._index.length?this._index=this._index.slice(0,r[0]):r[0]>this._index.length&&(this._index=this._index.concat(S(this._index.length,r[0]).map(o=>"row"+$(o,(r[0]-1).toString().length)))),r[1]<this._columns.length?this._columns=this._columns.slice(0,r[1]):r[1]>this._columns.length&&(this._columns=this._columns.concat(S(this._columns.length,r[1]).map(o=>"col"+$(o,(r[1]-1).toString().length)))),this._values=n}}),Object.defineProperty(this,"_columns",{value:[],configurable:!0,enumerable:!1,writable:!0}),Object.defineProperty(this,"columns",{configurable:!0,enumerable:!0,get(){return this._columns},set(n){s(l(n),"The new columns list must be a 1-dimensional array of strings!"),s(this.isEmpty||n.length===this.shape[1],"The new columns list must be the same length as the old columns list!"),s(b(n).length===1,"The new columns list must be a 1-dimensional array of strings!"),n=n.map(o=>(typeof o!="string"&&(o=JSON.stringify(o)||o.toString()),o.trim().length===0?"untitled_"+pt(8):o.trim()));let r=(()=>{let o=nt(n),i={};return o.values.forEach(m=>{i[m]=o.get(m)}),i})();n=n.map(o=>r[o]>1?o+"_"+pt(8):o),this._columns=n}}),Object.defineProperty(this,"_index",{value:[],configurable:!0,enumerable:!1,writable:!0}),Object.defineProperty(this,"index",{configurable:!0,enumerable:!0,get(){return this._index},set(n){s(l(n),"The new index must be a 1-dimensional array of strings!"),s(this.isEmpty||n.length===this.shape[0],"The new index must be the same length as the old index!"),s(b(n).length===1,"The new index must be a 1-dimensional array of strings!"),n=n.map(o=>(typeof o!="string"&&(o=JSON.stringify(o)||o.toString()),o.trim().length===0?"untitled_"+pt(8):o.trim()));let r=(()=>{let o=nt(n),i={};return o.values.forEach(m=>{i[m]=o.get(m)}),i})();n=n.map(o=>r[o]>1?o+"_"+pt(8):o),this._index=n}}),s(h(t)||k(t)||l(t),"The `data` passed into the constructor of a DataFrame must be either (1) an object where the key-value pairs are (respectively) column names and 1-dimensional arrays of values, or (2) a 2-dimensional array of values."),t)if(t instanceof _)this.values=I(t.values),this.columns=I(t.columns),this.index=I(t.index);else if(l(t)){let n=b(t);s(n.length===2,"The `data` array passed into the constructor of a DataFrame must be 2-dimensional!"),s(!q(t),"The 2-dimensional array passed into the constructor of a DataFrame must not contain sub-arrays (i.e., rows) of different lengths!"),this.values=t}else{this._columns=Object.keys(t).concat(Object.getOwnPropertySymbols(t)).map(m=>m.toString());let n=[],r=null,o=null;this._columns.forEach(m=>{h(o)&&(r=m,o=t[m].length),s(t[m].length===o,`The object passed into the DataFrame constructor contains arrays of different lengths! The key "${r}" points to an array containing ${o} items, and the key "${m}" points to an array containing ${t[m].length} items.`),o=t[m].length;let a=t[m];n.push(a)}),this._values=C(n);let i=b(this.values);this._index=S(0,i[0]).map(m=>"row"+$(m,(i[0]-1).toString().length))}}get shape(){return b(this.values)}get length(){return this.shape[0]}get width(){return this.shape[1]}get rows(){return this.index}set rows(t){this.index=t}get isEmpty(){return this.values.length===0||this.values.every(t=>t.length===0)}clear(){let t=new _(j(this.shape));return t.columns=this.columns.slice(),t.index=this.index.slice(),t}get(t,n){if(arguments.length===0)return this;if(arguments.length===1)try{return this.get(null,t)}catch{return this.get(t,null)}return Pt(this,t,n)}getSubsetByNames(t,n){return Ct(_,M,this,t,n)}getSubsetByIndices(t,n){return zt(this,t,n)}getDummies(t){return vt(_,this,t)}oneHotEncode(t){return vt(_,this,t)}transpose(){let t=new _(C(this.values));return t.columns=this.index.slice(),t.index=this.columns.slice(),t}get T(){return this.transpose()}resetIndex(t){return Jt(this,t)}copy(){return Ft(_,this)}assign(t,n){return At(_,M,this,t,n)}apply(t,n){return xt(_,M,this,t,n)}dropMissing(t,n,r){return Et(_,M,this,t,n,r)}dropNaN(t,n,r){return Mt(_,this,t,n,r)}drop(t,n){return jt(_,M,this,t,n)}dropColumns(t){return this.drop(null,t)}dropRows(t){return this.drop(t,null)}toDetailedObject(t){return Vt(this,t)}toObject(){return Wt(this)}toJSONString(t){return lt(this,t)}saveAsJSON(t,n){return Gt(this,t,n)}print(){return kt(_,M,this)}sort(t,n){return qt(this,t,n)}sortByIndex(){return this.sort()}filter(t,n){return Ut(_,M,this,t,n)}shuffle(t){return Lt(this,t)}append(t,n){return Nt(this,t,n)}concat(t,n){return this.append(t,n)}join(t,n){return this.append(t,n)}toString(){return JSON.stringify(this)}},M=ue(_);function it(e,t){return E(e,{shouldDropNaNs:t}).max}function N(e){return s(O(e),"You must pass a function into the `vectorize` function!"),function t(){let n,r,o=[],i=[],m=Object.keys(arguments).filter(a=>{let u=arguments[a];return l(u)?!0:g(u)?(n=!0,o.push(u),!0):y(u)?(r=!0,i.push(u),!0):!1}).map(a=>arguments[a]);if(m.slice(0,-1).forEach((a,u)=>{s(z(l(a)?b(a):a.shape,l(m[u+1])?b(m[u+1]):m[u+1].shape),`When passing multiple arrays into the \`${e.name}\` function, all of the arrays must have the same shape!`)}),m.length>0){let a=it(m.map(p=>p.length?p.length:p.values.length)),u=S(0,a).map(p=>{let c=Object.keys(arguments).map(d=>l(arguments[d])?arguments[d][p]:g(arguments[d])||y(arguments[d])?arguments[d].values[p]:arguments[d]);return t(...c)});if(r)try{if(i.length===1&&z(b(i[0]),b(u))){let p=new _(u);return p.index=i[0].index.slice(),p.columns=i[0].columns.slice(),p}else return new _(u)}catch{return u}if(n)try{if(o.length===1&&o[0].length===u.length){let p=new M(u);return p.name=o[0].name,p.index=o[0].index.slice(),p}else return new M(u)}catch{return u}return u}else return e(...arguments)}}function ke(e){try{return f(e)?typeof e=="bigint"?e<0?-e:e:Math.abs(e):NaN}catch{return NaN}}var ct=N(ke);function Je(){try{let e=0,t=!1,n=Object.values(arguments);for(let r of n){if(!f(r))return NaN;typeof r=="bigint"&&(t=!0,r=Number(r)),e+=r}if(t)try{return BigInt(e)}catch{}return e}catch{return NaN}}var St=N(Je);function Re(e,t){try{return t(e)}catch{return NaN}}var ht=N(Re);function Ye(e){try{return f(e)?(typeof e=="bigint"&&(e=Number(e)),Math.acos(e)):NaN}catch{return NaN}}var Ke=N(Ye);function $e(e){try{return f(e)?(typeof e=="bigint"&&(e=Number(e)),Math.asin(e)):NaN}catch{return NaN}}var Le=N($e);function qe(e){try{return f(e)?(typeof e=="bigint"&&(e=Number(e)),Math.atan(e)):NaN}catch{return NaN}}var Ve=N(qe);function We(e){try{return f(e)?typeof e=="bigint"?e:Math.ceil(e):NaN}catch{return NaN}}var He=N(We);function Xe(e,t){try{if(!f(e))return NaN;if(typeof e=="bigint")return e;if(h(t))t=1e-10;else if(!f(t))return NaN;return ct(e)<t?0:e}catch{return NaN}}var Qe=N(Xe);function Ot(e){if(y(e)||g(e)){let t=e.copy();return t.values=Ot(t.values),t}if(l(e))return e.map(t=>Ot(t));try{let t=JSON.parse(e);return f(t)?typeof t=="bigint"?Number(t):t>=0?Math.floor(t):Math.ceil(t):NaN}catch{return NaN}}var B=N(Ot);function le(e,t,n){try{return f(e)?f(t)?f(n)?typeof e=="bigint"?BigInt(le(B(e),t,n)):e<t?t:e>n?n:e:NaN:NaN:NaN}catch{return NaN}}var Ze=N(le);function nr(e){try{return f(e)?(typeof e=="bigint"&&(e=Number(e)),Math.cos(e)):NaN}catch{return NaN}}var or=N(nr);var ir=Object.freeze({boolean:"boolean",date:"date",null:"null",number:"number",object:"object",string:"string"});function pe(e,t){try{if(!f(e))return NaN;if(!f(t))return NaN;if(typeof e=="bigint"||typeof t=="bigint"){let n=pe(Number(e),Number(t));try{return BigInt(n)}catch{return n}}return Math.pow(e,t)}catch{return NaN}}var Tt=N(pe);function ce(e){try{if(!f(e))return NaN;if(typeof e=="bigint"){let t=ce(Number(e));try{return BigInt(t)}catch{return t}}return Math.sqrt(e)}catch{return NaN}}var he=N(ce);function sr(){try{let e=Object.values(arguments);if(e.length===0)return NaN;let t=!1,n=1;for(let r of e){if(!f(r))return NaN;typeof r=="bigint"&&(t=!0,r=Number(r)),n*=r}if(t)try{return BigInt(n)}catch{}return n}catch{return NaN}}var de=N(sr);function ur(e){try{if(!f(e))return NaN;if(typeof e=="bigint"){if(e===0n)return 1n;e=Number(e)}return Math.exp(e)}catch{return NaN}}var fr=N(ur);function _t(e){try{return typeof e=="bigint"?BigInt(_t(B(e))):e!==B(e)?NaN:e<=1?1:e*_t(e-1)}catch{return NaN}}var lr=N(_t);function pr(e){try{if(e==="Infinity")return 1/0;if(e==="-Infinity")return-1/0;let t=JSON.parse(e);return f(t)?t:NaN}catch{return NaN}}var cr=N(pr);function hr(e){try{return f(e)?typeof e=="bigint"?e:Math.floor(e):NaN}catch{return NaN}}var dr=N(hr);function be(e,t,n){try{if(!f(e))return NaN;if(!f(t))return NaN;if(!f(n))return NaN;if(typeof e=="bigint"||typeof t=="bigint"){let r=be(Number(e),Number(t),n);try{return BigInt(r)}catch{return r}}return n*(t-e)+e}catch{return NaN}}var Nr=N(be);function Ne(e,t){try{if(t=h(t)?Math.E:t,!f(e))return NaN;if(!f(t))return NaN;if(typeof e=="bigint"||typeof t=="bigint"){let n=Ne(Number(e),Number(t));try{return BigInt(n)}catch{return n}}return Math.log(e)/Math.log(t)}catch{return NaN}}var vr=N(Ne);function ve(e,t){try{if(!f(e))return NaN;if(!f(t))return NaN;if(typeof e=="bigint"||typeof t=="bigint"){let n=ve(Number(e),Number(t));try{return BigInt(n)}catch{return n}}return e%t}catch{return NaN}}var wr=N(ve);var hd=N((e,t,n,r,o)=>{try{let i=!1;for(let p of[e,t,n,r,o]){if(!f(p))return NaN;typeof p=="bigint"&&(i=!0)}i&&(e=Number(e),t=Number(t),n=Number(n),r=Number(r),o=Number(o));let m=(o-r)*(e-t),a=n-t;if(a===0)return NaN;let u=m/a+r;if(i)try{return BigInt(u)}catch{}return u}catch{return NaN}});function Or(e){try{return f(e)?typeof e=="bigint"?e:Math.round(e):NaN}catch{return NaN}}var Tr=N(Or);function we(e){try{return f(e)?typeof e=="bigint"?BigInt(we(Number(e))):e<0?-1:e>0?1:0:NaN}catch{return NaN}}var _r=N(we);function Dr(e){try{return f(e)?(typeof e=="bigint"&&(e=Number(e)),Math.sin(e)):NaN}catch{return NaN}}var Ir=N(Dr);function Ar(e){try{return f(e)?(typeof e=="bigint"&&(e=Number(e)),Math.tan(e)):NaN}catch{return NaN}}var Fr=N(Ar);function Se(e,t,n){arguments.length===2&&(f(arguments[1])?n=null:(n=t,t=null)),s(f(e)&&B(e)===e,"`keyLength` must be an integer!"),t&&(s(f(t)&&B(t)===t,"`keySeed` must be an integer!"),ft(t)),n&&s(w(n),"`charset` must be a string!");let r="";n=n||"abcdefg1234567890";for(let o=0;o<e;o++)r+=n[B(K()*n.length)];return r}typeof globalThis<"u"&&(globalThis.makeKey=Se);})();
|
|
14
|
+
\x1B[0m`)}};function s(e,t){if(!e)throw new R(t)}var yt=[Array,ArrayBuffer,BigInt64Array,BigUint64Array,Float32Array,Float64Array,Int16Array,Int32Array,Int8Array,Uint16Array,Uint32Array,Uint8Array,Uint8ClampedArray];function h(e){return e===null||typeof e>"u"}var Oe=yt.map(e=>e.name);function l(e){try{return e instanceof Array?!0:h(e.constructor)?!1:yt.indexOf(e.constructor)>-1||Oe.indexOf(e.constructor.name)>-1}catch{return!1}}function y(e){try{return!!e._symbol&&e._symbol===Symbol.for("@jrc03c/js-math-tools/dataframe")}catch{return!1}}function T(e){return typeof e=="function"}function C(e){return typeof e=="object"&&!h(e)&&!l(e)}function g(e){try{return!!e._symbol&&e._symbol===Symbol.for("@jrc03c/js-math-tools/series")}catch{return!1}}function V(e,t){if(y(e)){let i=V(e.values,t);return i.length>0&&f(i[0])&&i[0]>=0&&i[0]<e.index.length&&(i[0]=e.index[i[0]]),i.length>1&&f(i[1])&&i[1]>=0&&i[1]<e.columns.length&&(i[1]=e.columns[i[1]]),i}if(g(e)){let i=V(e.values,t);return i.length>0&&f(i[0])&&i[0]>=0&&i[0]<e.index.length&&(i[0]=e.index[i[0]]),i}if(s(C(e)||l(e),"You must pass (1) an object, array, Series, or DataFrame and (2) a function or value into the `indexOf` function!"),!T(t)){let i=t;t=a=>a===i}function n(i,a,m){if(m=m||[],m.indexOf(i)>-1)return null;if(C(i)){m.push(i);let u=Object.keys(i).concat(Object.getOwnPropertySymbols(i));for(let p=0;p<u.length;p++){let c=u[p],d=i[c];if(a(d))return[c];let v=n(d,a,m);if(v&&v.length>0)return[c].concat(v)}}else if(l(i)){m.push(i);for(let u=0;u<i.length;u++){let p=i[u];if(a(p))return[u];let c=n(p,a,m);if(c&&c.length>0)return[u].concat(c)}}else if(a(i))return[];return null}function r(i){try{return t(i)}catch{return!1}}let o=n(e,r);return o&&o.length>0?o:null}function D(e){function t(n){if(typeof n=="object"){if(n===null)return null;if(l(n))return n instanceof Array?n.map(o=>D(o)):n.slice();if(g(n)){let o=n.copy();return o.values=D(o.values),o}if(y(n)){let o=n.copy();return o.values=D(n.values),o}if(n instanceof Date)return new Date(n.getTime());n=q(n);let r={};return Object.keys(n).concat(Object.getOwnPropertySymbols(n)).forEach(o=>{r[o]=D(n[o])}),r}else return n}return t(q(e))}function q(e){function t(o,i,a){if(i=i||[],a=a||"",i.indexOf(o)>-1){let m=a.split("/").slice(a.startsWith("/")?1:0);if(m.some((p,c)=>{let d=m.slice(0,m.length-c-1),v=n;return d.forEach(O=>{v=v[O]}),v===o}))return`<reference to "${n===o?"/":"/"+V(n,o).join("/")}">`}return typeof o=="object"?o===null?null:(i.push(o),l(o)?typeof o.constructor<"u"&&o.constructor.name!=="Array"?o.slice():o.map((m,u)=>t(m,i,a+"/"+u)):(Object.keys(o).concat(Object.getOwnPropertySymbols(o)).forEach(m=>{o[m]=t(o[m],i,a+"/"+m.toString())}),o)):o}let n=e,r=t(n);if(y(e)){let o=e.copy();o._values=r.values,o._columns=r.columns,o._index=r.index,r=o}if(g(e)){let o=e.copy();o.name=r.name,o._values=r.values,o._index=r.index,r=o}return r}function G(e){return e instanceof Date&&e.toString()!=="Invalid Date"}var Dt=["number","int","float","bigint"];function P(e,t){function n(r,o){let i=typeof r,a=typeof o;if(i!==a&&!Dt.includes(i)&&!Dt.includes(a))return!1;if(i==="undefined"&&a==="undefined")return!0;if(i==="boolean"||i==="symbol")return r===o;if(i==="number"||i==="bigint")try{let m=r.toString(),u=o.toString();return m===u}catch{return!1}if(i==="string"||i==="function")return r===o;if(i==="object"){if(r===null||o===null)return r===null&&o===null;{if(G(r))return G(o)?r.getTime()===o.getTime():!1;if(G(o))return!1;if(r instanceof RegExp&&o instanceof RegExp)return r.toString()===o.toString();if(l(r)!==l(o))return!1;let m=Object.keys(r).concat(Object.getOwnPropertySymbols(r)),u=Object.keys(o).concat(Object.getOwnPropertySymbols(o));if(m.length!==u.length)return!1;for(let p=0;p<m.length;p++){let c=m[p];if(!n(r[c],o[c]))return!1}return!0}}}try{return n(e,t)}catch{return n(q(e),q(t))}}function rt(e){let t="abcdefg1234567890",n="";for(;n.length<e;)n+=t[Math.floor(Math.random()*t.length)];return n}var Te=rt(16),_e=rt(16),De=rt(16),xe=rt(16),Ie=rt(16),at=class{constructor(){this.clear()}get counts(){return this.values.map(t=>this.get(t))}get values(){return Object.values(this.valuesDict)}clear(){return this.countsDict={},this.valuesDict={},this}count(t){for(let n of t)l(n)?this.count(n):this.increment(n);return this}delete(t){let n=this.getStandardizedKey(t);return delete this.countsDict[n],delete this.valuesDict[n],this}get(t){return this.countsDict[this.getStandardizedKey(t)]||0}getStandardizedKey(t){return typeof t=="object"&&t===null?Te:h(t)?_e:T(t)?t.toString():typeof t=="symbol"?t.toString()+" - "+Ie:t===1/0?De:t===-1/0?xe:typeof t=="bigint"?t.toString():y(t)?t.toJSONString():g(t)?JSON.stringify(t.toObject()):JSON.stringify(t)}has(t){return!h(this.countsDict[this.getStandardizedKey(t)])}increment(t){return this.set(t,this.get(t)+1)}set(t,n){let r=this.getStandardizedKey(t);return this.countsDict[r]=n,this.valuesDict[r]=t,this}toArray(){return this.values.map(t=>({value:t,count:this.get(t)}))}toObject(){let t={};return this.values.forEach(n=>{t[n]=this.get(n)}),t}};function x(e){if(y(e)||g(e))return x(e.values);s(l(e),"The `flatten` function only works on arrays, Series, and DataFrames!");function t(n){let r=[];return n.forEach(o=>{l(o)?r=r.concat(t(o)):r.push(o)}),r}return t(e)}function E(e,t){t=t||{};let n=new at,r={},o=x(e),i=[],a=-1/0,m=1/0,u=!1,p=0;for(let d of o){if(typeof d=="bigint"&&(u=!0),!t.shouldDropNaNs||f(d))try{d>a&&(a=d),d<m&&(m=d),p+=Number(d),i.push(d)}catch{a=NaN,m=NaN,p=NaN}n.increment(d)}let c=p/i.length;if(r.counts=n,r.max=a,r.mean=c,r.min=m,r.n=o.length,r.sum=p,isNaN(r.mean)&&(r.max=NaN,r.min=NaN),t.shouldDropNaNs&&(r.nWithoutNaNs=i.length),t.mode){let d=Array.from(n.values.map(F=>[F,n.get(F)])).toSorted((F,st)=>st[1]-F[1]),v=d[0][1],O=[];for(let F of d)if(F[1]==v)O.push(F[0]);else break;r.mode=O.toSorted()}if(t.median)if(isNaN(c))r.median=NaN;else{let d=i.toSorted((O,F)=>Number(O)-Number(F)),v=Math.floor(d.length/2);if(d.length%2===0){let O=d[v-1],F=d[v];if(r.median=(Number(O)+Number(F))/2,u&&typeof O=="bigint"&&typeof F=="bigint")try{r.median=BigInt(r.median)}catch{}}else r.median=d[v]}if(t.stdev||t.variance){let d=0;for(let O of i)d+=Math.pow(Number(O)-c,2);d/=i.length;let v=Math.sqrt(d);r.stdev=v,r.variance=d}if(u){try{r.sum=BigInt(r.sum)}catch{}try{r.mean=BigInt(r.mean)}catch{}t.mode&&(r.mode=r.mode.map(d=>{try{return BigInt(d)}catch{return d}}))}return r}function nt(e,t){let{counts:n}=E(e);return h(t)||(T(t)?n.values.forEach(r=>{t(r)||n.delete(r)}):n.values.forEach(r=>{P(r,t)||n.delete(r)})),n}function bt(e){if(y(e)||g(e))return bt(e.values);if(l(e)){let t=!1,n=!1,r=null;for(let o of e){if(bt(o))return!0;if(l(o)){if(r===null)r=o.length;else if(o.length!==r)return!0;t=!0}else n=!0;if(t&&n)return!0}}return!1}function L(e){return bt(q(e))}function H(e){if(y(e)||g(e))return H(e.values);s(l(e),"The `isNested` function only works on arrays, Series, and DataFrames!");for(let t=0;t<e.length;t++)if(l(e[t]))return!0;return!1}var X="You must pass a natural number or a one-dimensional array of natural numbers into the `ndarray` function!";function A(e){s(!h(e),X),l(e)||(e=[e]),s(!H(e),X),s(e.length>0,X);let t=e[0];if(typeof t=="bigint"&&(t=Number(t)),s(f(t),X),s(t>=0,X),s(Math.floor(t)===t,X),s(t!==1/0,"We can't create an array containing an infinite number of values!"),e.length===1){let n=[];for(let r=0;r<t;r++)n.push(void 0);return n}else{let n=[];for(let r=0;r<t;r++)n.push(A(e.slice(1)));return n}}function B(e){if(y(e)||g(e)){let n=e.copy();return n.values=B(n.values),n.index=B(n.index),n}s(l(e),"The `reverse` function only works on arrays, Series, and DataFrames!");let t=[];for(let n=e.length-1;n>=0;n--)t.push(e[n]);return t}function w(e,t,n=1){s(!h(e)&&!h(t)&&!h(n),"You must pass two numbers and optionally a step value to the `range` function!"),s(f(e)&&f(t)&&f(n),"You must pass two numbers and optionally a step value to the `range` function!"),s(n>0,"The step value must be greater than 0! (NOTE: The step value is a magnitude; it does not indicate direction.)");let r=!1,o=typeof e=="bigint"||typeof t=="bigint"||typeof n=="bigint";if(e=Number(e),t=Number(t),n=Number(n),e>t){r=!0;let a=e;e=t+n,t=a+n}let i=[];for(let a=e;a<t;a+=n)if(o)try{i.push(BigInt(a))}catch{i.push(a)}else i.push(a);return r&&(i=B(i)),i}function ot(e){let t="abcdefg1234567890",n="";for(;n.length<e;)n+=t[Math.floor(Math.random()*t.length)];return n}var Fe=ot(256),Ae=ot(256),Ee=ot(256),Me=ot(256),je=ot(256);function U(e){if(y(e)||g(e))return U(e.values);s(l(e),"The `set` function only works on arrays, Series, and DataFrames!");let t=[],n={};return x(e).forEach(r=>{let o=typeof r=="object"&&r===null?Fe:h(r)?Ae:T(r)?r.toString():typeof r=="symbol"?r.toString()+" - "+je:r===1/0?Ee:r===-1/0?Me:typeof r=="bigint"?r.toString():y(r)?r.toJSONString():g(r)?JSON.stringify(r.toObject()):JSON.stringify(r);n[o]||t.push(r),n[o]=!0}),t}function xt(e){if(l(e)){let t=xt(e[0]);return[e.length].concat(t||[])}else return}function b(e){return y(e)||g(e)?b(e.values):(s(l(e),"The `shape` function only works on arrays, Series, and DataFrames!"),xt(e))}function Nt(e,t,n){if(h(n)&&(n=0),s(n===0||n===1||n==="vertical"||n==="horizontal",'The only valid axis values for use when appending data to a DataFrame are 0, 1, "vertical", and "horizontal". Note that 0 == "horizontal" and 1 == "vertical".'),l(t)){s(!L(t),"The array of data you're trying to append to this DataFrame is jagged!");let r=b(t);if(r.length===1)if(n===0){let o=e.copy();o._values.push(t);let i=Math.max(e.shape[1],r[0]);for(o._values.forEach(a=>{for(;a.length<i;)a.push(void 0)});o._index.length<o._values.length;)o._index.push("row"+o._index.length);for(;o._columns.length<i;)o._columns.push("col"+o._columns.length);return o}else{let o=Math.max(e.shape[0],r[0]),i=e.copy();for(w(0,o).forEach(a=>{a>=i._values.length&&i._values.push(A(e.shape[1])),i._values[a].push(t[a])});i._index.length<i._values.length;)i._index.push("row"+i._index.length);for(;i._columns.length<i._values[0].length;)i._columns.push("col"+i._columns.length);return i}else if(r.length===2)if(n===0){let o=Math.max(...t.map(a=>a.length).concat([e.shape[1]])),i=e.copy();for(i._values=i._values.concat(t).map(a=>{for(;a.length<o;)a.push(void 0);return a});i._index.length<i._values.length;)i._index.push("row"+i._index.length);for(;i._columns.length<o;)i._columns.push("col"+i._columns.length);return i}else{let o=Math.max(...t.map(m=>m.length))+e.shape[1],i=Math.max(e.shape[0],r[0]),a=e.copy();for(w(0,i).forEach(m=>{for(m>=a._values.length&&a._values.push(A(e.shape[1])),a._values[m]=a._values[m].concat(t[m]);a._values[m].length<o;)a._values[m].push(void 0)});a._index.length<a._values.length;)a._index.push("row"+a._index.length);for(;a._columns.length<o;)a._columns.push("col"+a._columns.length);return a}else throw new R("Only 1- and 2-dimensional arrays can be appended to a DataFrame!")}else if(g(t)){let r=Nt(e,t.values,n);return n===0?r.index[r.index.length-1]=r.index.indexOf(t.name)>-1?t.name+" (2)":t.name:r.columns[r.columns.length-1]=r.columns.indexOf(t.name)>-1?t.name+" (2)":t.name,r}else if(y(t))if(n===0){let r=e.copy(),o=U(r._columns.concat(t._columns)).length;for(r._values.forEach(i=>{for(;i.length<o;)i.push(void 0)}),t.apply(i=>{let a=i.copy(),m=[];r._columns.forEach(u=>{let p=a._index.indexOf(u);p>-1?(m.push(a._values[p]),a._values.splice(p,1),a._index.splice(p,1)):m.push(void 0)}),r._values.push(m.concat(a._values))},1),r._columns=r._columns.concat(t._columns.filter(i=>r._columns.indexOf(i)<0));r._index.length<r._values.length;){let i="row"+r._index.length;r._index.push(i+(e._index.indexOf(i)>-1?" (2)":""))}return r}else{let r=e.copy();return r._index.forEach((o,i)=>{let a=t._index.indexOf(o);a>-1?r._values[i]=r._values[i].concat(t._values[a]):r._values[i]=r._values[i].concat(A(t.shape[1]))}),t._index.forEach((o,i)=>{r._index.indexOf(o)<0&&(r._index.push(o),r._values.push(A(r._columns.length).concat(t._values[i])))}),r._columns=r._columns.concat(t._columns.map(o=>o+(r._columns.indexOf(o)>-1?" (2)":""))),r}else throw new R("Only 1- or 2-dimensional arrays, Series, and DataFrames can be appended to a DataFrame!")}function It(e,t,n,r,o){if(o=o||0,s(T(r),"The first parameter to the `apply` method must be a function."),s(o===0||o===1,"The second parameter to the `apply` method (the `axis`) must be 0 or 1."),o===0){let i={},a;if(n.columns.forEach((m,u)=>{let p=new t(n.values.map(d=>d[u]));p.name=m,p.index=n.index;let c=r(p,u,n);c instanceof t?i[m]=c.values:i[m]=c,h(a)&&(a=c instanceof t||l(c))}),a){let m=new e(i);return m.index=n.index,m}else{let m=new t(n.columns.map(u=>i[u]));return m.index=n.columns,m}}else if(o===1){let i,a=n.values.map((m,u)=>{let p=new t(m);p.name=n.index[u],p.index=n.columns;let c=r(p,u,n);return h(i)&&(i=c instanceof t||l(c)),c instanceof t?c.values:c});if(i){let m=new e(a);return m.index=n.index,m.columns=n.columns,m}else{let m=new t(a);return m.index=n.index,m}}}function S(e){return typeof e=="string"}function Ft(e,t,n,r,o){let i=m=>m instanceof e,a=m=>m instanceof t;if(h(o))if(i(r)){let m=n.copy(),u=m.shape,p=r.shape;for(let c=0;c<p[1];c++){let d=r.columns[c],v=m.columns.includes(d)?m.columns.indexOf(d):m.columns.length;m.columns.includes(d)||m._columns.push(d);for(let O=0;O<u[0];O++)m._values[O][v]=r._values[O][c]}return m}else{if(a(r))return n.assign(r.name,r.values);if(C(r))return n.assign(new e(r));throw new R("You must pass a DataFrame, Series, or object into the `assign` method!")}else{s(S(r),"If passing two arguments into the `assign` method, then the first argument must be a string name!"),s(l(o)&&!L(o)&&b(o).length===1,"If passing two arguments into the `assign` method, then the second argument must be a 1-dimensional array!");let m=n.copy();if(m.columns.includes(r)){let u=m.columns.indexOf(r);return m.columns[u]=r,m.values.forEach((p,c)=>p[u]=o[c]),m}else return m._columns.push(r),m._values.forEach((u,p)=>u.push(o[p])),m}}function At(e,t){if(t.isEmpty)return new e;let n=new e(D(t.values));return n.columns=t.columns.slice(),n.index=t.index.slice(),n}function Et(e,t,n,r,o){h(r)&&(r=[]),h(o)&&(o=[]),(S(r)||f(r))&&(r=[r]),(S(o)||f(o))&&(o=[o]),s(l(r),"The `drop` method only works on 1-dimensional arrays of numerical indices and/or strings."),s(l(o),"The `drop` method only works on 1-dimensional arrays of numerical indices and/or strings."),s(b(r).length===1,"The `drop` method only works on 1-dimensional arrays of numerical indices and/or strings."),s(b(o).length===1,"The `drop` method only works on 1-dimensional arrays of numerical indices and/or strings.");let i,a;n.index.forEach((u,p)=>{r.indexOf(u)<0&&r.indexOf(p)<0&&(i||(i=[]),i.push(u))}),n.columns.forEach((u,p)=>{o.indexOf(u)<0&&o.indexOf(p)<0&&(a||(a=[]),a.push(u))});let m=n.get(i,a);if(m instanceof t){let u=new e;u=u.assign(m),n.index.indexOf(m.name)>-1&&(u=u.transpose()),m=u}return m}function mt(e){return f(e)&&(e>=0?Math.floor(e)===e:Math.ceil(e)===e)}function k(e){return mt(e)&&e>=0}function Mt(e,t,n,r,o,i){r=r||0,s(r===0||r===1,"The first parameter of the `dropMissing` method (the `axis`) must be 0 or 1."),i=i||0,s(k(i),"The third parameter of the `dropMissing` method (the `threshold`) should be a whole number (meaning that data should be dropped if it contains more than `threshold` null values)."),o=i>0?"none":o||"any",s(o==="any"||o==="all"||o==="none","The second parameter of the `dropMissing` method (the `condition` parameter, which indicates the condition under which data should be dropped) should be 'any' or 'all' (meaning that if 'any' of the data contains null values, then it should be dropped; or that if 'all' of the data contains null values, then it should be dropped).");function a(p){if(i>0){let c=0;for(let d=0;d<p.length;d++){let v=p[d];if(h(v)&&c++,c>=i)return[]}}else if(o==="any")for(let c=0;c<p.length;c++){let d=p[c];if(h(d))return[]}else if(o==="all"){for(let c=0;c<p.length;c++){let d=p[c];if(!h(d))return p}return[]}return p}let m=n.copy(),u=Math.random().toString();if(r===0){m=m.assign(u,m.index);let p=m.values.map(a).filter(d=>d.length>0);if(b(p).length<2)return new e;m.values=p;let c=m.get(null,u);if(h(c))return new e;S(c)&&(c=[c]),c instanceof t&&(c=c.values),m.index=c,m=m.drop(null,u)}else if(r===1){let p={};if(m.columns.forEach((d,v)=>{let O=m.values.map(st=>st[v]),F=a(O);F.length>0&&(p[d]=F)}),Object.keys(p).length+Object.getOwnPropertySymbols(p).length===0)return new e;let c=new e(p);return c.index=m.index,c}return m}function ut(e){if(y(e)||g(e))return e.dropNaN(...Object.values(arguments).slice(1));s(l(e),"The `dropNaN` function only works on arrays, Series, and DataFrames!");let t=[];return e.forEach(n=>{try{return t.push(ut(n))}catch{if(f(n))return t.push(n)}}),t}function jt(e,t,n,r,o){n=n||0,s(n===0||n===1,"The first parameter of the `dropNaN` method (the `axis`) must be 0 or 1."),o=o||0,s(k(o),"The third parameter of the `dropNaN` method (the `threshold`) should be a whole number (meaning that data should be dropped if it contains more than `threshold` NaN values)."),r=o>0?"none":r||"any",s(r==="any"||r==="all"||r==="none","The second parameter of the `dropNaN` method (the `condition` parameter, which indicates the condition under which data should be dropped) should be 'any' or 'all' (meaning that if 'any' of the data contains NaN values, then it should be dropped; or that if 'all' of the data contains NaN values, then it should be dropped).");function i(m){let u=ut(m);return o>0?m.length-u.length<o:r==="any"?u.length===m.length:r==="all"?u.length>0:!0}let a=t.copy();if(n===0){let m=a.index.filter(u=>{let p=a.get(u,null).values;return i(p)});return m.length>0?a.get(m,null):new e}else if(n===1){let m=a.columns.filter(u=>{let p=a.get(null,u).values;return i(p)});return m.length>0?a.get(null,m):new e}return a}function Bt(e){let t={};return x(e).forEach((n,r)=>{t[n]=r}),t}function Q(e){return Object.keys(e).concat(Object.getOwnPropertySymbols(e)).sort((t,n)=>e[t]-e[n])}function Ut(e,t,n,r,o){s(T(r),"The `filter` method takes a single parameter: a function that is used to filter the values."),h(o)&&(o=0),s(o===0||o===1,"The `axis` parameter to the `filter` method must be 0 or 1.");let i=n.copy();if(i.isEmpty)return i;let a=Bt(i.index),m=Bt(i.columns);if(o===0){let u=0,p=i.values.filter((c,d)=>{let v=new t(c);v.name=n.index[d],v.index=n.columns;let O=r(v,d,n);return O?u++:delete a[i.index[d]],O});if(u===0)return new e;if(u===1){let c=new t(p[0]);return c.name=Q(a)[0],c.index=Q(m),c}i.values=p,i.index=Q(a)}else if(o===1){i=i.transpose();let u=0,p=i.values.filter((c,d)=>{let v=new t(c);v.name=n.columns[d],v.index=n.index;let O=r(v,d,n);return O?u++:delete m[i.index[d]],O});if(u===0)return new e;if(u===1){let c=new t(p[0]);return c.name=Q(m)[0],c.index=Q(a),c}i.values=p,i.index=Q(m),i=i.transpose()}return i}function Pt(e,t,n){(S(t)||f(t))&&(t=[t]),(S(n)||f(n))&&(n=[n]);for(let o in t)typeof t[o]=="bigint"&&(t[o]=Number(t[o]));for(let o in n)typeof n[o]=="bigint"&&(n[o]=Number(n[o]));let r=U((t||[]).concat(n||[]).map(o=>typeof o));return s(r.length<=2,"Only whole numbers and/or strings are allowed in `get` arrays!"),r.length===1&&s(r[0]==="string"||r[0]==="number","Only whole numbers and/or strings are allowed in `get` arrays!"),r.length===2&&(s(r.indexOf("string")>-1,"Only whole numbers and/or strings are allowed in `get` arrays!"),s(r.indexOf("number")>-1,"Only whole numbers and/or strings are allowed in `get` arrays!")),h(t)||(t=t.map(o=>{if(S(o))return s(e.index.indexOf(o)>-1,`Row "${o}" does not exist!`),o;if(f(o))return s(o>=0,`Index ${o} is out of bounds!`),s(Math.floor(o)===o,"Row numbers must be integers!"),s(o<e.index.length,`Index ${o} is out of bounds!`),e.index[o]})),h(n)||(n=n.map(o=>{if(S(o))return s(e.columns.indexOf(o)>-1,`Column "${o}" does not exist!`),o;if(f(o))return s(o>=0,`Column ${o} is out of bounds!`),s(Math.floor(o)===o,"Column numbers must be integers!"),s(o<e.columns.length,`Column ${o} is out of bounds!`),e.columns[o]})),e.getSubsetByNames(t,n)}function Be(e,t){try{return e<t?-1:e>t?1:0}catch{return e=typeof e=="object"&&e!==null?JSON.stringify(e):e.toString(),t=typeof t=="object"&&t!==null?JSON.stringify(t):t.toString(),e<t?-1:e>t?1:0}}function J(e,t){if(h(t)&&(t=Be),y(e)||g(e))return e.sort(...Object.values(arguments).slice(1));s(l(e),"The `sort` function only works on arrays, Series, and DataFrames!"),s(T(t),"The second parameter of the `sort` function must be a comparison function!");let n=e.slice();return n.sort(t),n}function Ue(e){let t=e.toLowerCase(),n="";for(let o=0;o<t.length;o++){let i=t[o];i.match(/[a-z0-9]/g)?n+=i:n+=" "}let r=n.split(" ").filter(o=>o.length>0);return r[0]+r.slice(1).map(o=>o[0].toUpperCase()+o.substring(1)).join("")}function vt(e,t,n){h(n)?n=t.columns:S(n)&&(n=[n]);let r={};n.forEach(i=>{s(S(i),"You must pass either a string or a one-dimensional array of strings into the `getDummies` (AKA `oneHotEncode`) method!");let a=t.columns.indexOf(i);s(a>-1,`The given DataFrame does not have a column called "${i}"!`);let m=t.values.map(p=>p[a]),u=J(U(m));m.forEach(p=>{u.forEach(c=>{let d=i+"_"+Ue(c.toString());r[d]||(r[d]=[]),p===c?r[d].push(1):r[d].push(0)})})});let o=new e(r);return o.index=t.index,o}function zt(e,t,n){let r=e.shape;h(t)&&(t=w(0,r[0])),h(n)&&(n=w(0,r[1])),f(t)&&(t=[t]),f(n)&&(n=[n]),s(l(t)&&l(n),"The `rowIndices` and `colIndices` parameters must be 1-dimensional arrays of whole numbers."),s(b(t).length===1&&b(n).length===1,"The `rowIndices` and `colIndices` parameters must be 1-dimensional arrays of whole numbers."),s(t.length>0,"The `rowIndices` array must contain at least one index."),s(n.length>0,"The `colIndices` array must contain at least one index."),t.forEach(a=>{s(k(a),"The `rowIndices` and `colIndices` parameters must be 1-dimensional arrays of whole numbers."),s(a<e.index.length,`The row index ${a} is out of bounds.`)}),n.forEach(a=>{s(k(a),"The `rowIndices` and `colIndices` parameters must be 1-dimensional arrays of whole numbers."),s(a<e.columns.length,`The column index ${a} is out of bounds.`)});let o=t.map(a=>e.index[a]),i=n.map(a=>e.columns[a]);return e.getSubsetByNames(o,i)}function Ct(e,t,n,r,o){h(r)&&(r=n.index),h(o)&&(o=n.columns),S(r)&&(r=[r]),S(o)&&(o=[o]),s(l(r)&&l(o),"The `rows` and `cols` parameters must be 1-dimensional arrays of strings."),s(b(r).length===1&&b(o).length===1,"The `rows` and `cols` parameters must be 1-dimensional arrays of strings."),s(r.length>0,"The `rows` array must contain at least one row name."),s(o.length>0,"The `cols` array must contain at least one column name."),r.forEach(m=>{s(S(m),"The `rows` and `cols` parameters must be 1-dimensional arrays of strings."),s(n.index.indexOf(m)>-1,`The row name "${m}" does not exist in the list of rows.`)}),o.forEach(m=>{s(S(m),"The `rows` and `cols` parameters must be 1-dimensional arrays of strings."),s(n.columns.indexOf(m)>-1,`The column name "${m}" does not exist in the list of columns.`)});let i=r.map(m=>o.map(u=>n.values[n.index.indexOf(m)][n.columns.indexOf(u)]));if(r.length===1&&o.length===1)return i[0][0];if(r.length===1){let m=new t(i[0]);return m.name=r[0],m.index=o,m}if(o.length===1){let m=new t(i.map(u=>u[0]));return m.name=o[0],m.index=r,m}let a=new e(i);return a.columns=o,a.index=r,a}function kt(e,t,n){function r(v,O){return S(v)&&v.length>O?v.substring(0,O-3)+"...":v}if(n.isEmpty)return console.table({}),console.log("Shape:",[0,0],`
|
|
15
|
+
`),n;let o=typeof window>"u"?20:10,i=Math.floor(o/2),a=4,m=Math.floor(a/2),u=o>n.index.length?null:w(0,i).concat(w(n.index.length-i,n.index.length)),p=a>n.columns.length?null:w(0,m).concat(w(n.columns.length-m,n.columns.length)),c=n.get(u,p);c instanceof t&&(n.shape[0]===1?(c=new e([c.values]),c.index=n.index,c.columns=new t(n.columns).get(p).values):n.shape[1]===1&&(c=new e([c.values]).transpose(),c.index=new t(n.index).get(u).values,c.columns=n.columns)),o<=n.index.length&&(c._index.splice(i,0,"..."),c._values.splice(i,0,w(0,c.columns.length).map(()=>"..."))),a<=n.columns.length&&(c._columns.splice(m,0,"..."),c._values=c._values.map(v=>(v.splice(m,0,"..."),v)));let d=28;return c instanceof t?(c.values=c.values.map(v=>r(v,d)),c.name=r(c.name,d),c.index=c.index.map(v=>r(v,d))):(c.values=c.values.map(v=>v.map(O=>r(O,d))),c.columns=c.columns.map(v=>r(v,d)),c.index=c.index.map(v=>r(v,d))),console.table(c.toDetailedObject()),console.log("Shape:",n.shape,`
|
|
16
|
+
`),n}function $(e,t){s(f(e),"The `leftPad` function only works on numbers!");let n=e.toString();for(;n.length<t;)n="0"+n;return n}function Jt(e,t){let n=t?e:e.copy();return n.index=w(0,e.shape[0]).map(r=>"row"+$(r,(n.index.length-1).toString().length)),n}function W(e,t){if(y(e)||g(e))return W(e.values,t);s(l(e),"The `product` function only works on arrays, Series, and DataFrames!");try{if(e.length===0)return NaN;let n=x(e),r=!1,o=1;for(let i of n){if(!f(i))if(t)i=1;else return NaN;typeof i=="bigint"&&(r=!0,i=Number(i)),o*=i}if(r)try{return BigInt(o)}catch{}return o}catch{return NaN}}function Rt(e){return mt(e)&&e>0}function Z(e,t){if(y(e)||g(e))return Z(e.values,t);if(s(l(e),"The first argument passed into the `reshape` function must be an array!"),f(t)&&(t=[t]),s(l(t),"The second argument passed into the `reshape` function must be a whole number or a one-dimensional array of whole numbers!"),s(b(t).length===1,"The first argument passed into the `reshape` function must be a whole number or a one-dimensional array of whole numbers!"),t=t.map(i=>(typeof i=="bigint"&&(i=Number(i)),s(Rt(i),"The first argument passed into the `reshape` function must be a whole number or a one-dimensional array of whole numbers!"),Number(i))),t.length===0)return x(e);let n=x(e);if(t.length===1&&t[0]===n.length)return n;s(W(t)===n.length,"The new shape doesn't match the number of values available in `x` (the first argument passed into the `reshape` function)!");let r=[],o=Math.floor(n.length/t[0]);for(let i=0;i<t[0];i++){let a=n.slice(i*o,(i+1)*o);r.push(Z(a,t.slice(1)))}return r}var $t=Math.pow(2,64),_=[];ft(Math.floor(Math.random()*$t));function Pe(e,t){e=I(e);function n(){e+=I("0x9e3779b97f4a7c15");let o=D(e);return o=(o^o>>BigInt(30))*I("0xbf58476d1ce4e5b9"),o=(o^o>>BigInt(27))*I("0x94d049bb133111eb"),o^o>>BigInt(31)}let r=[];for(let o=0;o<t;o++)r.push(n());return r}function I(e){return BigInt.asUintN(64,BigInt(e))}function Yt(e,t){return e=I(e),t=BigInt(t),I(I(e<<t)|I(e>>I(BigInt(64)-t)))}function ft(e){if(typeof e=="bigint"&&(e=Number(e)),h(e))return D(_);{s(f(e),"If passing a value into the `seed` function, then that value must be an integer!");let t=Pe(Math.floor(e),4);_[0]=t[0],_[1]=t[1],_[2]=t[2],_[3]=t[3]}}function Kt(){let e=I(Yt(_[0]+_[3],23)+_[0]),t=I(_[1]<<BigInt(17));return _[2]=I(_[2]^_[0]),_[3]=I(_[3]^_[1]),_[1]=I(_[1]^_[2]),_[0]=I(_[0]^_[3]),_[2]=I(_[2]^t),_[3]=Yt(_[3],45),Math.floor(Number(e))/$t}function Y(e){return h(e)?Kt():(l(e)||(e=[e]),Z(A(W(e)).map(Kt),e))}function tt(e){if(y(e)||g(e))return e.shuffle(...Object.values(arguments).slice(1));s(l(e),"The `shuffle` function only works on arrays, Series, and DataFrames!");let t=[],n=e.slice();for(let r=0;r<e.length;r++){let o=Math.floor(Y()*n.length);t.push(n.splice(o,1)[0])}return t}function qt(e,t){return h(t)&&(t=0),s(t===0||t===1,"The `axis` parameter to the `shuffle` must be 0, 1, or undefined."),e.get(t===0?tt(e.index):null,t===1?tt(e.columns):null)}function et(e){return typeof e=="boolean"}function Lt(e,t,n){return T(t)?ze(e,t,n):Ce(e,t,n)}function ze(e,t,n){if(n=h(n)?0:n,s(T(t),"When sorting a DataFrame using a function, the first argument to the `sort` method must be a function!"),s(f(n),"When sorting a DataFrame using a function, the second argument to the `sort` method must be null, undefined, 0, or 1 to indicate the axis along which the data should be sorted! An axis of 0 means that the rows will be sorted relative to each other, whereas an axis of 1 means that the columns will be sorted relative to each other."),n===0){let r=J(e.index,(o,i)=>t(e.get(o,null),e.get(i,null)));return e.get(r,null)}else{let r=J(e.columns,(o,i)=>t(e.get(null,o),e.get(null,i)));return e.get(null,r)}}function Ce(e,t,n){let r=e.copy(),o=Y().toString();r=r.assign(o,r.index),h(t)&&(t=[o],n=[!0]),(f(t)||S(t))&&(t=[t],(et(n)||S(n))&&(n=[n])),s(l(t),"The first parameter of the `sort` method must be (1) a string or index representing a column name or index, respectively; (2) a 1-dimensional array of strings and/or indices; or (3) null."),s(b(t).length===1,"The first parameter of the `sort` method must be (1) a string or index representing a column name or index, respectively; (2) a 1-dimensional array of strings and/or indices; or (3) null."),h(n)&&(n=w(0,t.length).map(()=>!0)),s(l(n),"The second parameter of the `sort` method must be (1) a string or boolean representing the sort direction ('ascending' / 'descending', or true / false); (2) a 1-dimensional array of strings and/or booleans; or (3) null."),s(b(n).length===1,"The second parameter of the `sort` method must be (1) a string or boolean representing the sort direction ('ascending' / 'descending', or true / false); (2) a 1-dimensional array of strings and/or booleans; or (3) null."),s(t.length===n.length,"The arrays passed into the `sort` method must be equal in length."),t=t.map(a=>{if(s(S(a)||f(a),"Column references can either be column names (as strings) or column indices (as whole numbers)."),S(a)){let m=r.columns.indexOf(a);return s(m>-1,`The column "${a}" does not exist!`),m}if(f(a))return s(k(a),"Column indices must be whole numbers!"),s(a<r.columns.length,`The index ${a} is out of bounds!`),a}),n=n.map(a=>{if(s(S(a)||et(a),"Direction references can either be strings ('ascending' or 'descending') or booleans (true or false)."),S(a)){let m=a.trim().toLowerCase();return s(m==="ascending"||m==="descending","Direction references can either be strings ('ascending' or 'descending') or booleans (true or false)."),m==="ascending"}if(et(a))return a}),r.values=J(r.values,(a,m)=>{let u=0;for(;a[t[u]]===m[t[u]]&&u<t.length;)u++;let p=n[u];if(a[t[u]]===m[t[u]])return 0;if(a[t[u]]<m[t[u]])return p?-1:1;if(a[t[u]]>m[t[u]])return p?1:-1});let i=r.columns.indexOf(o);return r.index=r.values.map(a=>a[i]),r=r.dropColumns(o),r}function Vt(e,t){h(t)?t=0:s(t===0||t===1,"The axis parameter of the `toDetailedObject` method must be undefined, 0, or 1. An axis of 0 indicates that the returned object should be organized first by rows and then by columns. An axis of 1 indicates that the returned object should be organized first by columns and then by rows.");let n={};return t===0?e.index.forEach((r,o)=>{let i={};e.columns.forEach((a,m)=>{i[a]=e.values[o][m]}),n[r]=i}):e.columns.forEach((r,o)=>{let i={};e.index.forEach((a,m)=>{i[a]=e.values[m][o]}),n[r]=i}),n}function lt(e,t){return JSON.stringify(e.toObject(t))}async function Gt(e,t){return JSON.parse(lt(e,t))}function Wt(e){let t={};return e.columns.forEach(n=>{t[n]=e.get(n).values}),t}function z(e){if(y(e)||g(e))return e.transpose();s(l(e),"The `transpose` function only works on arrays, Series, and DataFrames!");let t=b(e);if(s(t.length<=2,"I'm not smart enough to know how to transpose arrays that have more than 2 dimensions. Sorry for the inconvenience! Please only pass 1- or 2-dimensional arrays into the `transpose` function!"),t.length===1)return B(e);if(t.length===2){let n=A(B(t));for(let r=0;r<t[0];r++)for(let o=0;o<t[1];o++)n[o][r]=e[r][o];return n}}function St(e,t,n){if(g(n))return new e(t.values.concat(n.values));if(l(n)){let r=b(n);s(r.length===1&&!H(r),"Only vectors can be appended to Series!");let o=t.copy();return n.forEach((i,a)=>{o._values.push(i),o._index.push("item"+(t.values.length+a))}),o}return St(t,[n])}function Ht(e,t){s(T(t),"The parameter to the `apply` method must be a function.");let n=e.copy();return n._values=n._values.map((r,o)=>t(r,o)),n}function Xt(e){let t=e.copy(),n=[];return t._values=t.values.filter((r,o)=>h(r)?!1:(n.push(t.index[o]),!0)),t._index=n,t}function Qt(e,t){let n=[],r=[];t.values.forEach((i,a)=>{f(i)&&(r.push(i),n.push(t.index[a]))});let o=new e(r);return o.name=t.name,o.index=n,o}function Zt(e,t,n){let r=t.copy(),o=D(r.index),i=[],a=r.values.filter((m,u)=>{let p=n(m,u,r.values);return p||i.push(r.index[u]),p});return i.forEach(m=>{o.splice(o.indexOf(m),1)}),a.length===0?(r=new e,r.name=t.name,r):(r.values=a,r.index=o,r)}function te(e,t){(S(t)||f(t))&&(t=[t]);for(let r in t)typeof t[r]=="bigint"&&(t[r]=Number(t[r]));let n=U((t||[]).map(r=>typeof r));return s(n.length<=2,"Only whole numbers and/or strings are allowed in `get` arrays!"),n.length===1&&s(n[0]==="string"||n[0]==="number","Only whole numbers and/or strings are allowed in `get` arrays!"),n.length===2&&(s(n.indexOf("string")>-1,"Only whole numbers and/or strings are allowed in `get` arrays!"),s(n.indexOf("number")>-1,"Only whole numbers and/or strings are allowed in `get` arrays!")),h(t)||(t=t.map(r=>{if(typeof r=="string")return s(e.index.indexOf(r)>-1,`Index "${r}" does not exist!`),r;if(typeof r=="number")return s(r>=0,`Index ${r} is out of bounds!`),s(Math.floor(r)===r,"Indices must be integers!"),s(r<e.index.length,`Index ${r} is out of bounds!`),e.index[r]})),e.getSubsetByNames(t)}function ee(e,t){let n=e.shape;h(t)&&(t=w(0,n[0])),s(l(t),"The `indices` array must be 1-dimensional array of whole numbers."),s(b(t).length===1,"The `indices` array must be a 1-dimensional array of whole numbers."),s(t.length>0,"The `indices` array must contain at least one index."),t.forEach(o=>{s(k(o),"The `indices` array must be a 1-dimensional array of whole numbers."),s(o<e.index.length,`The row index ${o} is out of bounds.`)});let r=t.map(o=>e.index[o]);return e.getSubsetByNames(r)}function re(e,t,n){h(n)&&(n=t.index),s(l(n),"The `indices` array must be a 1-dimensional array of strings."),s(b(n).length===1,"The `indices` array must be a 1-dimensional array of strings."),s(n.length>0,"The `indices` array must contain at least one index name."),n.forEach(i=>{s(S(i),"The `indices` array must contain only strings."),s(t.index.indexOf(i)>-1,`The name "${i}" does not exist in the index.`)});let r=n.map(i=>t.values[t.index.indexOf(i)]);if(r.length===1)return r[0];let o=new e(r);return o.index=n,o.name=t.name,o}function ne(e){let t=e.copy(),n=typeof window>"u"?20:10;if(t.index.length>n){t=t.get(w(0,n/2).concat(w(t.index.length-n/2,t.index.length)));let o=D(t.index);o.splice(Math.floor(o.length/2),0,"..."),t.values.push("..."),t.index.push("..."),t=t.get(o)}let r={};return t.values.forEach((o,i)=>{let a={};a[t.name]=o,r[t.index[i]]=a}),console.table(r),console.log("Shape:",e.shape,`
|
|
17
|
+
`),e}function oe(e){let t=e.copy();return t.get(tt(t.index))}function ie(e,t,n){n=n||((u,p)=>u<p?-1:1),s(h(n)||T(n),"You must pass undefined, null, or a comparison function as the second argument to the `sort` method!");let r=z([t.values,t.index]),o=J(r,(u,p)=>n(u[0],p[0])),i=[],a=[];o.forEach(u=>{i.push(u[0]),a.push(u[1])});let m=new e;return m._values=i,m._index=a,m.name=t.name,m}function se(e,t){let n=z([t.values,t.index]);n=z(J(n,(o,i)=>{if(o[1]===i[1])return 0;if(o[1]<i[1])return-1;if(o[1]>i[1])return 1}));let r=new e(n[0]);return r.index=n[1],r.name=t.name,r}function ae(e){let t={};return t[e.name]={},e.index.forEach((n,r)=>{t[e.name][n]=e.values[r]}),t}var me=Symbol.for("@jrc03c/js-math-tools/series");function ue(e){class t{static[Symbol.hasInstance](r){try{return!!r._symbol&&r._symbol===me}catch{return!1}}constructor(r){if(this.name="data",Object.defineProperty(this,"_symbol",{configurable:!1,enumerable:!1,writable:!1,value:me}),Object.defineProperty(this,"_values",{value:[],configurable:!0,enumerable:!1,writable:!0}),Object.defineProperty(this,"values",{configurable:!0,enumerable:!0,get(){return this._values},set(o){s(l(o),"The new values must be a 1-dimensional array!");let i=b(o);s(i.length===1,"The new array of values must be 1-dimensional!"),i[0]<this._index.length?this._index=this._index.slice(0,i[0]):i[0]>this._index.length&&(this._index=this._index.concat(w(this._index.length,i[0]).map(a=>"item"+$(a,(o.length-1).toString().length)))),this._values=o}}),Object.defineProperty(this,"_index",{value:[],configurable:!0,enumerable:!1,writable:!0}),Object.defineProperty(this,"index",{configurable:!0,enumerable:!0,get(){return this._index},set(o){s(l(o),"The new index must be a 1-dimensional array of strings!"),s(o.length===this.shape[0],"The new index must be the same length as the old index!"),s(b(o).length===1,"The new index must be a 1-dimensional array of strings!"),o.forEach(i=>{s(S(i),"All of the row names must be strings!")}),this._index=o}}),r){if(r instanceof t)this.name=r.name,this.values=D(r.values),this.index=D(r.index);else if(l(r)){let o=b(r);s(o.length===1,"When passing an array into the constructor of a Series, the array must be 1-dimensional!"),this.values=r}else if(r instanceof Object){let o=Object.keys(r).concat(Object.getOwnPropertySymbols(r)).map(m=>m.toString());s(o.length===1,"When passing an object into the constructor of a Series, the object must have only 1 key-value pair, where the key is the name of the data and the value is the 1-dimensional array of values!");let i=o[0],a=r[i];s(b(a).length===1,"When passing an object into the constructor of a Series, the object must have only 1 key-value pair, where the key is the name of the data and the value is the 1-dimensional array of values!"),this.name=i,this.values=a.slice()}}}get shape(){return b(this.values)}get length(){return this.shape[0]}get isEmpty(){return this.values.filter(r=>!h(r)).length===0}clear(){let r=this.copy();return r.values.forEach((o,i)=>{r.values[i]=void 0}),r}get(r){return te(this,r)}getSubsetByNames(r){return re(t,this,r)}getSubsetByIndices(r){return ee(this,r)}loc(r){return this.getSubsetByNames(r)}iloc(r){return this.getSubsetByIndices(r)}reverse(){let r=new t(B(this.values));return r.index=B(this.index),r.name=this.name,r}resetIndex(){let r=this.copy();return r.index=w(0,this.shape[0]).map(o=>"item"+$(o,(r.index.length-1).toString().length)),r}copy(){let r=new t;return r._values=D(this.values),r._index=D(this.index),r.name=this.name,r}append(r){return St(t,this,r)}apply(r){return Ht(this,r)}concat(r){return this.append(r)}dropMissing(r,o){return Xt(this,r,o)}dropNaN(){return Qt(t,this)}toObject(){return ae(this)}print(){return ne(this)}shuffle(){return oe(this)}sort(r){return ie(t,this,r)}sortByIndex(){return se(t,this)}filter(r){return Zt(t,this,r)}toDataFrame(){let r=new e(z([this.values]));return r.columns=[this.name],r.index=this.index,r}transpose(){let r=this.copy();return r.values=B(r.values),r.index=B(r.index),r}getDummies(){return this.toDataFrame().getDummies()}oneHotEncode(){return this.getDummies()}}return t}var fe=Symbol.for("@jrc03c/js-math-tools/dataframe");function pt(e){let t="abcdefghijklmnopqrstuvwxyz1234567890",n="";for(let r=0;r<e;r++)n+=t[Math.floor(Y()*t.length)];return n}var K=class e{static[Symbol.hasInstance](t){try{return!!t._symbol&&t._symbol===fe}catch{return!1}}constructor(t){if(Object.defineProperty(this,"_symbol",{configurable:!1,enumerable:!1,writable:!1,value:fe}),Object.defineProperty(this,"_values",{value:[],configurable:!0,enumerable:!1,writable:!0}),Object.defineProperty(this,"values",{configurable:!0,enumerable:!0,get(){return this._values.length===0||!h(this._values[0])&&this._values[0].length===0?[[]]:this._values},set(n){s(l(n),"The new values must be a 2-dimensional array!");let r=b(n);s(r.length===2,"The new array of values must be 2-dimensional!"),r[0]<this._index.length?this._index=this._index.slice(0,r[0]):r[0]>this._index.length&&(this._index=this._index.concat(w(this._index.length,r[0]).map(o=>"row"+$(o,(r[0]-1).toString().length)))),r[1]<this._columns.length?this._columns=this._columns.slice(0,r[1]):r[1]>this._columns.length&&(this._columns=this._columns.concat(w(this._columns.length,r[1]).map(o=>"col"+$(o,(r[1]-1).toString().length)))),this._values=n}}),Object.defineProperty(this,"_columns",{value:[],configurable:!0,enumerable:!1,writable:!0}),Object.defineProperty(this,"columns",{configurable:!0,enumerable:!0,get(){return this._columns},set(n){s(l(n),"The new columns list must be a 1-dimensional array of strings!"),s(this.isEmpty||n.length===this.shape[1],"The new columns list must be the same length as the old columns list!"),s(b(n).length===1,"The new columns list must be a 1-dimensional array of strings!"),n=n.map(o=>(typeof o!="string"&&(o=JSON.stringify(o)||o.toString()),o.trim().length===0?"untitled_"+pt(8):o.trim()));let r=(()=>{let o=nt(n),i={};return o.values.forEach(a=>{i[a]=o.get(a)}),i})();n=n.map(o=>r[o]>1?o+"_"+pt(8):o),this._columns=n}}),Object.defineProperty(this,"_index",{value:[],configurable:!0,enumerable:!1,writable:!0}),Object.defineProperty(this,"index",{configurable:!0,enumerable:!0,get(){return this._index},set(n){s(l(n),"The new index must be a 1-dimensional array of strings!"),s(this.isEmpty||n.length===this.shape[0],"The new index must be the same length as the old index!"),s(b(n).length===1,"The new index must be a 1-dimensional array of strings!"),n=n.map(o=>(typeof o!="string"&&(o=JSON.stringify(o)||o.toString()),o.trim().length===0?"untitled_"+pt(8):o.trim()));let r=(()=>{let o=nt(n),i={};return o.values.forEach(a=>{i[a]=o.get(a)}),i})();n=n.map(o=>r[o]>1?o+"_"+pt(8):o),this._index=n}}),s(h(t)||C(t)||l(t),"The `data` passed into the constructor of a DataFrame must be either (1) an object where the key-value pairs are (respectively) column names and 1-dimensional arrays of values, or (2) a 2-dimensional array of values."),t)if(t instanceof e)this.values=D(t.values),this.columns=D(t.columns),this.index=D(t.index);else if(l(t)){let n=b(t);s(n.length===2,"The `data` array passed into the constructor of a DataFrame must be 2-dimensional!"),s(!L(t),"The 2-dimensional array passed into the constructor of a DataFrame must not contain sub-arrays (i.e., rows) of different lengths!"),this.values=t}else{this._columns=Object.keys(t).concat(Object.getOwnPropertySymbols(t)).map(a=>a.toString());let n=[],r=null,o=null;this._columns.forEach(a=>{h(o)&&(r=a,o=t[a].length),s(t[a].length===o,`The object passed into the DataFrame constructor contains arrays of different lengths! The key "${r}" points to an array containing ${o} items, and the key "${a}" points to an array containing ${t[a].length} items.`),o=t[a].length;let m=t[a];n.push(m)}),this._values=z(n);let i=b(this.values);this._index=w(0,i[0]).map(a=>"row"+$(a,(i[0]-1).toString().length))}}get shape(){return b(this.values)}get length(){return this.shape[0]}get width(){return this.shape[1]}get rows(){return this.index}set rows(t){this.index=t}get isEmpty(){return this.values.length===0||this.values.every(t=>t.length===0)}clear(){let t=new e(A(this.shape));return t.columns=this.columns.slice(),t.index=this.index.slice(),t}get(t,n){if(arguments.length===0)return this;if(arguments.length===1)try{return this.get(null,t)}catch{return this.get(t,null)}return Pt(this,t,n)}getSubsetByNames(t,n){return Ct(e,M,this,t,n)}getSubsetByIndices(t,n){return zt(this,t,n)}getDummies(t){return vt(e,this,t)}oneHotEncode(t){return vt(e,this,t)}transpose(){let t=new e(z(this.values));return t.columns=this.index.slice(),t.index=this.columns.slice(),t}get T(){return this.transpose()}resetIndex(t){return Jt(this,t)}copy(){return At(e,this)}assign(t,n){return Ft(e,M,this,t,n)}apply(t,n){return It(e,M,this,t,n)}dropMissing(t,n,r){return Mt(e,M,this,t,n,r)}dropNaN(t,n,r){return jt(e,this,t,n,r)}drop(t,n){return Et(e,M,this,t,n)}dropColumns(t){return this.drop(null,t)}dropRows(t){return this.drop(t,null)}toDetailedObject(t){return Vt(this,t)}toObject(){return Wt(this)}toJSONString(t){return lt(this,t)}saveAsJSON(t,n){return Gt(this,t,n)}print(){return kt(e,M,this)}sort(t,n){return Lt(this,t,n)}sortByIndex(){return this.sort()}filter(t,n){return Ut(e,M,this,t,n)}shuffle(t){return qt(this,t)}append(t,n){return Nt(this,t,n)}concat(t,n){return this.append(t,n)}join(t,n){return this.append(t,n)}toString(){return JSON.stringify(this)}},M=ue(K);function it(e,t){return E(e,{shouldDropNaNs:t}).max}function N(e){return s(T(e),"You must pass a function into the `vectorize` function!"),function t(){let n,r,o=[],i=[],a=Object.keys(arguments).filter(m=>{let u=arguments[m];return l(u)?!0:g(u)?(n=!0,o.push(u),!0):y(u)?(r=!0,i.push(u),!0):!1}).map(m=>arguments[m]);if(a.slice(0,-1).forEach((m,u)=>{s(P(l(m)?b(m):m.shape,l(a[u+1])?b(a[u+1]):a[u+1].shape),`When passing multiple arrays into the \`${e.name}\` function, all of the arrays must have the same shape!`)}),a.length>0){let m=it(a.map(p=>p.length?p.length:p.values.length)),u=w(0,m).map(p=>{let c=Object.keys(arguments).map(d=>l(arguments[d])?arguments[d][p]:g(arguments[d])||y(arguments[d])?arguments[d].values[p]:arguments[d]);return t(...c)});if(r)try{if(i.length===1&&P(b(i[0]),b(u))){let p=new K(u);return p.index=i[0].index.slice(),p.columns=i[0].columns.slice(),p}else return new K(u)}catch{return u}if(n)try{if(o.length===1&&o[0].length===u.length){let p=new M(u);return p.name=o[0].name,p.index=o[0].index.slice(),p}else return new M(u)}catch{return u}return u}else return e(...arguments)}}function ke(e){try{return f(e)?typeof e=="bigint"?e<0?-e:e:Math.abs(e):NaN}catch{return NaN}}var ct=N(ke);function Je(){try{let e=0,t=!1,n=Object.values(arguments);for(let r of n){if(!f(r))return NaN;typeof r=="bigint"&&(t=!0,r=Number(r)),e+=r}if(t)try{return BigInt(e)}catch{}return e}catch{return NaN}}var wt=N(Je);function Re(e,t){try{return t(e)}catch{return NaN}}var ht=N(Re);function Ye(e){try{return f(e)?(typeof e=="bigint"&&(e=Number(e)),Math.acos(e)):NaN}catch{return NaN}}var Ke=N(Ye);function $e(e){try{return f(e)?(typeof e=="bigint"&&(e=Number(e)),Math.asin(e)):NaN}catch{return NaN}}var qe=N($e);function Le(e){try{return f(e)?(typeof e=="bigint"&&(e=Number(e)),Math.atan(e)):NaN}catch{return NaN}}var Ve=N(Le);function We(e){try{return f(e)?typeof e=="bigint"?e:Math.ceil(e):NaN}catch{return NaN}}var He=N(We);function Xe(e,t){try{if(!f(e))return NaN;if(typeof e=="bigint")return e;if(h(t))t=1e-10;else if(!f(t))return NaN;return ct(e)<t?0:e}catch{return NaN}}var Qe=N(Xe);function Ot(e){if(y(e)||g(e)){let t=e.copy();return t.values=Ot(t.values),t}if(l(e))return e.map(t=>Ot(t));try{let t=JSON.parse(e);return f(t)?typeof t=="bigint"?Number(t):t>=0?Math.floor(t):Math.ceil(t):NaN}catch{return NaN}}var j=N(Ot);function le(e,t,n){try{return f(e)?f(t)?f(n)?typeof e=="bigint"?BigInt(le(j(e),t,n)):e<t?t:e>n?n:e:NaN:NaN:NaN}catch{return NaN}}var Ze=N(le);function nr(e){try{return f(e)?(typeof e=="bigint"&&(e=Number(e)),Math.cos(e)):NaN}catch{return NaN}}var or=N(nr);var ir=Object.freeze({boolean:"boolean",date:"date",null:"null",number:"number",object:"object",string:"string"});function pe(e,t){try{if(!f(e))return NaN;if(!f(t))return NaN;if(typeof e=="bigint"||typeof t=="bigint"){let n=pe(Number(e),Number(t));try{return BigInt(n)}catch{return n}}return Math.pow(e,t)}catch{return NaN}}var Tt=N(pe);function ce(e){try{if(!f(e))return NaN;if(typeof e=="bigint"){let t=ce(Number(e));try{return BigInt(t)}catch{return t}}return Math.sqrt(e)}catch{return NaN}}var he=N(ce);function sr(){try{let e=Object.values(arguments);if(e.length===0)return NaN;let t=!1,n=1;for(let r of e){if(!f(r))return NaN;typeof r=="bigint"&&(t=!0,r=Number(r)),n*=r}if(t)try{return BigInt(n)}catch{}return n}catch{return NaN}}var de=N(sr);function ur(e){try{if(!f(e))return NaN;if(typeof e=="bigint"){if(e===0n)return 1n;e=Number(e)}return Math.exp(e)}catch{return NaN}}var fr=N(ur);function _t(e){try{return typeof e=="bigint"?BigInt(_t(j(e))):e!==j(e)?NaN:e<=1?1:e*_t(e-1)}catch{return NaN}}var lr=N(_t);function pr(e){try{if(e==="Infinity")return 1/0;if(e==="-Infinity")return-1/0;let t=JSON.parse(e);return f(t)?t:NaN}catch{return NaN}}var cr=N(pr);function hr(e){try{return f(e)?typeof e=="bigint"?e:Math.floor(e):NaN}catch{return NaN}}var dr=N(hr);function be(e,t,n){try{if(!f(e))return NaN;if(!f(t))return NaN;if(!f(n))return NaN;if(typeof e=="bigint"||typeof t=="bigint"){let r=be(Number(e),Number(t),n);try{return BigInt(r)}catch{return r}}return n*(t-e)+e}catch{return NaN}}var Nr=N(be);function Ne(e,t){try{if(t=h(t)?Math.E:t,!f(e))return NaN;if(!f(t))return NaN;if(typeof e=="bigint"||typeof t=="bigint"){let n=Ne(Number(e),Number(t));try{return BigInt(n)}catch{return n}}return Math.log(e)/Math.log(t)}catch{return NaN}}var vr=N(Ne);function ve(e,t){try{if(!f(e))return NaN;if(!f(t))return NaN;if(typeof e=="bigint"||typeof t=="bigint"){let n=ve(Number(e),Number(t));try{return BigInt(n)}catch{return n}}return e%t}catch{return NaN}}var Sr=N(ve);var ld=N((e,t,n,r,o)=>{try{let i=!1;for(let p of[e,t,n,r,o]){if(!f(p))return NaN;typeof p=="bigint"&&(i=!0)}i&&(e=Number(e),t=Number(t),n=Number(n),r=Number(r),o=Number(o));let a=(o-r)*(e-t),m=n-t;if(m===0)return NaN;let u=a/m+r;if(i)try{return BigInt(u)}catch{}return u}catch{return NaN}});function Or(e){try{return f(e)?typeof e=="bigint"?e:Math.round(e):NaN}catch{return NaN}}var Tr=N(Or);function Se(e){try{return f(e)?typeof e=="bigint"?BigInt(Se(Number(e))):e<0?-1:e>0?1:0:NaN}catch{return NaN}}var _r=N(Se);function Dr(e){try{return f(e)?(typeof e=="bigint"&&(e=Number(e)),Math.sin(e)):NaN}catch{return NaN}}var xr=N(Dr);function Fr(e){try{return f(e)?(typeof e=="bigint"&&(e=Number(e)),Math.tan(e)):NaN}catch{return NaN}}var Ar=N(Fr);function we(e,t,n){arguments.length===2&&(f(arguments[1])?n=null:(n=t,t=null)),s(f(e)&&j(e)===e,"`keyLength` must be an integer!"),t&&(s(f(t)&&j(t)===t,"`keySeed` must be an integer!"),ft(t)),n&&s(S(n),"`charset` must be a string!");let r="";n=n||"abcdefg1234567890";for(let o=0;o<e;o++)r+=n[j(Y()*n.length)];return r}typeof globalThis<"u"&&(globalThis.makeKey=we);})();
|
package/package.json
CHANGED
|
@@ -4,12 +4,12 @@
|
|
|
4
4
|
"key": "./bin.mjs"
|
|
5
5
|
},
|
|
6
6
|
"dependencies": {
|
|
7
|
-
"@jrc03c/js-math-tools": "^0.0.
|
|
7
|
+
"@jrc03c/js-math-tools": "^0.0.93"
|
|
8
8
|
},
|
|
9
9
|
"description": "",
|
|
10
10
|
"devDependencies": {
|
|
11
11
|
"@jrc03c/fake-jest": "^0.0.16",
|
|
12
|
-
"esbuild": "^0.
|
|
12
|
+
"esbuild": "^0.25.0",
|
|
13
13
|
"eslint": "^8.36.0"
|
|
14
14
|
},
|
|
15
15
|
"keywords": [],
|
|
@@ -18,5 +18,5 @@
|
|
|
18
18
|
"module": "./src/index.mjs",
|
|
19
19
|
"name": "@jrc03c/make-key",
|
|
20
20
|
"type": "module",
|
|
21
|
-
"version": "0.0.
|
|
21
|
+
"version": "0.0.37"
|
|
22
22
|
}
|