js-rpc2 1.1.0 → 1.1.1

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": "js-rpc2",
3
- "version": "1.1.0",
3
+ "version": "1.1.1",
4
4
  "description": "js web websocket http rpc",
5
5
  "main": "index.js",
6
6
  "type": "module",
package/src/lib.js CHANGED
@@ -589,7 +589,8 @@ export async function rpcRunServerDecodeBuffer(extension, writer, buffer, logger
589
589
  }
590
590
  if (logger) {
591
591
  logger(`time: ${Date.now() - time}ms ${fnName}(${params.map(o => {
592
- if (typeof o == 'function') { return Function }
592
+ if (typeof o == 'function') { return `Function()` }
593
+ if (o instanceof Uint8Array) { return `Uint8Array(${o.length})` }
593
594
  return o
594
595
  }).join(', ')})`)
595
596
  }
package/src/lib.test.js CHANGED
@@ -133,13 +133,13 @@ test('测试RPC调用-WebSocket', async () => {
133
133
  console.info(string)
134
134
  strictEqual(string, 'hello asdfghjkl')
135
135
 
136
- let stringcallback = await client.callback('asdfghjkl', (progress) => {
136
+ let stringcallback = await client.callback('asdfghjkl', async (progress) => {
137
137
  console.info(`client : ${progress}`)
138
138
  })
139
139
  strictEqual(stringcallback, 'hello callback asdfghjkl')
140
140
 
141
141
  let callbackCount = 0
142
- let stringcallback2 = await client.callback2('asdfghjkl', (progress, buffer) => {
142
+ let stringcallback2 = await client.callback2('asdfghjkl', async (progress, buffer) => {
143
143
  console.info(`client : ${progress}`, buffer)
144
144
  callbackCount++
145
145
  })
@@ -211,6 +211,9 @@ test('测试RPC调用-KoaRouter', async () => {
211
211
  router: router,
212
212
  rpcKey: '11474f3dfbb861700cb6c3864b328311',
213
213
  extension: extension,
214
+ logger(msg) {
215
+ console.info(msg)
216
+ },
214
217
  })
215
218
 
216
219
  server.addListener('request', app.callback())
@@ -233,7 +236,7 @@ test('测试RPC调用-KoaRouter', async () => {
233
236
  strictEqual(string, 'hello asdfghjkl')
234
237
 
235
238
  let callbackCount = 0
236
- let stringcallback = await client.callback('asdfghjkl', (progress) => {
239
+ let stringcallback = await client.callback('asdfghjkl', async (progress) => {
237
240
  console.info(`client : ${progress}`)
238
241
  callbackCount++
239
242
  })
@@ -241,7 +244,7 @@ test('测试RPC调用-KoaRouter', async () => {
241
244
  strictEqual(3, callbackCount)
242
245
  strictEqual(stringcallback, 'hello callback asdfghjkl')
243
246
 
244
- let stringcallback2 = await client.callback2('asdfghjkl', (progress, buffer) => {
247
+ let stringcallback2 = await client.callback2('asdfghjkl', async (progress, buffer) => {
245
248
  console.info(`client : ${progress}`, buffer)
246
249
  })
247
250
  strictEqual(stringcallback2, 'hello callback asdfghjkl')