🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
Book a DemoInstallSign in
Socket

@directus/format-title

Package Overview
Dependencies
Maintainers
2
Versions
166
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@directus/format-title - npm Package Compare versions

Comparing version

to
9.15.0

dist/constants/acronyms.d.ts

214

dist/format-title.bundler.js

@@ -1,92 +0,11 @@

var prepositions = [
'about',
'above',
'across',
'after',
'against',
'along',
'among',
'around',
'at',
'because of',
'before',
'behind',
'below',
'beneath',
'beside',
'besides',
'between',
'beyond',
'but',
'by',
'concerning',
'despite',
'down',
'during',
'except',
'excepting',
'for',
'from',
'in',
'in front of',
'inside',
'in spite of',
'instead of',
'into',
'like',
'near',
'of',
'off',
'on',
'onto',
'out',
'outside',
'over',
'past',
'regarding',
'since',
'through',
'throughout',
'to',
'toward',
'under',
'underneath',
'until',
'up',
'upon',
'up to',
'with',
'within',
'without',
'with regard to',
'with respect to',
];
function decamelize(string) {
return string
.replace(/([a-z\d])([A-Z])/g, '$1_$2')
.replace(/([A-Z]+)([A-Z][a-z\d]+)/g, '$1_$2')
.toLowerCase();
}
var conjunctions = [
'and',
'that',
'but',
'or',
'as',
'if',
'when',
'than',
'because',
'while',
'where',
'after',
'so',
'though',
'since',
'until',
'whether',
'before',
'although',
'nor',
'like',
'once',
'unless',
'now',
'except',
];
function capitalize(word) {
return word.charAt(0).toUpperCase() + word.substring(1);
}

