-
-
Notifications
You must be signed in to change notification settings - Fork 72
/
test.ts
43 lines (31 loc) · 804 Bytes
/
test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// this is test file for TypeScript types
import sysend from '.';
sysend.on("foo", function(message: string) {
console.log(message.toUpperCase());
});
sysend.broadcast("foo", "hello");
type payload = {
message: string
};
sysend.on("bar", function(data: payload) {
console.log(data.message.toUpperCase());
});
const data: payload = { message: "something" };
sysend.broadcast("bar", data);
sysend.proxy("https://example.com");
sysend.serializer(function(data) {
return JSON.stringify(data);
}, function(string) {
return JSON.parse(string);
});
const rpc = sysend.rpc({
hello(str: string) {
return parseInt(str, 10);
}
});
rpc.then(service => {
service.hello("<ID>", "10").then(n => {
const x: number = n + 10;
console.log(x);
});
});