create-export 0.0.2 → 0.0.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-export",
3
- "version": "0.0.2",
3
+ "version": "0.0.4",
4
4
  "description": "Cloudflare Workers ESM Export Framework",
5
5
  "keywords": [
6
6
  "cloudflare",
@@ -31,6 +31,21 @@ export const math = {
31
31
  },
32
32
  };
33
33
 
34
+ // ReadableStream for streaming large data
35
+ export function streamData(count) {
36
+ let i = 0;
37
+ return new ReadableStream({
38
+ async pull(controller) {
39
+ if (i >= count) {
40
+ controller.close();
41
+ return;
42
+ }
43
+ await new Promise((r) => setTimeout(r, 50));
44
+ controller.enqueue(new TextEncoder().encode(`chunk-${i++}\n`));
45
+ },
46
+ });
47
+ }
48
+
34
49
  // Class export (Comlink-style)
35
50
  export class Counter {
36
51
  constructor(initial = 0) {
@@ -31,6 +31,21 @@ export const math = {
31
31
  },
32
32
  };
33
33
 
34
+ // ReadableStream for streaming large data
35
+ export function streamData(count: number): ReadableStream<Uint8Array> {
36
+ let i = 0;
37
+ return new ReadableStream({
38
+ async pull(controller) {
39
+ if (i >= count) {
40
+ controller.close();
41
+ return;
42
+ }
43
+ await new Promise((r) => setTimeout(r, 50));
44
+ controller.enqueue(new TextEncoder().encode(`chunk-${i++}\n`));
45
+ },
46
+ });
47
+ }
48
+
34
49
  // Class export (Comlink-style)
35
50
  export class Counter {
36
51
  private count: number;