From 3178951a8a092e93b59cd4f544c464addd7607b9 Mon Sep 17 00:00:00 2001 From: Tedde Lundgren Date: Tue, 12 Oct 2021 10:27:08 +0700 Subject: [PATCH] Clarify typescript instantiation cases which closes #187 --- README.md | 72 +++++++++++--------- index.d.ts | 16 +++++ promise/index.d.ts | 16 +++++ typescript/test.ts | 166 +++++++++++++++++++++++++-------------------- 4 files changed, 164 insertions(+), 106 deletions(-) diff --git a/README.md b/README.md index a98a255..fbe81a1 100644 --- a/README.md +++ b/README.md @@ -82,7 +82,7 @@ Server example in [examples/simple_example/server.js](examples/simple_example/se const jayson = require('jayson'); // create a server -const server = new jayson.server({ +const server = new jayson.Server({ add: function(args, callback) { callback(null, args[0] + args[1]); } @@ -97,7 +97,7 @@ Client example in [examples/simple_example/client.js](examples/simple_example/cl const jayson = require('jayson'); // create a client -const client = new jayson.client.http({ +const client = jayson.Client.http({ port: 3000 }); @@ -173,6 +173,14 @@ Since `v2.1.0` there is typescript support available with jayson. If you encounter any problems with the type definitions, see the [Contributing](#contributing) section. +### Typescript instantiation recommendations + +Unfortunately we've been unable to express the flexibility with which jayson clients and servers can be instantiated in the Typescript definitions. Specifically, jayson allows all classes to be instantiated with or without the `new` keyword and this has been hard to get Typescript to understand. This has caused problems for some users. When using Typescript with jayson, we recommend the following: + +1. Do not use `new` when instantiating client sub-classes. Use `jayson.Client.http()` **not** `new jayson.Client.http()` +2. Use `new` when instantiating all other classes. Use `new jayson.Server()`, `new jayson.Client()`, `new jayson.Method()`, etc. +3. If you feel that you have a solution for the problem of allowing instantiation with or without the `new` keyword, feel free to attempt a pull request. + ## Usage ### Client @@ -227,7 +235,7 @@ It is possible to pass a string URL as the first argument. The URL will be run t ```javascript const jayson = require('jayson'); -const client = new jayson.client.http('http://localhost:3000'); +const client = jayson.Client.http('http://localhost:3000'); // client.options is now the result of url.parse ``` @@ -349,7 +357,7 @@ Client example in [examples/notifications/client.js](examples/notifications/clie ```javascript const jayson = require('jayson'); -const client = new jayson.client.http({ +const client = jayson.Client.http({ port: 3000 }); @@ -365,7 +373,7 @@ Server example in [examples/notifications/server.js](examples/notifications/serv ```javascript const jayson = require('jayson'); -const server = new jayson.server({ +const server = new jayson.Server({ ping: function(args, callback) { // do something, do nothing callback(); @@ -393,13 +401,13 @@ Combined server/client example in [examples/batch_request/index.js](examples/bat ```javascript const jayson = require('jayson'); -const server = new jayson.server({ +const server = new jayson.Server({ add: function(args, callback) { callback(null, args[0] + args[1]); } }); -const client = new jayson.client(server); +const client = new jayson.Client(server); const batch = [ client.request('does_not_exist', [10, 5]), @@ -523,7 +531,7 @@ const jsonParser = require('body-parser').json; const connect = require('connect'); const app = connect(); -const server = new jayson.server({ +const server = new jayson.Server({ add: function(args, callback) { callback(null, args[0] + args[1]); } @@ -569,7 +577,7 @@ Websocket client example in [examples/websocket/client.js](examples/websocket/cl ```javascript const jayson = require('jayson'); -const client = jayson.client.websocket({ +const client = jayson.Client.websocket({ url: 'ws://localhost:12345', }); @@ -590,7 +598,7 @@ Server example in [examples/many_interfaces/server.js](examples/many_interfaces/ ```javascript const jayson = require('jayson'); -const server = new jayson.server(); +const server = new jayson.Server(); // "http" will be an instance of require('http').Server const http = server.http(); @@ -620,8 +628,8 @@ Frontend server example in [examples/relay/server_public.js](examples/relay/serv const jayson = require('jayson'); // create a server where "add" will relay a localhost-only server -const server = new jayson.server({ - add: new jayson.client.http({ +const server = new jayson.Server({ + add: jayson.Client.http({ port: 3001 }) }); @@ -635,7 +643,7 @@ Backend server example in [examples/relay/server_private.js](examples/relay/serv ```javascript const jayson = require('jayson'); -const server = new jayson.server({ +const server = new jayson.Server({ add: function(args, callback) { callback(null, args[0] + args[1]); } @@ -662,7 +670,7 @@ const methods = { } }; -const server = new jayson.server(methods, { +const server = new jayson.Server(methods, { router: function(method, params) { // regular by-name routing first if(typeof(this._methods[method]) === 'function') return this._methods[method]; @@ -685,7 +693,7 @@ Client example in [examples/method_routing/client.js](examples/method_routing/cl const jayson = require('jayson'); // create a client -const client = new jayson.client.http({ +const client = jayson.Client.http({ port: 3000 }); @@ -717,7 +725,7 @@ const methods = { // this reduction produces an object like this: {'foo.bar': [Function], 'math.add': [Function]} const map = _.reduce(methods, collapse('', '.'), {}); -const server = new jayson.server(map); +const server = new jayson.Server(map); function collapse(stem, sep) { return function(map, value, key) { @@ -785,7 +793,7 @@ const methods = { }; -const server = new jayson.server(methods, { +const server = new jayson.Server(methods, { // these options are given as options to jayson.Method when adding the method "sum". // this is because it is not wrapped in jayson.Method like the others. useContext: false, @@ -807,7 +815,7 @@ Client example in [examples/method_definitions/client.js](examples/method_defini ```javascript const jayson = require('jayson'); -const client = new jayson.client.http({ +const client = jayson.Client.http({ port: 3000 }); @@ -859,7 +867,7 @@ If you should like to return an error from an method request to indicate a failu ```javascript const jayson = require('jayson'); -const server = new jayson.server({ +const server = new jayson.Server({ i_cant_find_anything: function(args, callback) { const error = {code: 404, message: 'Cannot find ' + args.id}; callback(error); // will return the error object as given @@ -879,7 +887,7 @@ It is also possible to cause a method to return one of the predefined [JSON-RPC ```javascript const jayson = require('jayson'); -const server = new jayson.server({ +const server = new jayson.Server({ invalid_params: function(args, callback) { const error = this.error(-32602); // returns an error with the default properties set callback(error); @@ -892,7 +900,7 @@ You can even override the default messages: ```javascript const jayson = require('jayson'); -const server = new jayson.server({ +const server = new jayson.Server({ error_giver_of_doom: function(callback) { callback(true) // invalid error format, which causes an Internal Error to be returned instead } @@ -914,7 +922,7 @@ const connect = require('connect'); const jsonParser = require('body-parser').json; const app = connect(); -const server = new jayson.server({ +const server = new jayson.Server({ myNameIs: function(args, callback) { callback(null, 'Your name is: ' + args.name); } @@ -944,7 +952,7 @@ const jsonParser = require('body-parser').json; const express = require('express'); const app = express(); -const server = new jayson.server({ +const server = new jayson.Server({ getHeaders: function(args, context, callback) { callback(null, context.headers); @@ -982,7 +990,7 @@ Client example in [examples/context/client.js](examples/context/client.js): const jayson = require('jayson'); // create a client -const client = new jayson.client.http({ +const client = jayson.Client.http({ port: 3001 }); @@ -1049,7 +1057,7 @@ const options = { }; // create a server -const server = new jayson.server({ +const server = new jayson.Server({ increment: function(args, callback) { args.counter.increment(); callback(null, args.counter); @@ -1065,7 +1073,7 @@ A client example in [examples/reviving_and_replacing/client.js](examples/revivin const jayson = require('jayson'); const shared = require('./shared'); -const client = new jayson.client.http({ +const client = jayson.Client.http({ port: 3000, reviver: shared.reviver, replacer: shared.replacer @@ -1101,7 +1109,7 @@ Client example in [examples/named_parameters/client.js](examples/named_parameter ```javascript const jayson = require('jayson'); -const client = new jayson.client.http({ +const client = jayson.Client.http({ port: 3000 }); @@ -1116,7 +1124,7 @@ Server example in [examples/named_parameters/server.js](examples/named_parameter ```javascript const jayson = require('jayson'); -const server = new jayson.server({ +const server = new jayson.Server({ add: function(params, callback) { callback(null, params.a + params.b); } @@ -1151,7 +1159,7 @@ Server example in [examples/promise/server.js](examples/promise/server.js) showi const jayson = require('jayson/promise'); const _ = require('lodash'); -const server = new jayson.server({ +const server = new jayson.Server({ add: async function(args) { const sum = _.reduce(args, function(sum, value) { return sum + value; }, 0); @@ -1174,7 +1182,7 @@ Client example in [examples/promise/client.js](examples/promise/client.js) showi ```javascript const jayson = require('jayson/promise'); -const client = new jayson.client.http({ +const client = jayson.Client.http({ port: 3000 }); @@ -1207,7 +1215,7 @@ Client example in [examples/promise_batches/client.js](examples/promise_batches/ ```javascript const jayson = require('jayson/promise'); -const client = new jayson.client.http({ +const client = jayson.Client.http({ port: 3000 }); @@ -1291,7 +1299,7 @@ const express = require('express'); const app = express(); // create a plain jayson server -const server = new jayson.server({ +const server = new jayson.Server({ add: function(numbers, callback) { callback(null, _.reduce(numbers, (sum, val) => sum + val, 0)); } diff --git a/index.d.ts b/index.d.ts index 897980a..0e7002e 100644 --- a/index.d.ts +++ b/index.d.ts @@ -54,6 +54,10 @@ export declare class Utils { } +// lowercase Utils +export declare class utils extends Utils { +} + type UtilsJSON = { parse(str:string, options:UtilsJSONParseOptions | null | undefined, callback: (err?:Error, obj?:object) => void):void; stringify(obj:object, options:UtilsJSONStringifyOptions | null | undefined, callback: (err?:Error, str?:string) => void):void; @@ -186,6 +190,10 @@ export declare class Method { execute(server: Server, requestParams: RequestParamsLike, context:object, callback: MethodExecuteCallbackType): any | Promise; } +// lowercase Method +export declare class method extends Method { +} + export type MethodLike = Function | Method | Client; export type ServerRouterFunction = (this: Server, method: string, params: RequestParamsLike) => MethodLike; @@ -235,6 +243,10 @@ export declare class Server extends events.EventEmitter { call(request: JSONRPCRequestLike | Array, context: object, originalCallback?: ServerCallCallbackType): void; } +// lowercase Server +export declare class server extends Server { +} + export interface MiddlewareServerOptions extends ServerOptions { end?: boolean; } @@ -340,3 +352,7 @@ export declare class Client extends events.EventEmitter { request(method: string, params: RequestParamsLike, callback?: JSONRPCCallbackType): JSONRPCRequest; request(method: Array, callback: JSONRPCCallbackTypeBatch): Array; } + +// lowercase Client +export declare class client extends Client { +} diff --git a/promise/index.d.ts b/promise/index.d.ts index e07e56e..9542b90 100644 --- a/promise/index.d.ts +++ b/promise/index.d.ts @@ -54,6 +54,10 @@ export declare class Utils { } +// lowercase Utils +export declare class utils extends Utils { +} + type UtilsJSON = { parse(str:string, options:UtilsJSONParseOptions | null | undefined, callback: (err?:Error, obj?:object) => void):void; stringify(obj:object, options:UtilsJSONStringifyOptions | null | undefined, callback: (err?:Error, str?:string) => void):void; @@ -187,6 +191,10 @@ export declare class Method { execute(server: Server, requestParams: RequestParamsLike, context:object, callback: MethodExecuteCallbackType): any | Promise; } +// lowercase Method +export declare class method extends Method { +} + export type MethodLike = Function | Method | Client; export type ServerRouterFunction = (this: Server, method: string, params: RequestParamsLike) => MethodLike; @@ -236,6 +244,10 @@ export declare class Server extends events.EventEmitter { call(request: JSONRPCRequestLike | Array, context: object, originalCallback?: ServerCallCallbackType): void; } +// lowercase Server +export declare class server extends Server { +} + export interface MiddlewareServerOptions extends ServerOptions { end?: boolean; } @@ -341,3 +353,7 @@ export declare class Client extends events.EventEmitter { request(method:string, params:RequestParamsLike, id?:JSONRPCIDLike): Promise; request(method: Array): Promise; } + +// lowercase Client +export declare class client extends Client { +} diff --git a/typescript/test.ts b/typescript/test.ts index 62f82d3..573b7cf 100644 --- a/typescript/test.ts +++ b/typescript/test.ts @@ -12,11 +12,11 @@ import WebSocket from 'isomorphic-ws'; */ export function test_example_1() { - var jsonParser = require('body-parser').json; - var connect = require('connect'); - var app = connect(); + const jsonParser = require('body-parser').json; + const connect = require('connect'); + const app = connect(); - var server = new jayson.Server({ + const server = new jayson.Server({ add: function(args:any, callback:any) { callback(null, args[0] + args[1]); } @@ -31,15 +31,15 @@ export function test_example_1() { export function test_example_2() { - var server = new jayson.Server({ + const server = new jayson.Server({ add: function(args:any, callback:any) { callback(null, args[0] + args[1]); } }); - var client = new jayson.Client(server); + const client = new jayson.Client(server); - var batch = [ + const batch = [ client.request('does_not_exist', [10, 5]), client.request('add', [1, 1]), client.request('add', [0, 0], null) // a notification @@ -59,7 +59,7 @@ export function test_example_2() { export function test_example_3() { - var client = jayson.Client.https({ + const client = jayson.Client.https({ port: 3000 }); @@ -71,7 +71,7 @@ export function test_example_3() { export function test_example_4() { - var server = new jayson.Server({ + const server = new jayson.Server({ multiply: function(args:any, callback:any) { callback(null, args[0] * args[1]); } @@ -83,16 +83,16 @@ export function test_example_4() { } export function test_example_5() { - var fs = require('fs'); - var path = require('path'); + const fs = require('fs'); + const path = require('path'); - var options = { + const options = { port: 3000, host: 'localhost' }; // create a client - var client = jayson.Client.tcp(options); + const client = jayson.Client.tcp(options); // invoke "add" client.request('add', [1, 1], function(err:any, response:any) { @@ -102,14 +102,14 @@ export function test_example_5() { } export function test_example_6() { - var fs = require('fs'); - var path = require('path'); + const fs = require('fs'); + const path = require('path'); - var options = { + const options = { }; // create a server - var server = new jayson.Server({ + const server = new jayson.Server({ add: function(args:any, callback:any) { callback(null, args[0] + args[1]); } @@ -121,7 +121,7 @@ export function test_example_6() { export function test_example_7() { - var client = jayson.Client.http({ + const client = jayson.Client.http({ port: 3000 }); @@ -133,7 +133,7 @@ export function test_example_7() { export function test_example_8() { - var server = new jayson.Server({ + const server = new jayson.Server({ multiply: function(args:any, callback:any) { callback(null, args[0] * args[1]); } @@ -146,11 +146,11 @@ export function test_example_8() { export function test_example_9() { - var client = jaysonPromise.Client.http({ + const client = jaysonPromise.Client.http({ port: 3000 }); - var batch = [ + const batch = [ client.request('add', [1, 2, 3, 4, 5], undefined, false), client.request('add', [5, 6, 7, 8, 9], undefined, false), ]; @@ -163,11 +163,11 @@ export function test_example_9() { export function test_example_10() { - var server = new jayson.Server({ + const server = new jayson.Server({ add: function(args:any) { return new Promise(function(resolve, reject) { - var sum = reduce(args, function(sum:number, value:number) { return sum + value; }, 0); + const sum = reduce(args, function(sum:number, value:number) { return sum + value; }, 0); resolve(sum); }); } @@ -179,13 +179,13 @@ export function test_example_10() { export function test_example_11() { - var server = new jayson.Server(); + const server = new jayson.Server(); // "http" will be an instance of require('http').Server - var http = server.http(); + const http = server.http(); // "https" will be an instance of require('https').Server - var https = server.https({ + const https = server.https({ //cert: require('fs').readFileSync('cert.pem'), //key require('fs').readFileSync('key.pem') }); @@ -201,7 +201,7 @@ export function test_example_11() { export function test_example_12() { - var client = jayson.Client.http({ + const client = jayson.Client.http({ port: 3000 }); @@ -213,7 +213,7 @@ export function test_example_12() { export function test_example_13() { - var server = new jayson.Server({ + const server = new jayson.Server({ add: function(a:any, b:any, callback:any) { callback(null, a + b); } @@ -226,7 +226,7 @@ export function test_example_13() { export function test_example_14() { // create a client - var client = jayson.Client.http({ + const client = jayson.Client.http({ port: 3000 }); @@ -240,7 +240,7 @@ export function test_example_14() { export function test_example_15() { // create a server - var server = new jayson.Server({ + const server = new jayson.Server({ add: function(args:any, callback:any) { callback(null, args[0] + args[1]); } @@ -251,7 +251,7 @@ export function test_example_15() { export function test_example_16() { - var client = jayson.Client.http({ + const client = jayson.Client.http({ port: 3000 }); @@ -286,7 +286,7 @@ export function test_example_16() { } export function test_example_17() { - var methods = { + const methods = { // this function will be wrapped in jayson.Method with options given to the server sum: function(args:any, done:any) { @@ -296,14 +296,14 @@ export function test_example_17() { // this method gets the raw params as first arg to handler sumCollect: new jayson.Method({ handler: function(args:any, done:any) { - var total = sum(args); + const total = sum(args); done(null, total); }, }), // specifies some default values (alternate definition too) sumDefault: new jayson.Method(function(args:any, done:any) { - var total = sum(args); + const total = sum(args); done(null, total); }, { params: {a: 2, b: 5} // map of defaults @@ -312,7 +312,7 @@ export function test_example_17() { // this method returns true when it gets an array (which it always does) isArray: new jayson.Method({ handler: function(args:any, done:any) { - var result = isArray(args); + const result = isArray(args); done(null, result); }, params: Array // could also be "Object" @@ -320,7 +320,7 @@ export function test_example_17() { }; - var server = new jayson.Server(methods, { + const server = new jayson.Server(methods, { // Given as options to jayson.Method when adding the method "sum" params: Array }); @@ -337,7 +337,7 @@ export function test_example_17() { export function test_example_18() { - var client = jayson.Client.http({ + const client = jayson.Client.http({ port: 3000 }); @@ -349,12 +349,12 @@ export function test_example_18() { export function test_example_19() { - var cors = require('cors'); - var connect = require('connect'); - var jsonParser = require('body-parser').json; - var app = connect(); + const cors = require('cors'); + const connect = require('connect'); + const jsonParser = require('body-parser').json; + const app = connect(); - var server = new jayson.Server({ + const server = new jayson.Server({ myNameIs: function(args:any, callback:any) { callback(null, 'Your name is: ' + args.name); } @@ -369,11 +369,11 @@ export function test_example_19() { export function test_example_20() { - var client = jaysonPromise.Client.http({ + const client = jaysonPromise.Client.http({ port: 3000 }); - var reqs = [ + const reqs = [ client.request('add', [1, 2, 3, 4, 5]), client.request('rejection', []) ]; @@ -386,11 +386,11 @@ export function test_example_20() { export function test_example_21() { - var server = new jayson.Server({ + const server = new jayson.Server({ add: function(args:any) { return new Promise(function(resolve, reject) { - var sum = reduce(args, function(sum:any, value:any) { return sum + value; }, 0); + const sum = reduce(args, function(sum:any, value:any) { return sum + value; }, 0); resolve(sum); }); }, @@ -410,7 +410,7 @@ export function test_example_21() { export function test_example_22() { - var server = new jayson.Server({ + const server = new jayson.Server({ add: function(args:any, callback:any) { callback(null, args[0] + args[1]); } @@ -422,7 +422,7 @@ export function test_example_22() { export function test_example_23() { - var client = jayson.Client.http({ + const client = jayson.Client.http({ port: 3000 // the port of the frontend server }); @@ -435,7 +435,7 @@ export function test_example_23() { export function test_example_24() { // create a server where "add" will relay a localhost-only server - var server = new jayson.Server({ + const server = new jayson.Server({ add: jayson.Client.http({ port: 3001 }) @@ -446,12 +446,12 @@ export function test_example_24() { } export function test_example_25() { - var fs = require('fs'); - var path = require('path'); + const fs = require('fs'); + const path = require('path'); // Read node's tls documentation for more information about these options: // https://nodejs.org/api/tls.html#tls_tls_connect_options_callback - var options = { + const options = { key: fs.readFileSync(path.resolve('./../../../test/fixtures/keys/agent1-key.pem')), cert: fs.readFileSync(path.resolve('./../../../test/fixtures/keys/agent1-cert.pem')), @@ -462,7 +462,7 @@ export function test_example_25() { }; // create a client - var client = jayson.Client.tls(options); + const client = jayson.Client.tls(options); // invoke "add" client.request('add', [1, 1], function(err:any, response:any) { @@ -472,12 +472,12 @@ export function test_example_25() { } export function test_example_26() { - var fs = require('fs'); - var path = require('path'); + const fs = require('fs'); + const path = require('path'); // Read node's tls documentation for more information about these options: // https://nodejs.org/api/tls.html#tls_tls_createserver_options_secureconnectionlistener - var options = { + const options = { key: fs.readFileSync(path.resolve('./../../../test/fixtures/keys/agent1-key.pem')), cert: fs.readFileSync(path.resolve('./../../../test/fixtures/keys/agent1-cert.pem')), requestCert: true, @@ -486,7 +486,7 @@ export function test_example_26() { }; // create a server - var server = new jayson.Server({ + const server = new jayson.Server({ add: function(args:any, callback:any) { callback(null, args[0] + args[1]); } @@ -513,7 +513,7 @@ export function test_example_26() { exports.reviver = function(key:any, value:any) { if(value && value.$class === 'counter') { - var obj = new Counter(value.$props.count); + const obj = new Counter(value.$props.count); return obj; } return value; @@ -521,23 +521,23 @@ export function test_example_26() { } export function test_example_27() { - var shared = require('./shared'); + const shared = require('./shared'); - var client = jayson.Client.http({ + const client = jayson.Client.http({ port: 3000, reviver: shared.reviver, replacer: shared.replacer }); // create the object - var params = { + const params = { counter: new shared.Counter(2) }; // invoke "increment" client.request('increment', params, function(err:any, response:any) { if(err) throw err; - var result = response.result; + const result = response.result; console.log( result instanceof shared.Counter, // true result.count, // 3 @@ -547,16 +547,16 @@ export function test_example_27() { } export function test_example_28() { - var shared = require('./shared'); + const shared = require('./shared'); // Set the reviver/replacer options - var options = { + const options = { reviver: shared.reviver, replacer: shared.replacer }; // create a server - var server = new jayson.Server({ + const server = new jayson.Server({ increment: function(args:any, callback:any) { args.counter.increment(); callback(null, args.counter); @@ -568,7 +568,7 @@ export function test_example_28() { export function test_example_29() { - var client = jayson.Client.http({ + const client = jayson.Client.http({ port: 3000 }); @@ -581,7 +581,7 @@ export function test_example_29() { export function test_example_30() { - var server = new jayson.Server({ + const server = new jayson.Server({ ping: function(args:any, callback:any) { // do something, do nothing callback(); @@ -594,7 +594,7 @@ export function test_example_30() { export function test_example_31() { // create a client - var client = jayson.Client.http({ + const client = jayson.Client.http({ port: 3000 }); @@ -606,18 +606,18 @@ export function test_example_31() { } export function test_example_32() { - var methods = { + const methods = { add: function(args:any, callback:any) { callback(null, args[0] + args[1]); } }; - var server = new jayson.Server(methods, { + const server = new jayson.Server(methods, { router: function(method:any, params:any) { // regular by-name routing first if(typeof(this._methods[method]) === 'function') return this._methods[method]; if(method === 'add_2') { - var fn = (server.getMethod('add') as jayson.Method).getHandler() as jayson.MethodHandler; + const fn = (server.getMethod('add') as jayson.Method).getHandler() as jayson.MethodHandler; return new jayson.Method(function(args:any, done:any) { args.unshift(2); fn.call(server, args, done); @@ -630,15 +630,15 @@ export function test_example_32() { } export function test_Middleware() { - var app = require('express') as Express; + const app = require('express') as Express; - var server = new jayson.Server({ + const server = new jayson.Server({ add: function (args:any, callback:any) { callback(null, args[0] + args[1]); } }); - var jsonParser = require('body-parser').json; + const jsonParser = require('body-parser').json; // parse request body before the jayson middleware app.use(jsonParser()); app.use(server.middleware()); @@ -833,3 +833,21 @@ export async function test_websocket_Promise () { const result = await websocketClient.request('add', [1,2,3]); } + +export async function test_differentCases () { + jayson.client.http({host: 'http://something', port: 80}); + // new jayson.client.http({host: 'http://something', port: 80}); // gives error + jaysonPromise.client.http({port: 3000}); + // jayson.server(); // gives error + const server = new jayson.server(); + new jayson.client(server); + new jayson.Client(server); + new jayson.Method(); + new jayson.method(); + // jayson.Method(); // gives error + // jayson.method(); // givers error + // jayson.client(server); // gives error + // jayson.Client(server); // gives error + jayson.Utils.response(null, null, 1, 2); + jayson.utils.response(null, null, 1, 2); +}