create-export 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/package.json
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
// Define your exports here - these will be available to clients
|
|
2
2
|
|
|
3
|
+
// Async function
|
|
3
4
|
export async function greet(name) {
|
|
4
5
|
return `Hello, ${name}!`;
|
|
5
6
|
}
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
// Sync function (will be async on client)
|
|
9
|
+
export function add(a, b) {
|
|
8
10
|
return a + b;
|
|
9
11
|
}
|
|
10
12
|
|
|
11
|
-
// AsyncIterator
|
|
13
|
+
// AsyncIterator for streaming
|
|
12
14
|
export async function* countUp(start, end) {
|
|
13
15
|
for (let i = start; i <= end; i++) {
|
|
14
16
|
await new Promise((r) => setTimeout(r, 100));
|
|
@@ -18,13 +20,37 @@ export async function* countUp(start, end) {
|
|
|
18
20
|
|
|
19
21
|
// Nested object with methods
|
|
20
22
|
export const math = {
|
|
21
|
-
|
|
23
|
+
multiply(a, b) {
|
|
22
24
|
return a * b;
|
|
23
25
|
},
|
|
24
|
-
|
|
26
|
+
factorial(n) {
|
|
25
27
|
if (n <= 1) return 1;
|
|
26
28
|
let result = 1;
|
|
27
29
|
for (let i = 2; i <= n; i++) result *= i;
|
|
28
30
|
return result;
|
|
29
31
|
},
|
|
30
32
|
};
|
|
33
|
+
|
|
34
|
+
// Class export (Comlink-style)
|
|
35
|
+
export class Counter {
|
|
36
|
+
constructor(initial = 0) {
|
|
37
|
+
this.count = initial;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
increment() {
|
|
41
|
+
return ++this.count;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
decrement() {
|
|
45
|
+
return --this.count;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
getCount() {
|
|
49
|
+
return this.count;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
async asyncIncrement() {
|
|
53
|
+
await new Promise((r) => setTimeout(r, 100));
|
|
54
|
+
return ++this.count;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
@@ -1,14 +1,16 @@
|
|
|
1
1
|
// Define your exports here - these will be available to clients
|
|
2
2
|
|
|
3
|
+
// Async function
|
|
3
4
|
export async function greet(name: string): Promise<string> {
|
|
4
5
|
return `Hello, ${name}!`;
|
|
5
6
|
}
|
|
6
7
|
|
|
7
|
-
|
|
8
|
+
// Sync function (will be async on client)
|
|
9
|
+
export function add(a: number, b: number): number {
|
|
8
10
|
return a + b;
|
|
9
11
|
}
|
|
10
12
|
|
|
11
|
-
// AsyncIterator
|
|
13
|
+
// AsyncIterator for streaming
|
|
12
14
|
export async function* countUp(start: number, end: number): AsyncGenerator<number> {
|
|
13
15
|
for (let i = start; i <= end; i++) {
|
|
14
16
|
await new Promise((r) => setTimeout(r, 100));
|
|
@@ -18,13 +20,39 @@ export async function* countUp(start: number, end: number): AsyncGenerator<numbe
|
|
|
18
20
|
|
|
19
21
|
// Nested object with methods
|
|
20
22
|
export const math = {
|
|
21
|
-
|
|
23
|
+
multiply(a: number, b: number): number {
|
|
22
24
|
return a * b;
|
|
23
25
|
},
|
|
24
|
-
|
|
26
|
+
factorial(n: number): number {
|
|
25
27
|
if (n <= 1) return 1;
|
|
26
28
|
let result = 1;
|
|
27
29
|
for (let i = 2; i <= n; i++) result *= i;
|
|
28
30
|
return result;
|
|
29
31
|
},
|
|
30
32
|
};
|
|
33
|
+
|
|
34
|
+
// Class export (Comlink-style)
|
|
35
|
+
export class Counter {
|
|
36
|
+
private count: number;
|
|
37
|
+
|
|
38
|
+
constructor(initial: number = 0) {
|
|
39
|
+
this.count = initial;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
increment(): number {
|
|
43
|
+
return ++this.count;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
decrement(): number {
|
|
47
|
+
return --this.count;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
getCount(): number {
|
|
51
|
+
return this.count;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
async asyncIncrement(): Promise<number> {
|
|
55
|
+
await new Promise((r) => setTimeout(r, 100));
|
|
56
|
+
return ++this.count;
|
|
57
|
+
}
|
|
58
|
+
}
|