Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

snowtransfer

Package Overview
Dependencies
Maintainers
2
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

snowtransfer - npm Package Compare versions

Comparing version 0.5.2 to 0.5.3

20

dist/Ratelimiter.js

@@ -39,14 +39,20 @@ "use strict";

set global(value) {
if (value && this.globalReset) {
if (value && this.globalReset !== 0) {
if (this.globalResetTimeout)
clearTimeout(this.globalResetTimeout);
// eslint-disable-next-line @typescript-eslint/no-this-alias
const instance = this;
this.globalResetTimeout = setTimeout(() => {
this.globalResetTimeout = null;
this.globalReset = 0;
this.global = false;
for (const bkt of Object.values(this.buckets)) {
bkt.checkQueue();
}
instance.global = false;
}, this.globalReset);
}
else {
if (this.globalResetTimeout)
clearTimeout(this.globalResetTimeout);
this.globalResetTimeout = null;
this.globalReset = 0;
for (const bkt of Object.values(this.buckets)) {
bkt.checkQueue();
}
}
this._global = value;

@@ -53,0 +59,0 @@ }

@@ -97,9 +97,13 @@ "use strict";

if (request.statusCode === 429) {
const b = JSON.parse(request.body.toString()); // Discord says it will be a JSON, so if there's an error, sucks
if (b.reset_after)
this.ratelimiter.globalReset = b.reset_after * 1000;
if (b.global)
this.ratelimiter.global = true;
if (!this.ratelimiter.global) {
const b = JSON.parse(request.body.toString()); // Discord says it will be a JSON, so if there's an error, sucks
if (b.reset_after !== undefined)
this.ratelimiter.globalReset = b.reset_after * 1000;
else
this.ratelimiter.globalReset = 1000; // Should realistically never happen, but you never know
if (b.global !== undefined)
this.ratelimiter.global = b.global;
}
this.emit("rateLimit", { timeout: bkt.reset, limit: bkt.limit, method: method, path: endpoint, route: this.ratelimiter.routify(endpoint, method) });
throw new DiscordAPIError(endpoint, b.message || "unknnown", method, request.statusCode);
throw new DiscordAPIError(endpoint, "You're being ratelimited", method, request.statusCode);
}

@@ -106,0 +110,0 @@ this.emit("done", reqID, request);

{
"name": "snowtransfer",
"version": "0.5.2",
"version": "0.5.3",
"description": "Minimalistic Rest client for the Discord Api",

@@ -5,0 +5,0 @@ "main": "./dist/index.js",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc