Browse Source

bump

master
peter 5 years ago
parent
commit
ac9e6d3732
5 changed files with 10 additions and 10 deletions
  1. 1
    1
      package.json
  2. 1
    1
      src/Backend.ts
  3. 4
    4
      src/Types.ts
  4. 1
    1
      src/Utils.ts
  5. 3
    3
      test/TestBackend.ts

+ 1
- 1
package.json View File

1
 {
1
 {
2
   "name": "rpclibrary",
2
   "name": "rpclibrary",
3
-  "version": "1.0.4",
3
+  "version": "1.1.0",
4
   "description": "",
4
   "description": "",
5
   "main": "./js/Index.js",
5
   "main": "./js/Index.js",
6
   "scripts": {
6
   "scripts": {

+ 1
- 1
src/Backend.ts View File

46
         if(badRPC = exporters.flatMap(ex => ex.exportRPCs()).find(rpc => !rpc.name))
46
         if(badRPC = exporters.flatMap(ex => ex.exportRPCs()).find(rpc => !rpc.name))
47
         throw new Error(`
47
         throw new Error(`
48
             RPC did not provide a name. 
48
             RPC did not provide a name. 
49
-            \nUse funtion name(..){ .. } syntax instead.
49
+            \nUse 'funtion name(..){ .. }' syntax instead.
50
             \n
50
             \n
51
             \n<------------OFFENDING RPC:
51
             \n<------------OFFENDING RPC:
52
             \n`+badRPC.toString()+`
52
             \n`+badRPC.toString()+`

+ 4
- 4
src/Types.ts View File

48
 
48
 
49
 export type HookInfo<T = {}> = BaseInfo & { 
49
 export type HookInfo<T = {}> = BaseInfo & { 
50
     type: 'Hook', 
50
     type: 'Hook', 
51
-    generator: (socket) => HookFunction<T>
51
+    generator: (socket?:I.Socket) => HookFunction<T>
52
 }
52
 }
53
 
53
 
54
 export type CallInfo = BaseInfo & {
54
 export type CallInfo = BaseInfo & {
61
 
61
 
62
 export type OnFunction = (type: 'error' | 'close', f: (e?:any)=>void) => I.Socket
62
 export type OnFunction = (type: 'error' | 'close', f: (e?:any)=>void) => I.Socket
63
 export type HookCloseFunction<T = {}> = (res:SubscriptionResponse<T>, rpc:HookRPC<T>) => any
63
 export type HookCloseFunction<T = {}> = (res:SubscriptionResponse<T>, rpc:HookRPC<T>) => any
64
-export type HookFunction<T = {}> = (...args:[any, ...any[]]) => Promise<SubscriptionResponse<T> | ErrorResponse>
65
-export type AsyncFunction = (...args:any[]) => Promise<any>
66
-export type CallbackFunction = (...args:any[]) => void
64
+export type HookFunction<T = {}> = (...args:any) => Promise<SubscriptionResponse<T> | ErrorResponse>
65
+export type AsyncFunction = (...args:any) => Promise<any>
66
+export type CallbackFunction = (...args:any) => void

+ 1
- 1
src/Utils.ts View File

28
         case "function":
28
         case "function":
29
             if(!rpc.name) throw new Error(`
29
             if(!rpc.name) throw new Error(`
30
 RPC did not provide a name. 
30
 RPC did not provide a name. 
31
-\nUse funtion name(..){ .. } syntax instead.
31
+\nUse 'funtion name(..){ .. }' syntax instead.
32
 \n
32
 \n
33
 \n<------------OFFENDING RPC:
33
 \n<------------OFFENDING RPC:
34
 \n`+rpc.toString()+`
34
 \n`+rpc.toString()+`

+ 3
- 3
test/TestBackend.ts View File

24
                 subcallback = callback
24
                 subcallback = callback
25
                 return makeSubResponse()
25
                 return makeSubResponse()
26
             },
26
             },
27
-            onClose: (res:SubscriptionResponse, rpc:HookRPC) => { 
27
+            onClose: (res, rpc) => { 
28
                 console.log("Specific close handler for", rpc.name, res)
28
                 console.log("Specific close handler for", rpc.name, res)
29
                 subcallback = null 
29
                 subcallback = null 
30
             },
30
             },
31
-            onCallback: (...args:any) => { console.log.apply(console, args) }
31
+            onCallback: (...args) => { console.log.apply(console, args) }
32
         },
32
         },
33
         function add(...args:number[]):number {return args.reduce((a,b)=>a+b, 0)},
33
         function add(...args:number[]):number {return args.reduce((a,b)=>a+b, 0)},
34
         function triggerCallback(...messages:any[]):number {return subcallback.apply({}, messages)},
34
         function triggerCallback(...messages:any[]):number {return subcallback.apply({}, messages)},
35
     ]
35
     ]
36
 }])
36
 }])
37
 
37
 
38
-new RPCServer<{ topic: string}>(20001, [{
38
+new RPCServer<{ topic: string }>(20001, [{
39
     name: "HelloWorldRPCGroup",
39
     name: "HelloWorldRPCGroup",
40
     exportRPCs: () => [
40
     exportRPCs: () => [
41
         {
41
         {

Loading…
Cancel
Save