@@ -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 */
179198export function getClusterIdsByUcComponents ( ucComponents ) {
180199 return ucComponents . map ( ( c ) => extractUcClusterCode ( c . id ) )
0 commit comments