@livequery/rest 2.0.15 → 2.0.17
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.
|
@@ -4,8 +4,13 @@ export const Deduplicate = (ms = 1000) => next => {
|
|
|
4
4
|
return pipe(mergeMap(async (r) => {
|
|
5
5
|
const url = r.url.toString();
|
|
6
6
|
const cached = requests.get(url);
|
|
7
|
-
if (cached
|
|
8
|
-
|
|
7
|
+
if (cached) {
|
|
8
|
+
if (cached.time > Date.now() - ms) {
|
|
9
|
+
return cached.response.pipe(filter(Boolean), first());
|
|
10
|
+
}
|
|
11
|
+
else {
|
|
12
|
+
requests.delete(url);
|
|
13
|
+
}
|
|
9
14
|
}
|
|
10
15
|
requests.set(url, {
|
|
11
16
|
response: new BehaviorSubject(undefined),
|
|
@@ -13,7 +18,6 @@ export const Deduplicate = (ms = 1000) => next => {
|
|
|
13
18
|
});
|
|
14
19
|
return of(r).pipe(next(), tap(response => {
|
|
15
20
|
requests.get(url)?.response.next(response);
|
|
16
|
-
requests.delete(url);
|
|
17
21
|
}));
|
|
18
22
|
}), mergeMap($ => $));
|
|
19
23
|
};
|
package/package.json
CHANGED
package/build/AddHeadersHook.js
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { pipe, mergeMap } from "rxjs";
|
|
2
|
-
export const AddHeadersHook = (get_headers) => {
|
|
3
|
-
return next => pipe(mergeMap(async (r) => {
|
|
4
|
-
const headers = typeof get_headers == 'function' ? await get_headers() : get_headers;
|
|
5
|
-
return {
|
|
6
|
-
...r,
|
|
7
|
-
options: {
|
|
8
|
-
...r.options || {},
|
|
9
|
-
headers: {
|
|
10
|
-
...r.options?.headers || {},
|
|
11
|
-
...headers
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
};
|
|
15
|
-
}), next());
|
|
16
|
-
};
|
package/build/HeaderHook.d.ts
DELETED
package/build/HeaderHook.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { pipe, mergeMap } from "rxjs";
|
|
2
|
-
export const AddHeadersHook = (headers = {}) => {
|
|
3
|
-
return next => pipe(mergeMap(async (r) => {
|
|
4
|
-
const obj = r.options?.headers;
|
|
5
|
-
if (obj) {
|
|
6
|
-
for (const [k, v] of Object.entries(headers)) {
|
|
7
|
-
headers[k] = v;
|
|
8
|
-
}
|
|
9
|
-
}
|
|
10
|
-
return r;
|
|
11
|
-
}), next());
|
|
12
|
-
};
|
package/build/hooks/index.d.ts
DELETED
|
File without changes
|
package/build/hooks/index.js
DELETED
|
File without changes
|