@directus/format-title
Advanced tools
Comparing version
@@ -193,9 +193,2 @@ var prepositions = [ | ||
/** | ||
* Convert prepositions and conjunctions to lowercase | ||
* and special-case cased words | ||
* | ||
* @param {String} str String to process | ||
* @returns {String} str Processed string | ||
*/ | ||
function handleSpecialWords(str, index, words) { | ||
@@ -224,16 +217,5 @@ var lowercaseStr = str.toLowerCase(); | ||
} | ||
/** | ||
* Add a space to the accumulator and add the string | ||
* | ||
* @param {String} acc The accumulator | ||
* @param {String} str The string to paste after the acc value | ||
* @returns {String} New accumulator | ||
*/ | ||
function combine(acc, str) { | ||
return acc + " " + str; | ||
} | ||
/** | ||
* Capitalizes the first letter in the word | ||
* @param word Word to capitalize | ||
*/ | ||
function capitalize(word) { | ||
@@ -248,17 +230,5 @@ return word.charAt(0).toUpperCase() + word.substring(1); | ||
} | ||
/** | ||
* Formats a string to a "pretty" output | ||
* | ||
* @param {String} title The title to format | ||
* @param {RegExp} separator=/|s|-|_/g | ||
* @returns {String} The title formatted pretty | ||
* @example | ||
* | ||
* const safeName = 'comment_metadata'; | ||
* | ||
* const prettyName = formatTitle(safeName); | ||
* // => 'Comment Metadata' | ||
*/ | ||
function formatTitle(title, separator) { | ||
if (separator === void 0) { separator = /\s|-|_/g; } | ||
if (!separator) | ||
separator = new RegExp('/\s|-|_| ', 'g'); | ||
return decamelize(title) | ||
@@ -265,0 +235,0 @@ .split(separator) |
@@ -199,9 +199,2 @@ (function (global, factory) { | ||
/** | ||
* Convert prepositions and conjunctions to lowercase | ||
* and special-case cased words | ||
* | ||
* @param {String} str String to process | ||
* @returns {String} str Processed string | ||
*/ | ||
function handleSpecialWords(str, index, words) { | ||
@@ -230,16 +223,5 @@ var lowercaseStr = str.toLowerCase(); | ||
} | ||
/** | ||
* Add a space to the accumulator and add the string | ||
* | ||
* @param {String} acc The accumulator | ||
* @param {String} str The string to paste after the acc value | ||
* @returns {String} New accumulator | ||
*/ | ||
function combine(acc, str) { | ||
return acc + " " + str; | ||
} | ||
/** | ||
* Capitalizes the first letter in the word | ||
* @param word Word to capitalize | ||
*/ | ||
function capitalize(word) { | ||
@@ -254,17 +236,5 @@ return word.charAt(0).toUpperCase() + word.substring(1); | ||
} | ||
/** | ||
* Formats a string to a "pretty" output | ||
* | ||
* @param {String} title The title to format | ||
* @param {RegExp} separator=/|s|-|_/g | ||
* @returns {String} The title formatted pretty | ||
* @example | ||
* | ||
* const safeName = 'comment_metadata'; | ||
* | ||
* const prettyName = formatTitle(safeName); | ||
* // => 'Comment Metadata' | ||
*/ | ||
function formatTitle(title, separator) { | ||
if (separator === void 0) { separator = /\s|-|_/g; } | ||
if (!separator) | ||
separator = new RegExp('/\s|-|_| ', 'g'); | ||
return decamelize(title) | ||
@@ -271,0 +241,0 @@ .split(separator) |
@@ -7,9 +7,2 @@ "use strict"; | ||
var special_case_1 = require("./special-case"); | ||
/** | ||
* Convert prepositions and conjunctions to lowercase | ||
* and special-case cased words | ||
* | ||
* @param {String} str String to process | ||
* @returns {String} str Processed string | ||
*/ | ||
function handleSpecialWords(str, index, words) { | ||
@@ -38,16 +31,5 @@ var lowercaseStr = str.toLowerCase(); | ||
} | ||
/** | ||
* Add a space to the accumulator and add the string | ||
* | ||
* @param {String} acc The accumulator | ||
* @param {String} str The string to paste after the acc value | ||
* @returns {String} New accumulator | ||
*/ | ||
function combine(acc, str) { | ||
return acc + " " + str; | ||
} | ||
/** | ||
* Capitalizes the first letter in the word | ||
* @param word Word to capitalize | ||
*/ | ||
function capitalize(word) { | ||
@@ -62,17 +44,5 @@ return word.charAt(0).toUpperCase() + word.substring(1); | ||
} | ||
/** | ||
* Formats a string to a "pretty" output | ||
* | ||
* @param {String} title The title to format | ||
* @param {RegExp} separator=/|s|-|_/g | ||
* @returns {String} The title formatted pretty | ||
* @example | ||
* | ||
* const safeName = 'comment_metadata'; | ||
* | ||
* const prettyName = formatTitle(safeName); | ||
* // => 'Comment Metadata' | ||
*/ | ||
function formatTitle(title, separator) { | ||
if (separator === void 0) { separator = /\s|-|_/g; } | ||
if (!separator) | ||
separator = new RegExp('/\s|-|_| ', 'g'); | ||
return decamelize(title) | ||
@@ -79,0 +49,0 @@ .split(separator) |
@@ -1,14 +0,1 @@ | ||
/** | ||
* Formats a string to a "pretty" output | ||
* | ||
* @param {String} title The title to format | ||
* @param {RegExp} separator=/|s|-|_/g | ||
* @returns {String} The title formatted pretty | ||
* @example | ||
* | ||
* const safeName = 'comment_metadata'; | ||
* | ||
* const prettyName = formatTitle(safeName); | ||
* // => 'Comment Metadata' | ||
*/ | ||
export default function formatTitle(title: string, separator?: RegExp): string; |
{ | ||
"name": "@directus/format-title", | ||
"version": "3.0.0", | ||
"version": "3.1.0", | ||
"description": "Custom string formatter that converts any string into [Title Case](http://www.grammar-monster.com/lessons/capital_letters_title_case.htm)", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
-100%37785
-10.14%730
-12.36%