matterbridge 3.1.5-dev-20250718-054cd80 → 3.1.5

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 (211) hide show
  1. package/CHANGELOG.md +5 -6
  2. package/dist/cli.d.ts +26 -0
  3. package/dist/cli.d.ts.map +1 -0
  4. package/dist/cli.js +91 -2
  5. package/dist/cli.js.map +1 -0
  6. package/dist/cliEmitter.d.ts +34 -0
  7. package/dist/cliEmitter.d.ts.map +1 -0
  8. package/dist/cliEmitter.js +30 -0
  9. package/dist/cliEmitter.js.map +1 -0
  10. package/dist/clusters/export.d.ts +2 -0
  11. package/dist/clusters/export.d.ts.map +1 -0
  12. package/dist/clusters/export.js +2 -0
  13. package/dist/clusters/export.js.map +1 -0
  14. package/dist/defaultConfigSchema.d.ts +28 -0
  15. package/dist/defaultConfigSchema.d.ts.map +1 -0
  16. package/dist/defaultConfigSchema.js +24 -0
  17. package/dist/defaultConfigSchema.js.map +1 -0
  18. package/dist/deviceManager.d.ts +112 -0
  19. package/dist/deviceManager.d.ts.map +1 -0
  20. package/dist/deviceManager.js +94 -1
  21. package/dist/deviceManager.js.map +1 -0
  22. package/dist/devices/batteryStorage.d.ts +48 -0
  23. package/dist/devices/batteryStorage.d.ts.map +1 -0
  24. package/dist/devices/batteryStorage.js +48 -1
  25. package/dist/devices/batteryStorage.js.map +1 -0
  26. package/dist/devices/evse.d.ts +75 -0
  27. package/dist/devices/evse.d.ts.map +1 -0
  28. package/dist/devices/evse.js +74 -10
  29. package/dist/devices/evse.js.map +1 -0
  30. package/dist/devices/export.d.ts +9 -0
  31. package/dist/devices/export.d.ts.map +1 -0
  32. package/dist/devices/export.js +2 -0
  33. package/dist/devices/export.js.map +1 -0
  34. package/dist/devices/heatPump.d.ts +47 -0
  35. package/dist/devices/heatPump.d.ts.map +1 -0
  36. package/dist/devices/heatPump.js +50 -2
  37. package/dist/devices/heatPump.js.map +1 -0
  38. package/dist/devices/laundryDryer.d.ts +87 -0
  39. package/dist/devices/laundryDryer.d.ts.map +1 -0
  40. package/dist/devices/laundryDryer.js +83 -6
  41. package/dist/devices/laundryDryer.js.map +1 -0
  42. package/dist/devices/laundryWasher.d.ts +242 -0
  43. package/dist/devices/laundryWasher.d.ts.map +1 -0
  44. package/dist/devices/laundryWasher.js +91 -7
  45. package/dist/devices/laundryWasher.js.map +1 -0
  46. package/dist/devices/roboticVacuumCleaner.d.ts +112 -0
  47. package/dist/devices/roboticVacuumCleaner.d.ts.map +1 -0
  48. package/dist/devices/roboticVacuumCleaner.js +103 -14
  49. package/dist/devices/roboticVacuumCleaner.js.map +1 -0
  50. package/dist/devices/solarPower.d.ts +40 -0
  51. package/dist/devices/solarPower.d.ts.map +1 -0
  52. package/dist/devices/solarPower.js +38 -0
  53. package/dist/devices/solarPower.js.map +1 -0
  54. package/dist/devices/waterHeater.d.ts +111 -0
  55. package/dist/devices/waterHeater.d.ts.map +1 -0
  56. package/dist/devices/waterHeater.js +82 -2
  57. package/dist/devices/waterHeater.js.map +1 -0
  58. package/dist/frontend.d.ts +304 -0
  59. package/dist/frontend.d.ts.map +1 -0
  60. package/dist/frontend.js +430 -22
  61. package/dist/frontend.js.map +1 -0
  62. package/dist/globalMatterbridge.d.ts +59 -0
  63. package/dist/globalMatterbridge.d.ts.map +1 -0
  64. package/dist/globalMatterbridge.js +47 -0
  65. package/dist/globalMatterbridge.js.map +1 -0
  66. package/dist/helpers.d.ts +48 -0
  67. package/dist/helpers.d.ts.map +1 -0
  68. package/dist/helpers.js +53 -0
  69. package/dist/helpers.js.map +1 -0
  70. package/dist/index.d.ts +33 -0
  71. package/dist/index.d.ts.map +1 -0
  72. package/dist/index.js +30 -1
  73. package/dist/index.js.map +1 -0
  74. package/dist/logger/export.d.ts +2 -0
  75. package/dist/logger/export.d.ts.map +1 -0
  76. package/dist/logger/export.js +1 -0
  77. package/dist/logger/export.js.map +1 -0
  78. package/dist/matter/behaviors.d.ts +2 -0
  79. package/dist/matter/behaviors.d.ts.map +1 -0
  80. package/dist/matter/behaviors.js +2 -0
  81. package/dist/matter/behaviors.js.map +1 -0
  82. package/dist/matter/clusters.d.ts +2 -0
  83. package/dist/matter/clusters.d.ts.map +1 -0
  84. package/dist/matter/clusters.js +2 -0
  85. package/dist/matter/clusters.js.map +1 -0
  86. package/dist/matter/devices.d.ts +2 -0
  87. package/dist/matter/devices.d.ts.map +1 -0
  88. package/dist/matter/devices.js +2 -0
  89. package/dist/matter/devices.js.map +1 -0
  90. package/dist/matter/endpoints.d.ts +2 -0
  91. package/dist/matter/endpoints.d.ts.map +1 -0
  92. package/dist/matter/endpoints.js +2 -0
  93. package/dist/matter/endpoints.js.map +1 -0
  94. package/dist/matter/export.d.ts +5 -0
  95. package/dist/matter/export.d.ts.map +1 -0
  96. package/dist/matter/export.js +3 -0
  97. package/dist/matter/export.js.map +1 -0
  98. package/dist/matter/types.d.ts +3 -0
  99. package/dist/matter/types.d.ts.map +1 -0
  100. package/dist/matter/types.js +3 -0
  101. package/dist/matter/types.js.map +1 -0
  102. package/dist/matterbridge.d.ts +447 -0
  103. package/dist/matterbridge.d.ts.map +1 -0
  104. package/dist/matterbridge.js +791 -51
  105. package/dist/matterbridge.js.map +1 -0
  106. package/dist/matterbridgeAccessoryPlatform.d.ts +42 -0
  107. package/dist/matterbridgeAccessoryPlatform.d.ts.map +1 -0
  108. package/dist/matterbridgeAccessoryPlatform.js +36 -0
  109. package/dist/matterbridgeAccessoryPlatform.js.map +1 -0
  110. package/dist/matterbridgeBehaviors.d.ts +1340 -0
  111. package/dist/matterbridgeBehaviors.d.ts.map +1 -0
  112. package/dist/matterbridgeBehaviors.js +61 -1
  113. package/dist/matterbridgeBehaviors.js.map +1 -0
  114. package/dist/matterbridgeDeviceTypes.d.ts +709 -0
  115. package/dist/matterbridgeDeviceTypes.d.ts.map +1 -0
  116. package/dist/matterbridgeDeviceTypes.js +579 -15
  117. package/dist/matterbridgeDeviceTypes.js.map +1 -0
  118. package/dist/matterbridgeDynamicPlatform.d.ts +42 -0
  119. package/dist/matterbridgeDynamicPlatform.d.ts.map +1 -0
  120. package/dist/matterbridgeDynamicPlatform.js +36 -0
  121. package/dist/matterbridgeDynamicPlatform.js.map +1 -0
  122. package/dist/matterbridgeEndpoint.d.ts +1250 -0
  123. package/dist/matterbridgeEndpoint.d.ts.map +1 -0
  124. package/dist/matterbridgeEndpoint.js +1106 -42
  125. package/dist/matterbridgeEndpoint.js.map +1 -0
  126. package/dist/matterbridgeEndpointHelpers.d.ts +3198 -0
  127. package/dist/matterbridgeEndpointHelpers.d.ts.map +1 -0
  128. package/dist/matterbridgeEndpointHelpers.js +322 -12
  129. package/dist/matterbridgeEndpointHelpers.js.map +1 -0
  130. package/dist/matterbridgePlatform.d.ts +310 -0
  131. package/dist/matterbridgePlatform.d.ts.map +1 -0
  132. package/dist/matterbridgePlatform.js +233 -0
  133. package/dist/matterbridgePlatform.js.map +1 -0
  134. package/dist/matterbridgeTypes.d.ts +195 -0
  135. package/dist/matterbridgeTypes.d.ts.map +1 -0
  136. package/dist/matterbridgeTypes.js +25 -0
  137. package/dist/matterbridgeTypes.js.map +1 -0
  138. package/dist/pluginManager.d.ts +270 -0
  139. package/dist/pluginManager.d.ts.map +1 -0
  140. package/dist/pluginManager.js +249 -3
  141. package/dist/pluginManager.js.map +1 -0
  142. package/dist/shelly.d.ts +174 -0
  143. package/dist/shelly.d.ts.map +1 -0
  144. package/dist/shelly.js +168 -7
  145. package/dist/shelly.js.map +1 -0
  146. package/dist/storage/export.d.ts +2 -0
  147. package/dist/storage/export.d.ts.map +1 -0
  148. package/dist/storage/export.js +1 -0
  149. package/dist/storage/export.js.map +1 -0
  150. package/dist/update.d.ts +59 -0
  151. package/dist/update.d.ts.map +1 -0
  152. package/dist/update.js +54 -0
  153. package/dist/update.js.map +1 -0
  154. package/dist/utils/colorUtils.d.ts +117 -0
  155. package/dist/utils/colorUtils.d.ts.map +1 -0
  156. package/dist/utils/colorUtils.js +263 -2
  157. package/dist/utils/colorUtils.js.map +1 -0
  158. package/dist/utils/commandLine.d.ts +59 -0
  159. package/dist/utils/commandLine.d.ts.map +1 -0
  160. package/dist/utils/commandLine.js +54 -0
  161. package/dist/utils/commandLine.js.map +1 -0
  162. package/dist/utils/copyDirectory.d.ts +33 -0
  163. package/dist/utils/copyDirectory.d.ts.map +1 -0
  164. package/dist/utils/copyDirectory.js +38 -1
  165. package/dist/utils/copyDirectory.js.map +1 -0
  166. package/dist/utils/createDirectory.d.ts +34 -0
  167. package/dist/utils/createDirectory.d.ts.map +1 -0
  168. package/dist/utils/createDirectory.js +33 -0
  169. package/dist/utils/createDirectory.js.map +1 -0
  170. package/dist/utils/createZip.d.ts +39 -0
  171. package/dist/utils/createZip.d.ts.map +1 -0
  172. package/dist/utils/createZip.js +47 -2
  173. package/dist/utils/createZip.js.map +1 -0
  174. package/dist/utils/deepCopy.d.ts +32 -0
  175. package/dist/utils/deepCopy.d.ts.map +1 -0
  176. package/dist/utils/deepCopy.js +39 -0
  177. package/dist/utils/deepCopy.js.map +1 -0
  178. package/dist/utils/deepEqual.d.ts +54 -0
  179. package/dist/utils/deepEqual.d.ts.map +1 -0
  180. package/dist/utils/deepEqual.js +72 -1
  181. package/dist/utils/deepEqual.js.map +1 -0
  182. package/dist/utils/error.d.ts +44 -0
  183. package/dist/utils/error.d.ts.map +1 -0
  184. package/dist/utils/error.js +41 -0
  185. package/dist/utils/error.js.map +1 -0
  186. package/dist/utils/export.d.ts +12 -0
  187. package/dist/utils/export.d.ts.map +1 -0
  188. package/dist/utils/export.js +1 -0
  189. package/dist/utils/export.js.map +1 -0
  190. package/dist/utils/hex.d.ts +49 -0
  191. package/dist/utils/hex.d.ts.map +1 -0
  192. package/dist/utils/hex.js +58 -0
  193. package/dist/utils/hex.js.map +1 -0
  194. package/dist/utils/isvalid.d.ts +103 -0
  195. package/dist/utils/isvalid.d.ts.map +1 -0
  196. package/dist/utils/isvalid.js +101 -0
  197. package/dist/utils/isvalid.js.map +1 -0
  198. package/dist/utils/network.d.ts +74 -0
  199. package/dist/utils/network.d.ts.map +1 -0
  200. package/dist/utils/network.js +81 -5
  201. package/dist/utils/network.js.map +1 -0
  202. package/dist/utils/spawn.d.ts +33 -0
  203. package/dist/utils/spawn.d.ts.map +1 -0
  204. package/dist/utils/spawn.js +40 -0
  205. package/dist/utils/spawn.js.map +1 -0
  206. package/dist/utils/wait.d.ts +56 -0
  207. package/dist/utils/wait.d.ts.map +1 -0
  208. package/dist/utils/wait.js +62 -9
  209. package/dist/utils/wait.js.map +1 -0
  210. package/npm-shrinkwrap.json +2 -2
  211. package/package.json +2 -1
