@stacksjs/strings 0.64.6 → 0.67.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +44 -44
- package/dist/case.d.ts +90 -0
- package/dist/detect-indent.d.ts +6 -0
- package/dist/detect-newline.d.ts +2 -0
- package/dist/helpers.d.ts +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +979 -3
- package/dist/is.d.ts +43 -0
- package/dist/macro.d.ts +37 -0
- package/dist/pluralize.d.ts +20 -0
- package/dist/slug.d.ts +12 -0
- package/dist/sponge-case.d.ts +1 -0
- package/dist/string.d.ts +6 -0
- package/dist/swap-case.d.ts +1 -0
- package/dist/title-case.d.ts +13 -0
- package/dist/utils.d.ts +71 -0
- package/package.json +10 -25
- package/dist/index.js.map +0 -20
- package/src/case.ts +0 -31
- package/src/helpers.ts +0 -3
- package/src/index.ts +0 -2
- package/src/is.ts +0 -170
- package/src/macro.ts +0 -131
- package/src/pluralize.ts +0 -34
- package/src/string.ts +0 -5
- package/src/types.ts +0 -4
- package/src/utils.ts +0 -113
package/dist/index.js
CHANGED
|
@@ -1,4 +1,980 @@
|
|
|
1
|
-
var Ub=Object.create;var{getPrototypeOf:zb,defineProperty:w,getOwnPropertyNames:vb}=Object;var Rb=Object.prototype.hasOwnProperty;var Gb=(b,$,q)=>{q=b!=null?Ub(zb(b)):{};const J=$||!b||!b.__esModule?w(q,"default",{value:b,enumerable:!0}):q;for(let Q of vb(b))if(!Rb.call(J,Q))w(J,Q,{get:()=>b[Q],enumerable:!0});return J};var Hb=(b,$)=>()=>($||b(($={exports:{}}).exports,$),$.exports);var Fb=(b,$)=>{for(var q in $)w(b,q,{get:$[q],enumerable:!0,configurable:!0,set:(J)=>$[q]=()=>J})};var Yb=Hb((c,d)=>{(function(b,$,q){if(typeof c==="object")d.exports=q(),d.exports.default=q();else if(typeof define==="function"&&define.amd)define(q);else $[b]=q()})("slugify",c,function(){var b=JSON.parse(`{"$":"dollar","%":"percent","&":"and","<":"less",">":"greater","|":"or","\xA2":"cent","\xA3":"pound","\xA4":"currency","\xA5":"yen","\xA9":"(c)","\xAA":"a","\xAE":"(r)","\xBA":"o","\xC0":"A","\xC1":"A","\xC2":"A","\xC3":"A","\xC4":"A","\xC5":"A","\xC6":"AE","\xC7":"C","\xC8":"E","\xC9":"E","\xCA":"E","\xCB":"E","\xCC":"I","\xCD":"I","\xCE":"I","\xCF":"I","\xD0":"D","\xD1":"N","\xD2":"O","\xD3":"O","\xD4":"O","\xD5":"O","\xD6":"O","\xD8":"O","\xD9":"U","\xDA":"U","\xDB":"U","\xDC":"U","\xDD":"Y","\xDE":"TH","\xDF":"ss","\xE0":"a","\xE1":"a","\xE2":"a","\xE3":"a","\xE4":"a","\xE5":"a","\xE6":"ae","\xE7":"c","\xE8":"e","\xE9":"e","\xEA":"e","\xEB":"e","\xEC":"i","\xED":"i","\xEE":"i","\xEF":"i","\xF0":"d","\xF1":"n","\xF2":"o","\xF3":"o","\xF4":"o","\xF5":"o","\xF6":"o","\xF8":"o","\xF9":"u","\xFA":"u","\xFB":"u","\xFC":"u","\xFD":"y","\xFE":"th","\xFF":"y","\u0100":"A","\u0101":"a","\u0102":"A","\u0103":"a","\u0104":"A","\u0105":"a","\u0106":"C","\u0107":"c","\u010C":"C","\u010D":"c","\u010E":"D","\u010F":"d","\u0110":"DJ","\u0111":"dj","\u0112":"E","\u0113":"e","\u0116":"E","\u0117":"e","\u0118":"e","\u0119":"e","\u011A":"E","\u011B":"e","\u011E":"G","\u011F":"g","\u0122":"G","\u0123":"g","\u0128":"I","\u0129":"i","\u012A":"i","\u012B":"i","\u012E":"I","\u012F":"i","\u0130":"I","\u0131":"i","\u0136":"k","\u0137":"k","\u013B":"L","\u013C":"l","\u013D":"L","\u013E":"l","\u0141":"L","\u0142":"l","\u0143":"N","\u0144":"n","\u0145":"N","\u0146":"n","\u0147":"N","\u0148":"n","\u014C":"O","\u014D":"o","\u0150":"O","\u0151":"o","\u0152":"OE","\u0153":"oe","\u0154":"R","\u0155":"r","\u0158":"R","\u0159":"r","\u015A":"S","\u015B":"s","\u015E":"S","\u015F":"s","\u0160":"S","\u0161":"s","\u0162":"T","\u0163":"t","\u0164":"T","\u0165":"t","\u0168":"U","\u0169":"u","\u016A":"u","\u016B":"u","\u016E":"U","\u016F":"u","\u0170":"U","\u0171":"u","\u0172":"U","\u0173":"u","\u0174":"W","\u0175":"w","\u0176":"Y","\u0177":"y","\u0178":"Y","\u0179":"Z","\u017A":"z","\u017B":"Z","\u017C":"z","\u017D":"Z","\u017E":"z","\u018F":"E","\u0192":"f","\u01A0":"O","\u01A1":"o","\u01AF":"U","\u01B0":"u","\u01C8":"LJ","\u01C9":"lj","\u01CB":"NJ","\u01CC":"nj","\u0218":"S","\u0219":"s","\u021A":"T","\u021B":"t","\u0259":"e","\u02DA":"o","\u0386":"A","\u0388":"E","\u0389":"H","\u038A":"I","\u038C":"O","\u038E":"Y","\u038F":"W","\u0390":"i","\u0391":"A","\u0392":"B","\u0393":"G","\u0394":"D","\u0395":"E","\u0396":"Z","\u0397":"H","\u0398":"8","\u0399":"I","\u039A":"K","\u039B":"L","\u039C":"M","\u039D":"N","\u039E":"3","\u039F":"O","\u03A0":"P","\u03A1":"R","\u03A3":"S","\u03A4":"T","\u03A5":"Y","\u03A6":"F","\u03A7":"X","\u03A8":"PS","\u03A9":"W","\u03AA":"I","\u03AB":"Y","\u03AC":"a","\u03AD":"e","\u03AE":"h","\u03AF":"i","\u03B0":"y","\u03B1":"a","\u03B2":"b","\u03B3":"g","\u03B4":"d","\u03B5":"e","\u03B6":"z","\u03B7":"h","\u03B8":"8","\u03B9":"i","\u03BA":"k","\u03BB":"l","\u03BC":"m","\u03BD":"n","\u03BE":"3","\u03BF":"o","\u03C0":"p","\u03C1":"r","\u03C2":"s","\u03C3":"s","\u03C4":"t","\u03C5":"y","\u03C6":"f","\u03C7":"x","\u03C8":"ps","\u03C9":"w","\u03CA":"i","\u03CB":"y","\u03CC":"o","\u03CD":"y","\u03CE":"w","\u0401":"Yo","\u0402":"DJ","\u0404":"Ye","\u0406":"I","\u0407":"Yi","\u0408":"J","\u0409":"LJ","\u040A":"NJ","\u040B":"C","\u040F":"DZ","\u0410":"A","\u0411":"B","\u0412":"V","\u0413":"G","\u0414":"D","\u0415":"E","\u0416":"Zh","\u0417":"Z","\u0418":"I","\u0419":"J","\u041A":"K","\u041B":"L","\u041C":"M","\u041D":"N","\u041E":"O","\u041F":"P","\u0420":"R","\u0421":"S","\u0422":"T","\u0423":"U","\u0424":"F","\u0425":"H","\u0426":"C","\u0427":"Ch","\u0428":"Sh","\u0429":"Sh","\u042A":"U","\u042B":"Y","\u042C":"","\u042D":"E","\u042E":"Yu","\u042F":"Ya","\u0430":"a","\u0431":"b","\u0432":"v","\u0433":"g","\u0434":"d","\u0435":"e","\u0436":"zh","\u0437":"z","\u0438":"i","\u0439":"j","\u043A":"k","\u043B":"l","\u043C":"m","\u043D":"n","\u043E":"o","\u043F":"p","\u0440":"r","\u0441":"s","\u0442":"t","\u0443":"u","\u0444":"f","\u0445":"h","\u0446":"c","\u0447":"ch","\u0448":"sh","\u0449":"sh","\u044A":"u","\u044B":"y","\u044C":"","\u044D":"e","\u044E":"yu","\u044F":"ya","\u0451":"yo","\u0452":"dj","\u0454":"ye","\u0456":"i","\u0457":"yi","\u0458":"j","\u0459":"lj","\u045A":"nj","\u045B":"c","\u045D":"u","\u045F":"dz","\u0490":"G","\u0491":"g","\u0492":"GH","\u0493":"gh","\u049A":"KH","\u049B":"kh","\u04A2":"NG","\u04A3":"ng","\u04AE":"UE","\u04AF":"ue","\u04B0":"U","\u04B1":"u","\u04BA":"H","\u04BB":"h","\u04D8":"AE","\u04D9":"ae","\u04E8":"OE","\u04E9":"oe","\u0531":"A","\u0532":"B","\u0533":"G","\u0534":"D","\u0535":"E","\u0536":"Z","\u0537":"E'","\u0538":"Y'","\u0539":"T'","\u053A":"JH","\u053B":"I","\u053C":"L","\u053D":"X","\u053E":"C'","\u053F":"K","\u0540":"H","\u0541":"D'","\u0542":"GH","\u0543":"TW","\u0544":"M","\u0545":"Y","\u0546":"N","\u0547":"SH","\u0549":"CH","\u054A":"P","\u054B":"J","\u054C":"R'","\u054D":"S","\u054E":"V","\u054F":"T","\u0550":"R","\u0551":"C","\u0553":"P'","\u0554":"Q'","\u0555":"O''","\u0556":"F","\u0587":"EV","\u0621":"a","\u0622":"aa","\u0623":"a","\u0624":"u","\u0625":"i","\u0626":"e","\u0627":"a","\u0628":"b","\u0629":"h","\u062A":"t","\u062B":"th","\u062C":"j","\u062D":"h","\u062E":"kh","\u062F":"d","\u0630":"th","\u0631":"r","\u0632":"z","\u0633":"s","\u0634":"sh","\u0635":"s","\u0636":"dh","\u0637":"t","\u0638":"z","\u0639":"a","\u063A":"gh","\u0641":"f","\u0642":"q","\u0643":"k","\u0644":"l","\u0645":"m","\u0646":"n","\u0647":"h","\u0648":"w","\u0649":"a","\u064A":"y","\u064B":"an","\u064C":"on","\u064D":"en","\u064E":"a","\u064F":"u","\u0650":"e","\u0652":"","\u0660":"0","\u0661":"1","\u0662":"2","\u0663":"3","\u0664":"4","\u0665":"5","\u0666":"6","\u0667":"7","\u0668":"8","\u0669":"9","\u067E":"p","\u0686":"ch","\u0698":"zh","\u06A9":"k","\u06AF":"g","\u06CC":"y","\u06F0":"0","\u06F1":"1","\u06F2":"2","\u06F3":"3","\u06F4":"4","\u06F5":"5","\u06F6":"6","\u06F7":"7","\u06F8":"8","\u06F9":"9","\u0E3F":"baht","\u10D0":"a","\u10D1":"b","\u10D2":"g","\u10D3":"d","\u10D4":"e","\u10D5":"v","\u10D6":"z","\u10D7":"t","\u10D8":"i","\u10D9":"k","\u10DA":"l","\u10DB":"m","\u10DC":"n","\u10DD":"o","\u10DE":"p","\u10DF":"zh","\u10E0":"r","\u10E1":"s","\u10E2":"t","\u10E3":"u","\u10E4":"f","\u10E5":"k","\u10E6":"gh","\u10E7":"q","\u10E8":"sh","\u10E9":"ch","\u10EA":"ts","\u10EB":"dz","\u10EC":"ts","\u10ED":"ch","\u10EE":"kh","\u10EF":"j","\u10F0":"h","\u1E62":"S","\u1E63":"s","\u1E80":"W","\u1E81":"w","\u1E82":"W","\u1E83":"w","\u1E84":"W","\u1E85":"w","\u1E9E":"SS","\u1EA0":"A","\u1EA1":"a","\u1EA2":"A","\u1EA3":"a","\u1EA4":"A","\u1EA5":"a","\u1EA6":"A","\u1EA7":"a","\u1EA8":"A","\u1EA9":"a","\u1EAA":"A","\u1EAB":"a","\u1EAC":"A","\u1EAD":"a","\u1EAE":"A","\u1EAF":"a","\u1EB0":"A","\u1EB1":"a","\u1EB2":"A","\u1EB3":"a","\u1EB4":"A","\u1EB5":"a","\u1EB6":"A","\u1EB7":"a","\u1EB8":"E","\u1EB9":"e","\u1EBA":"E","\u1EBB":"e","\u1EBC":"E","\u1EBD":"e","\u1EBE":"E","\u1EBF":"e","\u1EC0":"E","\u1EC1":"e","\u1EC2":"E","\u1EC3":"e","\u1EC4":"E","\u1EC5":"e","\u1EC6":"E","\u1EC7":"e","\u1EC8":"I","\u1EC9":"i","\u1ECA":"I","\u1ECB":"i","\u1ECC":"O","\u1ECD":"o","\u1ECE":"O","\u1ECF":"o","\u1ED0":"O","\u1ED1":"o","\u1ED2":"O","\u1ED3":"o","\u1ED4":"O","\u1ED5":"o","\u1ED6":"O","\u1ED7":"o","\u1ED8":"O","\u1ED9":"o","\u1EDA":"O","\u1EDB":"o","\u1EDC":"O","\u1EDD":"o","\u1EDE":"O","\u1EDF":"o","\u1EE0":"O","\u1EE1":"o","\u1EE2":"O","\u1EE3":"o","\u1EE4":"U","\u1EE5":"u","\u1EE6":"U","\u1EE7":"u","\u1EE8":"U","\u1EE9":"u","\u1EEA":"U","\u1EEB":"u","\u1EEC":"U","\u1EED":"u","\u1EEE":"U","\u1EEF":"u","\u1EF0":"U","\u1EF1":"u","\u1EF2":"Y","\u1EF3":"y","\u1EF4":"Y","\u1EF5":"y","\u1EF6":"Y","\u1EF7":"y","\u1EF8":"Y","\u1EF9":"y","\u2013":"-","\u2018":"'","\u2019":"'","\u201C":"\\"","\u201D":"\\"","\u201E":"\\"","\u2020":"+","\u2022":"*","\u2026":"...","\u20A0":"ecu","\u20A2":"cruzeiro","\u20A3":"french franc","\u20A4":"lira","\u20A5":"mill","\u20A6":"naira","\u20A7":"peseta","\u20A8":"rupee","\u20A9":"won","\u20AA":"new shequel","\u20AB":"dong","\u20AC":"euro","\u20AD":"kip","\u20AE":"tugrik","\u20AF":"drachma","\u20B0":"penny","\u20B1":"peso","\u20B2":"guarani","\u20B3":"austral","\u20B4":"hryvnia","\u20B5":"cedi","\u20B8":"kazakhstani tenge","\u20B9":"indian rupee","\u20BA":"turkish lira","\u20BD":"russian ruble","\u20BF":"bitcoin","\u2120":"sm","\u2122":"tm","\u2202":"d","\u2206":"delta","\u2211":"sum","\u221E":"infinity","\u2665":"love","\u5143":"yuan","\u5186":"yen","\uFDFC":"rial","\uFEF5":"laa","\uFEF7":"laa","\uFEF9":"lai","\uFEFB":"la"}`),$=JSON.parse('{"bg":{"\u0419":"Y","\u0426":"Ts","\u0429":"Sht","\u042A":"A","\u042C":"Y","\u0439":"y","\u0446":"ts","\u0449":"sht","\u044A":"a","\u044C":"y"},"de":{"\xC4":"AE","\xE4":"ae","\xD6":"OE","\xF6":"oe","\xDC":"UE","\xFC":"ue","\xDF":"ss","%":"prozent","&":"und","|":"oder","\u2211":"summe","\u221E":"unendlich","\u2665":"liebe"},"es":{"%":"por ciento","&":"y","<":"menor que",">":"mayor que","|":"o","\xA2":"centavos","\xA3":"libras","\xA4":"moneda","\u20A3":"francos","\u2211":"suma","\u221E":"infinito","\u2665":"amor"},"fr":{"%":"pourcent","&":"et","<":"plus petit",">":"plus grand","|":"ou","\xA2":"centime","\xA3":"livre","\xA4":"devise","\u20A3":"franc","\u2211":"somme","\u221E":"infini","\u2665":"amour"},"pt":{"%":"porcento","&":"e","<":"menor",">":"maior","|":"ou","\xA2":"centavo","\u2211":"soma","\xA3":"libra","\u221E":"infinito","\u2665":"amor"},"uk":{"\u0418":"Y","\u0438":"y","\u0419":"Y","\u0439":"y","\u0426":"Ts","\u0446":"ts","\u0425":"Kh","\u0445":"kh","\u0429":"Shch","\u0449":"shch","\u0413":"H","\u0433":"h"},"vi":{"\u0110":"D","\u0111":"d"},"da":{"\xD8":"OE","\xF8":"oe","\xC5":"AA","\xE5":"aa","%":"procent","&":"og","|":"eller","$":"dollar","<":"mindre end",">":"st\xF8rre end"},"nb":{"&":"og","\xC5":"AA","\xC6":"AE","\xD8":"OE","\xE5":"aa","\xE6":"ae","\xF8":"oe"},"it":{"&":"e"},"nl":{"&":"en"},"sv":{"&":"och","\xC5":"AA","\xC4":"AE","\xD6":"OE","\xE5":"aa","\xE4":"ae","\xF6":"oe"}}');function q(J,Q){if(typeof J!=="string")throw new Error("slugify: string argument expected");Q=typeof Q==="string"?{replacement:Q}:Q||{};var Z=$[Q.locale]||{},G=Q.replacement===void 0?"-":Q.replacement,Y=Q.trim===void 0?!0:Q.trim,H=J.normalize().split("").reduce(function(X,L){var W=Z[L];if(W===void 0)W=b[L];if(W===void 0)W=L;if(W===G)W=" ";return X+W.replace(Q.remove||/[^\w\s$*_+~.()'"!\-:@]+/g,"")},"");if(Q.strict)H=H.replace(/[^A-Za-z0-9\s]/g,"");if(Y)H=H.trim();if(H=H.replace(/\s+/g,G),Q.lower)H=H.toLowerCase();return H}return q.extend=function(J){Object.assign(b,J)},q})});var Ob=Hb((t,e)=>{(function(b,$){if(typeof t==="object"&&typeof e==="object")e.exports=$();else if(typeof define==="function"&&define.amd)define(function(){return $()});else b.pluralize=$()})(t,function(){var b=[],$=[],q={},J={},Q={};function Z(V){if(typeof V==="string")return new RegExp("^"+V+"$","i");return V}function G(V,j){if(V===j)return j;if(V===V.toLowerCase())return j.toLowerCase();if(V===V.toUpperCase())return j.toUpperCase();if(V[0]===V[0].toUpperCase())return j.charAt(0).toUpperCase()+j.substr(1).toLowerCase();return j.toLowerCase()}function Y(V,j){return V.replace(/\$(\d{1,2})/g,function(K,D){return j[D]||""})}function H(V,j){return V.replace(j[0],function(K,D){var O=Y(j[1],arguments);if(K==="")return G(V[D-1],O);return G(K,O)})}function X(V,j,K){if(!V.length||q.hasOwnProperty(V))return j;var D=K.length;while(D--){var O=K[D];if(O[0].test(j))return H(j,O)}return j}function L(V,j,K){return function(D){var O=D.toLowerCase();if(j.hasOwnProperty(O))return G(D,O);if(V.hasOwnProperty(O))return G(D,V[O]);return X(O,D,K)}}function W(V,j,K,D){return function(O){var U=O.toLowerCase();if(j.hasOwnProperty(U))return!0;if(V.hasOwnProperty(U))return!1;return X(U,U,K)===U}}function B(V,j,K){var D=j===1?B.singular(V):B.plural(V);return(K?j+" ":"")+D}return B.plural=L(Q,J,b),B.isPlural=W(Q,J,b),B.singular=L(J,Q,$),B.isSingular=W(J,Q,$),B.addPluralRule=function(V,j){b.push([Z(V),j])},B.addSingularRule=function(V,j){$.push([Z(V),j])},B.addUncountableRule=function(V){if(typeof V==="string"){q[V.toLowerCase()]=!0;return}B.addPluralRule(V,"$0"),B.addSingularRule(V,"$0")},B.addIrregularRule=function(V,j){j=j.toLowerCase(),V=V.toLowerCase(),Q[V]=j,J[j]=V},[["I","we"],["me","us"],["he","they"],["she","they"],["them","them"],["myself","ourselves"],["yourself","yourselves"],["itself","themselves"],["herself","themselves"],["himself","themselves"],["themself","themselves"],["is","are"],["was","were"],["has","have"],["this","these"],["that","those"],["echo","echoes"],["dingo","dingoes"],["volcano","volcanoes"],["tornado","tornadoes"],["torpedo","torpedoes"],["genus","genera"],["viscus","viscera"],["stigma","stigmata"],["stoma","stomata"],["dogma","dogmata"],["lemma","lemmata"],["schema","schemata"],["anathema","anathemata"],["ox","oxen"],["axe","axes"],["die","dice"],["yes","yeses"],["foot","feet"],["eave","eaves"],["goose","geese"],["tooth","teeth"],["quiz","quizzes"],["human","humans"],["proof","proofs"],["carve","carves"],["valve","valves"],["looey","looies"],["thief","thieves"],["groove","grooves"],["pickaxe","pickaxes"],["passerby","passersby"]].forEach(function(V){return B.addIrregularRule(V[0],V[1])}),[[/s?$/i,"s"],[/[^\u0000-\u007F]$/i,"$0"],[/([^aeiou]ese)$/i,"$1"],[/(ax|test)is$/i,"$1es"],[/(alias|[^aou]us|t[lm]as|gas|ris)$/i,"$1es"],[/(e[mn]u)s?$/i,"$1s"],[/([^l]ias|[aeiou]las|[ejzr]as|[iu]am)$/i,"$1"],[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,"$1i"],[/(alumn|alg|vertebr)(?:a|ae)$/i,"$1ae"],[/(seraph|cherub)(?:im)?$/i,"$1im"],[/(her|at|gr)o$/i,"$1oes"],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i,"$1a"],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i,"$1a"],[/sis$/i,"ses"],[/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i,"$1$2ves"],[/([^aeiouy]|qu)y$/i,"$1ies"],[/([^ch][ieo][ln])ey$/i,"$1ies"],[/(x|ch|ss|sh|zz)$/i,"$1es"],[/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i,"$1ices"],[/\b((?:tit)?m|l)(?:ice|ouse)$/i,"$1ice"],[/(pe)(?:rson|ople)$/i,"$1ople"],[/(child)(?:ren)?$/i,"$1ren"],[/eaux$/i,"$0"],[/m[ae]n$/i,"men"],["thou","you"]].forEach(function(V){return B.addPluralRule(V[0],V[1])}),[[/s$/i,""],[/(ss)$/i,"$1"],[/(wi|kni|(?:after|half|high|low|mid|non|night|[^\w]|^)li)ves$/i,"$1fe"],[/(ar|(?:wo|[ae])l|[eo][ao])ves$/i,"$1f"],[/ies$/i,"y"],[/\b([pl]|zomb|(?:neck|cross)?t|coll|faer|food|gen|goon|group|lass|talk|goal|cut)ies$/i,"$1ie"],[/\b(mon|smil)ies$/i,"$1ey"],[/\b((?:tit)?m|l)ice$/i,"$1ouse"],[/(seraph|cherub)im$/i,"$1"],[/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i,"$1"],[/(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i,"$1sis"],[/(movie|twelve|abuse|e[mn]u)s$/i,"$1"],[/(test)(?:is|es)$/i,"$1is"],[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i,"$1us"],[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i,"$1um"],[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i,"$1on"],[/(alumn|alg|vertebr)ae$/i,"$1a"],[/(cod|mur|sil|vert|ind)ices$/i,"$1ex"],[/(matr|append)ices$/i,"$1ix"],[/(pe)(rson|ople)$/i,"$1rson"],[/(child)ren$/i,"$1"],[/(eau)x?$/i,"$1"],[/men$/i,"man"]].forEach(function(V){return B.addSingularRule(V[0],V[1])}),["adulthood","advice","agenda","aid","aircraft","alcohol","ammo","analytics","anime","athletics","audio","bison","blood","bream","buffalo","butter","carp","cash","chassis","chess","clothing","cod","commerce","cooperation","corps","debris","diabetes","digestion","elk","energy","equipment","excretion","expertise","firmware","flounder","fun","gallows","garbage","graffiti","hardware","headquarters","health","herpes","highjinks","homework","housework","information","jeans","justice","kudos","labour","literature","machinery","mackerel","mail","media","mews","moose","music","mud","manga","news","only","personnel","pike","plankton","pliers","police","pollution","premises","rain","research","rice","salmon","scissors","series","sewage","shambles","shrimp","software","species","staff","swine","tennis","traffic","transportation","trout","tuna","wealth","welfare","whiting","wildebeest","wildlife","you",/pok[eé]mon$/i,/[^aeiou]ese$/i,/deer$/i,/fish$/i,/measles$/i,/o[iu]s$/i,/pox$/i,/sheep$/i].forEach(B.addUncountableRule),B})});var Pb={};Fb(Pb,{truncate:()=>o,toString:()=>ob,titleCase:()=>x,template:()=>i,str:()=>ib,split:()=>M,snakeCase:()=>y,slug:()=>s,slash:()=>l,singular:()=>$b,sentenceCase:()=>g,random:()=>r,plural:()=>bb,pathCase:()=>k,pascalCase:()=>I,paramCase:()=>v,noCase:()=>z,lowercase:()=>lb,kebabCase:()=>v,isSingular:()=>Jb,isPlural:()=>qb,ensureSuffix:()=>p,ensurePrefix:()=>u,dotCase:()=>m,detectNewline:()=>C,detectIndent:()=>F,constantCase:()=>S,capitalize:()=>n,capitalCase:()=>T,camelCase:()=>E,addUncountableRule:()=>jb,addSingularRule:()=>Vb,addPluralRule:()=>Qb,addIrregularRule:()=>Zb,Str:()=>Lb});var a=Gb(Yb(),1);function l(b){return b.replace(/\\/g,"/")}function u(b,$){if(!$.startsWith(b))return b+$;return $}function p(b,$){return $.endsWith(b)?$:$+b}function i(b,...$){return b.replace(/{(\d+)}/g,(q,J)=>{const Q=Number(J);return Number.isNaN(Q)?q:$[Q]})}function o(b,$,q="..."){if(b.length<=$)return b;return b.slice(0,$-q.length)+q}function r(b=16,$=Eb){let q="",J=b;const Q=$.length;while(J--)q+=$[Math.random()*Q|0];return q}function s(b,$){if($)return a.default(b,$);return a.default(b,{lower:!0,strict:!0})}function Xb(b,$){const q=new Map;let J=0,Q,Z;for(let G of b.split(/\n/g)){if(!G)continue;let Y,H,X,L,W;const B=G.match(Nb);if(B===null)J=0,Q="";else{if(Y=B[0].length,H=B[1]?"space":"tab",$&&H==="space"&&Y===1)continue;if(H!==Q)J=0;Q=H,X=1,L=0;const V=Y-J;if(J=Y,V===0)X=0,L=1;else{const j=V>0?V:-V;Z=Ab(H,j)}W=q.get(Z),W=W===void 0?[1,0]:[W[0]+X,W[1]+L],q.set(Z,W)}}return q}function Ab(b,$){return(b==="space"?"s":"t")+String($)}function _b(b){const q=b[0]==="s"?"space":"tab",J=Number(b.slice(1));return{type:q,amount:J}}function Cb(b){let $,q=0,J=0;for(let[Q,[Z,G]]of b)if(Z>q||Z===q&&G>J)q=Z,J=G,$=Q;return $}function Mb(b,$){return(b==="space"?" ":"\t").repeat($)}var Nb=/^(?:( )+|\t+)/;function F(b){if(typeof b!=="string")throw new TypeError("Expected a string");let $=Xb(b,!0);if($.size===0)$=Xb(b,!1);const q=Cb($);let J,Q=0,Z="";if(q!==void 0)({type:J,amount:Q}=_b(q)),Z=Mb(J,Q);return{amount:Q,type:J,indent:Z}}function C(b){if(typeof b!=="string")throw new TypeError("Expected a string");const $=b.match(/(?:\r?\n)/g)||[];if($.length===0)return;const q=$.filter((Q)=>Q==="\r\n").length,J=$.length-q;return q>J?"\r\n":"\n"}var Eb="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";function n(b){return b[0]?b[0].toUpperCase()+b.slice(1).toLowerCase():""}function lb(b){return b.toLowerCase()}function M(b){let $=b.trim();$=$.replace(Tb,"$1\0$2").replace(Sb,"$1\0$2"),$=$.replace(kb,"\0");let q=0,J=$.length;while($.charAt(q)==="\0")q++;if(q===J)return[];while($.charAt(J-1)==="\0")J--;return $.slice(q,J).split(/\0/g)}function gb(b){const $=M(b);for(let q=0;q<$.length;q++){const J=$[q],Q=mb.exec(J);if(Q){const Z=Q.index+(Q[1]??Q[2]).length;$.splice(q,1,J.slice(0,Z),J.slice(Z))}}return $}function z(b,$){const[q,J,Q]=R(b,$);return q+J.map(N($?.locale)).join($?.delimiter??" ")+Q}function E(b,$){const[q,J,Q]=R(b,$),Z=N($?.locale),G=A($?.locale),Y=$?.mergeAmbiguousCharacters?h(Z,G):Wb(Z,G);return q+J.map((H,X)=>{if(X===0)return Z(H);return Y(H,X)}).join($?.delimiter??"")+Q}function I(b,$){const[q,J,Q]=R(b,$),Z=N($?.locale),G=A($?.locale),Y=$?.mergeAmbiguousCharacters?h(Z,G):Wb(Z,G);return q+J.map(Y).join($?.delimiter??"")+Q}function T(b,$){const[q,J,Q]=R(b,$),Z=N($?.locale),G=A($?.locale);return q+J.map(h(Z,G)).join($?.delimiter??" ")+Q}function S(b,$){const[q,J,Q]=R(b,$);return q+J.map(A($?.locale)).join($?.delimiter??"_")+Q}function m(b,$){return z(b,{delimiter:".",...$})}function v(b,$){return z(b,{delimiter:"-",...$})}function k(b,$){return z(b,{delimiter:"/",...$})}function g(b,$){const[q,J,Q]=R(b,$),Z=N($?.locale),G=A($?.locale),Y=h(Z,G);return q+J.map((H,X)=>{if(X===0)return Y(H);return Z(H)}).join($?.delimiter??" ")+Q}function y(b,$){return z(b,{delimiter:"_",...$})}function N(b){return b===!1?($)=>$.toLowerCase():($)=>$.toLocaleLowerCase(b)}function A(b){return b===!1?($)=>$.toUpperCase():($)=>$.toLocaleUpperCase(b)}function h(b,$){return(q)=>`${$(q[0])}${b(q.slice(1))}`}function Wb(b,$){return(q,J)=>{const Q=q[0];return(J>0&&Q>="0"&&Q<="9"?"_"+Q:$(Q))+b(q.slice(1))}}function R(b,$={}){const q=$.split??($.separateNumbers?gb:M),J=$.prefixCharacters??"",Q=$.suffixCharacters??"";let Z=0,G=b.length;while(Z<b.length){const Y=b.charAt(Z);if(!J.includes(Y))break;Z++}while(G>Z){const Y=G-1,H=b.charAt(Y);if(!Q.includes(H))break;G=Y}return[b.slice(0,Z),q(b.slice(Z,G)),b.slice(G)]}var Tb=/([\p{Ll}\d])(\p{Lu})/gu,Sb=/(\p{Lu})([\p{Lu}][\p{Ll}])/gu,mb=/(\d)\p{Ll}|(\p{L})\d/u,kb=/[^\p{L}\d]+/giu;function x(b,$={}){const{locale:q=void 0,sentenceCase:J=!1,sentenceTerminators:Q=Db,titleTerminators:Z=db,smallWords:G=ab,wordSeparators:Y=cb}=typeof $==="string"||Array.isArray($)?{locale:$}:$,H=J?Q:Z;let X="",L=!0;for(let W of b.matchAll(yb)){const{1:B,2:V,index:j=0}=W;if(V){X+=V;continue}if(hb.test(B)){const K=B.match(wb);if(K){const[D,O="",U=""]=K;X+=J&&!L?B:Kb(B,O.length,q),L=H.has(U.charAt(0));continue}X+=B,L=H.has(B.charAt(B.length-1))}else{const K=Array.from(B.matchAll(fb));let D=B,O=!1;for(let U=0;U<K.length;U++){const{0:_,index:f=0}=K[U],Bb=B.charAt(f+_.length);if(O=H.has(Bb),L)L=!1;else if(J||xb.test(_))continue;else if(K.length===1){if(G.has(_)){if(j+B.length!==b.length&&!O)continue}}else if(U>0){if(!Y.has(B.charAt(f-1)))continue;if(G.has(_)&&Y.has(Bb))continue}D=Kb(D,f,q)}X+=D,L=O||H.has(B.charAt(B.length-1))}}return X}function Kb(b,$,q){return b.slice(0,$)+b.charAt($).toLocaleUpperCase(q)+b.slice($+1)}var yb=/(\S+)|(.)/g,hb=/[\.#]\p{Alphabetic}/u,xb=/\p{Ll}(?=[\p{Lu}])/u,fb=/\p{Alphabetic}+/gu,wb=/^(\P{Alphabetic})*(?:\p{Alphabetic}\.){2,}(\P{Alphabetic})*$/u,cb=new Set(["\u2014","\u2013","-","\u2015","/"]),Db=new Set([".","!","?"]),db=new Set([...Db,":",'"',"'","\u201D"]),ab=new Set(["a","an","and","as","at","because","but","by","en","for","if","in","neither","nor","of","on","only","or","over","per","so","some","than","that","the","to","up","upon","v","versus","via","vs","when","with","without","yet"]);var P=Gb(Ob(),1),bb=(b,$,q)=>{if($!==void 0&&q)return`${$} ${P.plural(b)}`;return P.plural(b)},$b=(b)=>P.singular(b),qb=(b)=>P.isPlural(b),Jb=(b)=>P.isSingular(b),Qb=(b,$)=>P.addPluralRule(b,$),Vb=(b,$)=>P.addSingularRule(b,$),Zb=(b,$)=>P.addIrregularRule(b,$),jb=(b)=>P.addUncountableRule(b);var Lb={slash(b){return l(b)},ensurePrefix(b,$){return u(b,$)},ensureSuffix(b,$){return p(b,$)},template(b,...$){return i(b,...$)},truncate(b,$,q="..."){return o(b,$,q)},random(b=16){return r(b)},capitalize(b){return n(b)},slug(b){return s(b)},detectIndent(b){return F(b)},detectNewline(b){return C(b)},camelCase(b){return E(b)},capitalCase(b){return T(b)},constantCase(b){return S(b)},dotCase(b){return m(b)},noCase(b){return z(b)},paramCase(b){return v(b)},pascalCase(b){return I(b)},pathCase(b){return k(b)},sentenceCase(b){return g(b)},snakeCase(b){return y(b)},titleCase(b){return x(b)},kebabCase(b){return v(b)},plural(b){return bb(b)},singular(b){return $b(b)},isPlural(b){return qb(b)},isSingular(b){return Jb(b)},addPluralRule(b,$){return Qb(b,$)},addSingularRule(b,$){return Vb(b,$)},addIrregularRule(b,$){return Zb(b,$)},addUncountableRule(b){return jb(b)}},ib=Lb;function ob(b){return Object.prototype.toString.call(b)}export{o as truncate,ob as toString,x as titleCase,i as template,Pb as string,ib as str,M as split,y as snakeCase,s as slug,l as slash,$b as singular,g as sentenceCase,r as random,bb as plural,k as pathCase,I as pascalCase,v as paramCase,z as noCase,lb as lowercase,v as kebabCase,Jb as isSingular,qb as isPlural,p as ensureSuffix,u as ensurePrefix,m as dotCase,C as detectNewline,F as detectIndent,S as constantCase,n as capitalize,T as capitalCase,E as camelCase,jb as addUncountableRule,Vb as addSingularRule,Qb as addPluralRule,Zb as addIrregularRule,Lb as Str};
|
|
1
|
+
// @bun
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __export = (target, all) => {
|
|
4
|
+
for (var name in all)
|
|
5
|
+
__defProp(target, name, {
|
|
6
|
+
get: all[name],
|
|
7
|
+
enumerable: true,
|
|
8
|
+
configurable: true,
|
|
9
|
+
set: (newValue) => all[name] = () => newValue
|
|
10
|
+
});
|
|
11
|
+
};
|
|
2
12
|
|
|
3
|
-
|
|
4
|
-
|
|
13
|
+
// src/string.ts
|
|
14
|
+
var exports_string = {};
|
|
15
|
+
__export(exports_string, {
|
|
16
|
+
urlAlphabet: () => urlAlphabet,
|
|
17
|
+
truncate: () => truncate,
|
|
18
|
+
trainCase: () => trainCase,
|
|
19
|
+
toString: () => toString,
|
|
20
|
+
titleCase: () => titleCase,
|
|
21
|
+
template: () => template,
|
|
22
|
+
swapCase: () => swapCase,
|
|
23
|
+
str: () => str,
|
|
24
|
+
spongeCase: () => spongeCase,
|
|
25
|
+
splitSeparateNumbers: () => splitSeparateNumbers,
|
|
26
|
+
split: () => split,
|
|
27
|
+
snakeCase: () => snakeCase,
|
|
28
|
+
slugify: () => slugify,
|
|
29
|
+
slug: () => slug,
|
|
30
|
+
slash: () => slash,
|
|
31
|
+
singular: () => singular,
|
|
32
|
+
sentenceCase: () => sentenceCase,
|
|
33
|
+
random: () => random,
|
|
34
|
+
pluralize: () => pluralize,
|
|
35
|
+
plural: () => plural,
|
|
36
|
+
pathCase: () => pathCase,
|
|
37
|
+
pascalSnakeCase: () => pascalSnakeCase,
|
|
38
|
+
pascalCase: () => pascalCase,
|
|
39
|
+
noCase: () => noCase,
|
|
40
|
+
lowercase: () => lowercase,
|
|
41
|
+
kebabCase: () => kebabCase,
|
|
42
|
+
extendCharMap: () => extendCharMap,
|
|
43
|
+
ensureSuffix: () => ensureSuffix,
|
|
44
|
+
ensurePrefix: () => ensurePrefix,
|
|
45
|
+
dotCase: () => dotCase,
|
|
46
|
+
detectNewlineGraceful: () => detectNewlineGraceful,
|
|
47
|
+
detectNewline: () => detectNewline,
|
|
48
|
+
detectIndent: () => detectIndent,
|
|
49
|
+
constantCase: () => constantCase,
|
|
50
|
+
capitalize: () => capitalize,
|
|
51
|
+
capitalCase: () => capitalCase,
|
|
52
|
+
camelCase: () => camelCase,
|
|
53
|
+
WORD_SEPARATORS: () => WORD_SEPARATORS,
|
|
54
|
+
TITLE_TERMINATORS: () => TITLE_TERMINATORS,
|
|
55
|
+
Str: () => Str,
|
|
56
|
+
SMALL_WORDS: () => SMALL_WORDS,
|
|
57
|
+
SENTENCE_TERMINATORS: () => SENTENCE_TERMINATORS
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
// src/sponge-case.ts
|
|
61
|
+
function spongeCase(input, locale) {
|
|
62
|
+
let result = "";
|
|
63
|
+
for (const char of input) {
|
|
64
|
+
result += Math.random() > 0.5 ? char.toLocaleUpperCase(locale) : char.toLocaleLowerCase(locale);
|
|
65
|
+
}
|
|
66
|
+
return result;
|
|
67
|
+
}
|
|
68
|
+
// src/swap-case.ts
|
|
69
|
+
function swapCase(input, locale) {
|
|
70
|
+
let result = "";
|
|
71
|
+
for (const char of input) {
|
|
72
|
+
const lower = char.toLocaleLowerCase(locale);
|
|
73
|
+
result += char === lower ? char.toLocaleUpperCase(locale) : lower;
|
|
74
|
+
}
|
|
75
|
+
return result;
|
|
76
|
+
}
|
|
77
|
+
// src/title-case.ts
|
|
78
|
+
var TOKENS = /(\S+)|(.)/g;
|
|
79
|
+
var IS_SPECIAL_CASE = /[.#][\p{L}\p{N}]/u;
|
|
80
|
+
var IS_MANUAL_CASE = /\p{Ll}(?=\p{Lu})/u;
|
|
81
|
+
var ALPHANUMERIC_PATTERN = /[\p{L}\p{N}]+/gu;
|
|
82
|
+
var IS_ACRONYM = /^(\P{L})*(?:\p{L}\.){2,}(\P{L})*$/u;
|
|
83
|
+
var WORD_SEPARATORS = new Set(["\u2014", "\u2013", "-", "\u2015", "/"]);
|
|
84
|
+
var SENTENCE_TERMINATORS = new Set([".", "!", "?"]);
|
|
85
|
+
var TITLE_TERMINATORS = new Set([
|
|
86
|
+
...SENTENCE_TERMINATORS,
|
|
87
|
+
":",
|
|
88
|
+
'"',
|
|
89
|
+
"\'",
|
|
90
|
+
"\u201D"
|
|
91
|
+
]);
|
|
92
|
+
var SMALL_WORDS = new Set([
|
|
93
|
+
"a",
|
|
94
|
+
"an",
|
|
95
|
+
"and",
|
|
96
|
+
"as",
|
|
97
|
+
"at",
|
|
98
|
+
"because",
|
|
99
|
+
"but",
|
|
100
|
+
"by",
|
|
101
|
+
"en",
|
|
102
|
+
"for",
|
|
103
|
+
"if",
|
|
104
|
+
"in",
|
|
105
|
+
"neither",
|
|
106
|
+
"nor",
|
|
107
|
+
"of",
|
|
108
|
+
"on",
|
|
109
|
+
"only",
|
|
110
|
+
"or",
|
|
111
|
+
"over",
|
|
112
|
+
"per",
|
|
113
|
+
"so",
|
|
114
|
+
"some",
|
|
115
|
+
"than",
|
|
116
|
+
"that",
|
|
117
|
+
"the",
|
|
118
|
+
"to",
|
|
119
|
+
"up",
|
|
120
|
+
"upon",
|
|
121
|
+
"v",
|
|
122
|
+
"versus",
|
|
123
|
+
"via",
|
|
124
|
+
"vs",
|
|
125
|
+
"when",
|
|
126
|
+
"with",
|
|
127
|
+
"without",
|
|
128
|
+
"yet"
|
|
129
|
+
]);
|
|
130
|
+
function titleCase(input, options = {}) {
|
|
131
|
+
const {
|
|
132
|
+
locale = undefined,
|
|
133
|
+
sentenceCase = false,
|
|
134
|
+
sentenceTerminators = SENTENCE_TERMINATORS,
|
|
135
|
+
titleTerminators = TITLE_TERMINATORS,
|
|
136
|
+
smallWords = SMALL_WORDS,
|
|
137
|
+
wordSeparators = WORD_SEPARATORS
|
|
138
|
+
} = typeof options === "string" || Array.isArray(options) ? { locale: options } : options;
|
|
139
|
+
const terminators = sentenceCase ? sentenceTerminators : titleTerminators;
|
|
140
|
+
let result = "";
|
|
141
|
+
let isNewSentence = true;
|
|
142
|
+
for (const m of input.matchAll(TOKENS)) {
|
|
143
|
+
const { 1: token, 2: whiteSpace, index = 0 } = m;
|
|
144
|
+
if (whiteSpace) {
|
|
145
|
+
result += whiteSpace;
|
|
146
|
+
continue;
|
|
147
|
+
}
|
|
148
|
+
if (IS_SPECIAL_CASE.test(token)) {
|
|
149
|
+
const acronym = token.match(IS_ACRONYM);
|
|
150
|
+
if (acronym) {
|
|
151
|
+
const [_, prefix = "", suffix = ""] = acronym;
|
|
152
|
+
result += sentenceCase && !isNewSentence ? token : upperAt(token, prefix.length, locale);
|
|
153
|
+
isNewSentence = terminators.has(suffix.charAt(0));
|
|
154
|
+
continue;
|
|
155
|
+
}
|
|
156
|
+
result += token;
|
|
157
|
+
isNewSentence = terminators.has(token.charAt(token.length - 1));
|
|
158
|
+
} else {
|
|
159
|
+
const matches = Array.from(token.matchAll(ALPHANUMERIC_PATTERN));
|
|
160
|
+
let value = token;
|
|
161
|
+
let isSentenceEnd = false;
|
|
162
|
+
for (let i = 0;i < matches.length; i++) {
|
|
163
|
+
const { 0: word, index: wordIndex = 0 } = matches[i];
|
|
164
|
+
const nextChar = token.charAt(wordIndex + word.length);
|
|
165
|
+
isSentenceEnd = terminators.has(nextChar);
|
|
166
|
+
if (isNewSentence) {
|
|
167
|
+
isNewSentence = false;
|
|
168
|
+
} else if (sentenceCase || IS_MANUAL_CASE.test(word)) {
|
|
169
|
+
continue;
|
|
170
|
+
} else if (matches.length === 1) {
|
|
171
|
+
if (smallWords.has(word)) {
|
|
172
|
+
const isFinalToken = index + token.length === input.length;
|
|
173
|
+
if (!isFinalToken && !isSentenceEnd) {
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
}
|
|
177
|
+
} else if (i > 0) {
|
|
178
|
+
if (!wordSeparators.has(token.charAt(wordIndex - 1))) {
|
|
179
|
+
continue;
|
|
180
|
+
}
|
|
181
|
+
if (smallWords.has(word) && wordSeparators.has(nextChar)) {
|
|
182
|
+
continue;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
value = upperAt(value, wordIndex, locale);
|
|
186
|
+
}
|
|
187
|
+
result += value;
|
|
188
|
+
isNewSentence = isSentenceEnd || terminators.has(token.charAt(token.length - 1));
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
return result;
|
|
192
|
+
}
|
|
193
|
+
function upperAt(input, index, locale) {
|
|
194
|
+
return input.slice(0, index) + input.charAt(index).toLocaleUpperCase(locale) + input.slice(index + 1);
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
// src/case.ts
|
|
198
|
+
function capitalize(str) {
|
|
199
|
+
return str[0] ? str[0].toUpperCase() + str.slice(1).toLowerCase() : "";
|
|
200
|
+
}
|
|
201
|
+
function lowercase(str) {
|
|
202
|
+
return str.toLowerCase();
|
|
203
|
+
}
|
|
204
|
+
var SPLIT_LOWER_UPPER_RE = /([\p{Ll}\d])(\p{Lu})/gu;
|
|
205
|
+
var SPLIT_UPPER_UPPER_RE = /(\p{Lu})(\p{Lu}\p{Ll})/gu;
|
|
206
|
+
var SPLIT_SEPARATE_NUMBER_RE = /(\d)\p{Ll}|(\p{L})\d/u;
|
|
207
|
+
var DEFAULT_STRIP_REGEXP = /[^\p{L}\d]+/giu;
|
|
208
|
+
var SPLIT_REPLACE_VALUE = "$1\0$2";
|
|
209
|
+
var DEFAULT_PREFIX_SUFFIX_CHARACTERS = "";
|
|
210
|
+
function split(value) {
|
|
211
|
+
let result = value.trim();
|
|
212
|
+
result = result.replace(SPLIT_LOWER_UPPER_RE, SPLIT_REPLACE_VALUE).replace(SPLIT_UPPER_UPPER_RE, SPLIT_REPLACE_VALUE);
|
|
213
|
+
result = result.replace(DEFAULT_STRIP_REGEXP, "\0");
|
|
214
|
+
let start = 0;
|
|
215
|
+
let end = result.length;
|
|
216
|
+
while (result.charAt(start) === "\0")
|
|
217
|
+
start++;
|
|
218
|
+
if (start === end)
|
|
219
|
+
return [];
|
|
220
|
+
while (result.charAt(end - 1) === "\0")
|
|
221
|
+
end--;
|
|
222
|
+
return result.slice(start, end).split(/\0/g);
|
|
223
|
+
}
|
|
224
|
+
function splitSeparateNumbers(value) {
|
|
225
|
+
const words = split(value);
|
|
226
|
+
for (let i = 0;i < words.length; i++) {
|
|
227
|
+
const word = words[i];
|
|
228
|
+
const match = SPLIT_SEPARATE_NUMBER_RE.exec(word);
|
|
229
|
+
if (match) {
|
|
230
|
+
const offset = match.index + (match[1] ?? match[2]).length;
|
|
231
|
+
words.splice(i, 1, word.slice(0, offset), word.slice(offset));
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
return words;
|
|
235
|
+
}
|
|
236
|
+
function noCase(input, options) {
|
|
237
|
+
const [prefix, words, suffix] = splitPrefixSuffix(input, options);
|
|
238
|
+
return prefix + words.map(lowerFactory(options?.locale)).join(options?.delimiter ?? " ") + suffix;
|
|
239
|
+
}
|
|
240
|
+
function camelCase(input, options) {
|
|
241
|
+
const [prefix, words, suffix] = splitPrefixSuffix(input, options);
|
|
242
|
+
const lower = lowerFactory(options?.locale);
|
|
243
|
+
const upper = upperFactory(options?.locale);
|
|
244
|
+
const transform = options?.mergeAmbiguousCharacters ? capitalCaseTransformFactory(lower, upper) : pascalCaseTransformFactory(lower, upper);
|
|
245
|
+
return prefix + words.map((word, index) => {
|
|
246
|
+
if (index === 0)
|
|
247
|
+
return lower(word);
|
|
248
|
+
return transform(word, index);
|
|
249
|
+
}).join(options?.delimiter ?? "") + suffix;
|
|
250
|
+
}
|
|
251
|
+
function pascalCase(input, options) {
|
|
252
|
+
const [prefix, words, suffix] = splitPrefixSuffix(input, options);
|
|
253
|
+
const lower = lowerFactory(options?.locale);
|
|
254
|
+
const upper = upperFactory(options?.locale);
|
|
255
|
+
const transform = options?.mergeAmbiguousCharacters ? capitalCaseTransformFactory(lower, upper) : pascalCaseTransformFactory(lower, upper);
|
|
256
|
+
return prefix + words.map(transform).join(options?.delimiter ?? "") + suffix;
|
|
257
|
+
}
|
|
258
|
+
function pascalSnakeCase(input, options) {
|
|
259
|
+
return capitalCase(input, { delimiter: "_", ...options });
|
|
260
|
+
}
|
|
261
|
+
function capitalCase(input, options) {
|
|
262
|
+
const [prefix, words, suffix] = splitPrefixSuffix(input, options);
|
|
263
|
+
const lower = lowerFactory(options?.locale);
|
|
264
|
+
const upper = upperFactory(options?.locale);
|
|
265
|
+
return prefix + words.map(capitalCaseTransformFactory(lower, upper)).join(options?.delimiter ?? " ") + suffix;
|
|
266
|
+
}
|
|
267
|
+
function constantCase(input, options) {
|
|
268
|
+
const [prefix, words, suffix] = splitPrefixSuffix(input, options);
|
|
269
|
+
return prefix + words.map(upperFactory(options?.locale)).join(options?.delimiter ?? "_") + suffix;
|
|
270
|
+
}
|
|
271
|
+
function dotCase(input, options) {
|
|
272
|
+
return noCase(input, { delimiter: ".", ...options });
|
|
273
|
+
}
|
|
274
|
+
function kebabCase(input, options) {
|
|
275
|
+
return noCase(input, { delimiter: "-", ...options });
|
|
276
|
+
}
|
|
277
|
+
function pathCase(input, options) {
|
|
278
|
+
return noCase(input, { delimiter: "/", ...options });
|
|
279
|
+
}
|
|
280
|
+
function sentenceCase(input, options) {
|
|
281
|
+
const [prefix, words, suffix] = splitPrefixSuffix(input, options);
|
|
282
|
+
const lower = lowerFactory(options?.locale);
|
|
283
|
+
const upper = upperFactory(options?.locale);
|
|
284
|
+
const transform = capitalCaseTransformFactory(lower, upper);
|
|
285
|
+
return prefix + words.map((word, index) => {
|
|
286
|
+
if (index === 0)
|
|
287
|
+
return transform(word);
|
|
288
|
+
return lower(word);
|
|
289
|
+
}).join(options?.delimiter ?? " ") + suffix;
|
|
290
|
+
}
|
|
291
|
+
function snakeCase(input, options) {
|
|
292
|
+
return noCase(input, { delimiter: "_", ...options });
|
|
293
|
+
}
|
|
294
|
+
function trainCase(input, options) {
|
|
295
|
+
return capitalCase(input, { delimiter: "-", ...options });
|
|
296
|
+
}
|
|
297
|
+
function lowerFactory(locale) {
|
|
298
|
+
return locale === false ? (input) => input.toLowerCase() : (input) => input.toLocaleLowerCase(locale);
|
|
299
|
+
}
|
|
300
|
+
function upperFactory(locale) {
|
|
301
|
+
return locale === false ? (input) => input.toUpperCase() : (input) => input.toLocaleUpperCase(locale);
|
|
302
|
+
}
|
|
303
|
+
function capitalCaseTransformFactory(lower, upper) {
|
|
304
|
+
return (word) => `${upper(word[0])}${lower(word.slice(1))}`;
|
|
305
|
+
}
|
|
306
|
+
function pascalCaseTransformFactory(lower, upper) {
|
|
307
|
+
return (word, index) => {
|
|
308
|
+
const char0 = word[0];
|
|
309
|
+
const initial = index > 0 && char0 >= "0" && char0 <= "9" ? `_${char0}` : upper(char0);
|
|
310
|
+
return initial + lower(word.slice(1));
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
function splitPrefixSuffix(input, options = {}) {
|
|
314
|
+
const splitFn = options.split ?? split;
|
|
315
|
+
const prefixCharacters = options.prefixCharacters ?? DEFAULT_PREFIX_SUFFIX_CHARACTERS;
|
|
316
|
+
const suffixCharacters = options.suffixCharacters ?? DEFAULT_PREFIX_SUFFIX_CHARACTERS;
|
|
317
|
+
let prefixIndex = 0;
|
|
318
|
+
let suffixIndex = input.length;
|
|
319
|
+
while (prefixIndex < input.length) {
|
|
320
|
+
const char = input.charAt(prefixIndex);
|
|
321
|
+
if (!prefixCharacters.includes(char))
|
|
322
|
+
break;
|
|
323
|
+
prefixIndex++;
|
|
324
|
+
}
|
|
325
|
+
while (suffixIndex > prefixIndex) {
|
|
326
|
+
const index = suffixIndex - 1;
|
|
327
|
+
const char = input.charAt(index);
|
|
328
|
+
if (!suffixCharacters.includes(char))
|
|
329
|
+
break;
|
|
330
|
+
suffixIndex = index;
|
|
331
|
+
}
|
|
332
|
+
return [
|
|
333
|
+
input.slice(0, prefixIndex),
|
|
334
|
+
splitFn(input.slice(prefixIndex, suffixIndex)),
|
|
335
|
+
input.slice(suffixIndex)
|
|
336
|
+
];
|
|
337
|
+
}
|
|
338
|
+
// src/helpers.ts
|
|
339
|
+
function toString(v) {
|
|
340
|
+
return Object.prototype.toString.call(v);
|
|
341
|
+
}
|
|
342
|
+
// src/pluralize.ts
|
|
343
|
+
var pluralRules = [];
|
|
344
|
+
var singularRules = [];
|
|
345
|
+
var uncountables = {};
|
|
346
|
+
var irregularPlurals = {};
|
|
347
|
+
var irregularSingles = {};
|
|
348
|
+
function sanitizeRule(rule) {
|
|
349
|
+
return typeof rule === "string" ? new RegExp(`^${rule}\$`, "i") : rule;
|
|
350
|
+
}
|
|
351
|
+
function restoreCase(word, token) {
|
|
352
|
+
if (word === token)
|
|
353
|
+
return token;
|
|
354
|
+
if (word === word.toLowerCase())
|
|
355
|
+
return token.toLowerCase();
|
|
356
|
+
if (word === word.toUpperCase())
|
|
357
|
+
return token.toUpperCase();
|
|
358
|
+
if (word[0] === word[0].toUpperCase()) {
|
|
359
|
+
return token.charAt(0).toUpperCase() + token.slice(1).toLowerCase();
|
|
360
|
+
}
|
|
361
|
+
return token.toLowerCase();
|
|
362
|
+
}
|
|
363
|
+
function interpolate(str, ...args) {
|
|
364
|
+
return str.replace(/\$(\d{1,2})/g, (match, index) => args[Number(index)] || "");
|
|
365
|
+
}
|
|
366
|
+
function replace(word, rule) {
|
|
367
|
+
return word.replace(rule[0], (...matchArgs) => {
|
|
368
|
+
const result = interpolate(rule[1], ...matchArgs);
|
|
369
|
+
if (matchArgs[0] === "") {
|
|
370
|
+
return restoreCase(word[matchArgs[matchArgs.length - 2] - 1], result);
|
|
371
|
+
}
|
|
372
|
+
return restoreCase(matchArgs[0], result);
|
|
373
|
+
});
|
|
374
|
+
}
|
|
375
|
+
function sanitizeWord(token, word, rules) {
|
|
376
|
+
if (!token.length || uncountables[token]) {
|
|
377
|
+
return word;
|
|
378
|
+
}
|
|
379
|
+
for (let i = rules.length - 1;i >= 0; i--) {
|
|
380
|
+
const rule = rules[i];
|
|
381
|
+
if (rule[0].test(word))
|
|
382
|
+
return replace(word, rule);
|
|
383
|
+
}
|
|
384
|
+
return word;
|
|
385
|
+
}
|
|
386
|
+
function replaceWord(replaceMap, keepMap, rules) {
|
|
387
|
+
return (word) => {
|
|
388
|
+
const token = word.toLowerCase();
|
|
389
|
+
if (keepMap[token])
|
|
390
|
+
return restoreCase(word, token);
|
|
391
|
+
if (replaceMap[token])
|
|
392
|
+
return restoreCase(word, replaceMap[token]);
|
|
393
|
+
return sanitizeWord(token, word, rules);
|
|
394
|
+
};
|
|
395
|
+
}
|
|
396
|
+
function checkWord(replaceMap, keepMap, rules) {
|
|
397
|
+
return (word) => {
|
|
398
|
+
const token = word.toLowerCase();
|
|
399
|
+
if (keepMap[token])
|
|
400
|
+
return true;
|
|
401
|
+
if (replaceMap[token])
|
|
402
|
+
return false;
|
|
403
|
+
return sanitizeWord(token, token, rules) === token;
|
|
404
|
+
};
|
|
405
|
+
}
|
|
406
|
+
var pluralize = (word, options = {}) => {
|
|
407
|
+
const { count = 2, inclusive = false } = options;
|
|
408
|
+
if (typeof word !== "string") {
|
|
409
|
+
throw new TypeError("Word must be a string");
|
|
410
|
+
}
|
|
411
|
+
const pluralized = count === 1 ? pluralize.singular(word) : pluralize.plural(word);
|
|
412
|
+
return inclusive ? `${count} ${pluralized}` : pluralized;
|
|
413
|
+
};
|
|
414
|
+
var singular = (word) => {
|
|
415
|
+
return pluralize.singular(word);
|
|
416
|
+
};
|
|
417
|
+
var plural = (word, count = 2) => {
|
|
418
|
+
return pluralize(word, { count });
|
|
419
|
+
};
|
|
420
|
+
pluralize.plural = replaceWord(irregularSingles, irregularPlurals, pluralRules);
|
|
421
|
+
pluralize.isPlural = checkWord(irregularSingles, irregularPlurals, pluralRules);
|
|
422
|
+
pluralize.singular = replaceWord(irregularPlurals, irregularSingles, singularRules);
|
|
423
|
+
pluralize.isSingular = checkWord(irregularPlurals, irregularSingles, singularRules);
|
|
424
|
+
pluralize.addPluralRule = (rule, replacement) => {
|
|
425
|
+
pluralRules.push([sanitizeRule(rule), replacement]);
|
|
426
|
+
};
|
|
427
|
+
pluralize.addSingularRule = (rule, replacement) => {
|
|
428
|
+
singularRules.push([sanitizeRule(rule), replacement]);
|
|
429
|
+
};
|
|
430
|
+
pluralize.addUncountableRule = (word) => {
|
|
431
|
+
if (typeof word === "string") {
|
|
432
|
+
uncountables[word.toLowerCase()] = true;
|
|
433
|
+
return;
|
|
434
|
+
}
|
|
435
|
+
pluralize.addPluralRule(word, "$0");
|
|
436
|
+
pluralize.addSingularRule(word, "$0");
|
|
437
|
+
};
|
|
438
|
+
pluralize.addIrregularRule = (single, plural2) => {
|
|
439
|
+
const lowerPlural = plural2.toLowerCase();
|
|
440
|
+
const lowerSingle = single.toLowerCase();
|
|
441
|
+
irregularSingles[lowerSingle] = lowerPlural;
|
|
442
|
+
irregularPlurals[lowerPlural] = lowerSingle;
|
|
443
|
+
};
|
|
444
|
+
[
|
|
445
|
+
["I", "we"],
|
|
446
|
+
["me", "us"],
|
|
447
|
+
["he", "they"],
|
|
448
|
+
["she", "they"],
|
|
449
|
+
["them", "them"],
|
|
450
|
+
["myself", "ourselves"],
|
|
451
|
+
["yourself", "yourselves"],
|
|
452
|
+
["itself", "themselves"],
|
|
453
|
+
["herself", "themselves"],
|
|
454
|
+
["himself", "themselves"],
|
|
455
|
+
["themself", "themselves"],
|
|
456
|
+
["is", "are"],
|
|
457
|
+
["was", "were"],
|
|
458
|
+
["has", "have"],
|
|
459
|
+
["this", "these"],
|
|
460
|
+
["that", "those"],
|
|
461
|
+
["my", "our"],
|
|
462
|
+
["its", "their"],
|
|
463
|
+
["his", "their"],
|
|
464
|
+
["her", "their"],
|
|
465
|
+
["echo", "echoes"],
|
|
466
|
+
["dingo", "dingoes"],
|
|
467
|
+
["volcano", "volcanoes"],
|
|
468
|
+
["tornado", "tornadoes"],
|
|
469
|
+
["torpedo", "torpedoes"],
|
|
470
|
+
["genus", "genera"],
|
|
471
|
+
["viscus", "viscera"],
|
|
472
|
+
["stigma", "stigmata"],
|
|
473
|
+
["stoma", "stomata"],
|
|
474
|
+
["dogma", "dogmata"],
|
|
475
|
+
["lemma", "lemmata"],
|
|
476
|
+
["schema", "schemata"],
|
|
477
|
+
["anathema", "anathemata"],
|
|
478
|
+
["ox", "oxen"],
|
|
479
|
+
["axe", "axes"],
|
|
480
|
+
["die", "dice"],
|
|
481
|
+
["yes", "yeses"],
|
|
482
|
+
["foot", "feet"],
|
|
483
|
+
["eave", "eaves"],
|
|
484
|
+
["goose", "geese"],
|
|
485
|
+
["tooth", "teeth"],
|
|
486
|
+
["quiz", "quizzes"],
|
|
487
|
+
["human", "humans"],
|
|
488
|
+
["proof", "proofs"],
|
|
489
|
+
["carve", "carves"],
|
|
490
|
+
["valve", "valves"],
|
|
491
|
+
["looey", "looies"],
|
|
492
|
+
["thief", "thieves"],
|
|
493
|
+
["groove", "grooves"],
|
|
494
|
+
["pickaxe", "pickaxes"],
|
|
495
|
+
["passerby", "passersby"],
|
|
496
|
+
["canvas", "canvases"]
|
|
497
|
+
].forEach(([single, plural2]) => pluralize.addIrregularRule(single, plural2));
|
|
498
|
+
[
|
|
499
|
+
[/s?$/i, "s"],
|
|
500
|
+
[/[^\x20-\x7F]$/, "$0"],
|
|
501
|
+
[/([^aeiou]ese)$/i, "$1"],
|
|
502
|
+
[/(ax|test)is$/i, "$1es"],
|
|
503
|
+
[/(alias|[^aou]us|t[lm]as|gas|ris)$/i, "$1es"],
|
|
504
|
+
[/(e[mn]u)s?$/i, "$1s"],
|
|
505
|
+
[/([^l]ias|[aeiou]las|[ejzr]as|[iu]am)$/i, "$1"],
|
|
506
|
+
[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, "$1i"],
|
|
507
|
+
[/(alumn|alg|vertebr)(?:a|ae)$/i, "$1ae"],
|
|
508
|
+
[/(seraph|cherub)(?:im)?$/i, "$1im"],
|
|
509
|
+
[/(her|at|gr)o$/i, "$1oes"],
|
|
510
|
+
[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|automat|quor)(?:a|um)$/i, "$1a"],
|
|
511
|
+
[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)(?:a|on)$/i, "$1a"],
|
|
512
|
+
[/sis$/i, "ses"],
|
|
513
|
+
[/(?:(kni|wi|li)fe|(ar|l|ea|eo|oa|hoo)f)$/i, "$1$2ves"],
|
|
514
|
+
[/([^aeiouy]|qu)y$/i, "$1ies"],
|
|
515
|
+
[/([^ch][ieo][ln])ey$/i, "$1ies"],
|
|
516
|
+
[/(x|ch|ss|sh|zz)$/i, "$1es"],
|
|
517
|
+
[/(matr|cod|mur|sil|vert|ind|append)(?:ix|ex)$/i, "$1ices"],
|
|
518
|
+
[/\b((?:tit)?m|l)(?:ice|ouse)$/i, "$1ice"],
|
|
519
|
+
[/(pe)(?:rson|ople)$/i, "$1ople"],
|
|
520
|
+
[/(child)(?:ren)?$/i, "$1ren"],
|
|
521
|
+
[/eaux$/i, "$0"],
|
|
522
|
+
[/m[ae]n$/i, "men"],
|
|
523
|
+
["thou", "you"]
|
|
524
|
+
].forEach(([rule, replacement]) => pluralize.addPluralRule(rule, replacement));
|
|
525
|
+
[
|
|
526
|
+
[/s$/i, ""],
|
|
527
|
+
[/(ss)$/i, "$1"],
|
|
528
|
+
[/(wi|kni|(?:after|half|high|low|mid|non|night|\W|^)li)ves$/i, "$1fe"],
|
|
529
|
+
[/(ar|(?:wo|[ae])l|[eo][ao])ves$/i, "$1f"],
|
|
530
|
+
[/ies$/i, "y"],
|
|
531
|
+
[/(dg|ss|ois|lk|ok|wn|mb|th|ch|ec|oal|is|ck|ix|sser|ts|wb)ies$/i, "$1ie"],
|
|
532
|
+
[/\b(l|(?:neck|cross|hog|aun)?t|coll|faer|food|gen|goon|group|hipp|junk|vegg|(?:pork)?p|charl|calor|cut)ies$/i, "$1ie"],
|
|
533
|
+
[/\b(mon|smil)ies$/i, "$1ey"],
|
|
534
|
+
[/\b((?:tit)?m|l)ice$/i, "$1ouse"],
|
|
535
|
+
[/(seraph|cherub)im$/i, "$1"],
|
|
536
|
+
[/(x|ch|ss|sh|zz|tto|go|cho|alias|[^aou]us|t[lm]as|gas|(?:her|at|gr)o|[aeiou]ris)(?:es)?$/i, "$1"],
|
|
537
|
+
[/(analy|diagno|parenthe|progno|synop|the|empha|cri|ne)(?:sis|ses)$/i, "$1sis"],
|
|
538
|
+
[/(movie|twelve|abuse|e[mn]u)s$/i, "$1"],
|
|
539
|
+
[/(test)(?:is|es)$/i, "$1is"],
|
|
540
|
+
[/(alumn|syllab|vir|radi|nucle|fung|cact|stimul|termin|bacill|foc|uter|loc|strat)(?:us|i)$/i, "$1us"],
|
|
541
|
+
[/(agend|addend|millenni|dat|extrem|bacteri|desiderat|strat|candelabr|errat|ov|symposi|curricul|quor)a$/i, "$1um"],
|
|
542
|
+
[/(apheli|hyperbat|periheli|asyndet|noumen|phenomen|criteri|organ|prolegomen|hedr|automat)a$/i, "$1on"],
|
|
543
|
+
[/(alumn|alg|vertebr)ae$/i, "$1a"],
|
|
544
|
+
[/(cod|mur|sil|vert|ind)ices$/i, "$1ex"],
|
|
545
|
+
[/(matr|append)ices$/i, "$1ix"],
|
|
546
|
+
[/(pe)(rson|ople)$/i, "$1rson"],
|
|
547
|
+
[/(child)ren$/i, "$1"],
|
|
548
|
+
[/(eau)x?$/i, "$1"],
|
|
549
|
+
[/men$/i, "man"]
|
|
550
|
+
].forEach(([rule, replacement]) => pluralize.addSingularRule(rule, replacement));
|
|
551
|
+
[
|
|
552
|
+
"adulthood",
|
|
553
|
+
"advice",
|
|
554
|
+
"agenda",
|
|
555
|
+
"aid",
|
|
556
|
+
"aircraft",
|
|
557
|
+
"alcohol",
|
|
558
|
+
"ammo",
|
|
559
|
+
"analytics",
|
|
560
|
+
"anime",
|
|
561
|
+
"athletics",
|
|
562
|
+
"audio",
|
|
563
|
+
"bison",
|
|
564
|
+
"blood",
|
|
565
|
+
"bream",
|
|
566
|
+
"buffalo",
|
|
567
|
+
"butter",
|
|
568
|
+
"carp",
|
|
569
|
+
"cash",
|
|
570
|
+
"chassis",
|
|
571
|
+
"chess",
|
|
572
|
+
"clothing",
|
|
573
|
+
"cod",
|
|
574
|
+
"commerce",
|
|
575
|
+
"cooperation",
|
|
576
|
+
"corps",
|
|
577
|
+
"debris",
|
|
578
|
+
"diabetes",
|
|
579
|
+
"digestion",
|
|
580
|
+
"elk",
|
|
581
|
+
"energy",
|
|
582
|
+
"equipment",
|
|
583
|
+
"excretion",
|
|
584
|
+
"expertise",
|
|
585
|
+
"firmware",
|
|
586
|
+
"flounder",
|
|
587
|
+
"fun",
|
|
588
|
+
"gallows",
|
|
589
|
+
"garbage",
|
|
590
|
+
"graffiti",
|
|
591
|
+
"hardware",
|
|
592
|
+
"headquarters",
|
|
593
|
+
"health",
|
|
594
|
+
"herpes",
|
|
595
|
+
"highjinks",
|
|
596
|
+
"homework",
|
|
597
|
+
"housework",
|
|
598
|
+
"information",
|
|
599
|
+
"jeans",
|
|
600
|
+
"justice",
|
|
601
|
+
"kudos",
|
|
602
|
+
"labour",
|
|
603
|
+
"literature",
|
|
604
|
+
"machinery",
|
|
605
|
+
"mackerel",
|
|
606
|
+
"mail",
|
|
607
|
+
"media",
|
|
608
|
+
"mews",
|
|
609
|
+
"moose",
|
|
610
|
+
"music",
|
|
611
|
+
"mud",
|
|
612
|
+
"manga",
|
|
613
|
+
"news",
|
|
614
|
+
"only",
|
|
615
|
+
"personnel",
|
|
616
|
+
"pike",
|
|
617
|
+
"plankton",
|
|
618
|
+
"pliers",
|
|
619
|
+
"police",
|
|
620
|
+
"pollution",
|
|
621
|
+
"premises",
|
|
622
|
+
"rain",
|
|
623
|
+
"research",
|
|
624
|
+
"rice",
|
|
625
|
+
"salmon",
|
|
626
|
+
"scissors",
|
|
627
|
+
"series",
|
|
628
|
+
"sewage",
|
|
629
|
+
"shambles",
|
|
630
|
+
"shrimp",
|
|
631
|
+
"software",
|
|
632
|
+
"staff",
|
|
633
|
+
"swine",
|
|
634
|
+
"tennis",
|
|
635
|
+
"traffic",
|
|
636
|
+
"transportation",
|
|
637
|
+
"trout",
|
|
638
|
+
"tuna",
|
|
639
|
+
"wealth",
|
|
640
|
+
"welfare",
|
|
641
|
+
"whiting",
|
|
642
|
+
"wildebeest",
|
|
643
|
+
"wildlife",
|
|
644
|
+
"you",
|
|
645
|
+
/pok[e\u00E9]mon$/i,
|
|
646
|
+
/[^aeiou]ese$/i,
|
|
647
|
+
/deer$/i,
|
|
648
|
+
/fish$/i,
|
|
649
|
+
/measles$/i,
|
|
650
|
+
/o[iu]s$/i,
|
|
651
|
+
/pox$/i,
|
|
652
|
+
/sheep$/i
|
|
653
|
+
].forEach(pluralize.addUncountableRule);
|
|
654
|
+
|
|
655
|
+
// src/slug.ts
|
|
656
|
+
var charMap = JSON.parse(`{"$":"dollar","%":"percent","&":"and","<":"less",">":"greater","|":"or","\xA2":"cent","\xA3":"pound","\xA4":"currency","\xA5":"yen","\xA9":"(c)","\xAA":"a","\xAE":"(r)","\xBA":"o","\xC0":"A","\xC1":"A","\xC2":"A","\xC3":"A","\xC4":"A","\xC5":"A","\xC6":"AE","\xC7":"C","\xC8":"E","\xC9":"E","\xCA":"E","\xCB":"E","\xCC":"I","\xCD":"I","\xCE":"I","\xCF":"I","\xD0":"D","\xD1":"N","\xD2":"O","\xD3":"O","\xD4":"O","\xD5":"O","\xD6":"O","\xD8":"O","\xD9":"U","\xDA":"U","\xDB":"U","\xDC":"U","\xDD":"Y","\xDE":"TH","\xDF":"ss","\xE0":"a","\xE1":"a","\xE2":"a","\xE3":"a","\xE4":"a","\xE5":"a","\xE6":"ae","\xE7":"c","\xE8":"e","\xE9":"e","\xEA":"e","\xEB":"e","\xEC":"i","\xED":"i","\xEE":"i","\xEF":"i","\xF0":"d","\xF1":"n","\xF2":"o","\xF3":"o","\xF4":"o","\xF5":"o","\xF6":"o","\xF8":"o","\xF9":"u","\xFA":"u","\xFB":"u","\xFC":"u","\xFD":"y","\xFE":"th","\xFF":"y","\u0100":"A","\u0101":"a","\u0102":"A","\u0103":"a","\u0104":"A","\u0105":"a","\u0106":"C","\u0107":"c","\u010C":"C","\u010D":"c","\u010E":"D","\u010F":"d","\u0110":"DJ","\u0111":"dj","\u0112":"E","\u0113":"e","\u0116":"E","\u0117":"e","\u0118":"e","\u0119":"e","\u011A":"E","\u011B":"e","\u011E":"G","\u011F":"g","\u0122":"G","\u0123":"g","\u0128":"I","\u0129":"i","\u012A":"i","\u012B":"i","\u012E":"I","\u012F":"i","\u0130":"I","\u0131":"i","\u0136":"k","\u0137":"k","\u013B":"L","\u013C":"l","\u013D":"L","\u013E":"l","\u0141":"L","\u0142":"l","\u0143":"N","\u0144":"n","\u0145":"N","\u0146":"n","\u0147":"N","\u0148":"n","\u014C":"O","\u014D":"o","\u0150":"O","\u0151":"o","\u0152":"OE","\u0153":"oe","\u0154":"R","\u0155":"r","\u0158":"R","\u0159":"r","\u015A":"S","\u015B":"s","\u015E":"S","\u015F":"s","\u0160":"S","\u0161":"s","\u0162":"T","\u0163":"t","\u0164":"T","\u0165":"t","\u0168":"U","\u0169":"u","\u016A":"u","\u016B":"u","\u016E":"U","\u016F":"u","\u0170":"U","\u0171":"u","\u0172":"U","\u0173":"u","\u0174":"W","\u0175":"w","\u0176":"Y","\u0177":"y","\u0178":"Y","\u0179":"Z","\u017A":"z","\u017B":"Z","\u017C":"z","\u017D":"Z","\u017E":"z","\u018F":"E","\u0192":"f","\u01A0":"O","\u01A1":"o","\u01AF":"U","\u01B0":"u","\u01C8":"LJ","\u01C9":"lj","\u01CB":"NJ","\u01CC":"nj","\u0218":"S","\u0219":"s","\u021A":"T","\u021B":"t","\u0259":"e","\u02DA":"o","\u0386":"A","\u0388":"E","\u0389":"H","\u038A":"I","\u038C":"O","\u038E":"Y","\u038F":"W","\u0390":"i","\u0391":"A","\u0392":"B","\u0393":"G","\u0394":"D","\u0395":"E","\u0396":"Z","\u0397":"H","\u0398":"8","\u0399":"I","\u039A":"K","\u039B":"L","\u039C":"M","\u039D":"N","\u039E":"3","\u039F":"O","\u03A0":"P","\u03A1":"R","\u03A3":"S","\u03A4":"T","\u03A5":"Y","\u03A6":"F","\u03A7":"X","\u03A8":"PS","\u03A9":"W","\u03AA":"I","\u03AB":"Y","\u03AC":"a","\u03AD":"e","\u03AE":"h","\u03AF":"i","\u03B0":"y","\u03B1":"a","\u03B2":"b","\u03B3":"g","\u03B4":"d","\u03B5":"e","\u03B6":"z","\u03B7":"h","\u03B8":"8","\u03B9":"i","\u03BA":"k","\u03BB":"l","\u03BC":"m","\u03BD":"n","\u03BE":"3","\u03BF":"o","\u03C0":"p","\u03C1":"r","\u03C2":"s","\u03C3":"s","\u03C4":"t","\u03C5":"y","\u03C6":"f","\u03C7":"x","\u03C8":"ps","\u03C9":"w","\u03CA":"i","\u03CB":"y","\u03CC":"o","\u03CD":"y","\u03CE":"w","\u0401":"Yo","\u0402":"DJ","\u0404":"Ye","\u0406":"I","\u0407":"Yi","\u0408":"J","\u0409":"LJ","\u040A":"NJ","\u040B":"C","\u040F":"DZ","\u0410":"A","\u0411":"B","\u0412":"V","\u0413":"G","\u0414":"D","\u0415":"E","\u0416":"Zh","\u0417":"Z","\u0418":"I","\u0419":"J","\u041A":"K","\u041B":"L","\u041C":"M","\u041D":"N","\u041E":"O","\u041F":"P","\u0420":"R","\u0421":"S","\u0422":"T","\u0423":"U","\u0424":"F","\u0425":"H","\u0426":"C","\u0427":"Ch","\u0428":"Sh","\u0429":"Sh","\u042A":"U","\u042B":"Y","\u042C":"","\u042D":"E","\u042E":"Yu","\u042F":"Ya","\u0430":"a","\u0431":"b","\u0432":"v","\u0433":"g","\u0434":"d","\u0435":"e","\u0436":"zh","\u0437":"z","\u0438":"i","\u0439":"j","\u043A":"k","\u043B":"l","\u043C":"m","\u043D":"n","\u043E":"o","\u043F":"p","\u0440":"r","\u0441":"s","\u0442":"t","\u0443":"u","\u0444":"f","\u0445":"h","\u0446":"c","\u0447":"ch","\u0448":"sh","\u0449":"sh","\u044A":"u","\u044B":"y","\u044C":"","\u044D":"e","\u044E":"yu","\u044F":"ya","\u0451":"yo","\u0452":"dj","\u0454":"ye","\u0456":"i","\u0457":"yi","\u0458":"j","\u0459":"lj","\u045A":"nj","\u045B":"c","\u045D":"u","\u045F":"dz","\u0490":"G","\u0491":"g","\u0492":"GH","\u0493":"gh","\u049A":"KH","\u049B":"kh","\u04A2":"NG","\u04A3":"ng","\u04AE":"UE","\u04AF":"ue","\u04B0":"U","\u04B1":"u","\u04BA":"H","\u04BB":"h","\u04D8":"AE","\u04D9":"ae","\u04E8":"OE","\u04E9":"oe","\u0531":"A","\u0532":"B","\u0533":"G","\u0534":"D","\u0535":"E","\u0536":"Z","\u0537":"E'","\u0538":"Y'","\u0539":"T'","\u053A":"JH","\u053B":"I","\u053C":"L","\u053D":"X","\u053E":"C'","\u053F":"K","\u0540":"H","\u0541":"D'","\u0542":"GH","\u0543":"TW","\u0544":"M","\u0545":"Y","\u0546":"N","\u0547":"SH","\u0549":"CH","\u054A":"P","\u054B":"J","\u054C":"R'","\u054D":"S","\u054E":"V","\u054F":"T","\u0550":"R","\u0551":"C","\u0553":"P'","\u0554":"Q'","\u0555":"O''","\u0556":"F","\u0587":"EV","\u0621":"a","\u0622":"aa","\u0623":"a","\u0624":"u","\u0625":"i","\u0626":"e","\u0627":"a","\u0628":"b","\u0629":"h","\u062A":"t","\u062B":"th","\u062C":"j","\u062D":"h","\u062E":"kh","\u062F":"d","\u0630":"th","\u0631":"r","\u0632":"z","\u0633":"s","\u0634":"sh","\u0635":"s","\u0636":"dh","\u0637":"t","\u0638":"z","\u0639":"a","\u063A":"gh","\u0641":"f","\u0642":"q","\u0643":"k","\u0644":"l","\u0645":"m","\u0646":"n","\u0647":"h","\u0648":"w","\u0649":"a","\u064A":"y","\u064B":"an","\u064C":"on","\u064D":"en","\u064E":"a","\u064F":"u","\u0650":"e","\u0652":"","\u0660":"0","\u0661":"1","\u0662":"2","\u0663":"3","\u0664":"4","\u0665":"5","\u0666":"6","\u0667":"7","\u0668":"8","\u0669":"9","\u067E":"p","\u0686":"ch","\u0698":"zh","\u06A9":"k","\u06AF":"g","\u06CC":"y","\u06F0":"0","\u06F1":"1","\u06F2":"2","\u06F3":"3","\u06F4":"4","\u06F5":"5","\u06F6":"6","\u06F7":"7","\u06F8":"8","\u06F9":"9","\u0E3F":"baht","\u10D0":"a","\u10D1":"b","\u10D2":"g","\u10D3":"d","\u10D4":"e","\u10D5":"v","\u10D6":"z","\u10D7":"t","\u10D8":"i","\u10D9":"k","\u10DA":"l","\u10DB":"m","\u10DC":"n","\u10DD":"o","\u10DE":"p","\u10DF":"zh","\u10E0":"r","\u10E1":"s","\u10E2":"t","\u10E3":"u","\u10E4":"f","\u10E5":"k","\u10E6":"gh","\u10E7":"q","\u10E8":"sh","\u10E9":"ch","\u10EA":"ts","\u10EB":"dz","\u10EC":"ts","\u10ED":"ch","\u10EE":"kh","\u10EF":"j","\u10F0":"h","\u1E62":"S","\u1E63":"s","\u1E80":"W","\u1E81":"w","\u1E82":"W","\u1E83":"w","\u1E84":"W","\u1E85":"w","\u1E9E":"SS","\u1EA0":"A","\u1EA1":"a","\u1EA2":"A","\u1EA3":"a","\u1EA4":"A","\u1EA5":"a","\u1EA6":"A","\u1EA7":"a","\u1EA8":"A","\u1EA9":"a","\u1EAA":"A","\u1EAB":"a","\u1EAC":"A","\u1EAD":"a","\u1EAE":"A","\u1EAF":"a","\u1EB0":"A","\u1EB1":"a","\u1EB2":"A","\u1EB3":"a","\u1EB4":"A","\u1EB5":"a","\u1EB6":"A","\u1EB7":"a","\u1EB8":"E","\u1EB9":"e","\u1EBA":"E","\u1EBB":"e","\u1EBC":"E","\u1EBD":"e","\u1EBE":"E","\u1EBF":"e","\u1EC0":"E","\u1EC1":"e","\u1EC2":"E","\u1EC3":"e","\u1EC4":"E","\u1EC5":"e","\u1EC6":"E","\u1EC7":"e","\u1EC8":"I","\u1EC9":"i","\u1ECA":"I","\u1ECB":"i","\u1ECC":"O","\u1ECD":"o","\u1ECE":"O","\u1ECF":"o","\u1ED0":"O","\u1ED1":"o","\u1ED2":"O","\u1ED3":"o","\u1ED4":"O","\u1ED5":"o","\u1ED6":"O","\u1ED7":"o","\u1ED8":"O","\u1ED9":"o","\u1EDA":"O","\u1EDB":"o","\u1EDC":"O","\u1EDD":"o","\u1EDE":"O","\u1EDF":"o","\u1EE0":"O","\u1EE1":"o","\u1EE2":"O","\u1EE3":"o","\u1EE4":"U","\u1EE5":"u","\u1EE6":"U","\u1EE7":"u","\u1EE8":"U","\u1EE9":"u","\u1EEA":"U","\u1EEB":"u","\u1EEC":"U","\u1EED":"u","\u1EEE":"U","\u1EEF":"u","\u1EF0":"U","\u1EF1":"u","\u1EF2":"Y","\u1EF3":"y","\u1EF4":"Y","\u1EF5":"y","\u1EF6":"Y","\u1EF7":"y","\u1EF8":"Y","\u1EF9":"y","\u2013":"-","\u2018":"'","\u2019":"'","\u201C":"\\"","\u201D":"\\"","\u201E":"\\"","\u2020":"+","\u2022":"*","\u2026":"...","\u20A0":"ecu","\u20A2":"cruzeiro","\u20A3":"french franc","\u20A4":"lira","\u20A5":"mill","\u20A6":"naira","\u20A7":"peseta","\u20A8":"rupee","\u20A9":"won","\u20AA":"new shequel","\u20AB":"dong","\u20AC":"euro","\u20AD":"kip","\u20AE":"tugrik","\u20AF":"drachma","\u20B0":"penny","\u20B1":"peso","\u20B2":"guarani","\u20B3":"austral","\u20B4":"hryvnia","\u20B5":"cedi","\u20B8":"kazakhstani tenge","\u20B9":"indian rupee","\u20BA":"turkish lira","\u20BD":"russian ruble","\u20BF":"bitcoin","\u2120":"sm","\u2122":"tm","\u2202":"d","\u2206":"delta","\u2211":"sum","\u221E":"infinity","\u2665":"love","\u5143":"yuan","\u5186":"yen","\uFDFC":"rial","\uFEF5":"laa","\uFEF7":"laa","\uFEF9":"lai","\uFEFB":"la"}`);
|
|
657
|
+
var locales = JSON.parse('{"bg":{"\u0419":"Y","\u0426":"Ts","\u0429":"Sht","\u042A":"A","\u042C":"Y","\u0439":"y","\u0446":"ts","\u0449":"sht","\u044A":"a","\u044C":"y"},"de":{"\xC4":"AE","\xE4":"ae","\xD6":"OE","\xF6":"oe","\xDC":"UE","\xFC":"ue","\xDF":"ss","%":"prozent","&":"und","|":"oder","\u2211":"summe","\u221E":"unendlich","\u2665":"liebe"},"es":{"%":"por ciento","&":"y","<":"menor que",">":"mayor que","|":"o","\xA2":"centavos","\xA3":"libras","\xA4":"moneda","\u20A3":"francos","\u2211":"suma","\u221E":"infinito","\u2665":"amor"},"fr":{"%":"pourcent","&":"et","<":"plus petit",">":"plus grand","|":"ou","\xA2":"centime","\xA3":"livre","\xA4":"devise","\u20A3":"franc","\u2211":"somme","\u221E":"infini","\u2665":"amour"},"pt":{"%":"porcento","&":"e","<":"menor",">":"maior","|":"ou","\xA2":"centavo","\u2211":"soma","\xA3":"libra","\u221E":"infinito","\u2665":"amor"},"uk":{"\u0418":"Y","\u0438":"y","\u0419":"Y","\u0439":"y","\u0426":"Ts","\u0446":"ts","\u0425":"Kh","\u0445":"kh","\u0429":"Shch","\u0449":"shch","\u0413":"H","\u0433":"h"},"vi":{"\u0110":"D","\u0111":"d"},"da":{"\xD8":"OE","\xF8":"oe","\xC5":"AA","\xE5":"aa","%":"procent","&":"og","|":"eller","$":"dollar","<":"mindre end",">":"st\xF8rre end"},"nb":{"&":"og","\xC5":"AA","\xC6":"AE","\xD8":"OE","\xE5":"aa","\xE6":"ae","\xF8":"oe"},"it":{"&":"e"},"nl":{"&":"en"},"sv":{"&":"och","\xC5":"AA","\xC4":"AE","\xD6":"OE","\xE5":"aa","\xE4":"ae","\xF6":"oe"}}');
|
|
658
|
+
function slugify(string, options = {}) {
|
|
659
|
+
if (typeof string !== "string") {
|
|
660
|
+
throw new TypeError("slugify: string argument expected");
|
|
661
|
+
}
|
|
662
|
+
const {
|
|
663
|
+
replacement = "-",
|
|
664
|
+
remove = /[^\w\s$*+~.()'"!\-:@]+/g,
|
|
665
|
+
lower = false,
|
|
666
|
+
strict = false,
|
|
667
|
+
locale,
|
|
668
|
+
trim = true
|
|
669
|
+
} = options;
|
|
670
|
+
const localeMap = locale ? locales[locale] || {} : {};
|
|
671
|
+
const slug = string.normalize().split("").reduce((result, ch) => {
|
|
672
|
+
let appendChar = localeMap[ch] ?? charMap[ch] ?? ch;
|
|
673
|
+
appendChar = appendChar === replacement ? " " : appendChar;
|
|
674
|
+
return result + appendChar;
|
|
675
|
+
}, "").replace(remove, "");
|
|
676
|
+
const strictSlug = strict ? slug.replace(/[^A-Z0-9\s]/gi, "") : slug;
|
|
677
|
+
const trimmedSlug = trim ? strictSlug.trim() : strictSlug;
|
|
678
|
+
const finalSlug = trimmedSlug.replace(/\s+/g, replacement);
|
|
679
|
+
return lower ? finalSlug.toLowerCase() : finalSlug;
|
|
680
|
+
}
|
|
681
|
+
function extendCharMap(customMap) {
|
|
682
|
+
Object.assign(charMap, customMap);
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
// src/detect-indent.ts
|
|
686
|
+
var INDENT_REGEX = /^(?:( )+|\t+)/;
|
|
687
|
+
var INDENT_TYPE_SPACE = "space";
|
|
688
|
+
var INDENT_TYPE_TAB = "tab";
|
|
689
|
+
function makeIndentsMap(string, ignoreSingleSpaces = true) {
|
|
690
|
+
const indents = new Map;
|
|
691
|
+
let previousSize = 0;
|
|
692
|
+
let previousIndentType;
|
|
693
|
+
let key;
|
|
694
|
+
for (const line of string.split(/\n/g)) {
|
|
695
|
+
if (!line) {
|
|
696
|
+
continue;
|
|
697
|
+
}
|
|
698
|
+
let indent;
|
|
699
|
+
let indentType;
|
|
700
|
+
let use;
|
|
701
|
+
let weight;
|
|
702
|
+
let entry;
|
|
703
|
+
const matches = line.match(INDENT_REGEX);
|
|
704
|
+
if (matches === null) {
|
|
705
|
+
previousSize = 0;
|
|
706
|
+
previousIndentType = "";
|
|
707
|
+
} else {
|
|
708
|
+
indent = matches[0].length;
|
|
709
|
+
indentType = matches[1] ? INDENT_TYPE_SPACE : INDENT_TYPE_TAB;
|
|
710
|
+
if (ignoreSingleSpaces && indentType === INDENT_TYPE_SPACE && indent === 1) {
|
|
711
|
+
continue;
|
|
712
|
+
}
|
|
713
|
+
if (indentType !== previousIndentType) {
|
|
714
|
+
previousSize = 0;
|
|
715
|
+
}
|
|
716
|
+
previousIndentType = indentType;
|
|
717
|
+
use = 1;
|
|
718
|
+
weight = 0;
|
|
719
|
+
const indentDifference = indent - previousSize;
|
|
720
|
+
previousSize = indent;
|
|
721
|
+
if (indentDifference === 0) {
|
|
722
|
+
use = 0;
|
|
723
|
+
weight = 1;
|
|
724
|
+
} else {
|
|
725
|
+
const absoluteIndentDifference = indentDifference > 0 ? indentDifference : -indentDifference;
|
|
726
|
+
key = encodeIndentsKey(indentType, absoluteIndentDifference);
|
|
727
|
+
}
|
|
728
|
+
entry = indents.get(key);
|
|
729
|
+
entry = entry === undefined ? [1, 0] : [entry[0] + use, entry[1] + weight];
|
|
730
|
+
indents.set(key, entry);
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
return indents;
|
|
734
|
+
}
|
|
735
|
+
function encodeIndentsKey(indentType, indentAmount) {
|
|
736
|
+
const typeCharacter = indentType === INDENT_TYPE_SPACE ? "s" : "t";
|
|
737
|
+
return typeCharacter + String(indentAmount);
|
|
738
|
+
}
|
|
739
|
+
function decodeIndentsKey(indentsKey) {
|
|
740
|
+
const keyHasTypeSpace = indentsKey[0] === "s";
|
|
741
|
+
const type = keyHasTypeSpace ? INDENT_TYPE_SPACE : INDENT_TYPE_TAB;
|
|
742
|
+
const amount = Number(indentsKey.slice(1));
|
|
743
|
+
return { type, amount };
|
|
744
|
+
}
|
|
745
|
+
function getMostUsedKey(indents) {
|
|
746
|
+
let result;
|
|
747
|
+
let maxUsed = 0;
|
|
748
|
+
let maxWeight = 0;
|
|
749
|
+
for (const [key, [usedCount, weight]] of indents) {
|
|
750
|
+
if (usedCount > maxUsed || usedCount === maxUsed && weight > maxWeight) {
|
|
751
|
+
maxUsed = usedCount;
|
|
752
|
+
maxWeight = weight;
|
|
753
|
+
result = key;
|
|
754
|
+
}
|
|
755
|
+
}
|
|
756
|
+
return result;
|
|
757
|
+
}
|
|
758
|
+
function makeIndentString(type, amount) {
|
|
759
|
+
const indentCharacter = type === INDENT_TYPE_SPACE ? " " : "\t";
|
|
760
|
+
return indentCharacter.repeat(amount);
|
|
761
|
+
}
|
|
762
|
+
function detectIndent(string) {
|
|
763
|
+
if (typeof string !== "string") {
|
|
764
|
+
throw new TypeError("Expected a string");
|
|
765
|
+
}
|
|
766
|
+
let indents = makeIndentsMap(string, true);
|
|
767
|
+
if (indents.size === 0) {
|
|
768
|
+
indents = makeIndentsMap(string, false);
|
|
769
|
+
}
|
|
770
|
+
const keyOfMostUsedIndent = getMostUsedKey(indents);
|
|
771
|
+
let type;
|
|
772
|
+
let amount = 0;
|
|
773
|
+
let indent = "";
|
|
774
|
+
if (keyOfMostUsedIndent !== undefined) {
|
|
775
|
+
({ type, amount } = decodeIndentsKey(keyOfMostUsedIndent));
|
|
776
|
+
indent = makeIndentString(type, amount);
|
|
777
|
+
}
|
|
778
|
+
return {
|
|
779
|
+
amount,
|
|
780
|
+
type,
|
|
781
|
+
indent
|
|
782
|
+
};
|
|
783
|
+
}
|
|
784
|
+
// src/detect-newline.ts
|
|
785
|
+
function detectNewline(string) {
|
|
786
|
+
if (typeof string !== "string") {
|
|
787
|
+
throw new TypeError("Expected a string");
|
|
788
|
+
}
|
|
789
|
+
const newlines = string.match(/\r?\n/g) || [];
|
|
790
|
+
if (newlines.length === 0) {
|
|
791
|
+
return;
|
|
792
|
+
}
|
|
793
|
+
const crlf = newlines.filter((newline) => newline === "\r\n").length;
|
|
794
|
+
const lf = newlines.length - crlf;
|
|
795
|
+
return crlf > lf ? "\r\n" : "\n";
|
|
796
|
+
}
|
|
797
|
+
function detectNewlineGraceful(string) {
|
|
798
|
+
return typeof string === "string" && detectNewline(string) || "\n";
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
// src/utils.ts
|
|
802
|
+
var urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
|
803
|
+
function slash(str) {
|
|
804
|
+
return str.replace(/\\/g, "/");
|
|
805
|
+
}
|
|
806
|
+
function ensurePrefix(prefix, str) {
|
|
807
|
+
if (!str.startsWith(prefix))
|
|
808
|
+
return prefix + str;
|
|
809
|
+
return str;
|
|
810
|
+
}
|
|
811
|
+
function ensureSuffix(suffix, str) {
|
|
812
|
+
return str.endsWith(suffix) ? str : str + suffix;
|
|
813
|
+
}
|
|
814
|
+
function template(str, ...args) {
|
|
815
|
+
return str.replace(/\{(\d+)\}/g, (match, key) => {
|
|
816
|
+
const index = Number(key);
|
|
817
|
+
return Number.isNaN(index) ? match : args[index];
|
|
818
|
+
});
|
|
819
|
+
}
|
|
820
|
+
function truncate(str, length, end = "...") {
|
|
821
|
+
if (str.length <= length)
|
|
822
|
+
return str;
|
|
823
|
+
return str.slice(0, length - end.length) + end;
|
|
824
|
+
}
|
|
825
|
+
function random(size = 16, dict = urlAlphabet) {
|
|
826
|
+
let id = "";
|
|
827
|
+
let i = size;
|
|
828
|
+
const len = dict.length;
|
|
829
|
+
while (i--)
|
|
830
|
+
id += dict[Math.random() * len | 0];
|
|
831
|
+
return id;
|
|
832
|
+
}
|
|
833
|
+
function slug(str, options) {
|
|
834
|
+
if (options)
|
|
835
|
+
return slugify(str, options);
|
|
836
|
+
return slugify(str, {
|
|
837
|
+
lower: true,
|
|
838
|
+
strict: true
|
|
839
|
+
});
|
|
840
|
+
}
|
|
841
|
+
|
|
842
|
+
// src/macro.ts
|
|
843
|
+
var Str = {
|
|
844
|
+
slash(str) {
|
|
845
|
+
return slash(str);
|
|
846
|
+
},
|
|
847
|
+
ensurePrefix(prefix, str) {
|
|
848
|
+
return ensurePrefix(prefix, str);
|
|
849
|
+
},
|
|
850
|
+
ensureSuffix(suffix, str) {
|
|
851
|
+
return ensureSuffix(suffix, str);
|
|
852
|
+
},
|
|
853
|
+
template(str, ...args) {
|
|
854
|
+
return template(str, ...args);
|
|
855
|
+
},
|
|
856
|
+
truncate(str, length, end = "...") {
|
|
857
|
+
return truncate(str, length, end);
|
|
858
|
+
},
|
|
859
|
+
random(length = 16, dict) {
|
|
860
|
+
return random(length, dict);
|
|
861
|
+
},
|
|
862
|
+
capitalize(str) {
|
|
863
|
+
return capitalize(str);
|
|
864
|
+
},
|
|
865
|
+
slug(str) {
|
|
866
|
+
return slug(str);
|
|
867
|
+
},
|
|
868
|
+
detectIndent(str) {
|
|
869
|
+
return detectIndent(str);
|
|
870
|
+
},
|
|
871
|
+
detectNewline(str) {
|
|
872
|
+
return detectNewline(str);
|
|
873
|
+
},
|
|
874
|
+
camelCase(str) {
|
|
875
|
+
return camelCase(str);
|
|
876
|
+
},
|
|
877
|
+
capitalCase(str) {
|
|
878
|
+
return capitalCase(str);
|
|
879
|
+
},
|
|
880
|
+
constantCase(str) {
|
|
881
|
+
return constantCase(str);
|
|
882
|
+
},
|
|
883
|
+
dotCase(str) {
|
|
884
|
+
return dotCase(str);
|
|
885
|
+
},
|
|
886
|
+
noCase(str) {
|
|
887
|
+
return noCase(str);
|
|
888
|
+
},
|
|
889
|
+
paramCase(str) {
|
|
890
|
+
return undefined(str);
|
|
891
|
+
},
|
|
892
|
+
pascalCase(str) {
|
|
893
|
+
return pascalCase(str);
|
|
894
|
+
},
|
|
895
|
+
pathCase(str) {
|
|
896
|
+
return pathCase(str);
|
|
897
|
+
},
|
|
898
|
+
sentenceCase(str) {
|
|
899
|
+
return sentenceCase(str);
|
|
900
|
+
},
|
|
901
|
+
snakeCase(str) {
|
|
902
|
+
return snakeCase(str);
|
|
903
|
+
},
|
|
904
|
+
titleCase(str) {
|
|
905
|
+
return titleCase(str);
|
|
906
|
+
},
|
|
907
|
+
kebabCase(str) {
|
|
908
|
+
return kebabCase(str);
|
|
909
|
+
},
|
|
910
|
+
plural(str) {
|
|
911
|
+
return plural(str);
|
|
912
|
+
},
|
|
913
|
+
singular(str) {
|
|
914
|
+
return singular(str);
|
|
915
|
+
},
|
|
916
|
+
isPlural(str) {
|
|
917
|
+
return undefined(str);
|
|
918
|
+
},
|
|
919
|
+
isSingular(str) {
|
|
920
|
+
return undefined(str);
|
|
921
|
+
},
|
|
922
|
+
addPluralRule(rule, repl) {
|
|
923
|
+
undefined(rule, repl);
|
|
924
|
+
},
|
|
925
|
+
addSingularRule(rule, repl) {
|
|
926
|
+
undefined(rule, repl);
|
|
927
|
+
},
|
|
928
|
+
addIrregularRule(single, plural2) {
|
|
929
|
+
undefined(single, plural2);
|
|
930
|
+
},
|
|
931
|
+
addUncountableRule(word) {
|
|
932
|
+
undefined(word);
|
|
933
|
+
}
|
|
934
|
+
};
|
|
935
|
+
var str = Str;
|
|
936
|
+
export {
|
|
937
|
+
urlAlphabet,
|
|
938
|
+
truncate,
|
|
939
|
+
trainCase,
|
|
940
|
+
toString,
|
|
941
|
+
titleCase,
|
|
942
|
+
template,
|
|
943
|
+
swapCase,
|
|
944
|
+
exports_string as string,
|
|
945
|
+
str,
|
|
946
|
+
spongeCase,
|
|
947
|
+
splitSeparateNumbers,
|
|
948
|
+
split,
|
|
949
|
+
snakeCase,
|
|
950
|
+
slugify,
|
|
951
|
+
slug,
|
|
952
|
+
slash,
|
|
953
|
+
singular,
|
|
954
|
+
sentenceCase,
|
|
955
|
+
random,
|
|
956
|
+
pluralize,
|
|
957
|
+
plural,
|
|
958
|
+
pathCase,
|
|
959
|
+
pascalSnakeCase,
|
|
960
|
+
pascalCase,
|
|
961
|
+
noCase,
|
|
962
|
+
lowercase,
|
|
963
|
+
kebabCase,
|
|
964
|
+
extendCharMap,
|
|
965
|
+
ensureSuffix,
|
|
966
|
+
ensurePrefix,
|
|
967
|
+
dotCase,
|
|
968
|
+
detectNewlineGraceful,
|
|
969
|
+
detectNewline,
|
|
970
|
+
detectIndent,
|
|
971
|
+
constantCase,
|
|
972
|
+
capitalize,
|
|
973
|
+
capitalCase,
|
|
974
|
+
camelCase,
|
|
975
|
+
WORD_SEPARATORS,
|
|
976
|
+
TITLE_TERMINATORS,
|
|
977
|
+
Str,
|
|
978
|
+
SMALL_WORDS,
|
|
979
|
+
SENTENCE_TERMINATORS
|
|
980
|
+
};
|