@@ -171,2 +90,96 @@ var acronyms = [

var articles = ['a', 'an', 'the'];
var conjunctions = [
'and',
'that',
'but',
'or',
'as',
'if',
'when',
'than',
'because',
'while',
'where',
'after',
'so',
'though',
'since',
'until',
'whether',
'before',
'although',
'nor',
'like',
'once',
'unless',
'now',
'except',
];
var prepositions = [
'about',
'above',
'across',
'after',
'against',
'along',
'among',
'around',
'at',
'because of',
'before',
'behind',
'below',
'beneath',
'beside',
'besides',
'between',
'beyond',
'but',
'by',
'concerning',
'despite',
'down',
'during',
'except',
'excepting',
'for',
'from',
'in',
'in front of',
'inside',
'in spite of',
'instead of',
'into',
'like',
'near',
'of',
'off',
'on',
'onto',
'out',
'outside',
'over',
'past',
'regarding',
'since',
'through',
'throughout',
'to',
'toward',
'under',
'underneath',
'until',
'up',
'upon',
'up to',
'with',
'within',
'without',
'with regard to',
'with respect to',
];
var specialCase = [

@@ -210,2 +223,5 @@ '2FA',

/**
* See https://apastyle.apa.org/style-grammar-guidelines/capitalization/title-case for the rules
*/
function handleSpecialWords(str, index, words) {

@@ -228,2 +244,5 @@ const lowercaseStr = str.toLowerCase();

return str;
// Return the word capitalized if it's 4 characters or more
if (str.length >= 4)
return str;
if (prepositions.includes(lowercaseStr))

@@ -233,16 +252,11 @@ return lowercaseStr;

return lowercaseStr;
if (articles.includes(lowercaseStr))
return lowercaseStr;
return str;
}
function combine(acc, str) {
return `${acc} ${str}`;
}
function capitalize(word) {
return word.charAt(0).toUpperCase() + word.substring(1);
}
function decamelize(string) {
return string
.replace(/([a-z\d])([A-Z])/g, '$1_$2')
.replace(/([A-Z]+)([A-Z][a-z\d]+)/g, '$1_$2')
.toLowerCase();
}
function formatTitle(title, separator) {

@@ -254,3 +268,3 @@ if (!separator)

export { formatTitle as default };
export { formatTitle as default, formatTitle };
//# sourceMappingURL=format-title.bundler.js.map
'use strict';
var prepositions = [
'about',
'above',
'across',
'after',
'against',
'along',
'among',
'around',
'at',
'because of',
'before',
'behind',
'below',
'beneath',
'beside',
'besides',
'between',
'beyond',
'but',
'by',
'concerning',
'despite',
'down',
'during',
'except',
'excepting',
'for',
'from',
'in',
'in front of',
'inside',
'in spite of',
'instead of',
'into',
'like',
'near',
'of',
'off',
'on',
'onto',
'out',
'outside',
'over',
'past',
'regarding',
'since',
'through',
'throughout',
'to',
'toward',
'under',
'underneath',
'until',
'up',
'upon',
'up to',
'with',
'within',
'without',
'with regard to',
'with respect to',
];
Object.defineProperty(exports, '__esModule', { value: true });
var conjunctions = [
'and',
'that',
'but',
'or',
'as',
'if',
'when',
'than',
'because',
'while',
'where',
'after',
'so',
'though',
'since',
'until',
'whether',
'before',
'although',
'nor',
'like',
'once',
'unless',
'now',
'except',
];
function decamelize(string) {
return string
.replace(/([a-z\d])([A-Z])/g, '$1_$2')
.replace(/([A-Z]+)([A-Z][a-z\d]+)/g, '$1_$2')
.toLowerCase();
}
function capitalize(word) {
return word.charAt(0).toUpperCase() + word.substring(1);
}
var acronyms = [

@@ -173,2 +94,96 @@ '2D',

var articles = ['a', 'an', 'the'];
var conjunctions = [
'and',
'that',
'but',
'or',
'as',
'if',
'when',
'than',
'because',
'while',
'where',
'after',
'so',
'though',
'since',
'until',
'whether',
'before',
'although',
'nor',
'like',
'once',
'unless',
'now',
'except',
];
var prepositions = [
'about',
'above',
'across',
'after',
'against',
'along',
'among',
'around',
'at',
'because of',
'before',
'behind',
'below',
'beneath',
'beside',
'besides',
'between',
'beyond',
'but',
'by',
'concerning',
'despite',
'down',
'during',
'except',
'excepting',
'for',
'from',
'in',
'in front of',
'inside',
'in spite of',
'instead of',
'into',
'like',
'near',
'of',
'off',
'on',
'onto',
'out',
'outside',
'over',
'past',
'regarding',
'since',
'through',
'throughout',
'to',
'toward',
'under',
'underneath',
'until',
'up',
'upon',
'up to',
'with',
'within',
'without',
'with regard to',
'with respect to',
];
var specialCase = [

@@ -212,2 +227,5 @@ '2FA',

/**
* See https://apastyle.apa.org/style-grammar-guidelines/capitalization/title-case for the rules
*/
function handleSpecialWords(str, index, words) {

@@ -230,2 +248,5 @@ const lowercaseStr = str.toLowerCase();

return str;
// Return the word capitalized if it's 4 characters or more
if (str.length >= 4)
return str;
if (prepositions.includes(lowercaseStr))

@@ -235,16 +256,11 @@ return lowercaseStr;

return lowercaseStr;
if (articles.includes(lowercaseStr))
return lowercaseStr;
return str;
}
function combine(acc, str) {
return `${acc} ${str}`;
}
function capitalize(word) {
return word.charAt(0).toUpperCase() + word.substring(1);
}
function decamelize(string) {
return string
.replace(/([a-z\d])([A-Z])/g, '$1_$2')
.replace(/([A-Z]+)([A-Z][a-z\d]+)/g, '$1_$2')
.toLowerCase();
}
function formatTitle(title, separator) {

@@ -256,3 +272,4 @@ if (!separator)

module.exports = formatTitle;
exports["default"] = formatTitle;
exports.formatTitle = formatTitle;
//# sourceMappingURL=format-title.cjs.js.map

@@ -1,2 +0,2 @@

var e=["about","above","across","after","against","along","among","around","at","because of","before","behind","below","beneath","beside","besides","between","beyond","but","by","concerning","despite","down","during","except","excepting","for","from","in","in front of","inside","in spite of","instead of","into","like","near","of","off","on","onto","out","outside","over","past","regarding","since","through","throughout","to","toward","under","underneath","until","up","upon","up to","with","within","without","with regard to","with respect to"],t=["and","that","but","or","as","if","when","than","because","while","where","after","so","though","since","until","whether","before","although","nor","like","once","unless","now","except"],o=["2D","3D","4WD","API","BIOS","CCTV","CC","CCV","CD","CD-ROM","COBOL","CIA","CMS","CSS","CSV","CV","DIY","DVD","DB","DNA","E3","EIN","ESPN","FAQ","FAQs","FTP","FPS","FORTRAN","FBI","HTML","HTTP","ID","IP","ISO","JS","JSON","LASER","M2M","M2MM","M2O","MMORPG","NAFTA","NASA","NDA","O2M","PDF","PHP","POP","RAM","RNGR","ROM","RPG","RTFM","RTS","SCUBA","SITCOM","SKU","SMTP","SQL","SSN","SWAT","TBS","TTL","TV","TNA","UI","URL","USB","UWP","VIP","W3C","WYSIWYG","WWW","WWE","WWF"],n=["2FA","3D","4K","5K","8K","CTA","DateTime","GitHub","HD","IBMid","ID","IDs","iMac","IMAX","iOS","IP","iPad","iPhone","iPod","LDAP","LinkedIn","M2M","M2O","macOS","McDonalds","MySQL","O2M","PDFs","pH","PostgreSQL","SEO","UHD","UUID","XSS","YouTube"];function r(r,i,a){const s=r.toLowerCase(),u=r.toUpperCase();for(const e of n)if(e.toLowerCase()===s)return e;return o.includes(u)?u:0===i||i===a.length-1?r:e.includes(s)||t.includes(s)?s:r}function i(e,t){return`${e} ${t}`}function a(e){return e.charAt(0).toUpperCase()+e.substring(1)}function s(e,t){return t||(t=new RegExp("/s|-|_| ","g")),(o=e,o.replace(/([a-z\d])([A-Z])/g,"$1_$2").replace(/([A-Z]+)([A-Z][a-z\d]+)/g,"$1_$2").toLowerCase()).split(t).map(a).map(r).reduce(i);var o}export{s as default};
function e(e){return e.charAt(0).toUpperCase()+e.substring(1)}var t=["2D","3D","4WD","API","BIOS","CCTV","CC","CCV","CD","CD-ROM","COBOL","CIA","CMS","CSS","CSV","CV","DIY","DVD","DB","DNA","E3","EIN","ESPN","FAQ","FAQs","FTP","FPS","FORTRAN","FBI","HTML","HTTP","ID","IP","ISO","JS","JSON","LASER","M2M","M2MM","M2O","MMORPG","NAFTA","NASA","NDA","O2M","PDF","PHP","POP","RAM","RNGR","ROM","RPG","RTFM","RTS","SCUBA","SITCOM","SKU","SMTP","SQL","SSN","SWAT","TBS","TTL","TV","TNA","UI","URL","USB","UWP","VIP","W3C","WYSIWYG","WWW","WWE","WWF"],n=["a","an","the"],o=["and","that","but","or","as","if","when","than","because","while","where","after","so","though","since","until","whether","before","although","nor","like","once","unless","now","except"],i=["about","above","across","after","against","along","among","around","at","because of","before","behind","below","beneath","beside","besides","between","beyond","but","by","concerning","despite","down","during","except","excepting","for","from","in","in front of","inside","in spite of","instead of","into","like","near","of","off","on","onto","out","outside","over","past","regarding","since","through","throughout","to","toward","under","underneath","until","up","upon","up to","with","within","without","with regard to","with respect to"],r=["2FA","3D","4K","5K","8K","CTA","DateTime","GitHub","HD","IBMid","ID","IDs","iMac","IMAX","iOS","IP","iPad","iPhone","iPod","LDAP","LinkedIn","M2M","M2O","macOS","McDonalds","MySQL","O2M","PDFs","pH","PostgreSQL","SEO","UHD","UUID","XSS","YouTube"];function a(e,a,s){const u=e.toLowerCase(),S=e.toUpperCase();for(const e of r)if(e.toLowerCase()===u)return e;return t.includes(S)?S:0===a||a===s.length-1||e.length>=4?e:i.includes(u)||o.includes(u)||n.includes(u)?u:e}function s(e,t){return`${e} ${t}`}function u(t,n){return n||(n=new RegExp("/s|-|_| ","g")),(o=t,o.replace(/([a-z\d])([A-Z])/g,"$1_$2").replace(/([A-Z]+)([A-Z][a-z\d]+)/g,"$1_$2").toLowerCase()).split(n).map(e).map(a).reduce(s);var o}export{u as default,u as formatTitle};
//# sourceMappingURL=format-title.esm.min.js.map

@@ -1,2 +0,2 @@

var formatTitle=function(){"use strict";var e=["about","above","across","after","against","along","among","around","at","because of","before","behind","below","beneath","beside","besides","between","beyond","but","by","concerning","despite","down","during","except","excepting","for","from","in","in front of","inside","in spite of","instead of","into","like","near","of","off","on","onto","out","outside","over","past","regarding","since","through","throughout","to","toward","under","underneath","until","up","upon","up to","with","within","without","with regard to","with respect to"],t=["and","that","but","or","as","if","when","than","because","while","where","after","so","though","since","until","whether","before","although","nor","like","once","unless","now","except"],n=["2D","3D","4WD","API","BIOS","CCTV","CC","CCV","CD","CD-ROM","COBOL","CIA","CMS","CSS","CSV","CV","DIY","DVD","DB","DNA","E3","EIN","ESPN","FAQ","FAQs","FTP","FPS","FORTRAN","FBI","HTML","HTTP","ID","IP","ISO","JS","JSON","LASER","M2M","M2MM","M2O","MMORPG","NAFTA","NASA","NDA","O2M","PDF","PHP","POP","RAM","RNGR","ROM","RPG","RTFM","RTS","SCUBA","SITCOM","SKU","SMTP","SQL","SSN","SWAT","TBS","TTL","TV","TNA","UI","URL","USB","UWP","VIP","W3C","WYSIWYG","WWW","WWE","WWF"],o=["2FA","3D","4K","5K","8K","CTA","DateTime","GitHub","HD","IBMid","ID","IDs","iMac","IMAX","iOS","IP","iPad","iPhone","iPod","LDAP","LinkedIn","M2M","M2O","macOS","McDonalds","MySQL","O2M","PDFs","pH","PostgreSQL","SEO","UHD","UUID","XSS","YouTube"];function r(r,i,a){for(var u=r.toLowerCase(),s=r.toUpperCase(),c=0,S=o;c<S.length;c++){var d=S[c];if(d.toLowerCase()===u)return d}return n.includes(s)?s:0===i||i===a.length-1?r:e.includes(u)||t.includes(u)?u:r}function i(e,t){return"".concat(e," ").concat(t)}function a(e){return e.charAt(0).toUpperCase()+e.substring(1)}return function(e,t){return t||(t=new RegExp("/s|-|_| ","g")),(n=e,n.replace(/([a-z\d])([A-Z])/g,"$1_$2").replace(/([A-Z]+)([A-Z][a-z\d]+)/g,"$1_$2").toLowerCase()).split(t).map(a).map(r).reduce(i);var n}}();
var formatTitle=function(e){"use strict";function t(e){return e.charAt(0).toUpperCase()+e.substring(1)}var n=["2D","3D","4WD","API","BIOS","CCTV","CC","CCV","CD","CD-ROM","COBOL","CIA","CMS","CSS","CSV","CV","DIY","DVD","DB","DNA","E3","EIN","ESPN","FAQ","FAQs","FTP","FPS","FORTRAN","FBI","HTML","HTTP","ID","IP","ISO","JS","JSON","LASER","M2M","M2MM","M2O","MMORPG","NAFTA","NASA","NDA","O2M","PDF","PHP","POP","RAM","RNGR","ROM","RPG","RTFM","RTS","SCUBA","SITCOM","SKU","SMTP","SQL","SSN","SWAT","TBS","TTL","TV","TNA","UI","URL","USB","UWP","VIP","W3C","WYSIWYG","WWW","WWE","WWF"],o=["a","an","the"],r=["and","that","but","or","as","if","when","than","because","while","where","after","so","though","since","until","whether","before","although","nor","like","once","unless","now","except"],i=["about","above","across","after","against","along","among","around","at","because of","before","behind","below","beneath","beside","besides","between","beyond","but","by","concerning","despite","down","during","except","excepting","for","from","in","in front of","inside","in spite of","instead of","into","like","near","of","off","on","onto","out","outside","over","past","regarding","since","through","throughout","to","toward","under","underneath","until","up","upon","up to","with","within","without","with regard to","with respect to"],a=["2FA","3D","4K","5K","8K","CTA","DateTime","GitHub","HD","IBMid","ID","IDs","iMac","IMAX","iOS","IP","iPad","iPhone","iPod","LDAP","LinkedIn","M2M","M2O","macOS","McDonalds","MySQL","O2M","PDFs","pH","PostgreSQL","SEO","UHD","UUID","XSS","YouTube"];function u(e,t,u){const s=e.toLowerCase(),c=e.toUpperCase();for(const e of a)if(e.toLowerCase()===s)return e;return n.includes(c)?c:0===t||t===u.length-1||e.length>=4?e:i.includes(s)||r.includes(s)||o.includes(s)?s:e}function s(e,t){return`${e} ${t}`}function c(e,n){return n||(n=new RegExp("/s|-|_| ","g")),(o=e,o.replace(/([a-z\d])([A-Z])/g,"$1_$2").replace(/([A-Z]+)([A-Z][a-z\d]+)/g,"$1_$2").toLowerCase()).split(n).map(t).map(u).reduce(s);var o}return e.default=c,e.formatTitle=c,Object.defineProperty(e,"__esModule",{value:!0}),e}({});
//# sourceMappingURL=format-title.global.min.js.map
declare function formatTitle(title: string, separator?: RegExp): string;
export { formatTitle as default };
export { formatTitle as default, formatTitle };
{
"name": "@directus/format-title",
"version": "9.14.1",
"description": "Custom string formatter that converts any string into [Title Case](http://www.grammar-monster.com/lessons/capital_letters_title_case.htm)",
"keywords": [
"title-case",
"title",
"case",
"directus",
"format",
"string",
"articles",
"conjunctions",
"prepositions"
],
"main": "dist/format-title.cjs.js",
"exports": {
".": {
"import": {
"node": "./index.mjs",
"default": "./dist/format-title.bundler.js"
},
"require": "./dist/format-title.cjs.js"
},
"./package.json": "./package.json"
},
"module": "dist/format-title.bundler.js",
"unpkg": "dist/format-title.esm.min.js",
"types": "dist/index.d.ts",
"files": [
"dist",
"index.mjs"
],
"author": "rijkvanzanten <rijkvanzanten@me.com>",
"repository": {
"type": "git",
"url": "git+https://github.com/directus/directus.git"
},
"license": "MIT",
"engines": {
"node": ">=6.0.0"
},
"scripts": {
"prebuild": "rimraf dist",
"build": "rollup -c",
"dev": "rollup -c -w"
},
"devDependencies": {
"@rollup/plugin-commonjs": "21.0.1",
"@rollup/plugin-json": "4.1.0",
"@rollup/plugin-node-resolve": "13.1.3",
"rimraf": "3.0.2",
"rollup": "2.67.3",
"rollup-plugin-dts": "4.1.0",
"rollup-plugin-sourcemaps": "0.6.3",
"rollup-plugin-terser": "7.0.2",
"rollup-plugin-typescript2": "0.31.2",
"typescript": "4.5.2"
},
"gitHead": "398839be6e3aff81e20eff349ca9f60557096f03"
}
"name": "@directus/format-title",
"version": "9.15.0",
"description": "Custom string formatter that converts any string into [Title Case](http://www.grammar-monster.com/lessons/capital_letters_title_case.htm)",
"keywords": [
"title-case",
"title",
"case",
"directus",
"format",
"string",
"articles",
"conjunctions",
"prepositions"
],
"main": "dist/format-title.cjs.js",
"exports": {
".": {
"import": {
"node": "./index.mjs",
"default": "./dist/format-title.bundler.js"
},
"require": "./dist/format-title.cjs.js"
},
"./package.json": "./package.json"
},
"module": "dist/format-title.bundler.js",
"unpkg": "dist/format-title.esm.min.js",
"types": "dist/index.d.ts",
"files": [
"dist",
"index.mjs"
],
"author": "rijkvanzanten <rijkvanzanten@me.com>",
"repository": {
"type": "git",
"url": "git+https://github.com/directus/directus.git"
},
"license": "MIT",
"engines": {
"node": ">=6.0.0"
},
"devDependencies": {
"@rollup/plugin-commonjs": "21.1.0",
"@rollup/plugin-json": "4.1.0",
"@rollup/plugin-node-resolve": "13.3.0",
"@types/jest": "^28.1.4",
"@typescript-eslint/eslint-plugin": "^5.30.5",
"@typescript-eslint/parser": "^5.30.5",
"eslint": "^8.19.0",
"eslint-config-prettier": "^8.5.0",
"eslint-plugin-prettier": "^4.2.1",
"jest": "^28.1.2",
"lint-staged": "^13.0.3",
"prettier": "^2.7.1",
"rimraf": "3.0.2",
"rollup": "2.76.0",
"rollup-plugin-dts": "4.2.2",
"rollup-plugin-sourcemaps": "0.6.3",
"rollup-plugin-terser": "7.0.2",
"rollup-plugin-typescript2": "0.32.1",
"simple-git-hooks": "^2.8.0",
"ts-jest": "^28.0.5",
"typescript": "4.5.2"
},
"simple-git-hooks": {
"pre-commit": "npx lint-staged"
},
"lint-staged": {
"*.{js,ts}": "eslint --fix"
},
"gitHead": "24621f3934dc77eb23441331040ed13c676ceffd",
"scripts": {
"prebuild": "rimraf dist",
"build": "rollup -c",
"dev": "rollup -c -w",
"lint": "eslint src",
"test": "jest --coverage",
"test:watch": "jest --coverage --watchAll"
}
}
## Title Formatter
Custom string formatter that converts any string into
[Title Case](http://www.grammar-monster.com/lessons/capital_letters_title_case.htm)
[Title Case](https://apastyle.apa.org/style-grammar-guidelines/capitalization/title-case) for the rules

@@ -12,3 +12,3 @@ This package converts any string into title case. This means only using capital letters for the principal words.

| `snowWhiteAndTheSevenDwarfs` | Snow White and the Seven Dwarfs |
| `NewcastleUponTyne` | Newcastle upon Tyne |
| `NewcastleUponTyne` | Newcastle Upon Tyne |
| `brighton_on_sea` | Brighton on Sea |

@@ -15,0 +15,0 @@ | `apple_releases_new_ipad` | Apple Releases New iPad |

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet