@ix-xs/twitch.api 2.0.1 → 2.0.2
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/CHANGELOG.md +9 -0
- package/dist/index.cjs +4 -2
- package/dist/index.d.cts +4 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,15 @@
|
|
|
3
3
|
All notable changes to `@ix-xs/twitch.api` are documented here. This project
|
|
4
4
|
adheres to [Semantic Versioning](https://semver.org).
|
|
5
5
|
|
|
6
|
+
## 2.0.2
|
|
7
|
+
|
|
8
|
+
### Fixed
|
|
9
|
+
|
|
10
|
+
- `twitch.rateLimitOf()` returned `undefined` on a client with little traffic.
|
|
11
|
+
Twitch reports a reset time that is already reached when the bucket is
|
|
12
|
+
nearly full, and the client took that for a finished window. It now reports
|
|
13
|
+
the bucket as full once its reset time has passed.
|
|
14
|
+
|
|
6
15
|
## 2.0.1
|
|
7
16
|
|
|
8
17
|
### Changed
|
package/dist/index.cjs
CHANGED
|
@@ -3104,7 +3104,8 @@ var RateLimiter = class {
|
|
|
3104
3104
|
if (!state) return 0;
|
|
3105
3105
|
const now = Date.now();
|
|
3106
3106
|
if (now >= state.resetAt) {
|
|
3107
|
-
this.#buckets.delete(bucket);
|
|
3107
|
+
if (state.limit === 0) this.#buckets.delete(bucket);
|
|
3108
|
+
else state.remaining = state.limit;
|
|
3108
3109
|
return 0;
|
|
3109
3110
|
}
|
|
3110
3111
|
if (state.remaining > 0) {
|
|
@@ -3638,7 +3639,8 @@ var Twitch = class _Twitch {
|
|
|
3638
3639
|
}
|
|
3639
3640
|
rateLimitOf(userId) {
|
|
3640
3641
|
const state = this.#shared.limiter.get(userId ? `user:${userId}` : "app");
|
|
3641
|
-
|
|
3642
|
+
if (!state || state.limit === 0) return void 0;
|
|
3643
|
+
return state.resetAt > Date.now() ? { ...state } : { ...state, remaining: state.limit };
|
|
3642
3644
|
}
|
|
3643
3645
|
close() {
|
|
3644
3646
|
this.#shared.auth.close();
|
package/dist/index.d.cts
CHANGED
|
@@ -11218,6 +11218,10 @@ declare class Twitch {
|
|
|
11218
11218
|
/**
|
|
11219
11219
|
* What is known about a rate limit bucket: the app token's by default, a
|
|
11220
11220
|
* user's when you pass their ID. `undefined` until Twitch has reported it.
|
|
11221
|
+
*
|
|
11222
|
+
* `resetAt` is when the bucket is full again. Twitch refills it as time
|
|
11223
|
+
* passes, so with little traffic that moment is always close: once it has
|
|
11224
|
+
* passed, the bucket is reported full.
|
|
11221
11225
|
*/
|
|
11222
11226
|
rateLimitOf(userId?: string): {
|
|
11223
11227
|
limit: number;
|
package/dist/index.d.ts
CHANGED
|
@@ -11218,6 +11218,10 @@ declare class Twitch {
|
|
|
11218
11218
|
/**
|
|
11219
11219
|
* What is known about a rate limit bucket: the app token's by default, a
|
|
11220
11220
|
* user's when you pass their ID. `undefined` until Twitch has reported it.
|
|
11221
|
+
*
|
|
11222
|
+
* `resetAt` is when the bucket is full again. Twitch refills it as time
|
|
11223
|
+
* passes, so with little traffic that moment is always close: once it has
|
|
11224
|
+
* passed, the bucket is reported full.
|
|
11221
11225
|
*/
|
|
11222
11226
|
rateLimitOf(userId?: string): {
|
|
11223
11227
|
limit: number;
|
package/dist/index.js
CHANGED
|
@@ -3102,7 +3102,8 @@ var RateLimiter = class {
|
|
|
3102
3102
|
if (!state) return 0;
|
|
3103
3103
|
const now = Date.now();
|
|
3104
3104
|
if (now >= state.resetAt) {
|
|
3105
|
-
this.#buckets.delete(bucket);
|
|
3105
|
+
if (state.limit === 0) this.#buckets.delete(bucket);
|
|
3106
|
+
else state.remaining = state.limit;
|
|
3106
3107
|
return 0;
|
|
3107
3108
|
}
|
|
3108
3109
|
if (state.remaining > 0) {
|
|
@@ -3636,7 +3637,8 @@ var Twitch = class _Twitch {
|
|
|
3636
3637
|
}
|
|
3637
3638
|
rateLimitOf(userId) {
|
|
3638
3639
|
const state = this.#shared.limiter.get(userId ? `user:${userId}` : "app");
|
|
3639
|
-
|
|
3640
|
+
if (!state || state.limit === 0) return void 0;
|
|
3641
|
+
return state.resetAt > Date.now() ? { ...state } : { ...state, remaining: state.limit };
|
|
3640
3642
|
}
|
|
3641
3643
|
close() {
|
|
3642
3644
|
this.#shared.auth.close();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ix-xs/twitch.api",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.2",
|
|
4
4
|
"description": "The whole Twitch API, typed. A zero-dependency client for JavaScript and TypeScript: all 149 Helix endpoints and 83 EventSub events, with tokens, rate limits, pagination and reconnects handled for you.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"twitch",
|