pragma-core
Advanced tools
Comparing version 2021.3.0-1 to 2022.2.5-3
@@ -22,1 +22,38 @@ | ||
} | ||
/** | ||
* Split a camel case string into individual words. | ||
* @param {string} word Word to split | ||
* @param {boolean} capitalise Uppercase first letter (default: true) | ||
* @param {string} ignoreFromChar Ignore character and subseqent string | ||
* @returns {string|*} | ||
*/ | ||
export function splitWord(word, capitalise = true, ignoreFromChar = null) { | ||
if (word == null) | ||
return word; | ||
/** Ignore character and subseqent string*/ | ||
if (ignoreFromChar != null && ignoreFromChar.length > 0 && word.includes(ignoreFromChar)) { | ||
word = word.split(ignoreFromChar)[0]; | ||
} | ||
/** Uppercase first letter */ | ||
if (capitalise === true) { | ||
word = `${word.charAt(0).toUpperCase()}${word.slice(1)}`; | ||
} | ||
/** Define expression to identify words */ | ||
const expression = /(^[a-z]|[A-Z0-9])[a-z]*/g; | ||
const matches = word.match(expression); | ||
if (matches == null) | ||
return word; | ||
const result = []; | ||
for(const match of matches) { | ||
match.length > 1 ? result.push( ` ${match}`) : result.push(match); | ||
} | ||
return result.join("").trim(); | ||
} |
{ | ||
"name": "pragma-core", | ||
"version": "2021.3.0-1", | ||
"version": "2022.2.5-3", | ||
"description": "The purpose of this module is to provide classes and utility functions that can be reused by the various other pragma modules.", | ||
@@ -27,15 +27,6 @@ "main": "commonjs/src/index.js", | ||
"devDependencies": { | ||
"chai": "^3.5.0", | ||
"glob": "^7.1.3", | ||
"istanbul": "^0.4.5", | ||
"mkdirp": "^0.5.1", | ||
"mocha": "^6.1.4", | ||
"mocha-teamcity-reporter": "^2.5.1", | ||
"nyc": "^14.0.0", | ||
"pragma-testing": "^1.0.6", | ||
"puppeteer": "^1.11.0", | ||
"puppeteer-to-istanbul": "^1.2.2", | ||
"sinon": "^2.4.1", | ||
"local-web-server": "2.6.1" | ||
"pragma-testing": "2022.4.0-1" | ||
} | ||
} |
8542
3
8
181