web-background 1.0.7 โ†’ 1.0.8

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.
Files changed (2) hide show
  1. package/README.md +8 -20
  2. package/package.json +4 -2
package/README.md CHANGED
@@ -1,28 +1,16 @@
1
- # ๐Ÿš€ Web Background
1
+ # Web Background
2
2
 
3
3
  **Simple Web Worker Library - Run complex tasks in the background!**
4
4
 
5
5
  Web Background is a simple yet powerful library that enables you to execute heavy computations in the background without blocking the main thread in web browsers.
6
6
 
7
- ## โœจ Features
7
+ ## Features
8
8
 
9
9
  - ๐ŸŽฏ **Simple API**: Execute workers instantly with a single function
10
- - ๐Ÿง  **Automatic Context Capture**: Automatically detects and transfers external variables
11
- - ๐Ÿš€ **High-Performance Caching**: Cache identical functions for faster re-execution
12
10
  - ๐Ÿงน **Automatic Memory Management**: Auto-cleanup workers and cache on GC
13
11
  - ๐Ÿ’ช **Full TypeScript Support**: Complete type safety
14
12
  - ๐Ÿ“ฆ **Zero Dependencies**: No external dependencies
15
13
 
16
- ## ๐Ÿ“ฆ Installation
17
-
18
- ```bash
19
- npm install web-background
20
- # or
21
- yarn add web-background
22
- # or
23
- pnpm add web-background
24
- ```
25
-
26
14
  ## ๐Ÿš€ Quick Start
27
15
 
28
16
  ### Basic Usage
@@ -44,7 +32,7 @@ console.log(result); // 15
44
32
  const multiplier = 10;
45
33
  const processWithContext = background(
46
34
  (numbers: number[]) => numbers.map((x) => x * multiplier),
47
- { multiplier } // Explicit passing when needed
35
+ { multiplier }, // Explicit passing when needed
48
36
  );
49
37
  ```
50
38
 
@@ -52,7 +40,7 @@ const processWithContext = background(
52
40
 
53
41
  ```typescript
54
42
  // Image data processing
55
- const processImage = background((imageData: ImageData) => {
43
+ const generateBluredData = background((imageData: ImageData) => {
56
44
  const { data, width, height } = imageData;
57
45
  const processed = new Uint8ClampedArray(data.length);
58
46
 
@@ -67,7 +55,7 @@ const processImage = background((imageData: ImageData) => {
67
55
  processed[i + 3] = data[i + 3]; // A
68
56
  }
69
57
 
70
- return new ImageData(processed, width, height);
58
+ return processed;
71
59
  });
72
60
 
73
61
  // Usage
@@ -75,11 +63,11 @@ const canvas = document.querySelector("canvas");
75
63
  const ctx = canvas.getContext("2d");
76
64
  const originalData = ctx.getImageData(0, 0, canvas.width, canvas.height);
77
65
 
78
- const blurredData = await processImage(originalData);
79
- ctx.putImageData(blurredData, 0, 0);
66
+ const blurredData = await generateBluredData(originalData);
67
+ ctx.putImageData(new ImageData(blurredData), 0, 0);
80
68
  ```
81
69
 
82
- ## ๐Ÿ› ๏ธ API Reference
70
+ ## API Reference
83
71
 
84
72
  ### `background<T>(fn: T, context?: Record<string, any>): FunctionInBackground<T>`
85
73
 
package/package.json CHANGED
@@ -7,7 +7,7 @@
7
7
  "Background",
8
8
  "Web Background"
9
9
  ],
10
- "version": "1.0.7",
10
+ "version": "1.0.8",
11
11
  "main": "dist/index.js",
12
12
  "module": "dist/index.js",
13
13
  "type": "module",
@@ -30,5 +30,7 @@
30
30
  "rollup-plugin-typescript2": "^0.36.0",
31
31
  "typescript": "5.2"
32
32
  },
33
- "files": ["dist"]
33
+ "files": [
34
+ "dist"
35
+ ]
34
36
  }