market-data-tradingview-ws 2.1.3 → 2.1.4
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/lib/client.js +8 -1
- package/lib/tradingView.js +0 -1
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -186,8 +186,14 @@ module.exports = class Client {
|
|
|
186
186
|
#intentionalClose = false;
|
|
187
187
|
#watchdogTimer = null;
|
|
188
188
|
#lastMessageAt = 0;
|
|
189
|
+
#chartInitialLimitMax = 1500;
|
|
189
190
|
|
|
190
191
|
constructor(config = {}) {
|
|
192
|
+
const initialLimitMax = Number(process.env.chart_initial_limit_max ?? 1500);
|
|
193
|
+
if (!Number.isSafeInteger(initialLimitMax) || initialLimitMax <= 0 || initialLimitMax > 40000) {
|
|
194
|
+
throw new RangeError('chart_initial_limit_max must be a positive safe integer no greater than 40000');
|
|
195
|
+
}
|
|
196
|
+
this.#chartInitialLimitMax = initialLimitMax;
|
|
191
197
|
const cfg = config && typeof config === 'object' ? config : {};
|
|
192
198
|
this.#configuredMaxChartSessions = utils.positive(cfg.max, this.#configuredMaxChartSessions);
|
|
193
199
|
this.#maxChartSessions = this.#configuredMaxChartSessions;
|
|
@@ -254,8 +260,9 @@ module.exports = class Client {
|
|
|
254
260
|
const identity = this.#validateChartIdentity({ symbol, period });
|
|
255
261
|
if (!identity.ok) return identity;
|
|
256
262
|
|
|
263
|
+
if (typeof limit !== 'number' && typeof limit !== 'string') return { ok: false, reason: 'invalid_limit' };
|
|
257
264
|
const normalizedLimit = Number(limit);
|
|
258
|
-
if (!Number.
|
|
265
|
+
if (!Number.isSafeInteger(normalizedLimit) || normalizedLimit <= 0 || normalizedLimit > this.#chartInitialLimitMax) return { ok: false, reason: 'invalid_limit' };
|
|
259
266
|
|
|
260
267
|
return { ...identity, limit: normalizedLimit };
|
|
261
268
|
}
|
package/lib/tradingView.js
CHANGED