@@ -1,23 +1,89 @@
1
+ /* eslint-disable @typescript-eslint/no-unused-vars */
2
+ /**
3
+ * This file contains the deepEqual function.
4
+ *
5
+ * @file deepEqual.ts
6
+ * @author Luca Liguori
7
+ * @created 2025-02-16
8
+ * @version 1.0.0
9
+ * @license Apache-2.0
10
+ *
11
+ * Copyright 2025, 2026, 2027 Luca Liguori.
12
+ *
13
+ * Licensed under the Apache License, Version 2.0 (the "License");
14
+ * you may not use this file except in compliance with the License.
15
+ * You may obtain a copy of the License at
16
+ *
17
+ * http://www.apache.org/licenses/LICENSE-2.0
18
+ *
19
+ * Unless required by applicable law or agreed to in writing, software
20
+ * distributed under the License is distributed on an "AS IS" BASIS,
21
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22
+ * See the License for the specific language governing permissions and
23
+ * limitations under the License.
24
+ */
25
+ /* eslint-disable @typescript-eslint/no-explicit-any */
26
+ /**
27
+ * Performs a deep comparison between two values to determine if they are equivalent.
28
+ * This comparison includes primitive types, arrays, and objects, allowing for optional
29
+ * exclusion of specific properties from the comparison in objects.
30
+ *
31
+ * @param {any} a The first value to compare.
32
+ * @param {any} b The second value to compare.
33
+ * @param {string[]} [excludeProperties] An array of property names to exclude from the comparison in objects.
34
+ * @returns {boolean} True if the values are deeply equal, excluding any specified properties; otherwise, false.
35
+ *
36
+ * Note: This function utilizes recursion for deep comparison of nested structures and includes a debugging
37
+ * mechanism that can be toggled on or off for detailed comparison logging. It is important to ensure that
38
+ * objects do not contain circular references when enabling debug logging to avoid infinite loops.
39
+ *
40
+ * Example usage:
41
+ * ```
42
+ * const obj1 = { a: 1, b: { c: 2 } };
43
+ * const obj2 = { a: 1, b: { c: 2 } };
44
+ * console.log(deepEqual(obj1, obj2)); // true
45
+ *
46
+ * const arr1 = [1, 2, [3, 4]];
47
+ * const arr2 = [1, 2, [3, 4]];
48
+ * console.log(deepEqual(arr1, arr2)); // true
49
+ *
50
+ * const obj3 = { a: 1, b: { c: 2, d: 3 } };
51
+ * const obj4 = { a: 1, b: { c: 2 } };
52
+ * console.log(deepEqual(obj3, obj4, ['d'])); // true, excluding property 'd' from comparison
53
+ * ```
54
+ */
1
55
  export function deepEqual(a, b, excludeProperties = []) {
56
+ // Toggle debugging on or off easily
57
+ // const debug = false;
58
+ // Helper function for conditional logging
2
59
  const debugLog = (...messages) => {
60
+ // if (debug) {
61
+ // console.log(...messages);
62
+ // }
3
63
  };
64
+ // If both are the same instance, return true (handles primitives and same object references)
4
65
  if (a === b) {
5
66
  return true;
6
67
  }
68
+ // If types are different, return false
7
69
  if (typeof a !== typeof b) {
8
70
  debugLog(`deepEqual false for typeof a: ${typeof a} typeof b: ${typeof b}`);
9
71
  return false;
10
72
  }
73
+ // If one of them is null (and we know they are not equal from the first check), return false
11
74
  if (a == null || b == null) {
12
75
  debugLog('deepEqual false for == null');
13
76
  return false;
14
77
  }
78
+ // Handle Dates compare by timestamp
15
79
  if (a instanceof Date && b instanceof Date) {
16
80
  return a.getTime() === b.getTime();
17
81
  }
82
+ // Handle Regexps compare by their source & flags
18
83
  if (a instanceof RegExp && b instanceof RegExp) {
19
84
  return a.source === b.source && a.flags === b.flags;
20
85
  }
86
+ // Handle Arrays
21
87
  if (Array.isArray(a) && Array.isArray(b)) {
22
88
  if (a.length !== b.length) {
23
89
  debugLog(`deepEqual false for array a.length(${a.length}) !== b.length(${b.length})`);
@@ -33,26 +99,31 @@ export function deepEqual(a, b, excludeProperties = []) {
33
99
  }
34
100
  return true;
35
101
  }
102
+ // Handle Objects (and exclude null, functions, and arrays)
36
103
  if (typeof a === 'object' && typeof b === 'object') {
37
104
  const aProps = Object.getOwnPropertyNames(a).filter((prop) => !excludeProperties.includes(prop));
38
105
  const bProps = Object.getOwnPropertyNames(b).filter((prop) => !excludeProperties.includes(prop));
106
+ // If their property lengths are different, they're different objects
39
107
  if (aProps.length !== bProps.length) {
40
108
  debugLog(`deepEqual false for aProps.length(${aProps.length}) !== bProps.length(${bProps.length})`);
41
109
  debugLog(`- aProps.length(${aProps.length}):`, aProps);
42
110
  debugLog(`- bProps.length(${bProps.length}):`, bProps);
43
111
  return false;
44
112
  }
113
+ // Check each property in 'a' to see if it's in 'b' and if it's equal (deep check)
45
114
  for (const prop of aProps) {
46
115
  if (!Object.prototype.hasOwnProperty.call(b, prop)) {
47
116
  debugLog(`deepEqual false for !b.hasOwnProperty(${prop})`);
48
117
  return false;
49
118
  }
50
119
  if (!deepEqual(a[prop], b[prop], excludeProperties)) {
51
- debugLog(`deepEqual false for !deepEqual(a[${prop}], b[${prop}])`);
120
+ debugLog(`deepEqual false for !deepEqual(a[${prop}], b[${prop}])` /* , a[prop], b[prop]*/);
52
121
  return false;
53
122
  }
54
123
  }
55
124
  return true;
56
125
  }
126
+ // If none of the above, the objects are not equal
57
127
  return false;
58
128
  }
129
+ //# sourceMappingURL=deepEqual.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"deepEqual.js","sourceRoot":"","sources":["../../src/utils/deepEqual.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,44 @@
1
+ /**
2
+ * This file contains the error functions.
3
+ *
4
+ * @file error.ts
5
+ * @author Luca Liguori
6
+ * @created 2025-07-17
7
+ * @version 1.0.0
8
+ * @license Apache-2.0
9
+ *
10
+ * Copyright 2025, 2026, 2027 Luca Liguori.
11
+ *
12
+ * Licensed under the Apache License, Version 2.0 (the "License");
13
+ * you may not use this file except in compliance with the License.
14
+ * You may obtain a copy of the License at
15
+ *
16
+ * http://www.apache.org/licenses/LICENSE-2.0
17
+ *
18
+ * Unless required by applicable law or agreed to in writing, software
19
+ * distributed under the License is distributed on an "AS IS" BASIS,
20
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21
+ * See the License for the specific language governing permissions and
22
+ * limitations under the License.
23
+ */
24
+ import type { AnsiLogger } from 'node-ansi-logger';
25
+ /**
26
+ * Logs an error message using the provided AnsiLogger instance.
27
+ *
28
+ * @param {AnsiLogger} log - The AnsiLogger instance to use for logging.
29
+ * @param {string} message - The error message to log.
30
+ * @param {unknown} error - The error object or value to log. If it's an Error instance,
31
+ * its message and stack trace will be included in the log.
32
+ */
33
+ export declare function logError(log: AnsiLogger, message: string, error: unknown): void;
34
+ /**
35
+ * Logs an error message using the provided AnsiLogger instance with detailed inspection.
36
+ * Uses util.inspect to get a detailed view of the error with a stack depth of 10 levels.
37
+ * If the error is an Error instance, it also includes the error message.
38
+ *
39
+ * @param {AnsiLogger} log - The AnsiLogger instance to use for logging.
40
+ * @param {string} message - The error message to log.
41
+ * @param {unknown} error - The error object or value to log. Will be inspected with depth 10.
42
+ */
43
+ export declare function inspectError(log: AnsiLogger, message: string, error: unknown): void;
44
+ //# sourceMappingURL=error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/utils/error.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAIH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,kBAAkB,CAAC;AAEnD;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAE/E;AAED;;;;;;;;GAQG;AACH,wBAAgB,YAAY,CAAC,GAAG,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,GAAG,IAAI,CAInF"}
@@ -1,9 +1,50 @@
1
+ /**
2
+ * This file contains the error functions.
3
+ *
4
+ * @file error.ts
5
+ * @author Luca Liguori
6
+ * @created 2025-07-17
7
+ * @version 1.0.0
8
+ * @license Apache-2.0
9
+ *
10
+ * Copyright 2025, 2026, 2027 Luca Liguori.
11
+ *
12
+ * Licensed under the Apache License, Version 2.0 (the "License");
13
+ * you may not use this file except in compliance with the License.
14
+ * You may obtain a copy of the License at
15
+ *
16
+ * http://www.apache.org/licenses/LICENSE-2.0
17
+ *
18
+ * Unless required by applicable law or agreed to in writing, software
19
+ * distributed under the License is distributed on an "AS IS" BASIS,
20
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21
+ * See the License for the specific language governing permissions and
22
+ * limitations under the License.
23
+ */
1
24
  import { inspect } from 'node:util';
25
+ /**
26
+ * Logs an error message using the provided AnsiLogger instance.
27
+ *
28
+ * @param {AnsiLogger} log - The AnsiLogger instance to use for logging.
29
+ * @param {string} message - The error message to log.
30
+ * @param {unknown} error - The error object or value to log. If it's an Error instance,
31
+ * its message and stack trace will be included in the log.
32
+ */
2
33
  export function logError(log, message, error) {
3
34
  log.error(`${message}: ${error instanceof Error ? error.message + '\nStack:\n' + error.stack : error}`);
4
35
  }
36
+ /**
37
+ * Logs an error message using the provided AnsiLogger instance with detailed inspection.
38
+ * Uses util.inspect to get a detailed view of the error with a stack depth of 10 levels.
39
+ * If the error is an Error instance, it also includes the error message.
40
+ *
41
+ * @param {AnsiLogger} log - The AnsiLogger instance to use for logging.
42
+ * @param {string} message - The error message to log.
43
+ * @param {unknown} error - The error object or value to log. Will be inspected with depth 10.
44
+ */
5
45
  export function inspectError(log, message, error) {
6
46
  const errorMessage = error instanceof Error ? `${error.message}\n` : '';
7
47
  const inspectedError = inspect(error, { depth: 10, colors: true, showHidden: false });
8
48
  log.error(`${message}: ${errorMessage}${inspectedError}`);
9
49
  }
50
+ //# sourceMappingURL=error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/utils/error.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAIpC;;;;;;;GAOG;AACH,MAAM,UAAU,QAAQ,CAAC,GAAe,EAAE,OAAe,EAAE,KAAc;IACvE,GAAG,CAAC,KAAK,CAAC,GAAG,OAAO,KAAK,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,GAAG,YAAY,GAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,KAAK,EAAE,CAAC,CAAC;AAC1G,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,YAAY,CAAC,GAAe,EAAE,OAAe,EAAE,KAAc;IAC3E,MAAM,YAAY,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,KAAK,CAAC,OAAO,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;IACxE,MAAM,cAAc,GAAG,OAAO,CAAC,KAAK,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,KAAK,EAAE,CAAC,CAAC;IACtF,GAAG,CAAC,KAAK,CAAC,GAAG,OAAO,KAAK,YAAY,GAAG,cAAc,EAAE,CAAC,CAAC;AAC5D,CAAC"}
@@ -0,0 +1,12 @@
1
+ export * from './network.js';
2
+ export * from './commandLine.js';
3
+ export * from './isvalid.js';
4
+ export * from './colorUtils.js';
5
+ export * from './deepCopy.js';
6
+ export * from './deepEqual.js';
7
+ export * from './copyDirectory.js';
8
+ export * from './createDirectory.js';
9
+ export * from './createZip.js';
10
+ export * from './wait.js';
11
+ export * from './hex.js';
12
+ //# sourceMappingURL=export.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"export.d.ts","sourceRoot":"","sources":["../../src/utils/export.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC"}
@@ -9,3 +9,4 @@ export * from './createDirectory.js';
9
9
  export * from './createZip.js';
10
10
  export * from './wait.js';
11
11
  export * from './hex.js';
12
+ //# sourceMappingURL=export.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"export.js","sourceRoot":"","sources":["../../src/utils/export.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,kBAAkB,CAAC;AACjC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,eAAe,CAAC;AAC9B,cAAc,gBAAgB,CAAC;AAC/B,cAAc,oBAAoB,CAAC;AACnC,cAAc,sBAAsB,CAAC;AACrC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC"}
@@ -0,0 +1,49 @@
1
+ /**
2
+ * This file contains the hex functions.
3
+ *
4
+ * @file hex.ts
5
+ * @author Luca Liguori
6
+ * @created 2025-05-06
7
+ * @version 1.0.0
8
+ * @license Apache-2.0
9
+ *
10
+ * Copyright 2025, 2026, 2027 Luca Liguori.
11
+ *
12
+ * Licensed under the Apache License, Version 2.0 (the "License");
13
+ * you may not use this file except in compliance with the License.
14
+ * You may obtain a copy of the License at
15
+ *
16
+ * http://www.apache.org/licenses/LICENSE-2.0
17
+ *
18
+ * Unless required by applicable law or agreed to in writing, software
19
+ * distributed under the License is distributed on an "AS IS" BASIS,
20
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21
+ * See the License for the specific language governing permissions and
22
+ * limitations under the License.
23
+ */
24
+ /**
25
+ * Converts an ArrayBuffer or Uint8Array to a hexadecimal string.
26
+ *
27
+ * Accepts any {ArrayBufferLike} input: a raw ArrayBuffer (binary data storage) or
28
+ * a Uint8Array (TypedArray view over an ArrayBuffer). While an ArrayBuffer holds
29
+ * the raw memory, a Uint8Array is a typed view into that memory, letting you access
30
+ * its bytes directly. This function normalizes both by creating a Uint8Array view
31
+ * before conversion.
32
+ *
33
+ * @param {ArrayBufferLike} buffer - The buffer or typed-array view to convert.
34
+ * @returns {string} A lowercase hex string representation of the buffer's bytes.
35
+ *
36
+ * @throws {TypeError} If the input is not an ArrayBuffer or ArrayBufferView.
37
+ */
38
+ export declare function bufferToHex(buffer: ArrayBufferLike): string;
39
+ /**
40
+ * Converts a hexadecimal string to a Uint8Array.
41
+ *
42
+ * @param {string} hex - The hex string to convert. Can include uppercase or lowercase characters.
43
+ * @returns {Uint8Array} A Uint8Array representing the corresponding binary data.
44
+ *
45
+ * @throws {TypeError} If the input is not a string.
46
+ * @throws {Error} If the input length is odd or contains non-hex characters.
47
+ */
48
+ export declare function hexToBuffer(hex: string): Uint8Array;
49
+ //# sourceMappingURL=hex.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hex.d.ts","sourceRoot":"","sources":["../../src/utils/hex.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH;;;;;;;;;;;;;GAaG;AACH,wBAAgB,WAAW,CAAC,MAAM,EAAE,eAAe,GAAG,MAAM,CAa3D;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,UAAU,CAgCnD"}
package/dist/utils/hex.js CHANGED
@@ -1,27 +1,85 @@
1
+ /**
2
+ * This file contains the hex functions.
3
+ *
4
+ * @file hex.ts
5
+ * @author Luca Liguori
6
+ * @created 2025-05-06
7
+ * @version 1.0.0
8
+ * @license Apache-2.0
9
+ *
10
+ * Copyright 2025, 2026, 2027 Luca Liguori.
11
+ *
12
+ * Licensed under the Apache License, Version 2.0 (the "License");
13
+ * you may not use this file except in compliance with the License.
14
+ * You may obtain a copy of the License at
15
+ *
16
+ * http://www.apache.org/licenses/LICENSE-2.0
17
+ *
18
+ * Unless required by applicable law or agreed to in writing, software
19
+ * distributed under the License is distributed on an "AS IS" BASIS,
20
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21
+ * See the License for the specific language governing permissions and
22
+ * limitations under the License.
23
+ */
24
+ /**
25
+ * Converts an ArrayBuffer or Uint8Array to a hexadecimal string.
26
+ *
27
+ * Accepts any {ArrayBufferLike} input: a raw ArrayBuffer (binary data storage) or
28
+ * a Uint8Array (TypedArray view over an ArrayBuffer). While an ArrayBuffer holds
29
+ * the raw memory, a Uint8Array is a typed view into that memory, letting you access
30
+ * its bytes directly. This function normalizes both by creating a Uint8Array view
31
+ * before conversion.
32
+ *
33
+ * @param {ArrayBufferLike} buffer - The buffer or typed-array view to convert.
34
+ * @returns {string} A lowercase hex string representation of the buffer's bytes.
35
+ *
36
+ * @throws {TypeError} If the input is not an ArrayBuffer or ArrayBufferView.
37
+ */
1
38
  export function bufferToHex(buffer) {
39
+ // Check if the input is an ArrayBuffer or ArrayBufferView
2
40
  if (!(buffer instanceof ArrayBuffer || ArrayBuffer.isView(buffer))) {
3
41
  throw new TypeError('Expected input to be an ArrayBuffer or ArrayBufferView');
4
42
  }
43
+ // Create a Uint8Array view over the buffer
5
44
  const bytes = buffer instanceof Uint8Array ? buffer : new Uint8Array(buffer);
45
+ // Convert each byte to 2-digit hex
6
46
  return Array.from(bytes)
7
47
  .map((byte) => byte.toString(16).padStart(2, '0'))
8
48
  .join('');
9
49
  }
50
+ /**
51
+ * Converts a hexadecimal string to a Uint8Array.
52
+ *
53
+ * @param {string} hex - The hex string to convert. Can include uppercase or lowercase characters.
54
+ * @returns {Uint8Array} A Uint8Array representing the corresponding binary data.
55
+ *
56
+ * @throws {TypeError} If the input is not a string.
57
+ * @throws {Error} If the input length is odd or contains non-hex characters.
58
+ */
10
59
  export function hexToBuffer(hex) {
60
+ // Ensure the input is a string
11
61
  if (typeof hex !== 'string') {
12
62
  throw new TypeError('Expected a string for hex input');
13
63
  }
64
+ // Trim any whitespace from the input string
14
65
  const cleaned = hex.trim();
66
+ // Check if the length of the hex string is even
15
67
  if (cleaned.length % 2 !== 0) {
16
68
  throw new Error('Invalid hex string length, must be even');
17
69
  }
70
+ // Validate that the string contains only valid hex characters
18
71
  if (!/^[0-9a-fA-F]*$/.test(cleaned)) {
19
72
  throw new Error('Invalid hex string, contains non-hex characters');
20
73
  }
74
+ // Calculate the length of the resulting Uint8Array
21
75
  const length = cleaned.length / 2;
76
+ // Create a Uint8Array to hold the binary data
22
77
  const result = new Uint8Array(length);
78
+ // Convert each pair of hex characters into a byte
23
79
  for (let i = 0; i < length; i++) {
24
80
  result[i] = parseInt(cleaned.substr(i * 2, 2), 16);
25
81
  }
82
+ // Return the resulting Uint8Array
26
83
  return result;
27
84
  }
85
+ //# sourceMappingURL=hex.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"hex.js","sourceRoot":"","sources":["../../src/utils/hex.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,WAAW,CAAC,MAAuB;IACjD,0DAA0D;IAC1D,IAAI,CAAC,CAAC,MAAM,YAAY,WAAW,IAAI,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;QACnE,MAAM,IAAI,SAAS,CAAC,wDAAwD,CAAC,CAAC;IAChF,CAAC;IAED,2CAA2C;IAC3C,MAAM,KAAK,GAAG,MAAM,YAAY,UAAU,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;IAE7E,mCAAmC;IACnC,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC;SACrB,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;SACjD,IAAI,CAAC,EAAE,CAAC,CAAC;AACd,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,WAAW,CAAC,GAAW;IACrC,+BAA+B;IAC/B,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QAC5B,MAAM,IAAI,SAAS,CAAC,iCAAiC,CAAC,CAAC;IACzD,CAAC;IAED,4CAA4C;IAC5C,MAAM,OAAO,GAAG,GAAG,CAAC,IAAI,EAAE,CAAC;IAE3B,gDAAgD;IAChD,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC,EAAE,CAAC;QAC7B,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;IAC7D,CAAC;IAED,8DAA8D;IAC9D,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC;QACpC,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;IACrE,CAAC;IAED,mDAAmD;IACnD,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,CAAC,CAAC;IAElC,8CAA8C;IAC9C,MAAM,MAAM,GAAG,IAAI,UAAU,CAAC,MAAM,CAAC,CAAC;IAEtC,kDAAkD;IAClD,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QAChC,MAAM,CAAC,CAAC,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IACrD,CAAC;IAED,kCAAkC;IAClC,OAAO,MAAM,CAAC;AAChB,CAAC"}
@@ -0,0 +1,103 @@
1
+ /**
2
+ * This file contains the validation functions.
3
+ *
4
+ * @file isvalid.ts
5
+ * @author Luca Liguori
6
+ * @created 2025-02-16
7
+ * @version 1.0.0
8
+ * @license Apache-2.0
9
+ *
10
+ * Copyright 2025, 2026, 2027 Luca Liguori.
11
+ *
12
+ * Licensed under the Apache License, Version 2.0 (the "License");
13
+ * you may not use this file except in compliance with the License.
14
+ * You may obtain a copy of the License at
15
+ *
16
+ * http://www.apache.org/licenses/LICENSE-2.0
17
+ *
18
+ * Unless required by applicable law or agreed to in writing, software
19
+ * distributed under the License is distributed on an "AS IS" BASIS,
20
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21
+ * See the License for the specific language governing permissions and
22
+ * limitations under the License.
23
+ */
24
+ /**
25
+ * Checks if a given string is a valid IPv4 address.
26
+ *
27
+ * @param {string} ipv4Address - The string to be checked.
28
+ * @returns {boolean} - Returns true if the string is a valid IPv4 address, otherwise returns false.
29
+ */
30
+ export declare function isValidIpv4Address(ipv4Address: string): boolean;
31
+ /**
32
+ * Checks if a value is a valid number within the specified range.
33
+ *
34
+ * @param {any} value - The value to be checked.
35
+ * @param {number} min - The minimum value allowed (optional).
36
+ * @param {number} max - The maximum value allowed (optional).
37
+ * @returns {value is number} Returns true if the value is a valid number within the specified range, otherwise false.
38
+ */
39
+ export declare function isValidNumber(value: any, min?: number, max?: number): value is number;
40
+ /**
41
+ * Checks if a value is a valid boolean.
42
+ *
43
+ * @param {any} value - The value to be checked.
44
+ * @returns {value is boolean} `true` if the value is a valid boolean, `false` otherwise.
45
+ */
46
+ export declare function isValidBoolean(value: any): value is boolean;
47
+ /**
48
+ * Checks if a value is a valid string.
49
+ *
50
+ * @param {any} value - The value to be checked.
51
+ * @param {number} minLength - The min string length (optional).
52
+ * @param {number} maxLength - The max string length (optional).
53
+ * @returns {value is string} A boolean indicating whether the value is a valid string.
54
+ */
55
+ export declare function isValidString(value: any, minLength?: number, maxLength?: number): value is string;
56
+ /**
57
+ * Checks if a value is a valid RegExp.
58
+ *
59
+ * @param {any} value - The value to be checked.
60
+ * @returns {value is RegExp} A boolean indicating whether the value is a valid RegExp.
61
+ */
62
+ export declare function isValidRegExp(value: any): value is RegExp;
63
+ /**
64
+ * Checks if a value is a valid object.
65
+ *
66
+ * @param {any} value - The value to be checked.
67
+ * @param {number} minLength - The min number of keys (optional).
68
+ * @param {number} maxLength - The max number of keys (optional).
69
+ * @returns {value is object} A boolean indicating whether the value is a valid object.
70
+ */
71
+ export declare function isValidObject(value: any, minLength?: number, maxLength?: number): value is object;
72
+ /**
73
+ * Checks if a value is a valid array.
74
+ *
75
+ * @param {any} value - The value to be checked.
76
+ * @param {number} minLength - The min number of elements (optional).
77
+ * @param {number} maxLength - The max number of elements (optional).
78
+ * @returns {value is unknown[]} A boolean indicating whether the value is a valid array.
79
+ */
80
+ export declare function isValidArray(value: any, minLength?: number, maxLength?: number): value is unknown[];
81
+ /**
82
+ * Checks if the given value is null.
83
+ *
84
+ * @param {any} value - The value to check.
85
+ * @returns {value is null} `true` if the value is null, `false` otherwise.
86
+ */
87
+ export declare function isValidNull(value: any): value is null;
88
+ /**
89
+ * Checks if a value is undefined.
90
+ *
91
+ * @param {any} value - The value to check.
92
+ * @returns {value is undefined} `true` if the value is undefined, `false` otherwise.
93
+ */
94
+ export declare function isValidUndefined(value: any): value is undefined;
95
+ /**
96
+ * Converts a semantic version string like "6.11.0-1011-raspi" to a numeric version code like 61100.
97
+ * Format: major * 10000 + minor * 100 + patch
98
+ *
99
+ * @param {string} versionString The version string to parse
100
+ * @returns {number | undefined} A numeric version code or undefined if parsing fails
101
+ */
102
+ export declare function parseVersionString(versionString: string): number | undefined;
103
+ //# sourceMappingURL=isvalid.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"isvalid.d.ts","sourceRoot":"","sources":["../../src/utils/isvalid.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAEH;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAG/D;AAED;;;;;;;GAOG;AAEH,wBAAgB,aAAa,CAAC,KAAK,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,MAAM,EAAE,GAAG,CAAC,EAAE,MAAM,GAAG,KAAK,IAAI,MAAM,CAKrF;AAED;;;;;GAKG;AAEH,wBAAgB,cAAc,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,OAAO,CAE3D;AAED;;;;;;;GAOG;AAEH,wBAAgB,aAAa,CAAC,KAAK,EAAE,GAAG,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,KAAK,IAAI,MAAM,CAKjG;AAED;;;;;GAKG;AAEH,wBAAgB,aAAa,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,MAAM,CAEzD;AAED;;;;;;;GAOG;AAEH,wBAAgB,aAAa,CAAC,KAAK,EAAE,GAAG,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,KAAK,IAAI,MAAM,CAMjG;AAED;;;;;;;GAOG;AAEH,wBAAgB,YAAY,CAAC,KAAK,EAAE,GAAG,EAAE,SAAS,CAAC,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,KAAK,IAAI,OAAO,EAAE,CAKnG;AAED;;;;;GAKG;AAEH,wBAAgB,WAAW,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,IAAI,CAErD;AAED;;;;;GAKG;AAEH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,GAAG,GAAG,KAAK,IAAI,SAAS,CAE/D;AAED;;;;;;GAMG;AACH,wBAAgB,kBAAkB,CAAC,aAAa,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAgB5E"}
@@ -1,7 +1,45 @@
1
+ /**
2
+ * This file contains the validation functions.
3
+ *
4
+ * @file isvalid.ts
5
+ * @author Luca Liguori
6
+ * @created 2025-02-16
7
+ * @version 1.0.0
8
+ * @license Apache-2.0
9
+ *
10
+ * Copyright 2025, 2026, 2027 Luca Liguori.
11
+ *
12
+ * Licensed under the Apache License, Version 2.0 (the "License");
13
+ * you may not use this file except in compliance with the License.
14
+ * You may obtain a copy of the License at
15
+ *
16
+ * http://www.apache.org/licenses/LICENSE-2.0
17
+ *
18
+ * Unless required by applicable law or agreed to in writing, software
19
+ * distributed under the License is distributed on an "AS IS" BASIS,
20
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
21
+ * See the License for the specific language governing permissions and
22
+ * limitations under the License.
23
+ */
24
+ /**
25
+ * Checks if a given string is a valid IPv4 address.
26
+ *
27
+ * @param {string} ipv4Address - The string to be checked.
28
+ * @returns {boolean} - Returns true if the string is a valid IPv4 address, otherwise returns false.
29
+ */
1
30
  export function isValidIpv4Address(ipv4Address) {
2
31
  const ipv4Regex = /^(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/;
3
32
  return ipv4Regex.test(ipv4Address);
4
33
  }
34
+ /**
35
+ * Checks if a value is a valid number within the specified range.
36
+ *
37
+ * @param {any} value - The value to be checked.
38
+ * @param {number} min - The minimum value allowed (optional).
39
+ * @param {number} max - The maximum value allowed (optional).
40
+ * @returns {value is number} Returns true if the value is a valid number within the specified range, otherwise false.
41
+ */
42
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
5
43
  export function isValidNumber(value, min, max) {
6
44
  if (value === undefined || value === null || typeof value !== 'number' || Number.isNaN(value) || !Number.isFinite(value))
7
45
  return false;
@@ -11,9 +49,25 @@ export function isValidNumber(value, min, max) {
11
49
  return false;
12
50
  return true;
13
51
  }
52
+ /**
53
+ * Checks if a value is a valid boolean.
54
+ *
55
+ * @param {any} value - The value to be checked.
56
+ * @returns {value is boolean} `true` if the value is a valid boolean, `false` otherwise.
57
+ */
58
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
14
59
  export function isValidBoolean(value) {
15
60
  return value !== undefined && value !== null && typeof value === 'boolean';
16
61
  }
62
+ /**
63
+ * Checks if a value is a valid string.
64
+ *
65
+ * @param {any} value - The value to be checked.
66
+ * @param {number} minLength - The min string length (optional).
67
+ * @param {number} maxLength - The max string length (optional).
68
+ * @returns {value is string} A boolean indicating whether the value is a valid string.
69
+ */
70
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
17
71
  export function isValidString(value, minLength, maxLength) {
18
72
  if (value === undefined || value === null || typeof value !== 'string')
19
73
  return false;
@@ -23,9 +77,25 @@ export function isValidString(value, minLength, maxLength) {
23
77
  return false;
24
78
  return true;
25
79
  }
80
+ /**
81
+ * Checks if a value is a valid RegExp.
82
+ *
83
+ * @param {any} value - The value to be checked.
84
+ * @returns {value is RegExp} A boolean indicating whether the value is a valid RegExp.
85
+ */
86
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
26
87
  export function isValidRegExp(value) {
27
88
  return value !== undefined && value !== null && value instanceof RegExp;
28
89
  }
90
+ /**
91
+ * Checks if a value is a valid object.
92
+ *
93
+ * @param {any} value - The value to be checked.
94
+ * @param {number} minLength - The min number of keys (optional).
95
+ * @param {number} maxLength - The max number of keys (optional).
96
+ * @returns {value is object} A boolean indicating whether the value is a valid object.
97
+ */
98
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
29
99
  export function isValidObject(value, minLength, maxLength) {
30
100
  if (value === undefined || value === null || typeof value !== 'object' || Array.isArray(value))
31
101
  return false;
@@ -36,6 +106,15 @@ export function isValidObject(value, minLength, maxLength) {
36
106
  return false;
37
107
  return true;
38
108
  }
109
+ /**
110
+ * Checks if a value is a valid array.
111
+ *
112
+ * @param {any} value - The value to be checked.
113
+ * @param {number} minLength - The min number of elements (optional).
114
+ * @param {number} maxLength - The max number of elements (optional).
115
+ * @returns {value is unknown[]} A boolean indicating whether the value is a valid array.
116
+ */
117
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
39
118
  export function isValidArray(value, minLength, maxLength) {
40
119
  if (value === undefined || value === null || !Array.isArray(value))
41
120
  return false;
@@ -45,12 +124,33 @@ export function isValidArray(value, minLength, maxLength) {
45
124
  return false;
46
125
  return true;
47
126
  }
127
+ /**
128
+ * Checks if the given value is null.
129
+ *
130
+ * @param {any} value - The value to check.
131
+ * @returns {value is null} `true` if the value is null, `false` otherwise.
132
+ */
133
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
48
134
  export function isValidNull(value) {
49
135
  return value === null;
50
136
  }
137
+ /**
138
+ * Checks if a value is undefined.
139
+ *
140
+ * @param {any} value - The value to check.
141
+ * @returns {value is undefined} `true` if the value is undefined, `false` otherwise.
142
+ */
143
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
51
144
  export function isValidUndefined(value) {
52
145
  return value === undefined;
53
146
  }
147
+ /**
148
+ * Converts a semantic version string like "6.11.0-1011-raspi" to a numeric version code like 61100.
149
+ * Format: major * 10000 + minor * 100 + patch
150
+ *
151
+ * @param {string} versionString The version string to parse
152
+ * @returns {number | undefined} A numeric version code or undefined if parsing fails
153
+ */
54
154
  export function parseVersionString(versionString) {
55
155
  if (!isValidString(versionString))
56
156
  return undefined;
@@ -67,3 +167,4 @@ export function parseVersionString(versionString) {
67
167
  }
68
168
  return major * 10000 + minor * 100 + patch;
69
169
  }
170
+ //# sourceMappingURL=isvalid.js.map