steamutils 1.0.49 → 1.0.50
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 +25 -5
- package/index.js +1 -1
- package/package.json +1 -1
package/SteamClient.js
CHANGED
@@ -157,18 +157,34 @@ function SteamClient({
|
|
157
157
|
}
|
158
158
|
|
159
159
|
const intervals = {}
|
160
|
+
const intervalRandoms = {}
|
160
161
|
|
161
162
|
function doSetInterval(cb, timeout, key) {
|
163
|
+
const isRandom = Array.isArray(timeout)
|
162
164
|
if (!key) {
|
163
165
|
key = uuidv4()
|
164
166
|
}
|
165
|
-
if (
|
166
|
-
|
167
|
-
|
168
|
-
|
167
|
+
if (isRandom) {
|
168
|
+
if (intervalRandoms[key] !== undefined) {
|
169
|
+
try {
|
170
|
+
clearTimeout(intervalRandoms[key])
|
171
|
+
} catch (e) {
|
172
|
+
}
|
173
|
+
}
|
174
|
+
intervals[key] = setTimeout(function () {
|
175
|
+
doSetInterval(cb, timeout, key)
|
176
|
+
cb()
|
177
|
+
}, _.random(timeout[0], timeout[1]))
|
178
|
+
} else {
|
179
|
+
if (intervals[key] !== undefined) {
|
180
|
+
try {
|
181
|
+
clearInterval(intervals[key])
|
182
|
+
} catch (e) {
|
183
|
+
}
|
169
184
|
}
|
185
|
+
intervals[key] = setInterval(cb, timeout)
|
170
186
|
}
|
171
|
-
|
187
|
+
|
172
188
|
return key
|
173
189
|
}
|
174
190
|
|
@@ -177,6 +193,10 @@ function SteamClient({
|
|
177
193
|
clearInterval(intervals[key])
|
178
194
|
delete intervals[key]
|
179
195
|
}
|
196
|
+
for (const key in intervalRandoms) {
|
197
|
+
clearTimeout(intervalRandoms[key])
|
198
|
+
delete intervalRandoms[key]
|
199
|
+
}
|
180
200
|
}
|
181
201
|
|
182
202
|
function getAccountInfoName() {
|
package/index.js
CHANGED