libshv-js 10.0.1 → 10.0.3

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/dist/cpon.js CHANGED
@@ -208,11 +208,12 @@ class CponReader {
208
208
  // multiline_comment_entered;
209
209
  while (true) {
210
210
  b = this.ctx.getByte();
211
- if (b === STAR) {
212
- b = this.ctx.getByte();
213
- if (b === SLASH) {
214
- break;
215
- }
211
+ if (b !== STAR) {
212
+ continue;
213
+ }
214
+ b = this.ctx.getByte();
215
+ if (b === SLASH) {
216
+ break;
216
217
  }
217
218
  }
218
219
  }
@@ -474,10 +475,7 @@ class CponReader {
474
475
  }
475
476
  }
476
477
  else if (b === 120) { // 'x'
477
- if (n === 1 && val !== 0) {
478
- break;
479
- }
480
- if (n !== 1) {
478
+ if (n !== 1 || (n === 1 && val !== 0)) {
481
479
  break;
482
480
  }
483
481
  this.ctx.getByte();
package/dist/ws-client.js CHANGED
@@ -313,57 +313,58 @@ class WsClient {
313
313
  };
314
314
  const handleResponse = (response) => {
315
315
  const requestId = response.meta[RPC_MESSAGE_REQUEST_ID];
316
- if (this.rpcHandlers[requestId] !== undefined) {
317
- const handler = this.rpcHandlers[requestId];
318
- clearTimeout(handler.timeout_handle);
319
- // eslint-disable-next-line unicorn/no-computed-property-existence-check
320
- if (RPC_MESSAGE_DELAY in response.value) {
321
- if (handler.delayCallback !== undefined) {
322
- handler.delayCallback(response.value[RPC_MESSAGE_DELAY].value);
323
- }
324
- handler.timeout_handle = makeTimeout(this.timeout, handler.resolve);
325
- return;
316
+ if (this.rpcHandlers[requestId] === undefined) {
317
+ return;
318
+ }
319
+ const handler = this.rpcHandlers[requestId];
320
+ clearTimeout(handler.timeout_handle);
321
+ // eslint-disable-next-line unicorn/no-computed-property-existence-check
322
+ if (RPC_MESSAGE_DELAY in response.value) {
323
+ if (handler.delayCallback !== undefined) {
324
+ handler.delayCallback(response.value[RPC_MESSAGE_DELAY].value);
326
325
  }
327
- handler.resolve((() => {
328
- // eslint-disable-next-line unicorn/no-computed-property-existence-check
329
- if (RPC_MESSAGE_ERROR in response.value) {
330
- const code = response.value[RPC_MESSAGE_ERROR][ERROR_CODE];
331
- // eslint-disable-next-line @typescript-eslint/naming-convention
332
- const ErrorTypeCtor = (() => {
333
- switch (code) {
334
- case ErrorCode.InvalidRequest: return InvalidRequest;
335
- case ErrorCode.MethodNotFound: return MethodNotFound;
336
- case ErrorCode.InvalidParams: return InvalidParams;
337
- case ErrorCode.InternalError: return InternalError;
338
- case ErrorCode.ParseError: return ParseError;
339
- case ErrorCode.MethodCallTimeout: return MethodCallTimeout;
340
- case ErrorCode.MethodCallCancelled: return MethodCallCancelled;
341
- case ErrorCode.MethodCallException: return MethodCallException;
342
- case ErrorCode.Unknown: return Unknown;
343
- case ErrorCode.LoginRequired: return LoginRequired;
344
- case ErrorCode.UserIDRequired: return UserIDRequired;
345
- case ErrorCode.NotImplemented: return NotImplemented;
346
- default: return Unknown;
347
- }
348
- })();
349
- return new ErrorTypeCtor(response.value[RPC_MESSAGE_ERROR]);
350
- }
351
- // eslint-disable-next-line unicorn/no-computed-property-existence-check
352
- if (RPC_MESSAGE_RESULT in response.value) {
353
- return response.value[RPC_MESSAGE_RESULT];
354
- }
355
- // At this point, the RpcResponse either has:
356
- // - no keys, which means that the response has an implicit Null result.
357
- // - has some unknown keys, in which case we will produce an error for the client.
358
- // https://silicon-heaven.github.io/shv-doc/rpcmessage.html#response
359
- const rpcMessageKeys = Object.keys(response.value);
360
- if (rpcMessageKeys.length !== 0) {
361
- return new NotImplemented(`Got an RpcResponse with unsupported keys: ${rpcMessageKeys.join(' ')}`);
362
- }
363
- })());
364
- // eslint-disable-next-line @typescript-eslint/no-array-delete, @typescript-eslint/no-dynamic-delete
365
- delete this.rpcHandlers[requestId];
326
+ handler.timeout_handle = makeTimeout(this.timeout, handler.resolve);
327
+ return;
366
328
  }
329
+ handler.resolve((() => {
330
+ // eslint-disable-next-line unicorn/no-computed-property-existence-check
331
+ if (RPC_MESSAGE_ERROR in response.value) {
332
+ const code = response.value[RPC_MESSAGE_ERROR][ERROR_CODE];
333
+ // eslint-disable-next-line @typescript-eslint/naming-convention
334
+ const ErrorTypeCtor = (() => {
335
+ switch (code) {
336
+ case ErrorCode.InvalidRequest: return InvalidRequest;
337
+ case ErrorCode.MethodNotFound: return MethodNotFound;
338
+ case ErrorCode.InvalidParams: return InvalidParams;
339
+ case ErrorCode.InternalError: return InternalError;
340
+ case ErrorCode.ParseError: return ParseError;
341
+ case ErrorCode.MethodCallTimeout: return MethodCallTimeout;
342
+ case ErrorCode.MethodCallCancelled: return MethodCallCancelled;
343
+ case ErrorCode.MethodCallException: return MethodCallException;
344
+ case ErrorCode.Unknown: return Unknown;
345
+ case ErrorCode.LoginRequired: return LoginRequired;
346
+ case ErrorCode.UserIDRequired: return UserIDRequired;
347
+ case ErrorCode.NotImplemented: return NotImplemented;
348
+ default: return Unknown;
349
+ }
350
+ })();
351
+ return new ErrorTypeCtor(response.value[RPC_MESSAGE_ERROR]);
352
+ }
353
+ // eslint-disable-next-line unicorn/no-computed-property-existence-check
354
+ if (RPC_MESSAGE_RESULT in response.value) {
355
+ return response.value[RPC_MESSAGE_RESULT];
356
+ }
357
+ // At this point, the RpcResponse either has:
358
+ // - no keys, which means that the response has an implicit Null result.
359
+ // - has some unknown keys, in which case we will produce an error for the client.
360
+ // https://silicon-heaven.github.io/shv-doc/rpcmessage.html#response
361
+ const rpcMessageKeys = Object.keys(response.value);
362
+ if (rpcMessageKeys.length !== 0) {
363
+ return new NotImplemented(`Got an RpcResponse with unsupported keys: ${rpcMessageKeys.join(' ')}`);
364
+ }
365
+ })());
366
+ // eslint-disable-next-line @typescript-eslint/no-array-delete, @typescript-eslint/no-dynamic-delete
367
+ delete this.rpcHandlers[requestId];
367
368
  };
368
369
  // eslint-disable-next-line @typescript-eslint/strict-void-return
369
370
  this.websocket.addEventListener('message', async (evt) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "libshv-js",
3
- "version": "10.0.1",
3
+ "version": "10.0.3",
4
4
  "description": "Typescript implementation of libshv",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -41,9 +41,9 @@
41
41
  "@typescript-eslint/parser": "^8.56.1",
42
42
  "@eslint/js": "^10.0.1",
43
43
  "eslint": "^10.0.0",
44
- "eslint-config-xo": "^2.0.0",
44
+ "eslint-config-xo": "^5.0.0",
45
45
  "eslint-formatter-unix": "^9.0.1",
46
- "eslint-plugin-unicorn": "^74.0.0",
46
+ "eslint-plugin-unicorn": "^77.0.0",
47
47
  "typescript": "^6.0.2",
48
48
  "typescript-eslint": "^8.46.1"
49
49
  },