@jcbuisson/express-x-client 1.0.9 → 1.0.10

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.mjs +4 -3
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jcbuisson/express-x-client",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "main": "src/index.mjs",
package/src/index.mjs CHANGED
@@ -1,7 +1,8 @@
1
1
 
2
2
  import { v4 } from 'uuid'
3
3
 
4
- function expressxClient(socket) {
4
+ function expressxClient(socket, options={}) {
5
+ if (options.debug === undefined) options.debug = false
5
6
 
6
7
  const waitingPromisesByUid = {}
7
8
  const action2service2handlers = {}
@@ -18,13 +19,13 @@ function expressxClient(socket) {
18
19
 
19
20
  // on connection
20
21
  socket.on("connected", async (connectionId) => {
21
- console.log('connected', connectionId)
22
+ if (options.debug) console.log('connected', connectionId)
22
23
  if (onConnectionCallback) onConnectionCallback(connectionId)
23
24
  })
24
25
 
25
26
  // on receiving response from service request
26
27
  socket.on('client-response', ({ uid, error, result }) => {
27
- console.log('client-response', uid, error, result)
28
+ if (options.debug) console.log('client-response', uid, error, result)
28
29
  if (!waitingPromisesByUid[uid]) return // may not exist because a timeout removed it
29
30
  const [resolve, reject] = waitingPromisesByUid[uid]
30
31
  if (error) {