Skip to content

Commit 98633eb

Browse files
paulr34cursoragent
andcommitted
address review: add examples to extractUcClusterCode and getClusterIdsByUcComponents JSDocs
Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent e6495df commit 98633eb

1 file changed

Lines changed: 24 additions & 5 deletions

File tree

src/util/util.js

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -153,9 +153,20 @@ export function getUcComponents(ucComponentTreeResponse) {
153153
}
154154

155155
/**
156-
* Returns the short cluster code from a UC component id, regardless of
157-
* which prefix format the id uses. Use this when you need to compare ids
158-
* that came from different sources.
156+
* Returns the short cluster code from a UC component id, regardless of which
157+
* prefix format the id uses. Strips everything up to the last '%' and then
158+
* everything up to the last '-', and lowercases the result. Use this when
159+
* you need to compare ids that came from different sources.
160+
*
161+
* Examples:
162+
* "studiocomproot-Zigbee-Cluster_Library-Common-zigbee_basic"
163+
* -> "zigbee_basic"
164+
* "matter:1.0.0-Matter-Clusters-%extension-matter%matter_level_control"
165+
* -> "matter_level_control"
166+
* "%extension-zigbee%zigbee_basic"
167+
* -> "zigbee_basic"
168+
* "zigbee_basic"
169+
* -> "zigbee_basic"
159170
*
160171
* @param {*} id
161172
* @returns {string}
@@ -171,10 +182,18 @@ export function extractUcClusterCode(id) {
171182
}
172183

173184
/**
174-
* Extract a list of cluster ids (in short cluster-code form) from a list of
175-
* UC component objects.
185+
* Returns the short cluster codes (see extractUcClusterCode) for a list of UC
186+
* component objects.
187+
*
188+
* Example:
189+
* input: [
190+
* { id: "studiocomproot-Zigbee-Cluster_Library-Common-zigbee_basic" },
191+
* { id: "matter:1.0.0-Matter-Clusters-%extension-matter%matter_level_control" }
192+
* ]
193+
* output: ["zigbee_basic", "matter_level_control"]
176194
*
177195
* @param {*} ucComponents - an array of UC component objects with `id`
196+
* @returns {string[]}
178197
*/
179198
export function getClusterIdsByUcComponents(ucComponents) {
180199
return ucComponents.map((c) => extractUcClusterCode(c.id))

0 commit comments

Comments
 (0)