color-name-list 12.0.0 → 12.2.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.
Files changed (39) hide show
  1. package/.vscode/tasks.json +10 -0
  2. package/README.md +2 -2
  3. package/changes.svg +3 -3
  4. package/dist/colornames.bestof.csv +26 -16
  5. package/dist/colornames.bestof.esm.js +1 -1
  6. package/dist/colornames.bestof.esm.mjs +1 -1
  7. package/dist/colornames.bestof.html +1 -1
  8. package/dist/colornames.bestof.json +1 -1
  9. package/dist/colornames.bestof.min.json +1 -1
  10. package/dist/colornames.bestof.scss +1 -1
  11. package/dist/colornames.bestof.umd.js +1 -1
  12. package/dist/colornames.bestof.xml +78 -38
  13. package/dist/colornames.bestof.yaml +61 -31
  14. package/dist/colornames.csv +36 -97
  15. package/dist/colornames.esm.js +1 -1
  16. package/dist/colornames.esm.mjs +1 -1
  17. package/dist/colornames.html +1 -1
  18. package/dist/colornames.json +1 -1
  19. package/dist/colornames.min.json +1 -1
  20. package/dist/colornames.scss +1 -1
  21. package/dist/colornames.short.csv +13 -15
  22. package/dist/colornames.short.esm.js +1 -1
  23. package/dist/colornames.short.esm.mjs +1 -1
  24. package/dist/colornames.short.html +1 -1
  25. package/dist/colornames.short.json +1 -1
  26. package/dist/colornames.short.min.json +1 -1
  27. package/dist/colornames.short.scss +1 -1
  28. package/dist/colornames.short.umd.js +1 -1
  29. package/dist/colornames.short.xml +32 -40
  30. package/dist/colornames.short.yaml +26 -32
  31. package/dist/colornames.umd.js +1 -1
  32. package/dist/colornames.xml +88 -332
  33. package/dist/colornames.yaml +68 -251
  34. package/dist/history.json +1 -1
  35. package/package.json +1 -1
  36. package/scripts/lib.js +24 -1
  37. package/src/colornames.csv +38 -99
  38. package/tests/duplicate-plurals-allowlist.json +7 -0
  39. package/tests/duplicates.test.js +2 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "color-name-list",
3
- "version": "12.0.0",
3
+ "version": "12.2.0",
4
4
  "description": "long list of color names",
5
5
  "main": "dist/colornames.json",
6
6
  "browser": "dist/colornames.umd.js",
package/scripts/lib.js CHANGED
@@ -131,7 +131,7 @@ export const normalizeNameForDuplicates = (name) => {
131
131
  * @returns {Array<{norm:string, entries:Array<{name:string, lineNumber?:number}>}>}
132
132
  */
133
133
  export const findNearDuplicateNameConflicts = (items, options = {}) => {
134
- const { allowlist = [] } = options;
134
+ const { allowlist = [], foldPlurals = false, pluralAllowlist = [] } = options;
135
135
 
136
136
  // Normalize allowlist entries so callers can provide raw names or already-normalized keys.
137
137
  const allowSet = new Set(
@@ -148,6 +148,29 @@ export const findNearDuplicateNameConflicts = (items, options = {}) => {
148
148
  byNorm.get(norm).push({ name: item.name, lineNumber: item.lineNumber });
149
149
  }
150
150
 
151
+ // Optional plural folding: merge keys ending in 's' with their singular if present.
152
+ if (foldPlurals) {
153
+ const pluralAllowSet = new Set(
154
+ (Array.isArray(pluralAllowlist) ? pluralAllowlist : [])
155
+ .filter((v) => typeof v === 'string' && v.trim().length)
156
+ .map((v) => normalizeNameForDuplicates(String(v)))
157
+ );
158
+ // We iterate over a snapshot of keys because we'll mutate the map.
159
+ for (const key of Array.from(byNorm.keys())) {
160
+ if (key.length < 4) continue; // avoid over-aggressive folding for tiny words
161
+ if (!key.endsWith('s')) continue;
162
+ if (key.endsWith('ss')) continue; // glass vs glas, moss vs mos, keep
163
+ if (pluralAllowSet.has(key)) continue; // explicit allow: don't fold
164
+ const singular = key.slice(0, -1);
165
+ if (byNorm.has(singular)) {
166
+ // merge arrays
167
+ const merged = [...byNorm.get(singular), ...byNorm.get(key)];
168
+ byNorm.set(singular, merged);
169
+ byNorm.delete(key);
170
+ }
171
+ }
172
+ }
173
+
151
174
  const conflicts = [];
152
175
  for (const [norm, arr] of byNorm.entries()) {
153
176
  if (allowSet.has(norm)) continue; // explicitly allowed