-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtitleize.min.js
13 lines (13 loc) · 5.38 KB
/
titleize.min.js
1
2
3
4
5
6
7
8
9
10
11
12
13
var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.SIMPLE_FROUND_POLYFILL=!1;$jscomp.ISOLATE_POLYFILLS=!1;$jscomp.FORCE_POLYFILL_PROMISE=!1;$jscomp.FORCE_POLYFILL_PROMISE_WHEN_NO_UNHANDLED_REJECTION=!1;$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(a,b,c){if(a==Array.prototype||a==Object.prototype)return a;a[b]=c.value;return a};
$jscomp.getGlobal=function(a){a=["object"==typeof globalThis&&globalThis,a,"object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global];for(var b=0;b<a.length;++b){var c=a[b];if(c&&c.Math==Math)return c}throw Error("Cannot find global object");};$jscomp.global=$jscomp.getGlobal(this);$jscomp.IS_SYMBOL_NATIVE="function"===typeof Symbol&&"symbol"===typeof Symbol("x");$jscomp.TRUST_ES6_POLYFILLS=!$jscomp.ISOLATE_POLYFILLS||$jscomp.IS_SYMBOL_NATIVE;$jscomp.polyfills={};
$jscomp.propertyToPolyfillSymbol={};$jscomp.POLYFILL_PREFIX="$jscp$";var $jscomp$lookupPolyfilledValue=function(a,b,c){if(!c||null!=a){c=$jscomp.propertyToPolyfillSymbol[b];if(null==c)return a[b];c=a[c];return void 0!==c?c:a[b]}};$jscomp.polyfill=function(a,b,c,d){b&&($jscomp.ISOLATE_POLYFILLS?$jscomp.polyfillIsolated(a,b,c,d):$jscomp.polyfillUnisolated(a,b,c,d))};
$jscomp.polyfillUnisolated=function(a,b,c,d){c=$jscomp.global;a=a.split(".");for(d=0;d<a.length-1;d++){var e=a[d];if(!(e in c))return;c=c[e]}a=a[a.length-1];d=c[a];b=b(d);b!=d&&null!=b&&$jscomp.defineProperty(c,a,{configurable:!0,writable:!0,value:b})};
$jscomp.polyfillIsolated=function(a,b,c,d){var e=a.split(".");a=1===e.length;d=e[0];d=!a&&d in $jscomp.polyfills?$jscomp.polyfills:$jscomp.global;for(var f=0;f<e.length-1;f++){var g=e[f];if(!(g in d))return;d=d[g]}e=e[e.length-1];c=$jscomp.IS_SYMBOL_NATIVE&&"es6"===c?d[e]:null;b=b(c);null!=b&&(a?$jscomp.defineProperty($jscomp.polyfills,e,{configurable:!0,writable:!0,value:b}):b!==c&&(void 0===$jscomp.propertyToPolyfillSymbol[e]&&(c=1E9*Math.random()>>>0,$jscomp.propertyToPolyfillSymbol[e]=$jscomp.IS_SYMBOL_NATIVE?
$jscomp.global.Symbol(e):$jscomp.POLYFILL_PREFIX+c+"$"+e),$jscomp.defineProperty(d,$jscomp.propertyToPolyfillSymbol[e],{configurable:!0,writable:!0,value:b})))};$jscomp.polyfill("Object.is",function(a){return a?a:function(b,c){return b===c?0!==b||1/b===1/c:b!==b&&c!==c}},"es6","es3");
$jscomp.polyfill("Array.prototype.includes",function(a){return a?a:function(b,c){var d=this;d instanceof String&&(d=String(d));var e=d.length;c=c||0;for(0>c&&(c=Math.max(c+e,0));c<e;c++){var f=d[c];if(f===b||Object.is(f,b))return!0}return!1}},"es7","es3");
$jscomp.checkStringArgs=function(a,b,c){if(null==a)throw new TypeError("The 'this' value for String.prototype."+c+" must not be null or undefined");if(b instanceof RegExp)throw new TypeError("First argument to String.prototype."+c+" must not be a regular expression");return a+""};$jscomp.polyfill("String.prototype.includes",function(a){return a?a:function(b,c){return-1!==$jscomp.checkStringArgs(this,b,"includes").indexOf(b,c||0)}},"es6","es3");
$jscomp.polyfill("String.prototype.replaceAll",function(a){return a?a:function(b,c){if(b instanceof RegExp&&!b.global)throw new TypeError("String.prototype.replaceAll called with a non-global RegExp argument.");return b instanceof RegExp?this.replace(b,c):this.replace(new RegExp(String(b).replace(/([-()\[\]{}+?*.$\^|,:#<!\\])/g,"\\$1").replace(/\x08/g,"\\x08"),"g"),c)}},"es_2021","es3");
var symbols=/[!\u00a1\u2044\u00f7\u2026\u00e6\u00ab\u2264\u03c0\u00f8\u00ac^\u02da\u00a8\u2206\u00a5\u02d9\u2020\u00ae\u00b4\u2211\u0153\u00e5\u00df\u2202\u0192\u2202\u00a9\u02d9~\u00b5\u222b\u221a\u00e7\u2248\u00a7\u00b1"#$%&()*+,./:;<=>\u00bf?@[\\\]^_`{|}~\u2039\u2122\u203a\u20ac\u00a3\u00a2\u221e]/,lowerCasedWords="a an the and but or nor via to on onto per for in into of by at as yet so".split(" "),capitalize=function(a){a=a.toString().split("");a[0]=a[0].toUpperCase();return a.join("")},cleanseSymbolList=
function(a,b){a.split("").forEach(function(c){b=b.replace(new RegExp("[\\"+c+"]","g"),"")});return b},getWordForTitle=function(a,b,c,d){d=void 0===d?{}:d;return a===a.toUpperCase()&&d.keepUpperCaseWords?a:d.keepUpperCaseLetters?capitalize(a):0===b||b==c.length-1?capitalize(a.toLowerCase()):lowerCasedWords.includes(a.toLowerCase())?a.toLowerCase():capitalize(a.toLowerCase())},titleize=function(a,b){b=void 0===b?{}:b;if("string"!==typeof a)try{throw new TypeError("No string was provided");}catch(d){throw console.error(d.name+
":",d.message),d;}else if(!a)try{throw Error("Empty string provided");}catch(d){throw console.error(d.name+":",d.message),d;}var c=b.ignoreSymbols?cleanseSymbolList(b.ignoreSymbols,symbols.toString().slice(2,-2)):symbols.toString().slice(2,-2);c=new RegExp("["+c+"]","gi");b.isSlug&&(a="string"===typeof b.isSlug?a.replaceAll(b.isSlug," "):a.replace(/-/g," "));return a.replace(c,"").split(" ").filter(function(d){if(d)return d}).map(function(d,e,f){for(var g=/([\w+])-([\w+])/gi,h=[];;){var k=g.exec(d);
if(!k)break;h.push(k[k[1]?1:2])}if(b.isSlug)return getWordForTitle(d,e,f,b);if(-1!==d.indexOf("-")&&3<=d.length&&h.length)return d.split("-").map(function(l){return getWordForTitle(l,e,f,b)}).join("-");if(-1!==d.indexOf("-")&&3>d.length||-1!==d.indexOf("-")&&3<=d.length&&!h.length){if(0<d.replace(/-/g,"").length)return getWordForTitle(d.replace(/-/g,""),e,f,b)}else return getWordForTitle(d,e,f,b)}).join(" ").trim()};module.exports=titleize;