@upstash/ratelimit 2.2.0 → 2.2.1

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/dist/index.mjs CHANGED
@@ -796,6 +796,8 @@ var Ratelimit = class {
796
796
  * }
797
797
  * return "Yes"
798
798
  * ```
799
+ *
800
+ * @see node_modules/@upstash/ratelimit/docs/methods.mdx
799
801
  */
800
802
  limit = async (identifier, req) => {
801
803
  let timeoutId = null;
@@ -833,6 +835,8 @@ var Ratelimit = class {
833
835
  * }
834
836
  * return "Yes"
835
837
  * ```
838
+ *
839
+ * @see node_modules/@upstash/ratelimit/docs/methods.mdx
836
840
  */
837
841
  blockUntilReady = async (identifier, timeout) => {
838
842
  if (timeout <= 0) {
@@ -856,6 +860,9 @@ var Ratelimit = class {
856
860
  }
857
861
  return res;
858
862
  };
863
+ /**
864
+ * @see node_modules/@upstash/ratelimit/docs/methods.mdx
865
+ */
859
866
  resetUsedTokens = async (identifier) => {
860
867
  const pattern = [this.prefix, identifier].join(":");
861
868
  await this.limiter().resetTokens(this.ctx, pattern);
@@ -867,6 +874,8 @@ var Ratelimit = class {
867
874
  * @returns object with `remaining`, `reset`, and `limit` fields. `remaining` denotes
868
875
  * the remaining tokens, `limit` is the effective limit (considering dynamic
869
876
  * limits if enabled), and `reset` denotes the timestamp when the tokens reset.
877
+ *
878
+ * @see node_modules/@upstash/ratelimit/docs/methods.mdx
870
879
  */
871
880
  getRemaining = async (identifier) => {
872
881
  const pattern = [this.prefix, identifier].join(":");
@@ -1004,6 +1013,7 @@ var Ratelimit = class {
1004
1013
  * ```
1005
1014
  *
1006
1015
  * @param options.limit - The new rate limit to apply globally, or false to disable
1016
+ * @see node_modules/@upstash/ratelimit/docs/methods.mdx
1007
1017
  */
1008
1018
  setDynamicLimit = async (options) => {
1009
1019
  if (!this.dynamicLimits) {
@@ -1024,6 +1034,7 @@ var Ratelimit = class {
1024
1034
  * ```
1025
1035
  *
1026
1036
  * @returns Object containing the current global dynamic limit, or null if not set
1037
+ * @see node_modules/@upstash/ratelimit/docs/methods.mdx
1027
1038
  */
1028
1039
  getDynamicLimit = async () => {
1029
1040
  if (!this.dynamicLimits) {
@@ -1038,7 +1049,7 @@ var Ratelimit = class {
1038
1049
  };
1039
1050
 
1040
1051
  // src/version.ts
1041
- var VERSION = "2.2.0";
1052
+ var VERSION = "2.2.1";
1042
1053
 
1043
1054
  // src/telemetry.ts
1044
1055
  var taggedClients = /* @__PURE__ */ new WeakSet();
@@ -1071,6 +1082,8 @@ function randomId() {
1071
1082
  var MultiRegionRatelimit = class extends Ratelimit {
1072
1083
  /**
1073
1084
  * Create a new Ratelimit instance by providing a `@upstash/redis` instance and the algorithn of your choice.
1085
+ *
1086
+ * @see node_modules/@upstash/ratelimit/docs/features.mdx
1074
1087
  */
1075
1088
  constructor(config) {
1076
1089
  super({
@@ -1113,6 +1126,7 @@ var MultiRegionRatelimit = class extends Ratelimit {
1113
1126
  *
1114
1127
  * @param tokens - How many requests a user can make in each time window.
1115
1128
  * @param window - A fixed timeframe
1129
+ * @see node_modules/@upstash/ratelimit/docs/algorithms.mdx
1116
1130
  */
1117
1131
  static fixedWindow(tokens, window) {
1118
1132
  const windowDuration = ms(window);
@@ -1276,6 +1290,7 @@ var MultiRegionRatelimit = class extends Ratelimit {
1276
1290
  *
1277
1291
  * @param tokens - How many requests a user can make in each time window.
1278
1292
  * @param window - The duration in which the user can max X requests.
1293
+ * @see node_modules/@upstash/ratelimit/docs/algorithms.mdx
1279
1294
  */
1280
1295
  static slidingWindow(tokens, window) {
1281
1296
  const windowSize = ms(window);
@@ -1444,6 +1459,8 @@ var MultiRegionRatelimit = class extends Ratelimit {
1444
1459
  var RegionRatelimit = class extends Ratelimit {
1445
1460
  /**
1446
1461
  * Create a new Ratelimit instance by providing a `@upstash/redis` instance and the algorithm of your choice.
1462
+ *
1463
+ * @see node_modules/@upstash/ratelimit/docs/gettingstarted.mdx
1447
1464
  */
1448
1465
  constructor(config) {
1449
1466
  super({
@@ -1479,6 +1496,7 @@ var RegionRatelimit = class extends Ratelimit {
1479
1496
  *
1480
1497
  * @param tokens - How many requests a user can make in each time window.
1481
1498
  * @param window - A fixed timeframe
1499
+ * @see node_modules/@upstash/ratelimit/docs/algorithms.mdx
1482
1500
  */
1483
1501
  static fixedWindow(tokens, window) {
1484
1502
  const windowDuration = ms(window);
@@ -1570,6 +1588,7 @@ var RegionRatelimit = class extends Ratelimit {
1570
1588
  *
1571
1589
  * @param tokens - How many requests a user can make in each time window.
1572
1590
  * @param window - The duration in which the user can max X requests.
1591
+ * @see node_modules/@upstash/ratelimit/docs/algorithms.mdx
1573
1592
  */
1574
1593
  static slidingWindow(tokens, window) {
1575
1594
  const windowSize = ms(window);
@@ -1663,6 +1682,8 @@ var RegionRatelimit = class extends Ratelimit {
1663
1682
  * rate.
1664
1683
  * - Allows to set a higher initial burst limit by setting `maxTokens` higher
1665
1684
  * than `refillRate`
1685
+ *
1686
+ * @see node_modules/@upstash/ratelimit/docs/algorithms.mdx
1666
1687
  */
1667
1688
  static tokenBucket(refillRate, interval, maxTokens) {
1668
1689
  const intervalDuration = ms(interval);
@@ -1759,6 +1780,7 @@ var RegionRatelimit = class extends Ratelimit {
1759
1780
  *
1760
1781
  * @param tokens - How many requests a user can make in each time window.
1761
1782
  * @param window - A fixed timeframe
1783
+ * @see node_modules/@upstash/ratelimit/docs/algorithms.mdx
1762
1784
  */
1763
1785
  static cachedFixedWindow(tokens, window) {
1764
1786
  const windowDuration = ms(window);