steamutils 1.5.7 → 1.5.9
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/SteamClient.js +4 -0
- package/create_remote_file.js +153 -153
- package/index.js +7933 -7930
- package/package.json +1 -1
- package/race.js +2241 -0
- package/remote.js +2249 -2240
- package/utils.js +31 -1
package/utils.js
CHANGED
@@ -7,6 +7,7 @@ import readline from "readline";
|
|
7
7
|
import https from "https";
|
8
8
|
import { promisify } from "util";
|
9
9
|
import { pipeline } from "stream";
|
10
|
+
import _ from "lodash";
|
10
11
|
|
11
12
|
const isBrowser = typeof window !== "undefined";
|
12
13
|
const g_rgCurrencyData = {
|
@@ -1078,7 +1079,7 @@ export async function downloadLargeImage(url, filePath) {
|
|
1078
1079
|
}
|
1079
1080
|
|
1080
1081
|
//from large text file
|
1081
|
-
export function readRandomLine(filePath) {
|
1082
|
+
export function readRandomLine(filePath, isValidLine) {
|
1082
1083
|
return new Promise((resolve, reject) => {
|
1083
1084
|
const rl = readline.createInterface({
|
1084
1085
|
input: fs.createReadStream(filePath),
|
@@ -1089,6 +1090,10 @@ export function readRandomLine(filePath) {
|
|
1089
1090
|
let lineNumber = 0;
|
1090
1091
|
|
1091
1092
|
rl.on("line", (line) => {
|
1093
|
+
if (typeof isValidLine === "function" && !isValidLine(line)) {
|
1094
|
+
return;
|
1095
|
+
}
|
1096
|
+
|
1092
1097
|
lineNumber += 1;
|
1093
1098
|
// Choose this line with probability 1 / lineNumber
|
1094
1099
|
if (Math.random() < 1 / lineNumber) {
|
@@ -1109,3 +1114,28 @@ export function readRandomLine(filePath) {
|
|
1109
1114
|
});
|
1110
1115
|
});
|
1111
1116
|
}
|
1117
|
+
|
1118
|
+
export async function getImageSize(url) {
|
1119
|
+
if (!url || typeof url !== "string") {
|
1120
|
+
return;
|
1121
|
+
}
|
1122
|
+
let response = null;
|
1123
|
+
try {
|
1124
|
+
response = await axios.head(url);
|
1125
|
+
} catch (e) {
|
1126
|
+
/* empty */
|
1127
|
+
}
|
1128
|
+
if (!response) {
|
1129
|
+
return;
|
1130
|
+
}
|
1131
|
+
const contentLength = response.headers?.["content-length"];
|
1132
|
+
if (contentLength) {
|
1133
|
+
const sizeInBytes = parseInt(contentLength, 10);
|
1134
|
+
const sizeInMB = sizeInBytes / (1024 * 1024); // Convert to MB
|
1135
|
+
return sizeInMB.toFixed(2); // Return size in MB with 2 decimal places
|
1136
|
+
}
|
1137
|
+
}
|
1138
|
+
|
1139
|
+
export function getGreetMessage() {
|
1140
|
+
return _.sample(["nha", "nhá", "nhé"]);
|
1141
|
+
}
|