pragma-core
Advanced tools
Comparing version 2022.4.0-4 to 2022.4.0-5
@@ -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": "2022.4.0-4", | ||
"version": "2022.4.0-5", | ||
"description": "The purpose of this module is to provide classes and utility functions that can be reused by the various other pragma modules.", | ||
@@ -5,0 +5,0 @@ "main": "commonjs/src/index.js", |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
7739
162
1