homebridge-plugin-utils 1.11.1 → 1.11.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.
@@ -391,7 +391,7 @@ export class FeatureOptions {
391
391
  option = option.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
392
392
  // This regular expression is a bit more intricate than you might think it should be due to the need to ensure we capture values at the very end of the option when
393
393
  // the option is enabled, and that we ignore the values at the end when the option is disabled in order to correctly traverse the hierarchy.
394
- return new RegExp("^(Disable|Enable)\\." + option + (!id ? "" : "\\." + id) + "(?:(?<=^Enable\\." + option + (!id ? "" : "\\." + id) + ")\\.([^\\.]+))?$", "gi");
394
+ return new RegExp("^(Disable|Enable)\\." + option + (!id ? "" : "\\." + id) + "(?:(?<=^Enable\\." + option + (!id ? "" : "\\." + id) + ")\\.([^\\.]*))?$", "gi");
395
395
  }
396
396
  }
397
397
  //# sourceMappingURL=featureoptions.js.map
@@ -391,7 +391,7 @@ export class FeatureOptions {
391
391
  option = option.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
392
392
  // This regular expression is a bit more intricate than you might think it should be due to the need to ensure we capture values at the very end of the option when
393
393
  // the option is enabled, and that we ignore the values at the end when the option is disabled in order to correctly traverse the hierarchy.
394
- return new RegExp("^(Disable|Enable)\\." + option + (!id ? "" : "\\." + id) + "(?:(?<=^Enable\\." + option + (!id ? "" : "\\." + id) + ")\\.([^\\.]+))?$", "gi");
394
+ return new RegExp("^(Disable|Enable)\\." + option + (!id ? "" : "\\." + id) + "(?:(?<=^Enable\\." + option + (!id ? "" : "\\." + id) + ")\\.([^\\.]*))?$", "gi");
395
395
  }
396
396
  }
397
397
  //# sourceMappingURL=featureoptions.js.map
@@ -536,7 +536,7 @@ export class webUiFeatureOptions {
536
536
 
537
537
  // Find the option in our list and delete it if it exists.
538
538
  const optionRegex = new RegExp("^(?:Enable|Disable)\\." + checkbox.id + (!currentDevice ? "" : ("\\." + currentDevice.serialNumber)) +
539
- "(?:\\.([^\\.]+))?$", "gi");
539
+ "(?:\\.([^\\.]*))?$", "gi");
540
540
 
541
541
  const newOptions = this.#featureOptions.configuredOptions.filter(entry => !optionRegex.test(entry));
542
542
 
package/dist/util.d.ts CHANGED
@@ -32,6 +32,18 @@ export interface HomebridgePluginLogging {
32
32
  info: (message: string, ...parameters: unknown[]) => void;
33
33
  warn: (message: string, ...parameters: unknown[]) => void;
34
34
  }
35
+ /**
36
+ * A utility method that retries an operation at a specific interval for up to an absolute total number of retries.
37
+ * @param operation - The operation callback to try until successful.
38
+ * @param retryInterval - Interval to retry, in milliseconds.
39
+ * @param totalRetries - Optionally, specify the total number of retries.
40
+ *
41
+ * @returns Returns `true` when the operation is successful, `false` otherwise or if the total number of retries has been exceeded.
42
+ *
43
+ * @remarks `operation` must be an asynchronous function that returns `true` when successful, and `false` otherwise.
44
+ *
45
+ * @category Utilities
46
+ */
35
47
  export declare function retry(operation: () => Promise<boolean>, retryInterval: number, totalRetries?: number): Promise<boolean>;
36
48
  export declare function runWithTimeout<T>(promise: Promise<T>, timeout: number): Promise<Nullable<T>>;
37
49
  export declare function sleep(sleepTimer: number): Promise<NodeJS.Timeout>;
package/dist/util.js CHANGED
@@ -2,16 +2,27 @@
2
2
  *
3
3
  * util.ts: Useful utility functions when writing TypeScript.
4
4
  */
