@percy/config
Advanced tools
Comparing version 1.5.1 to 1.6.0
import merge from './merge.js'; | ||
import { getSchema } from '../validate.js'; // Edge case camelizations | ||
const CAMELCASE_MAP = new Map([['css', 'CSS'], ['javascript', 'JavaScript']]); // Converts kebab-cased and snake_cased strings to camelCase. | ||
const CAMELCASE_MAP = new Map([['css', 'CSS'], ['javascript', 'JavaScript']]); // Regular expression that matches words from boundaries or consecutive casing | ||
const KEBAB_SNAKE_REG = /[-_]([^-_]+)/g; | ||
const WORD_REG = /[a-z]{2,}|[A-Z]{2,}|[0-9]{2,}|[^-_\s]+?(?=[A-Z0-9-_\s]|$)/g; // Converts kebab-cased and snake_cased strings to camelCase. | ||
export function camelcase(str) { | ||
if (typeof str !== 'string') return str; | ||
return str.replace(KEBAB_SNAKE_REG, (match, word) => CAMELCASE_MAP.get(word) || word[0].toUpperCase() + word.slice(1)); | ||
return str.match(WORD_REG).reduce((s, w, i) => s + (i ? CAMELCASE_MAP.get(w.toLowerCase()) || w[0].toUpperCase() + w.slice(1).toLowerCase() : w.toLowerCase()), ''); | ||
} // Coverts camelCased and snake_cased strings to kebab-case. | ||
const CAMEL_SNAKE_REG = /([a-z])([A-Z]+)|_([^_]+)/g; | ||
export function kebabcase(str) { | ||
if (typeof str !== 'string') return str; | ||
return Array.from(CAMELCASE_MAP).reduce((str, [word, camel]) => str.replace(camel, `-${word}`), str).replace(CAMEL_SNAKE_REG, (match, p, n, w) => `${p || ''}-${(n || w).toLowerCase()}`); | ||
return Array.from(CAMELCASE_MAP).reduce((str, [word, camel]) => str.replace(camel, `-${word}`), str).match(WORD_REG).join('-').toLowerCase(); | ||
} // Removes undefined empty values and renames kebab-case properties to camelCase. Optionally | ||
@@ -17,0 +17,0 @@ // allows deep merging with options.overrides, converting keys to kebab-case with options.kebab, |
{ | ||
"name": "@percy/config", | ||
"version": "1.5.1", | ||
"version": "1.6.0", | ||
"license": "MIT", | ||
@@ -37,3 +37,3 @@ "repository": { | ||
"dependencies": { | ||
"@percy/logger": "1.5.1", | ||
"@percy/logger": "1.6.0", | ||
"ajv": "^8.6.2", | ||
@@ -46,3 +46,3 @@ "cosmiconfig": "^7.0.0", | ||
}, | ||
"gitHead": "c67c0d482d3da18e529f7bc2e1c219c04e59bbea" | ||
"gitHead": "dd03aec4a68a26425cda3afd10fa142011198b5f" | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33610
709
+ Added@percy/logger@1.6.0(transitive)
- Removed@percy/logger@1.5.1(transitive)
Updated@percy/logger@1.6.0