@sapphire/ratelimits 2.4.5-next.fca7a80.0 β†’ 2.4.5

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 CHANGED
@@ -2,6 +2,39 @@
2
2
 
3
3
  All notable changes to this project will be documented in this file.
4
4
 
5
+ # [@sapphire/ratelimits@2.4.5](https://github.com/sapphiredev/utilities/compare/@sapphire/ratelimits@2.4.4...@sapphire/ratelimits@2.4.5) - (2022-09-18)
6
+
7
+ ## 🏠 Refactor
8
+
9
+ - Split `@sapphire/time-utilities` into 4 sub-packages (#462) ([574299a](https://github.com/sapphiredev/utilities/commit/574299a99e658f6500a2a7efa587a0919b2d1313))
10
+
11
+ ## πŸ› Bug Fixes
12
+
13
+ - **deps:** Update all non-major dependencies ([e20f299](https://github.com/sapphiredev/utilities/commit/e20f29906e83cee000aaba9c6827e3bec5173d28))
14
+ - **deps:** Update all non-major dependencies ([2308bd7](https://github.com/sapphiredev/utilities/commit/2308bd74356b6b2e0c12995b25f4d8ade4803fe9))
15
+ - **deps:** Update all non-major dependencies ([84af0db](https://github.com/sapphiredev/utilities/commit/84af0db2db749223b036aa99fe19a2e9af5681c6))
16
+ - **deps:** Update all non-major dependencies ([50cd8de](https://github.com/sapphiredev/utilities/commit/50cd8dea593b6f5ae75571209456b3421e2ca59a))
17
+
18
+ ## πŸ“ Documentation
19
+
20
+ - Change name of @kyranet (#451) ([df4fdef](https://github.com/sapphiredev/utilities/commit/df4fdefce18659975a4ebc224723638507d02d35))
21
+ - Update @RealShadowNova as a contributor ([a869ba0](https://github.com/sapphiredev/utilities/commit/a869ba0abfad041610b9115187d426aebe671af6))
22
+ - Add @muchnameless as a contributor ([a1221fe](https://github.com/sapphiredev/utilities/commit/a1221fea68506e99591d5d00ec552a07c26833f9))
23
+ - Add @enxg as a contributor ([d2382f0](https://github.com/sapphiredev/utilities/commit/d2382f04e3909cb4ad11798a0a10e683f6cf5383))
24
+ - Add @EvolutionX-10 as a contributor ([efc3a32](https://github.com/sapphiredev/utilities/commit/efc3a320a72ae258996dd62866d206c33f8d4961))
25
+ - Add @MajesticString as a contributor ([295b3e9](https://github.com/sapphiredev/utilities/commit/295b3e9849a4b0fe64074bae02f6426378a303c3))
26
+ - Add @Mzato0001 as a contributor ([c790ef2](https://github.com/sapphiredev/utilities/commit/c790ef25df2d7e22888fa9f8169167aa555e9e19))
27
+ - Add @NotKaskus as a contributor ([00da8f1](https://github.com/sapphiredev/utilities/commit/00da8f199137b9277119823f322d1f2d168d928a))
28
+ - Add @imranbarbhuiya as a contributor ([fb674c2](https://github.com/sapphiredev/utilities/commit/fb674c2c5594d41e71662263553dcb4bac9e37f4))
29
+ - Add @axisiscool as a contributor ([ce1aa31](https://github.com/sapphiredev/utilities/commit/ce1aa316871a88d3663efbdf2a42d3d8dfe6a27f))
30
+ - Add @dhruv-kaushikk as a contributor ([ebbf43f](https://github.com/sapphiredev/utilities/commit/ebbf43f63617daba96e72c50a234bf8b64f6ddc4))
31
+ - Add @Commandtechno as a contributor ([f1d69fa](https://github.com/sapphiredev/utilities/commit/f1d69fabe1ee0abe4be08b19e63dbec03102f7ce))
32
+ - Fix typedoc causing OOM crashes ([63ba41c](https://github.com/sapphiredev/utilities/commit/63ba41c4b6678554b1c7043a22d3296db4f59360))
33
+
34
+ ## πŸ§ͺ Testing
35
+
36
+ - Migrate to vitest (#380) ([075ec73](https://github.com/sapphiredev/utilities/commit/075ec73c7a8e3374fad3ada612d37eb4ac36ec8d))
37
+
5
38
  ## [2.4.4](https://github.com/sapphiredev/utilities/compare/@sapphire/ratelimits@2.4.3...@sapphire/ratelimits@2.4.4) (2022-04-01)
6
39
 
7
40
  **Note:** Version bump only for package @sapphire/ratelimits
package/README.md CHANGED
@@ -118,7 +118,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
118
118
  <table>
119
119
  <tr>
120
120
  <td align="center"><a href="https://favware.tech/"><img src="https://avatars3.githubusercontent.com/u/4019718?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Jeroen Claassens</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=favna" title="Code">πŸ’»</a> <a href="#infra-favna" title="Infrastructure (Hosting, Build-Tools, etc)">πŸš‡</a> <a href="#projectManagement-favna" title="Project Management">πŸ“†</a> <a href="https://github.com/sapphiredev/utilities/commits?author=favna" title="Documentation">πŸ“–</a> <a href="https://github.com/sapphiredev/utilities/commits?author=favna" title="Tests">⚠️</a></td>
121
- <td align="center"><a href="https://github.com/kyranet"><img src="https://avatars0.githubusercontent.com/u/24852502?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Antonio RomΓ‘n</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=kyranet" title="Code">πŸ’»</a> <a href="#projectManagement-kyranet" title="Project Management">πŸ“†</a> <a href="https://github.com/sapphiredev/utilities/pulls?q=is%3Apr+reviewed-by%3Akyranet" title="Reviewed Pull Requests">πŸ‘€</a> <a href="https://github.com/sapphiredev/utilities/commits?author=kyranet" title="Tests">⚠️</a></td>
121
+ <td align="center"><a href="https://github.com/kyranet"><img src="https://avatars0.githubusercontent.com/u/24852502?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Aura RomΓ‘n</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=kyranet" title="Code">πŸ’»</a> <a href="#projectManagement-kyranet" title="Project Management">πŸ“†</a> <a href="https://github.com/sapphiredev/utilities/pulls?q=is%3Apr+reviewed-by%3Akyranet" title="Reviewed Pull Requests">πŸ‘€</a> <a href="https://github.com/sapphiredev/utilities/commits?author=kyranet" title="Tests">⚠️</a></td>
122
122
  <td align="center"><a href="https://github.com/PyroTechniac"><img src="https://avatars2.githubusercontent.com/u/39341355?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Gryffon Bellish</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=PyroTechniac" title="Code">πŸ’»</a> <a href="https://github.com/sapphiredev/utilities/pulls?q=is%3Apr+reviewed-by%3APyroTechniac" title="Reviewed Pull Requests">πŸ‘€</a> <a href="https://github.com/sapphiredev/utilities/commits?author=PyroTechniac" title="Tests">⚠️</a></td>
123
123
  <td align="center"><a href="https://github.com/vladfrangu"><img src="https://avatars3.githubusercontent.com/u/17960496?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Vlad Frangu</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=vladfrangu" title="Code">πŸ’»</a> <a href="https://github.com/sapphiredev/utilities/issues?q=author%3Avladfrangu" title="Bug reports">πŸ›</a> <a href="https://github.com/sapphiredev/utilities/pulls?q=is%3Apr+reviewed-by%3Avladfrangu" title="Reviewed Pull Requests">πŸ‘€</a> <a href="#userTesting-vladfrangu" title="User Testing">πŸ““</a> <a href="https://github.com/sapphiredev/utilities/commits?author=vladfrangu" title="Tests">⚠️</a></td>
124
124
  <td align="center"><a href="https://github.com/Stitch07"><img src="https://avatars0.githubusercontent.com/u/29275227?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Stitch07</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=Stitch07" title="Code">πŸ’»</a> <a href="#projectManagement-Stitch07" title="Project Management">πŸ“†</a> <a href="https://github.com/sapphiredev/utilities/commits?author=Stitch07" title="Tests">⚠️</a></td>
@@ -128,7 +128,7 @@ Thanks goes to these wonderful people ([emoji key](https://allcontributors.org/d
128
128
  <tr>
129
129
  <td align="center"><a href="https://github.com/Nytelife26"><img src="https://avatars1.githubusercontent.com/u/22531310?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Tyler J Russell</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=Nytelife26" title="Documentation">πŸ“–</a></td>
130
130
  <td align="center"><a href="https://github.com/Alcremie"><img src="https://avatars0.githubusercontent.com/u/54785334?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ivan Lieder</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=Alcremie" title="Code">πŸ’»</a> <a href="https://github.com/sapphiredev/utilities/issues?q=author%3AAlcremie" title="Bug reports">πŸ›</a></td>
131
- <td align="center"><a href="https://github.com/RealShadowNova"><img src="https://avatars3.githubusercontent.com/u/46537907?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Hezekiah Hendry</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=RealShadowNova" title="Code">πŸ’»</a></td>
131
+ <td align="center"><a href="https://github.com/RealShadowNova"><img src="https://avatars3.githubusercontent.com/u/46537907?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Hezekiah Hendry</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=RealShadowNova" title="Code">πŸ’»</a> <a href="#tool-RealShadowNova" title="Tools">πŸ”§</a></td>
132
132
  <td align="center"><a href="https://github.com/Vetlix"><img src="https://avatars.githubusercontent.com/u/31412314?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Vetlix</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=Vetlix" title="Code">πŸ’»</a></td>
133
133
  <td align="center"><a href="https://github.com/ethamitc"><img src="https://avatars.githubusercontent.com/u/27776796?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Ethan Mitchell</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=ethamitc" title="Documentation">πŸ“–</a></td>
134
134
  <td align="center"><a href="https://github.com/noftaly"><img src="https://avatars.githubusercontent.com/u/34779161?v=4?s=100" width="100px;" alt=""/><br /><sub><b>Elliot</b></sub></a><br /><a href="https://github.com/sapphiredev/utilities/commits?author=noftaly" title="Code">πŸ’»</a></td>
package/dist/index.d.ts CHANGED
@@ -1,3 +1,92 @@
1
- export * from './lib/RateLimit';
2
- export * from './lib/RateLimitManager';
3
- //# sourceMappingURL=index.d.ts.map
1
+ declare class RateLimitManager<K = string> extends Map<K, RateLimit<K>> {
2
+ /**
3
+ * The amount of milliseconds for the {@link RateLimit ratelimits} from this manager to expire.
4
+ */
5
+ readonly time: number;
6
+ /**
7
+ * The amount of times a {@link RateLimit} can drip before it's limited.
8
+ */
9
+ readonly limit: number;
10
+ /**
11
+ * The interval to sweep expired {@link RateLimit ratelimits}.
12
+ */
13
+ private sweepInterval;
14
+ /**
15
+ * @param time The amount of milliseconds for the ratelimits from this manager to expire.
16
+ * @param limit The amount of times a {@link RateLimit} can drip before it's limited.
17
+ */
18
+ constructor(time: number, limit?: number);
19
+ /**
20
+ * Gets a {@link RateLimit} from this manager or creates it if it does not exist.
21
+ * @param id The id for the {@link RateLimit}
22
+ */
23
+ acquire(id: K): RateLimit<K>;
24
+ /**
25
+ * Creates a {@link RateLimit} for this manager.
26
+ * @param id The id the {@link RateLimit} belongs to
27
+ */
28
+ create(id: K): RateLimit<K>;
29
+ /**
30
+ * Wraps Collection's set method to set interval to sweep inactive {@link RateLimit}s.
31
+ * @param id The id the {@link RateLimit} belongs to
32
+ * @param value The {@link RateLimit} to set
33
+ */
34
+ set(id: K, value: RateLimit<K>): this;
35
+ /**
36
+ * Wraps Collection's sweep method to clear the interval when this manager is empty.
37
+ */
38
+ sweep(): void;
39
+ /**
40
+ * The delay in milliseconds for {@link RateLimitManager.sweepInterval}.
41
+ */
42
+ static sweepIntervalDuration: number;
43
+ }
44
+
45
+ declare class RateLimit<K = string> {
46
+ /**
47
+ * The remaining amount of times this entry can be dripped before the bucket is empty.
48
+ */
49
+ remaining: number;
50
+ /**
51
+ * The timestamp that represents when this entry will reset back to a available state.
52
+ */
53
+ expires: number;
54
+ /**
55
+ * The {@link RateLimitManager} this entry is for.
56
+ */
57
+ private manager;
58
+ /**
59
+ * @param manager The manager for this entry.
60
+ */
61
+ constructor(manager: RateLimitManager<K>);
62
+ /**
63
+ * Whether this entry is expired or not, allowing the bucket to be reset.
64
+ */
65
+ get expired(): boolean;
66
+ /**
67
+ * Whether this entry is limited or not.
68
+ */
69
+ get limited(): boolean;
70
+ /**
71
+ * The remaining time in milliseconds before resetting.
72
+ */
73
+ get remainingTime(): number;
74
+ /**
75
+ * Consumes {@link RateLimit.remaining} by one if it's not limited, calling {@link RateLimit.reset} first if {@link RateLimit.expired} is true.
76
+ */
77
+ consume(): this;
78
+ /**
79
+ * Resets the entry back to it's full state.
80
+ */
81
+ reset(): this;
82
+ /**
83
+ * Resets the entry's {@link RateLimit.remaining} uses back to full state.
84
+ */
85
+ resetRemaining(): this;
86
+ /**
87
+ * Resets the entry's {@link RateLimit.expires} to the current time plus {@link RateLimitManager.time}.
88
+ */
89
+ resetTime(): this;
90
+ }
91
+
92
+ export { RateLimit, RateLimitManager };