web-background 0.0.1 → 0.0.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 +1 -1
- package/dist/background.d.ts +1 -7
- package/dist/index.js +5 -3
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/background.d.ts
CHANGED
|
@@ -1,7 +1 @@
|
|
|
1
|
-
|
|
2
|
-
type ReturnFnWithPayload<Payload, ReturnValue> = (payload: Payload) => ReturnValue;
|
|
3
|
-
export declare function background<Payload = never, ReturnValue = void>(fn: (payload: Payload) => ReturnValue): {
|
|
4
|
-
(): Promise<ReturnValue>;
|
|
5
|
-
(payload: Payload): Promise<ReturnValue>;
|
|
6
|
-
} | (Payload extends never ? ReturnFn<Promise<ReturnValue>> : ReturnFnWithPayload<Payload, Promise<ReturnValue>>);
|
|
7
|
-
export {};
|
|
1
|
+
export declare function background<Payload = never, ReturnValue = void>(fn: (payload: Payload) => ReturnValue): any;
|
package/dist/index.js
CHANGED
|
@@ -83,15 +83,17 @@ class WorkerBuilder {
|
|
|
83
83
|
|
|
84
84
|
function background(fn) {
|
|
85
85
|
function createWorker() {
|
|
86
|
-
return WorkerBuilder.fromModule((UtilWorker), { module: fn
|
|
86
|
+
return WorkerBuilder.fromModule((UtilWorker), { module: fn });
|
|
87
87
|
}
|
|
88
88
|
if (typeof window === 'undefined') {
|
|
89
89
|
function runWithCreatingWorker(payload) {
|
|
90
|
-
|
|
90
|
+
const worker = createWorker();
|
|
91
|
+
return worker.request.call(worker, payload);
|
|
91
92
|
}
|
|
92
93
|
return runWithCreatingWorker;
|
|
93
94
|
}
|
|
94
|
-
|
|
95
|
+
const worker = createWorker();
|
|
96
|
+
return worker.request.bind(worker);
|
|
95
97
|
}
|
|
96
98
|
|
|
97
99
|
export { background };
|