@spoosh/plugin-throttle 0.1.1 → 0.1.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/README.md +6 -5
- package/dist/index.d.mts +7 -1
- package/dist/index.d.ts +7 -1
- package/package.json +4 -4
package/README.md
CHANGED
|
@@ -13,14 +13,15 @@ npm install @spoosh/plugin-throttle
|
|
|
13
13
|
## Usage
|
|
14
14
|
|
|
15
15
|
```typescript
|
|
16
|
+
import { Spoosh } from "@spoosh/core";
|
|
16
17
|
import { throttlePlugin } from "@spoosh/plugin-throttle";
|
|
17
18
|
|
|
18
|
-
const
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
19
|
+
const client = new Spoosh<ApiSchema, Error>("/api")
|
|
20
|
+
.use([
|
|
21
|
+
// ...otherPlugins,
|
|
22
|
+
throttlePlugin(),
|
|
23
|
+
]);
|
|
22
24
|
|
|
23
|
-
// Max 1 request per second - extras return cached data
|
|
24
25
|
const { data } = useRead((api) => api.expensive.$get(), { throttle: 1000 });
|
|
25
26
|
```
|
|
26
27
|
|
package/dist/index.d.mts
CHANGED
|
@@ -19,7 +19,13 @@ type ThrottleWriteResult = object;
|
|
|
19
19
|
*
|
|
20
20
|
* @example
|
|
21
21
|
* ```ts
|
|
22
|
-
*
|
|
22
|
+
* import { Spoosh } from "@spoosh/core";
|
|
23
|
+
*
|
|
24
|
+
* const client = new Spoosh<ApiSchema, Error>("/api")
|
|
25
|
+
* .use([
|
|
26
|
+
* // ... other plugins
|
|
27
|
+
* throttlePlugin(),
|
|
28
|
+
* ]);
|
|
23
29
|
*
|
|
24
30
|
* // Throttle to max once per second
|
|
25
31
|
* useRead((api) => api.posts.$get(), {
|
package/dist/index.d.ts
CHANGED
|
@@ -19,7 +19,13 @@ type ThrottleWriteResult = object;
|
|
|
19
19
|
*
|
|
20
20
|
* @example
|
|
21
21
|
* ```ts
|
|
22
|
-
*
|
|
22
|
+
* import { Spoosh } from "@spoosh/core";
|
|
23
|
+
*
|
|
24
|
+
* const client = new Spoosh<ApiSchema, Error>("/api")
|
|
25
|
+
* .use([
|
|
26
|
+
* // ... other plugins
|
|
27
|
+
* throttlePlugin(),
|
|
28
|
+
* ]);
|
|
23
29
|
*
|
|
24
30
|
* // Throttle to max once per second
|
|
25
31
|
* useRead((api) => api.posts.$get(), {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spoosh/plugin-throttle",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "Request throttling plugin for Spoosh - limits request frequency",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -33,11 +33,11 @@
|
|
|
33
33
|
}
|
|
34
34
|
},
|
|
35
35
|
"peerDependencies": {
|
|
36
|
-
"@spoosh/core": ">=0.
|
|
36
|
+
"@spoosh/core": ">=0.3.0"
|
|
37
37
|
},
|
|
38
38
|
"devDependencies": {
|
|
39
|
-
"@spoosh/core": "0.
|
|
40
|
-
"@spoosh/test-utils": "0.1.
|
|
39
|
+
"@spoosh/core": "0.3.0",
|
|
40
|
+
"@spoosh/test-utils": "0.1.3"
|
|
41
41
|
},
|
|
42
42
|
"scripts": {
|
|
43
43
|
"dev": "tsup --watch",
|