MCPcopy Create free account
hub / github.com/32comic/image2pixel-web / convertPerlerCodeMap

Function convertPerlerCodeMap

scripts/convert-bead-palettes.js:178–198  ·  view source on GitHub ↗
(codeMap)

Source from the content-addressed store, hash-verified

176}
177
178function convertPerlerCodeMap(codeMap) {
179 const newCodeMap = {};
180 let unmapped = 0;
181 for (const [key, sku] of Object.entries(codeMap)) {
182 const pNumber = PERLER_SKU_TO_PNUMBER[sku];
183 if (pNumber) {
184 newCodeMap[key] = pNumber;
185 } else {
186 // Fallback: try to extract a short code
187 const match = sku.match(/(\d+)$/);
188 const fallback = match ? match[1] : sku;
189 console.warn(` No P-number mapping for SKU ${sku}, using fallback "${fallback}"`);
190 newCodeMap[key] = fallback;
191 unmapped++;
192 }
193 }
194 if (unmapped > 0) {
195 console.warn(` ${unmapped} colors had no P-number mapping`);
196 }
197 return newCodeMap;
198}
199
200// Process each brand
201for (const brand of BRANDS) {

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected