@thangnv-dev/rate-limiter-node 0.0.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.
@@ -0,0 +1,3 @@
1
+ export { RATE_LIMITER_DEFAULT_TOKENS } from './rate-limiter.js';
2
+ export type { RateLimiter, RateLimiterTakeInput, RateLimiterTakeResult } from './rate-limiter.js';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,mBAAmB,CAAA;AAC/D,YAAY,EAAE,WAAW,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,mBAAmB,CAAA"}
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export { RATE_LIMITER_DEFAULT_TOKENS } from './rate-limiter.js';
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,2BAA2B,EAAE,MAAM,mBAAmB,CAAA"}
@@ -0,0 +1,20 @@
1
+ import 'temporal-polyfill/global';
2
+ export declare const RATE_LIMITER_DEFAULT_TOKENS = 1n;
3
+ export interface RateLimiterTakeInput {
4
+ readonly key: string;
5
+ readonly capacity: bigint;
6
+ readonly refillTokens?: bigint;
7
+ readonly refillInterval: Temporal.Duration;
8
+ readonly tokens?: bigint;
9
+ }
10
+ export interface RateLimiterTakeResult {
11
+ readonly allowed: boolean;
12
+ readonly limit: bigint;
13
+ readonly remaining: bigint;
14
+ readonly retryAfter: Temporal.Duration;
15
+ }
16
+ export interface RateLimiter {
17
+ take(input: RateLimiterTakeInput): Promise<RateLimiterTakeResult>;
18
+ reset(key: string): Promise<void>;
19
+ }
20
+ //# sourceMappingURL=rate-limiter.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rate-limiter.d.ts","sourceRoot":"","sources":["../src/rate-limiter.ts"],"names":[],"mappings":"AAAA,OAAO,0BAA0B,CAAA;AAEjC,eAAO,MAAM,2BAA2B,KAAK,CAAA;AAE7C,MAAM,WAAW,oBAAoB;IACnC,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAA;IACpB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;IACzB,QAAQ,CAAC,YAAY,CAAC,EAAE,MAAM,CAAA;IAC9B,QAAQ,CAAC,cAAc,EAAE,QAAQ,CAAC,QAAQ,CAAA;IAC1C,QAAQ,CAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CACzB;AAED,MAAM,WAAW,qBAAqB;IACpC,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAA;IACzB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;IACtB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAA;IAC1B,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,QAAQ,CAAA;CACvC;AAED,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,KAAK,EAAE,oBAAoB,GAAG,OAAO,CAAC,qBAAqB,CAAC,CAAA;IACjE,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAAA;CAClC"}
@@ -0,0 +1,3 @@
1
+ import 'temporal-polyfill/global';
2
+ export const RATE_LIMITER_DEFAULT_TOKENS = 1n;
3
+ //# sourceMappingURL=rate-limiter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rate-limiter.js","sourceRoot":"","sources":["../src/rate-limiter.ts"],"names":[],"mappings":"AAAA,OAAO,0BAA0B,CAAA;AAEjC,MAAM,CAAC,MAAM,2BAA2B,GAAG,EAAE,CAAA"}
package/package.json ADDED
@@ -0,0 +1,37 @@
1
+ {
2
+ "name": "@thangnv-dev/rate-limiter-node",
3
+ "version": "0.0.1",
4
+ "private": false,
5
+ "publishConfig": {
6
+ "access": "public"
7
+ },
8
+ "type": "module",
9
+ "main": "./dist/index.js",
10
+ "types": "./dist/index.d.ts",
11
+ "exports": {
12
+ ".": {
13
+ "types": "./dist/index.d.ts",
14
+ "default": "./dist/index.js"
15
+ }
16
+ },
17
+ "files": [
18
+ "dist"
19
+ ],
20
+ "scripts": {
21
+ "build": "tsc -p tsconfig.build.json",
22
+ "lint": "eslint .",
23
+ "typecheck": "tsc --noEmit",
24
+ "test": "vitest run"
25
+ },
26
+ "devDependencies": {
27
+ "@typescript-eslint/eslint-plugin": "^8.56.0",
28
+ "@typescript-eslint/parser": "^8.56.0",
29
+ "eslint": "^10.0.0",
30
+ "temporal-polyfill": "^0.3.0",
31
+ "typescript": "^5.9.3",
32
+ "vitest": "^4.0.18"
33
+ },
34
+ "peerDependencies": {
35
+ "temporal-polyfill": "*"
36
+ }
37
+ }