5
- // Retry an operation until we're successful.
5
+ /**
6
+ * A utility method that retries an operation at a specific interval for up to an absolute total number of retries.
7
+ * @param operation - The operation callback to try until successful.
8
+ * @param retryInterval - Interval to retry, in milliseconds.
9
+ * @param totalRetries - Optionally, specify the total number of retries.
10
+ *
11
+ * @returns Returns `true` when the operation is successful, `false` otherwise or if the total number of retries has been exceeded.
12
+ *
13
+ * @remarks `operation` must be an asynchronous function that returns `true` when successful, and `false` otherwise.
14
+ *
15
+ * @category Utilities
16
+ */
6
17
  export async function retry(operation, retryInterval, totalRetries) {
7
- if ((totalRetries !== undefined) && (totalRetries < 0)) {
18
+ if ((totalRetries !== undefined) && (totalRetries <= 0)) {
8
19
  return false;
9
20
  }
10
21
  // Try the operation that was requested.
11
22
  if (!(await operation())) {
12
23
  // If the operation wasn't successful, let's sleep for the requested interval and try again.
13
24
  await sleep(retryInterval);
14
- return retry(operation, retryInterval, (totalRetries === undefined) ? undefined : totalRetries--);
25
+ return retry(operation, retryInterval, (totalRetries === undefined) ? undefined : --totalRetries);
15
26
  }
16
27
  // We were successful - we're done.
17
28
  return true;
package/dist/util.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA2CH,6CAA6C;AAC7C,MAAM,CAAC,KAAK,UAAU,KAAK,CAAC,SAAiC,EAAE,aAAqB,EAAE,YAAqB;IAEzG,IAAG,CAAC,YAAY,KAAK,SAAS,CAAC,IAAI,CAAC,YAAY,GAAG,CAAC,CAAC,EAAE,CAAC;QAEtD,OAAO,KAAK,CAAC;IACf,CAAC;IAED,wCAAwC;IACxC,IAAG,CAAC,CAAC,MAAM,SAAS,EAAE,CAAC,EAAE,CAAC;QAExB,4FAA4F;QAC5F,MAAM,KAAK,CAAC,aAAa,CAAC,CAAC;QAE3B,OAAO,KAAK,CAAC,SAAS,EAAE,aAAa,EAAE,CAAC,YAAY,KAAK,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,YAAY,EAAE,CAAC,CAAC;IACpG,CAAC;IAED,mCAAmC;IACnC,OAAO,IAAI,CAAC;AACd,CAAC;AAED,uDAAuD;AACvD,MAAM,CAAC,KAAK,UAAU,cAAc,CAAI,OAAmB,EAAE,OAAe;IAE1E,MAAM,cAAc,GAAG,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;IAEhG,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,cAAc,CAAC,CAA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G,IAAI,OAAO,CAAO,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC,CAAC,CAAC;IAEhG,OAAO,OAAO,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,cAAc,CAAC,CAAC,CAAC;AACjD,CAAC;AAED,4BAA4B;AAC5B,MAAM,CAAC,KAAK,UAAU,KAAK,CAAC,UAAkB;IAE5C,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC;AACjE,CAAC;AAED,2DAA2D;AAC3D,MAAM,UAAU,YAAY,CAAC,IAAY;IAEvC,+JAA+J;IAC/J,EAAE;IACF,6DAA6D;IAC7D,2DAA2D;IAC3D,0BAA0B;IAC1B,EAAE;IACF,wFAAwF;IACxF,OAAO,IAAI,CAAC,OAAO,CAAC,oBAAoB,EAAE,GAAG,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,IAAI,EAAE,CAAC;AAC7E,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "homebridge-plugin-utils",
3
- "version": "1.11.1",
3
+ "version": "1.11.3",
4
4
  "displayName": "Homebridge Plugin Utilities",
5
5
  "description": "Opinionated utilities to provide common capabilities and create rich configuration webUI experiences for Homebridge plugins.",
6
6
  "author": {