@ricsam/isolate-encoding 0.1.4 → 0.1.6
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 +18 -5
- package/dist/cjs/package.json +1 -1
- package/dist/mjs/package.json +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,6 +1,14 @@
|
|
|
1
1
|
# @ricsam/isolate-encoding
|
|
2
2
|
|
|
3
|
-
Base64 encoding and decoding via `atob` and `btoa
|
|
3
|
+
Base64 encoding and decoding via `atob` and `btoa` for isolated-vm V8 sandbox.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm add @ricsam/isolate-encoding
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Usage
|
|
4
12
|
|
|
5
13
|
```typescript
|
|
6
14
|
import { setupEncoding } from "@ricsam/isolate-encoding";
|
|
@@ -8,11 +16,12 @@ import { setupEncoding } from "@ricsam/isolate-encoding";
|
|
|
8
16
|
const handle = await setupEncoding(context);
|
|
9
17
|
```
|
|
10
18
|
|
|
11
|
-
|
|
19
|
+
## Injected Globals
|
|
20
|
+
|
|
12
21
|
- `atob(encodedData)` - Decode a Base64-encoded string
|
|
13
22
|
- `btoa(stringToEncode)` - Encode a string to Base64
|
|
14
23
|
|
|
15
|
-
|
|
24
|
+
## Usage in Isolate
|
|
16
25
|
|
|
17
26
|
```javascript
|
|
18
27
|
// Encode string to Base64
|
|
@@ -31,7 +40,7 @@ const base64Data = btoa(JSON.stringify(data));
|
|
|
31
40
|
const originalData = JSON.parse(atob(base64Data));
|
|
32
41
|
```
|
|
33
42
|
|
|
34
|
-
|
|
43
|
+
## Error Handling
|
|
35
44
|
|
|
36
45
|
```javascript
|
|
37
46
|
// btoa throws for characters outside Latin1 range (0-255)
|
|
@@ -47,4 +56,8 @@ try {
|
|
|
47
56
|
} catch (e) {
|
|
48
57
|
console.error("Invalid Base64 string");
|
|
49
58
|
}
|
|
50
|
-
```
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
## License
|
|
62
|
+
|
|
63
|
+
MIT
|
package/dist/cjs/package.json
CHANGED
package/dist/mjs/package.json
CHANGED