@stacksjs/strings 0.68.2 → 0.69.1
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/dist/case.d.ts +10 -10
- package/dist/detect-indent.d.ts +2 -2
- package/dist/index.js +29 -19
- package/dist/macro.d.ts +1 -1
- package/dist/pluralize.d.ts +10 -9
- package/dist/slug.d.ts +5 -2
- package/dist/title-case.d.ts +2 -2
- package/dist/utils.d.ts +3 -2
- package/package.json +6 -8
package/dist/case.d.ts
CHANGED
|
@@ -2,10 +2,12 @@ export declare function capitalize(str: string): string;
|
|
|
2
2
|
export declare function lowercase(str: string): string;
|
|
3
3
|
declare const DEFAULT_PREFIX_SUFFIX_CHARACTERS: unknown;
|
|
4
4
|
export declare type Locale = string[] | string | false | undefined
|
|
5
|
-
|
|
5
|
+
|
|
6
|
+
export interface PascalCaseOptions extends CaseOptions {
|
|
6
7
|
mergeAmbiguousCharacters?: boolean
|
|
7
8
|
}
|
|
8
|
-
|
|
9
|
+
|
|
10
|
+
export interface CaseOptions {
|
|
9
11
|
locale?: Locale
|
|
10
12
|
split?: (value: string) => string[]
|
|
11
13
|
delimiter?: string
|
|
@@ -26,11 +28,9 @@ export declare function pathCase(input: string, options?: CaseOptions): string;
|
|
|
26
28
|
export declare function sentenceCase(input: string, options?: CaseOptions): string;
|
|
27
29
|
export declare function snakeCase(input: string, options?: CaseOptions): string;
|
|
28
30
|
export declare function trainCase(input: string, options?: CaseOptions): string;
|
|
29
|
-
declare function
|
|
30
|
-
declare function
|
|
31
|
-
declare function
|
|
32
|
-
declare function
|
|
33
|
-
declare function
|
|
34
|
-
|
|
35
|
-
export * from './swap-case'
|
|
36
|
-
export * from './title-case'
|
|
31
|
+
export declare function paramCase(input: string, options?: CaseOptions): string;
|
|
32
|
+
declare function lowerFactory(locale: Locale): (input: string) => string;
|
|
33
|
+
declare function upperFactory(locale: Locale): (input: string) => string;
|
|
34
|
+
declare function capitalCaseTransformFactory(lower: (input: string)): void;
|
|
35
|
+
declare function pascalCaseTransformFactory(lower: (input: string)): void;
|
|
36
|
+
declare function splitPrefixSuffix(input: string, options: CaseOptions): [string, string[], string];
|
package/dist/detect-indent.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
declare const INDENT_TYPE_SPACE: 'space' const INDENT_TYPE_TAB = 'tab';
|
|
2
|
-
declare function makeIndentsMap(string: string, ignoreSingleSpaces: boolean
|
|
2
|
+
declare function makeIndentsMap(string: string, ignoreSingleSpaces: boolean): void;
|
|
3
3
|
declare function encodeIndentsKey(indentType: any, indentAmount: any): void;
|
|
4
4
|
declare function decodeIndentsKey(indentsKey: any): void;
|
|
5
5
|
declare function getMostUsedKey(indents: any): void;
|
|
6
6
|
declare function makeIndentString(type: any, amount: any): void;
|
|
7
|
-
export declare function detectIndent(string: string);
|
|
7
|
+
export declare function detectIndent(string: string): void;
|
|
8
8
|
|
|
9
9
|
export default detectIndent;
|
package/dist/index.js
CHANGED
|
@@ -36,6 +36,7 @@ __export(exports_string, {
|
|
|
36
36
|
pathCase: () => pathCase,
|
|
37
37
|
pascalSnakeCase: () => pascalSnakeCase,
|
|
38
38
|
pascalCase: () => pascalCase,
|
|
39
|
+
paramCase: () => paramCase,
|
|
39
40
|
noCase: () => noCase,
|
|
40
41
|
lowercase: () => lowercase,
|
|
41
42
|
kebabCase: () => kebabCase,
|
|
@@ -86,7 +87,7 @@ var TITLE_TERMINATORS = new Set([
|
|
|
86
87
|
...SENTENCE_TERMINATORS,
|
|
87
88
|
":",
|
|
88
89
|
'"',
|
|
89
|
-
"
|
|
90
|
+
"'",
|
|
90
91
|
"\u201D"
|
|
91
92
|
]);
|
|
92
93
|
var SMALL_WORDS = new Set([
|
|
@@ -205,19 +206,19 @@ var SPLIT_LOWER_UPPER_RE = /([\p{Ll}\d])(\p{Lu})/gu;
|
|
|
205
206
|
var SPLIT_UPPER_UPPER_RE = /(\p{Lu})(\p{Lu}\p{Ll})/gu;
|
|
206
207
|
var SPLIT_SEPARATE_NUMBER_RE = /(\d)\p{Ll}|(\p{L})\d/u;
|
|
207
208
|
var DEFAULT_STRIP_REGEXP = /[^\p{L}\d]+/giu;
|
|
208
|
-
var SPLIT_REPLACE_VALUE = "$1\
|
|
209
|
+
var SPLIT_REPLACE_VALUE = "$1\x00$2";
|
|
209
210
|
var DEFAULT_PREFIX_SUFFIX_CHARACTERS = "";
|
|
210
211
|
function split(value) {
|
|
211
212
|
let result = value.trim();
|
|
212
213
|
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, "\
|
|
214
|
+
result = result.replace(DEFAULT_STRIP_REGEXP, "\x00");
|
|
214
215
|
let start = 0;
|
|
215
216
|
let end = result.length;
|
|
216
|
-
while (result.charAt(start) === "\
|
|
217
|
+
while (result.charAt(start) === "\x00")
|
|
217
218
|
start++;
|
|
218
219
|
if (start === end)
|
|
219
220
|
return [];
|
|
220
|
-
while (result.charAt(end - 1) === "\
|
|
221
|
+
while (result.charAt(end - 1) === "\x00")
|
|
221
222
|
end--;
|
|
222
223
|
return result.slice(start, end).split(/\0/g);
|
|
223
224
|
}
|
|
@@ -294,6 +295,9 @@ function snakeCase(input, options) {
|
|
|
294
295
|
function trainCase(input, options) {
|
|
295
296
|
return capitalCase(input, { delimiter: "-", ...options });
|
|
296
297
|
}
|
|
298
|
+
function paramCase(input, options) {
|
|
299
|
+
return kebabCase(input, options);
|
|
300
|
+
}
|
|
297
301
|
function lowerFactory(locale) {
|
|
298
302
|
return locale === false ? (input) => input.toLowerCase() : (input) => input.toLocaleLowerCase(locale);
|
|
299
303
|
}
|
|
@@ -346,7 +350,7 @@ var uncountables = {};
|
|
|
346
350
|
var irregularPlurals = {};
|
|
347
351
|
var irregularSingles = {};
|
|
348
352
|
function sanitizeRule(rule) {
|
|
349
|
-
return typeof rule === "string" ? new RegExp(`^${rule}
|
|
353
|
+
return typeof rule === "string" ? new RegExp(`^${rule}$`, "i") : rule;
|
|
350
354
|
}
|
|
351
355
|
function restoreCase(word, token) {
|
|
352
356
|
if (word === token)
|
|
@@ -651,9 +655,10 @@ pluralize.addIrregularRule = (single, plural2) => {
|
|
|
651
655
|
/pox$/i,
|
|
652
656
|
/sheep$/i
|
|
653
657
|
].forEach(pluralize.addUncountableRule);
|
|
658
|
+
var pluralize_default = pluralize;
|
|
654
659
|
|
|
655
660
|
// src/slug.ts
|
|
656
|
-
var charMap = JSON.parse(
|
|
661
|
+
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
662
|
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
663
|
function slugify(string, options = {}) {
|
|
659
664
|
if (typeof string !== "string") {
|
|
@@ -790,12 +795,16 @@ function detectNewline(string) {
|
|
|
790
795
|
if (newlines.length === 0) {
|
|
791
796
|
return;
|
|
792
797
|
}
|
|
793
|
-
const crlf = newlines.filter((newline) => newline ===
|
|
798
|
+
const crlf = newlines.filter((newline) => newline === `\r
|
|
799
|
+
`).length;
|
|
794
800
|
const lf = newlines.length - crlf;
|
|
795
|
-
return crlf > lf ?
|
|
801
|
+
return crlf > lf ? `\r
|
|
802
|
+
` : `
|
|
803
|
+
`;
|
|
796
804
|
}
|
|
797
805
|
function detectNewlineGraceful(string) {
|
|
798
|
-
return typeof string === "string" && detectNewline(string) ||
|
|
806
|
+
return typeof string === "string" && detectNewline(string) || `
|
|
807
|
+
`;
|
|
799
808
|
}
|
|
800
809
|
|
|
801
810
|
// src/utils.ts
|
|
@@ -887,7 +896,7 @@ var Str = {
|
|
|
887
896
|
return noCase(str);
|
|
888
897
|
},
|
|
889
898
|
paramCase(str) {
|
|
890
|
-
return
|
|
899
|
+
return paramCase(str);
|
|
891
900
|
},
|
|
892
901
|
pascalCase(str) {
|
|
893
902
|
return pascalCase(str);
|
|
@@ -908,28 +917,28 @@ var Str = {
|
|
|
908
917
|
return kebabCase(str);
|
|
909
918
|
},
|
|
910
919
|
plural(str) {
|
|
911
|
-
return plural(str);
|
|
920
|
+
return pluralize_default.plural(str);
|
|
912
921
|
},
|
|
913
922
|
singular(str) {
|
|
914
|
-
return singular(str);
|
|
923
|
+
return pluralize_default.singular(str);
|
|
915
924
|
},
|
|
916
925
|
isPlural(str) {
|
|
917
|
-
return
|
|
926
|
+
return pluralize_default.isPlural(str);
|
|
918
927
|
},
|
|
919
928
|
isSingular(str) {
|
|
920
|
-
return
|
|
929
|
+
return pluralize_default.isSingular(str);
|
|
921
930
|
},
|
|
922
931
|
addPluralRule(rule, repl) {
|
|
923
|
-
|
|
932
|
+
pluralize_default.addPluralRule(rule, repl);
|
|
924
933
|
},
|
|
925
934
|
addSingularRule(rule, repl) {
|
|
926
|
-
|
|
935
|
+
pluralize_default.addSingularRule(rule, repl);
|
|
927
936
|
},
|
|
928
937
|
addIrregularRule(single, plural2) {
|
|
929
|
-
|
|
938
|
+
pluralize_default.addIrregularRule(single, plural2);
|
|
930
939
|
},
|
|
931
940
|
addUncountableRule(word) {
|
|
932
|
-
|
|
941
|
+
pluralize_default.addUncountableRule(word);
|
|
933
942
|
}
|
|
934
943
|
};
|
|
935
944
|
var str = Str;
|
|
@@ -958,6 +967,7 @@ export {
|
|
|
958
967
|
pathCase,
|
|
959
968
|
pascalSnakeCase,
|
|
960
969
|
pascalCase,
|
|
970
|
+
paramCase,
|
|
961
971
|
noCase,
|
|
962
972
|
lowercase,
|
|
963
973
|
kebabCase,
|
package/dist/macro.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export declare const Str: {
|
|
|
6
6
|
* Truncate a string
|
|
7
7
|
*/
|
|
8
8
|
truncate: () => unknown;
|
|
9
|
-
random: (length
|
|
9
|
+
random: (length, dict?: string) => void;
|
|
10
10
|
capitalize: (str: string) => void;
|
|
11
11
|
slug: (str: string) => void;
|
|
12
12
|
detectIndent: (str: string) => void;
|
package/dist/pluralize.d.ts
CHANGED
|
@@ -4,7 +4,8 @@ export declare interface PluralizeOptions {
|
|
|
4
4
|
}
|
|
5
5
|
declare type Rule = [RegExp, string]
|
|
6
6
|
type StringOrRegExp = string | RegExp
|
|
7
|
-
|
|
7
|
+
|
|
8
|
+
interface PluralizeFunction {
|
|
8
9
|
(word: string, options?: PluralizeOptions): string
|
|
9
10
|
plural: (word: string) => string
|
|
10
11
|
isPlural: (word: string) => boolean
|
|
@@ -15,18 +16,18 @@ declare interface PluralizeFunction {
|
|
|
15
16
|
addUncountableRule: (word: string | RegExp) => void
|
|
16
17
|
addIrregularRule: (single: string, plural: string) => void
|
|
17
18
|
}
|
|
18
|
-
|
|
19
|
-
|
|
19
|
+
|
|
20
|
+
const pluralRules: Rule[] = []
|
|
21
|
+
const singularRules: Rule[] = []
|
|
22
|
+
const uncountables: Record<string, boolean> = {}
|
|
23
|
+
const irregularPlurals: Record<string, string> = {}
|
|
24
|
+
const irregularSingles: Record<string, string> = {}
|
|
20
25
|
declare function sanitizeRule(rule: string | RegExp): RegExp;
|
|
21
26
|
declare function restoreCase(word: string, token: string): string;
|
|
22
27
|
declare function interpolate(str: string, ...args: any[]): string;
|
|
23
28
|
declare function replace(word: string, rule: Rule): string;
|
|
24
29
|
declare function sanitizeWord(token: string, word: string, rules: Rule[]): string;
|
|
25
|
-
declare function replaceWord(replaceMap: Record<string, string>, keepMap: Record<string, string>, rules: Rule[]): (word: string) => string
|
|
26
|
-
declare function checkWord(replaceMap: Record<string, string>, keepMap: Record<string, string>, rules: Rule[]): (word: string) => boolean
|
|
27
|
-
export declare const pluralize: PluralizeFunction;
|
|
28
|
-
export declare const singular: PluralizeFunction;
|
|
29
|
-
export declare const plural: PluralizeFunction;
|
|
30
|
-
declare const lowerPlural: unknown;
|
|
30
|
+
declare function replaceWord(replaceMap: Record<string, string>, keepMap: Record<string, string>, rules: Rule[]): (word: string) => string;
|
|
31
|
+
declare function checkWord(replaceMap: Record<string, string>, keepMap: Record<string, string>, rules: Rule[]): (word: string) => boolean;
|
|
31
32
|
|
|
32
33
|
export default pluralize;
|
package/dist/slug.d.ts
CHANGED
|
@@ -8,6 +8,9 @@ export declare interface SlugifyOptions {
|
|
|
8
8
|
}
|
|
9
9
|
declare type CharMap = Record<string, string>
|
|
10
10
|
type LocaleMap = Record<string, CharMap>
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
|
|
12
|
+
const charMap: CharMap = JSON.parse('{"$":"dollar","%":"percent","&":"and","<":"less",">":"greater","|":"or","¢":"cent","£":"pound","¤":"currency","¥":"yen","©":"(c)","ª":"a","®":"(r)","º":"o","À":"A","Á":"A","Â":"A","Ã":"A","Ä":"A","Å":"A","Æ":"AE","Ç":"C","È":"E","É":"E","Ê":"E","Ë":"E","Ì":"I","Í":"I","Î":"I","Ï":"I","Ð":"D","Ñ":"N","Ò":"O","Ó":"O","Ô":"O","Õ":"O","Ö":"O","Ø":"O","Ù":"U","Ú":"U","Û":"U","Ü":"U","Ý":"Y","Þ":"TH","ß":"ss","à":"a","á":"a","â":"a","ã":"a","ä":"a","å":"a","æ":"ae","ç":"c","è":"e","é":"e","ê":"e","ë":"e","ì":"i","í":"i","î":"i","ï":"i","ð":"d","ñ":"n","ò":"o","ó":"o","ô":"o","õ":"o","ö":"o","ø":"o","ù":"u","ú":"u","û":"u","ü":"u","ý":"y","þ":"th","ÿ":"y","Ā":"A","ā":"a","Ă":"A","ă":"a","Ą":"A","ą":"a","Ć":"C","ć":"c","Č":"C","č":"c","Ď":"D","ď":"d","Đ":"DJ","đ":"dj","Ē":"E","ē":"e","Ė":"E","ė":"e","Ę":"e","ę":"e","Ě":"E","ě":"e","Ğ":"G","ğ":"g","Ģ":"G","ģ":"g","Ĩ":"I","ĩ":"i","Ī":"i","ī":"i","Į":"I","į":"i","İ":"I","ı":"i","Ķ":"k","ķ":"k","Ļ":"L","ļ":"l","Ľ":"L","ľ":"l","Ł":"L","ł":"l","Ń":"N","ń":"n","Ņ":"N","ņ":"n","Ň":"N","ň":"n","Ō":"O","ō":"o","Ő":"O","ő":"o","Œ":"OE","œ":"oe","Ŕ":"R","ŕ":"r","Ř":"R","ř":"r","Ś":"S","ś":"s","Ş":"S","ş":"s","Š":"S","š":"s","Ţ":"T","ţ":"t","Ť":"T","ť":"t","Ũ":"U","ũ":"u","Ū":"u","ū":"u","Ů":"U","ů":"u","Ű":"U","ű":"u","Ų":"U","ų":"u","Ŵ":"W","ŵ":"w","Ŷ":"Y","ŷ":"y","Ÿ":"Y","Ź":"Z","ź":"z","Ż":"Z","ż":"z","Ž":"Z","ž":"z","Ə":"E","ƒ":"f","Ơ":"O","ơ":"o","Ư":"U","ư":"u","Lj":"LJ","lj":"lj","Nj":"NJ","nj":"nj","Ș":"S","ș":"s","Ț":"T","ț":"t","ə":"e","˚":"o","Ά":"A","Έ":"E","Ή":"H","Ί":"I","Ό":"O","Ύ":"Y","Ώ":"W","ΐ":"i","Α":"A","Β":"B","Γ":"G","Δ":"D","Ε":"E","Ζ":"Z","Η":"H","Θ":"8","Ι":"I","Κ":"K","Λ":"L","Μ":"M","Ν":"N","Ξ":"3","Ο":"O","Π":"P","Ρ":"R","Σ":"S","Τ":"T","Υ":"Y","Φ":"F","Χ":"X","Ψ":"PS","Ω":"W","Ϊ":"I","Ϋ":"Y","ά":"a","έ":"e","ή":"h","ί":"i","ΰ":"y","α":"a","β":"b","γ":"g","δ":"d","ε":"e","ζ":"z","η":"h","θ":"8","ι":"i","κ":"k","λ":"l","μ":"m","ν":"n","ξ":"3","ο":"o","π":"p","ρ":"r","ς":"s","σ":"s","τ":"t","υ":"y","φ":"f","χ":"x","ψ":"ps","ω":"w","ϊ":"i","ϋ":"y","ό":"o","ύ":"y","ώ":"w","Ё":"Yo","Ђ":"DJ","Є":"Ye","І":"I","Ї":"Yi","Ј":"J","Љ":"LJ","Њ":"NJ","Ћ":"C","Џ":"DZ","А":"A","Б":"B","В":"V","Г":"G","Д":"D","Е":"E","Ж":"Zh","З":"Z","И":"I","Й":"J","К":"K","Л":"L","М":"M","Н":"N","О":"O","П":"P","Р":"R","С":"S","Т":"T","У":"U","Ф":"F","Х":"H","Ц":"C","Ч":"Ch","Ш":"Sh","Щ":"Sh","Ъ":"U","Ы":"Y","Ь":"","Э":"E","Ю":"Yu","Я":"Ya","а":"a","б":"b","в":"v","г":"g","д":"d","е":"e","ж":"zh","з":"z","и":"i","й":"j","к":"k","л":"l","м":"m","н":"n","о":"o","п":"p","р":"r","с":"s","т":"t","у":"u","ф":"f","х":"h","ц":"c","ч":"ch","ш":"sh","щ":"sh","ъ":"u","ы":"y","ь":"","э":"e","ю":"yu","я":"ya","ё":"yo","ђ":"dj","є":"ye","і":"i","ї":"yi","ј":"j","љ":"lj","њ":"nj","ћ":"c","ѝ":"u","џ":"dz","Ґ":"G","ґ":"g","Ғ":"GH","ғ":"gh","Қ":"KH","қ":"kh","Ң":"NG","ң":"ng","Ү":"UE","ү":"ue","Ұ":"U","ұ":"u","Һ":"H","һ":"h","Ә":"AE","ә":"ae","Ө":"OE","ө":"oe","Ա":"A","Բ":"B","Գ":"G","Դ":"D","Ե":"E","Զ":"Z","Է":"E\'","Ը":"Y\'","Թ":"T\'","Ժ":"JH","Ի":"I","Լ":"L","Խ":"X","Ծ":"C\'","Կ":"K","Հ":"H","Ձ":"D\'","Ղ":"GH","Ճ":"TW","Մ":"M","Յ":"Y","Ն":"N","Շ":"SH","Չ":"CH","Պ":"P","Ջ":"J","Ռ":"R\'","Ս":"S","Վ":"V","Տ":"T","Ր":"R","Ց":"C","Փ":"P\'","Ք":"Q\'","Օ":"O\'\'","Ֆ":"F","և":"EV","ء":"a","آ":"aa","أ":"a","ؤ":"u","إ":"i","ئ":"e","ا":"a","ب":"b","ة":"h","ت":"t","ث":"th","ج":"j","ح":"h","خ":"kh","د":"d","ذ":"th","ر":"r","ز":"z","س":"s","ش":"sh","ص":"s","ض":"dh","ط":"t","ظ":"z","ع":"a","غ":"gh","ف":"f","ق":"q","ك":"k","ل":"l","م":"m","ن":"n","ه":"h","و":"w","ى":"a","ي":"y","ً":"an","ٌ":"on","ٍ":"en","َ":"a","ُ":"u","ِ":"e","ْ":"","٠":"0","١":"1","٢":"2","٣":"3","٤":"4","٥":"5","٦":"6","٧":"7","٨":"8","٩":"9","پ":"p","چ":"ch","ژ":"zh","ک":"k","گ":"g","ی":"y","۰":"0","۱":"1","۲":"2","۳":"3","۴":"4","۵":"5","۶":"6","۷":"7","۸":"8","۹":"9","฿":"baht","ა":"a","ბ":"b","გ":"g","დ":"d","ე":"e","ვ":"v","ზ":"z","თ":"t","ი":"i","კ":"k","ლ":"l","მ":"m","ნ":"n","ო":"o","პ":"p","ჟ":"zh","რ":"r","ს":"s","ტ":"t","უ":"u","ფ":"f","ქ":"k","ღ":"gh","ყ":"q","შ":"sh","ჩ":"ch","ც":"ts","ძ":"dz","წ":"ts","ჭ":"ch","ხ":"kh","ჯ":"j","ჰ":"h","Ṣ":"S","ṣ":"s","Ẁ":"W","ẁ":"w","Ẃ":"W","ẃ":"w","Ẅ":"W","ẅ":"w","ẞ":"SS","Ạ":"A","ạ":"a","Ả":"A","ả":"a","Ấ":"A","ấ":"a","Ầ":"A","ầ":"a","Ẩ":"A","ẩ":"a","Ẫ":"A","ẫ":"a","Ậ":"A","ậ":"a","Ắ":"A","ắ":"a","Ằ":"A","ằ":"a","Ẳ":"A","ẳ":"a","Ẵ":"A","ẵ":"a","Ặ":"A","ặ":"a","Ẹ":"E","ẹ":"e","Ẻ":"E","ẻ":"e","Ẽ":"E","ẽ":"e","Ế":"E","ế":"e","Ề":"E","ề":"e","Ể":"E","ể":"e","Ễ":"E","ễ":"e","Ệ":"E","ệ":"e","Ỉ":"I","ỉ":"i","Ị":"I","ị":"i","Ọ":"O","ọ":"o","Ỏ":"O","ỏ":"o","Ố":"O","ố":"o","Ồ":"O","ồ":"o","Ổ":"O","ổ":"o","Ỗ":"O","ỗ":"o","Ộ":"O","ộ":"o","Ớ":"O","ớ":"o","Ờ":"O","ờ":"o","Ở":"O","ở":"o","Ỡ":"O","ỡ":"o","Ợ":"O","ợ":"o","Ụ":"U","ụ":"u","Ủ":"U","ủ":"u","Ứ":"U","ứ":"u","Ừ":"U","ừ":"u","Ử":"U","ử":"u","Ữ":"U","ữ":"u","Ự":"U","ự":"u","Ỳ":"Y","ỳ":"y","Ỵ":"Y","ỵ":"y","Ỷ":"Y","ỷ":"y","Ỹ":"Y","ỹ":"y","–":"-","‘":"\'","’":"\'","“":"\\\"","”":"\\\"","„":"\\\"","†":"+","•":"*","…":"...","₠":"ecu","₢":"cruzeiro","₣":"french franc","₤":"lira","₥":"mill","₦":"naira","₧":"peseta","₨":"rupee","₩":"won","₪":"new shequel","₫":"dong","€":"euro","₭":"kip","₮":"tugrik","₯":"drachma","₰":"penny","₱":"peso","₲":"guarani","₳":"austral","₴":"hryvnia","₵":"cedi","₸":"kazakhstani tenge","₹":"indian rupee","₺":"turkish lira","₽":"russian ruble","₿":"bitcoin","℠":"sm","™":"tm","∂":"d","∆":"delta","∑":"sum","∞":"infinity","♥":"love","元":"yuan","円":"yen","﷼":"rial","ﻵ":"laa","ﻷ":"laa","ﻹ":"lai","ﻻ":"la"}')
|
|
13
|
+
|
|
14
|
+
const locales: LocaleMap = JSON.parse('{"bg":{"Й":"Y","Ц":"Ts","Щ":"Sht","Ъ":"A","Ь":"Y","й":"y","ц":"ts","щ":"sht","ъ":"a","ь":"y"},"de":{"Ä":"AE","ä":"ae","Ö":"OE","ö":"oe","Ü":"UE","ü":"ue","ß":"ss","%":"prozent","&":"und","|":"oder","∑":"summe","∞":"unendlich","♥":"liebe"},"es":{"%":"por ciento","&":"y","<":"menor que",">":"mayor que","|":"o","¢":"centavos","£":"libras","¤":"moneda","₣":"francos","∑":"suma","∞":"infinito","♥":"amor"},"fr":{"%":"pourcent","&":"et","<":"plus petit",">":"plus grand","|":"ou","¢":"centime","£":"livre","¤":"devise","₣":"franc","∑":"somme","∞":"infini","♥":"amour"},"pt":{"%":"porcento","&":"e","<":"menor",">":"maior","|":"ou","¢":"centavo","∑":"soma","£":"libra","∞":"infinito","♥":"amor"},"uk":{"И":"Y","и":"y","Й":"Y","й":"y","Ц":"Ts","ц":"ts","Х":"Kh","х":"kh","Щ":"Shch","щ":"shch","Г":"H","г":"h"},"vi":{"Đ":"D","đ":"d"},"da":{"Ø":"OE","ø":"oe","Å":"AA","å":"aa","%":"procent","&":"og","|":"eller","$":"dollar","<":"mindre end",">":"større end"},"nb":{"&":"og","Å":"AA","Æ":"AE","Ø":"OE","å":"aa","æ":"ae","ø":"oe"},"it":{"&":"e"},"nl":{"&":"en"},"sv":{"&":"och","Å":"AA","Ä":"AE","Ö":"OE","å":"aa","ä":"ae","ö":"oe"}}')
|
|
15
|
+
export declare function slugify(string: string, options: SlugifyOptions): string;
|
|
13
16
|
export declare function extendCharMap(customMap: CharMap): void;
|
package/dist/title-case.d.ts
CHANGED
|
@@ -10,5 +10,5 @@ export declare interface TitleCaseOptions {
|
|
|
10
10
|
titleTerminators?: Set<string>
|
|
11
11
|
wordSeparators?: Set<string>
|
|
12
12
|
}
|
|
13
|
-
export declare function titleCase(input: string, options: TitleCaseOptions | string[] | string
|
|
14
|
-
declare function upperAt(input: string, index: number, locale: string | string[] | undefined
|
|
13
|
+
export declare function titleCase(input: string, options: TitleCaseOptions | string[] | string): string;
|
|
14
|
+
declare function upperAt(input: string, index: number, locale: string | string[] | undefined): void;
|
package/dist/utils.d.ts
CHANGED
|
@@ -11,8 +11,9 @@ export declare function slash(str: string): string;
|
|
|
11
11
|
export declare function ensurePrefix(prefix: string, str: string): string;
|
|
12
12
|
export declare function ensureSuffix(suffix: string, str: string): string;
|
|
13
13
|
export declare function template(str: string, ...args: any[]): string;
|
|
14
|
-
export declare function truncate(str: string, length: number, end
|
|
15
|
-
export declare function random(size
|
|
14
|
+
export declare function truncate(str: string, length: number, end): string;
|
|
15
|
+
export declare function random(size, dict: string): string;
|
|
16
16
|
export declare function slug(str: string, options?: SlugOptions): string;
|
|
17
|
+
|
|
17
18
|
export * from './detect-indent'
|
|
18
19
|
export * from './detect-newline'
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stacksjs/strings",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.69.1",
|
|
5
5
|
"description": "The Stacks string utilities.",
|
|
6
6
|
"author": "Chris Breuer",
|
|
7
7
|
"contributors": ["Chris Breuer <chris@stacksjs.org>"],
|
|
@@ -51,14 +51,12 @@
|
|
|
51
51
|
"test": "bun test",
|
|
52
52
|
"prepublishOnly": "bun run build"
|
|
53
53
|
},
|
|
54
|
-
"
|
|
54
|
+
"devDependencies": {
|
|
55
|
+
"@stacksjs/alias": "0.68.2",
|
|
56
|
+
"@stacksjs/development": "0.68.2",
|
|
57
|
+
"@stacksjs/types": "0.68.2",
|
|
58
|
+
"@types/validator": "^13.12.2",
|
|
55
59
|
"macroable": "^7.0.2",
|
|
56
60
|
"validator": "^13.12.0"
|
|
57
|
-
},
|
|
58
|
-
"devDependencies": {
|
|
59
|
-
"@stacksjs/alias": "0.68.1",
|
|
60
|
-
"@stacksjs/development": "0.68.1",
|
|
61
|
-
"@stacksjs/types": "0.68.1",
|
|
62
|
-
"@types/validator": "^13.12.2"
|
|
63
61
|
}
|
|
64
62
|
}
|