homebridge-plugin-utils 1.2.0 → 1.3.0
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/build/eslint-rules.mjs +1 -0
- package/dist/utils.d.ts +1 -1
- package/dist/utils.js +5 -2
- package/dist/utils.js.map +1 -1
- package/package.json +3 -3
package/build/eslint-rules.mjs
CHANGED
|
@@ -209,6 +209,7 @@ const commonRules = {
|
|
|
209
209
|
"no-await-in-loop": "warn",
|
|
210
210
|
"no-console": "warn",
|
|
211
211
|
"prefer-arrow-callback": "warn",
|
|
212
|
+
"prefer-const": "warn",
|
|
212
213
|
"quotes": ["warn", "double", { "avoidEscape": true }],
|
|
213
214
|
"sort-imports": "warn",
|
|
214
215
|
"sort-keys": "warn",
|
package/dist/utils.d.ts
CHANGED
|
@@ -28,4 +28,4 @@ export interface HomebridgePluginLogging {
|
|
|
28
28
|
warn: (message: string, ...parameters: unknown[]) => void;
|
|
29
29
|
}
|
|
30
30
|
export declare function sleep(sleepTimer: number): Promise<NodeJS.Timeout>;
|
|
31
|
-
export declare function retry(operation: () => Promise<boolean>, retryInterval: number): Promise<boolean>;
|
|
31
|
+
export declare function retry(operation: () => Promise<boolean>, retryInterval: number, totalRetries?: number): Promise<boolean>;
|
package/dist/utils.js
CHANGED
|
@@ -7,12 +7,15 @@ export function sleep(sleepTimer) {
|
|
|
7
7
|
return new Promise(resolve => setTimeout(resolve, sleepTimer));
|
|
8
8
|
}
|
|
9
9
|
// Retry an operation until we're successful.
|
|
10
|
-
export async function retry(operation, retryInterval) {
|
|
10
|
+
export async function retry(operation, retryInterval, totalRetries) {
|
|
11
|
+
if ((totalRetries !== undefined) && (totalRetries < 0)) {
|
|
12
|
+
return false;
|
|
13
|
+
}
|
|
11
14
|
// Try the operation that was requested.
|
|
12
15
|
if (!(await operation())) {
|
|
13
16
|
// If the operation wasn't successful, let's sleep for the requested interval and try again.
|
|
14
17
|
await sleep(retryInterval);
|
|
15
|
-
return retry(operation, retryInterval);
|
|
18
|
+
return retry(operation, retryInterval, (totalRetries === undefined) ? undefined : totalRetries--);
|
|
16
19
|
}
|
|
17
20
|
// We were successful - we're done.
|
|
18
21
|
return true;
|
package/dist/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA4CH,4BAA4B;AAC5B,MAAM,UAAU,KAAK,CAAC,UAAkB;IAEtC,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC;AACjE,CAAC;AAED,6CAA6C;AAC7C,MAAM,CAAC,KAAK,UAAU,KAAK,CAAC,SAAiC,EAAE,aAAqB;
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../src/utils.ts"],"names":[],"mappings":"AAAA;;;GAGG;AA4CH,4BAA4B;AAC5B,MAAM,UAAU,KAAK,CAAC,UAAkB;IAEtC,OAAO,IAAI,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC;AACjE,CAAC;AAED,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"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "homebridge-plugin-utils",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.3.0",
|
|
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": {
|
|
@@ -40,11 +40,11 @@
|
|
|
40
40
|
"main": "dist/index.js",
|
|
41
41
|
"devDependencies": {
|
|
42
42
|
"@stylistic/eslint-plugin": "2.1.0",
|
|
43
|
-
"@types/node": "20.
|
|
43
|
+
"@types/node": "20.14.0",
|
|
44
44
|
"eslint": "8.57.0",
|
|
45
45
|
"shx": "^0.3.4",
|
|
46
46
|
"typescript": "5.4.5",
|
|
47
|
-
"typescript-eslint": "^7.
|
|
47
|
+
"typescript-eslint": "^7.12.0"
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"mqtt": "^5.7.0"
|