@stryke/string-format 0.13.2 → 0.13.3
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/CHANGELOG.md +7 -0
- package/dist/acronyms.cjs +411 -1
- package/dist/acronyms.mjs +407 -1
- package/dist/acronyms.mjs.map +1 -1
- package/dist/articles.cjs +10 -1
- package/dist/articles.mjs +9 -1
- package/dist/articles.mjs.map +1 -1
- package/dist/camel-case.cjs +32 -1
- package/dist/camel-case.mjs +31 -1
- package/dist/camel-case.mjs.map +1 -1
- package/dist/combine.cjs +15 -1
- package/dist/combine.mjs +14 -1
- package/dist/combine.mjs.map +1 -1
- package/dist/conjunctions.cjs +32 -1
- package/dist/conjunctions.mjs +31 -1
- package/dist/conjunctions.mjs.map +1 -1
- package/dist/constant-case.cjs +32 -1
- package/dist/constant-case.mjs +31 -1
- package/dist/constant-case.mjs.map +1 -1
- package/dist/deburr.cjs +28 -1
- package/dist/deburr.mjs +28 -1
- package/dist/deburr.mjs.map +1 -1
- package/dist/decamelize.cjs +14 -1
- package/dist/decamelize.mjs +13 -1
- package/dist/decamelize.mjs.map +1 -1
- package/dist/escape.cjs +49 -1
- package/dist/escape.mjs +47 -1
- package/dist/escape.mjs.map +1 -1
- package/dist/format-special-cases.cjs +33 -1
- package/dist/format-special-cases.mjs +33 -1
- package/dist/format-special-cases.mjs.map +1 -1
- package/dist/get-words.cjs +40 -1
- package/dist/get-words.mjs +37 -1
- package/dist/get-words.mjs.map +1 -1
- package/dist/helpers/src/remove-accents.cjs +415 -1
- package/dist/helpers/src/remove-accents.mjs +414 -1
- package/dist/helpers/src/remove-accents.mjs.map +1 -1
- package/dist/index.cjs +75 -1
- package/dist/index.mjs +30 -1
- package/dist/kebab-case.cjs +34 -1
- package/dist/kebab-case.mjs +33 -1
- package/dist/kebab-case.mjs.map +1 -1
- package/dist/lower-case-first.cjs +17 -1
- package/dist/lower-case-first.mjs +16 -1
- package/dist/lower-case-first.mjs.map +1 -1
- package/dist/normalize-email.cjs +31 -1
- package/dist/normalize-email.mjs +30 -1
- package/dist/normalize-email.mjs.map +1 -1
- package/dist/package.cjs +124 -1
- package/dist/package.mjs +120 -1
- package/dist/package.mjs.map +1 -1
- package/dist/pad.cjs +25 -1
- package/dist/pad.mjs +24 -1
- package/dist/pad.mjs.map +1 -1
- package/dist/pascal-case.cjs +32 -1
- package/dist/pascal-case.mjs +31 -1
- package/dist/pascal-case.mjs.map +1 -1
- package/dist/period-split.cjs +38 -1
- package/dist/period-split.mjs +37 -1
- package/dist/period-split.mjs.map +1 -1
- package/dist/prepositions.cjs +68 -1
- package/dist/prepositions.mjs +67 -1
- package/dist/prepositions.mjs.map +1 -1
- package/dist/pretty-bytes.cjs +129 -1
- package/dist/pretty-bytes.mjs +127 -1
- package/dist/pretty-bytes.mjs.map +1 -1
- package/dist/snake-case.cjs +42 -1
- package/dist/snake-case.mjs +41 -1
- package/dist/snake-case.mjs.map +1 -1
- package/dist/special-cases.cjs +53 -1
- package/dist/special-cases.mjs +52 -1
- package/dist/special-cases.mjs.map +1 -1
- package/dist/start-case.cjs +46 -1
- package/dist/start-case.mjs +45 -1
- package/dist/start-case.mjs.map +1 -1
- package/dist/strip-indents.cjs +24 -3
- package/dist/strip-indents.mjs +23 -3
- package/dist/strip-indents.mjs.map +1 -1
- package/dist/title-case.cjs +19 -1
- package/dist/title-case.mjs +19 -1
- package/dist/title-case.mjs.map +1 -1
- package/dist/types/src/base.cjs +6 -1
- package/dist/types/src/base.mjs +5 -1
- package/dist/types/src/base.mjs.map +1 -1
- package/dist/unescape.cjs +30 -1
- package/dist/unescape.mjs +29 -1
- package/dist/unescape.mjs.map +1 -1
- package/dist/upper-case-first.cjs +17 -1
- package/dist/upper-case-first.mjs +16 -1
- package/dist/upper-case-first.mjs.map +1 -1
- package/dist/vowels.cjs +40 -1
- package/dist/vowels.mjs +38 -1
- package/dist/vowels.mjs.map +1 -1
- package/package.json +2 -2
package/dist/articles.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"articles.mjs","names":[],"sources":["../src/articles.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nexport const ARTICLES = [\"a\", \"an\", \"the\"];\n"],"mappings":"AAkBA,MAAa,
|
|
1
|
+
{"version":3,"file":"articles.mjs","names":[],"sources":["../src/articles.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nexport const ARTICLES = [\"a\", \"an\", \"the\"];\n"],"mappings":";AAkBA,MAAa,WAAW;CAAC;CAAK;CAAM;CAAM"}
|
package/dist/camel-case.cjs
CHANGED
|
@@ -1 +1,32 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_acronyms = require('./acronyms.cjs');
|
|
2
|
+
const require_get_words = require('./get-words.cjs');
|
|
3
|
+
|
|
4
|
+
//#region src/camel-case.ts
|
|
5
|
+
/**
|
|
6
|
+
* Check if the input string is in camel case.
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* Camel case is defined as a lowercase first letter followed by any number of uppercase letters and digits - "thisIsAnExample".
|
|
10
|
+
*
|
|
11
|
+
* @param input - The input string to check.
|
|
12
|
+
* @returns True if the input is in camel case, false otherwise.
|
|
13
|
+
*/
|
|
14
|
+
function isCamelCase(input) {
|
|
15
|
+
return input ? /^[a-z][a-z0-9]*$/.test(input) && require_acronyms.ACRONYM_LIST.includes(input.trim().toUpperCase()) || /^(?:[a-z][a-z0-9]*[A-Z]+)*$/.test(input) : false;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Convert the input string to camel case.
|
|
19
|
+
*
|
|
20
|
+
* @remarks
|
|
21
|
+
* Camel case is defined as a lowercase first letter followed by any number of uppercase letters and digits - "thisIsAnExample".
|
|
22
|
+
*
|
|
23
|
+
* @param input - The input string.
|
|
24
|
+
* @returns The camel-cased string.
|
|
25
|
+
*/
|
|
26
|
+
function camelCase(input) {
|
|
27
|
+
return isCamelCase(input) || input === void 0 ? input : require_get_words.getWords(input).map((word, index) => index === 0 ? word.trim().toLowerCase() : require_acronyms.ACRONYM_LIST.includes(word.trim().toUpperCase()) ? require_acronyms.ACRONYMS[word.trim().toUpperCase()]?.display || word.trim().toUpperCase() : word.trim().charAt(0).toUpperCase() + word.trim().slice(1).toLowerCase()).join("");
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
//#endregion
|
|
31
|
+
exports.camelCase = camelCase;
|
|
32
|
+
exports.isCamelCase = isCamelCase;
|
package/dist/camel-case.mjs
CHANGED
|
@@ -1,2 +1,32 @@
|
|
|
1
|
-
import{ACRONYMS
|
|
1
|
+
import { ACRONYMS, ACRONYM_LIST } from "./acronyms.mjs";
|
|
2
|
+
import { getWords } from "./get-words.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/camel-case.ts
|
|
5
|
+
/**
|
|
6
|
+
* Check if the input string is in camel case.
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* Camel case is defined as a lowercase first letter followed by any number of uppercase letters and digits - "thisIsAnExample".
|
|
10
|
+
*
|
|
11
|
+
* @param input - The input string to check.
|
|
12
|
+
* @returns True if the input is in camel case, false otherwise.
|
|
13
|
+
*/
|
|
14
|
+
function isCamelCase(input) {
|
|
15
|
+
return input ? /^[a-z][a-z0-9]*$/.test(input) && ACRONYM_LIST.includes(input.trim().toUpperCase()) || /^(?:[a-z][a-z0-9]*[A-Z]+)*$/.test(input) : false;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Convert the input string to camel case.
|
|
19
|
+
*
|
|
20
|
+
* @remarks
|
|
21
|
+
* Camel case is defined as a lowercase first letter followed by any number of uppercase letters and digits - "thisIsAnExample".
|
|
22
|
+
*
|
|
23
|
+
* @param input - The input string.
|
|
24
|
+
* @returns The camel-cased string.
|
|
25
|
+
*/
|
|
26
|
+
function camelCase(input) {
|
|
27
|
+
return isCamelCase(input) || input === void 0 ? input : getWords(input).map((word, index) => index === 0 ? word.trim().toLowerCase() : ACRONYM_LIST.includes(word.trim().toUpperCase()) ? ACRONYMS[word.trim().toUpperCase()]?.display || word.trim().toUpperCase() : word.trim().charAt(0).toUpperCase() + word.trim().slice(1).toLowerCase()).join("");
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
//#endregion
|
|
31
|
+
export { camelCase, isCamelCase };
|
|
2
32
|
//# sourceMappingURL=camel-case.mjs.map
|
package/dist/camel-case.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"camel-case.mjs","names":[],"sources":["../src/camel-case.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { ACRONYM_LIST, ACRONYMS } from \"./acronyms\";\nimport { getWords } from \"./get-words\";\n\n/**\n * Check if the input string is in camel case.\n *\n * @remarks\n * Camel case is defined as a lowercase first letter followed by any number of uppercase letters and digits - \"thisIsAnExample\".\n *\n * @param input - The input string to check.\n * @returns True if the input is in camel case, false otherwise.\n */\nexport function isCamelCase(input: string | undefined): boolean {\n return input\n ? (/^[a-z][a-z0-9]*$/.test(input) &&\n ACRONYM_LIST.includes(input.trim().toUpperCase())) ||\n /^(?:[a-z][a-z0-9]*[A-Z]+)*$/.test(input)\n : false;\n}\n\n/**\n * Convert the input string to camel case.\n *\n * @remarks\n * Camel case is defined as a lowercase first letter followed by any number of uppercase letters and digits - \"thisIsAnExample\".\n *\n * @param input - The input string.\n * @returns The camel-cased string.\n */\nexport function camelCase<T extends string | undefined>(input: T): T {\n return (\n isCamelCase(input) || input === undefined\n ? input\n : getWords(input)\n .map((word, index) =>\n index === 0\n ? word.trim().toLowerCase()\n : ACRONYM_LIST.includes(word.trim().toUpperCase())\n ? ACRONYMS[word.trim().toUpperCase()]?.display ||\n word.trim().toUpperCase()\n : word.trim().charAt(0).toUpperCase() +\n word.trim().slice(1).toLowerCase()\n )\n .join(\"\")\n ) as T;\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"camel-case.mjs","names":[],"sources":["../src/camel-case.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { ACRONYM_LIST, ACRONYMS } from \"./acronyms\";\nimport { getWords } from \"./get-words\";\n\n/**\n * Check if the input string is in camel case.\n *\n * @remarks\n * Camel case is defined as a lowercase first letter followed by any number of uppercase letters and digits - \"thisIsAnExample\".\n *\n * @param input - The input string to check.\n * @returns True if the input is in camel case, false otherwise.\n */\nexport function isCamelCase(input: string | undefined): boolean {\n return input\n ? (/^[a-z][a-z0-9]*$/.test(input) &&\n ACRONYM_LIST.includes(input.trim().toUpperCase())) ||\n /^(?:[a-z][a-z0-9]*[A-Z]+)*$/.test(input)\n : false;\n}\n\n/**\n * Convert the input string to camel case.\n *\n * @remarks\n * Camel case is defined as a lowercase first letter followed by any number of uppercase letters and digits - \"thisIsAnExample\".\n *\n * @param input - The input string.\n * @returns The camel-cased string.\n */\nexport function camelCase<T extends string | undefined>(input: T): T {\n return (\n isCamelCase(input) || input === undefined\n ? input\n : getWords(input)\n .map((word, index) =>\n index === 0\n ? word.trim().toLowerCase()\n : ACRONYM_LIST.includes(word.trim().toUpperCase())\n ? ACRONYMS[word.trim().toUpperCase()]?.display ||\n word.trim().toUpperCase()\n : word.trim().charAt(0).toUpperCase() +\n word.trim().slice(1).toLowerCase()\n )\n .join(\"\")\n ) as T;\n}\n"],"mappings":";;;;;;;;;;;;;AA8BA,SAAgB,YAAY,OAAoC;AAC9D,QAAO,QACF,mBAAmB,KAAK,MAAM,IAC7B,aAAa,SAAS,MAAM,MAAM,CAAC,aAAa,CAAC,IACjD,8BAA8B,KAAK,MAAM,GAC3C;;;;;;;;;;;AAYN,SAAgB,UAAwC,OAAa;AACnE,QACE,YAAY,MAAM,IAAI,UAAU,SAC5B,QACA,SAAS,MAAM,CACZ,KAAK,MAAM,UACV,UAAU,IACN,KAAK,MAAM,CAAC,aAAa,GACzB,aAAa,SAAS,KAAK,MAAM,CAAC,aAAa,CAAC,GAC9C,SAAS,KAAK,MAAM,CAAC,aAAa,GAAG,WACrC,KAAK,MAAM,CAAC,aAAa,GACzB,KAAK,MAAM,CAAC,OAAO,EAAE,CAAC,aAAa,GACnC,KAAK,MAAM,CAAC,MAAM,EAAE,CAAC,aAAa,CACzC,CACA,KAAK,GAAG"}
|
package/dist/combine.cjs
CHANGED
|
@@ -1 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
//#region src/combine.ts
|
|
3
|
+
/**
|
|
4
|
+
* Combine two strings with a space in between.
|
|
5
|
+
*
|
|
6
|
+
* @param acc - The accumulated string.
|
|
7
|
+
* @param str - The string to add.
|
|
8
|
+
* @returns The combined string.
|
|
9
|
+
*/
|
|
10
|
+
function combine(acc, str) {
|
|
11
|
+
return `${acc} ${str}`;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
//#endregion
|
|
15
|
+
exports.combine = combine;
|
package/dist/combine.mjs
CHANGED
|
@@ -1,2 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/combine.ts
|
|
2
|
+
/**
|
|
3
|
+
* Combine two strings with a space in between.
|
|
4
|
+
*
|
|
5
|
+
* @param acc - The accumulated string.
|
|
6
|
+
* @param str - The string to add.
|
|
7
|
+
* @returns The combined string.
|
|
8
|
+
*/
|
|
9
|
+
function combine(acc, str) {
|
|
10
|
+
return `${acc} ${str}`;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
export { combine };
|
|
2
15
|
//# sourceMappingURL=combine.mjs.map
|
package/dist/combine.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"combine.mjs","names":[],"sources":["../src/combine.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\n/**\n * Combine two strings with a space in between.\n *\n * @param acc - The accumulated string.\n * @param str - The string to add.\n * @returns The combined string.\n */\nexport function combine(acc: string, str: string): string {\n return `${acc} ${str}`;\n}\n"],"mappings":"AAyBA,SAAgB,
|
|
1
|
+
{"version":3,"file":"combine.mjs","names":[],"sources":["../src/combine.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\n/**\n * Combine two strings with a space in between.\n *\n * @param acc - The accumulated string.\n * @param str - The string to add.\n * @returns The combined string.\n */\nexport function combine(acc: string, str: string): string {\n return `${acc} ${str}`;\n}\n"],"mappings":";;;;;;;;AAyBA,SAAgB,QAAQ,KAAa,KAAqB;AACxD,QAAO,GAAG,IAAI,GAAG"}
|
package/dist/conjunctions.cjs
CHANGED
|
@@ -1 +1,32 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
//#region src/conjunctions.ts
|
|
3
|
+
const CONJUNCTIONS = [
|
|
4
|
+
"and",
|
|
5
|
+
"that",
|
|
6
|
+
"but",
|
|
7
|
+
"or",
|
|
8
|
+
"as",
|
|
9
|
+
"if",
|
|
10
|
+
"when",
|
|
11
|
+
"than",
|
|
12
|
+
"because",
|
|
13
|
+
"while",
|
|
14
|
+
"where",
|
|
15
|
+
"after",
|
|
16
|
+
"so",
|
|
17
|
+
"though",
|
|
18
|
+
"since",
|
|
19
|
+
"until",
|
|
20
|
+
"whether",
|
|
21
|
+
"before",
|
|
22
|
+
"although",
|
|
23
|
+
"nor",
|
|
24
|
+
"like",
|
|
25
|
+
"once",
|
|
26
|
+
"unless",
|
|
27
|
+
"now",
|
|
28
|
+
"except"
|
|
29
|
+
];
|
|
30
|
+
|
|
31
|
+
//#endregion
|
|
32
|
+
exports.CONJUNCTIONS = CONJUNCTIONS;
|
package/dist/conjunctions.mjs
CHANGED
|
@@ -1,2 +1,32 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/conjunctions.ts
|
|
2
|
+
const CONJUNCTIONS = [
|
|
3
|
+
"and",
|
|
4
|
+
"that",
|
|
5
|
+
"but",
|
|
6
|
+
"or",
|
|
7
|
+
"as",
|
|
8
|
+
"if",
|
|
9
|
+
"when",
|
|
10
|
+
"than",
|
|
11
|
+
"because",
|
|
12
|
+
"while",
|
|
13
|
+
"where",
|
|
14
|
+
"after",
|
|
15
|
+
"so",
|
|
16
|
+
"though",
|
|
17
|
+
"since",
|
|
18
|
+
"until",
|
|
19
|
+
"whether",
|
|
20
|
+
"before",
|
|
21
|
+
"although",
|
|
22
|
+
"nor",
|
|
23
|
+
"like",
|
|
24
|
+
"once",
|
|
25
|
+
"unless",
|
|
26
|
+
"now",
|
|
27
|
+
"except"
|
|
28
|
+
];
|
|
29
|
+
|
|
30
|
+
//#endregion
|
|
31
|
+
export { CONJUNCTIONS };
|
|
2
32
|
//# sourceMappingURL=conjunctions.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"conjunctions.mjs","names":[],"sources":["../src/conjunctions.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nexport const CONJUNCTIONS = [\n \"and\",\n \"that\",\n \"but\",\n \"or\",\n \"as\",\n \"if\",\n \"when\",\n \"than\",\n \"because\",\n \"while\",\n \"where\",\n \"after\",\n \"so\",\n \"though\",\n \"since\",\n \"until\",\n \"whether\",\n \"before\",\n \"although\",\n \"nor\",\n \"like\",\n \"once\",\n \"unless\",\n \"now\",\n \"except\"\n];\n"],"mappings":"AAkBA,MAAa,
|
|
1
|
+
{"version":3,"file":"conjunctions.mjs","names":[],"sources":["../src/conjunctions.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nexport const CONJUNCTIONS = [\n \"and\",\n \"that\",\n \"but\",\n \"or\",\n \"as\",\n \"if\",\n \"when\",\n \"than\",\n \"because\",\n \"while\",\n \"where\",\n \"after\",\n \"so\",\n \"though\",\n \"since\",\n \"until\",\n \"whether\",\n \"before\",\n \"although\",\n \"nor\",\n \"like\",\n \"once\",\n \"unless\",\n \"now\",\n \"except\"\n];\n"],"mappings":";AAkBA,MAAa,eAAe;CAC1B;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACD"}
|
package/dist/constant-case.cjs
CHANGED
|
@@ -1 +1,32 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_get_words = require('./get-words.cjs');
|
|
2
|
+
const require_snake_case = require('./snake-case.cjs');
|
|
3
|
+
|
|
4
|
+
//#region src/constant-case.ts
|
|
5
|
+
/**
|
|
6
|
+
* Check if the input string is in constant case.
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* Constant case is defined as all uppercase letters with underscores separating words - "THIS_IS_AN_EXAMPLE".
|
|
10
|
+
*
|
|
11
|
+
* @param input - The input string to check.
|
|
12
|
+
* @returns True if the input is in constant case, false otherwise.
|
|
13
|
+
*/
|
|
14
|
+
function isConstantCase(input) {
|
|
15
|
+
return input ? /^[A-Z0-9_]+$/.test(input) : false;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Convert the input string to constant case.
|
|
19
|
+
*
|
|
20
|
+
* @remarks
|
|
21
|
+
* Constant case is defined as all uppercase letters with underscores separating words - "THIS_IS_AN_EXAMPLE".
|
|
22
|
+
*
|
|
23
|
+
* @param input - The input string.
|
|
24
|
+
* @returns The constant-cased string.
|
|
25
|
+
*/
|
|
26
|
+
function constantCase(input) {
|
|
27
|
+
return isConstantCase(input) || input === void 0 ? input : require_snake_case.isSnakeCase(input) ? input.toUpperCase() : require_get_words.getWords(input).join("_").toUpperCase();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
//#endregion
|
|
31
|
+
exports.constantCase = constantCase;
|
|
32
|
+
exports.isConstantCase = isConstantCase;
|
package/dist/constant-case.mjs
CHANGED
|
@@ -1,2 +1,32 @@
|
|
|
1
|
-
import{getWords
|
|
1
|
+
import { getWords } from "./get-words.mjs";
|
|
2
|
+
import { isSnakeCase } from "./snake-case.mjs";
|
|
3
|
+
|
|
4
|
+
//#region src/constant-case.ts
|
|
5
|
+
/**
|
|
6
|
+
* Check if the input string is in constant case.
|
|
7
|
+
*
|
|
8
|
+
* @remarks
|
|
9
|
+
* Constant case is defined as all uppercase letters with underscores separating words - "THIS_IS_AN_EXAMPLE".
|
|
10
|
+
*
|
|
11
|
+
* @param input - The input string to check.
|
|
12
|
+
* @returns True if the input is in constant case, false otherwise.
|
|
13
|
+
*/
|
|
14
|
+
function isConstantCase(input) {
|
|
15
|
+
return input ? /^[A-Z0-9_]+$/.test(input) : false;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Convert the input string to constant case.
|
|
19
|
+
*
|
|
20
|
+
* @remarks
|
|
21
|
+
* Constant case is defined as all uppercase letters with underscores separating words - "THIS_IS_AN_EXAMPLE".
|
|
22
|
+
*
|
|
23
|
+
* @param input - The input string.
|
|
24
|
+
* @returns The constant-cased string.
|
|
25
|
+
*/
|
|
26
|
+
function constantCase(input) {
|
|
27
|
+
return isConstantCase(input) || input === void 0 ? input : isSnakeCase(input) ? input.toUpperCase() : getWords(input).join("_").toUpperCase();
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
//#endregion
|
|
31
|
+
export { constantCase, isConstantCase };
|
|
2
32
|
//# sourceMappingURL=constant-case.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constant-case.mjs","names":[],"sources":["../src/constant-case.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { getWords } from \"./get-words\";\nimport { isSnakeCase } from \"./snake-case\";\n\n/**\n * Check if the input string is in constant case.\n *\n * @remarks\n * Constant case is defined as all uppercase letters with underscores separating words - \"THIS_IS_AN_EXAMPLE\".\n *\n * @param input - The input string to check.\n * @returns True if the input is in constant case, false otherwise.\n */\nexport function isConstantCase(input: string | undefined): boolean {\n return input ? /^[A-Z0-9_]+$/.test(input) : false;\n}\n\n/**\n * Convert the input string to constant case.\n *\n * @remarks\n * Constant case is defined as all uppercase letters with underscores separating words - \"THIS_IS_AN_EXAMPLE\".\n *\n * @param input - The input string.\n * @returns The constant-cased string.\n */\nexport function constantCase<T extends string | undefined>(input: T): T {\n return isConstantCase(input) || input === undefined\n ? input\n : isSnakeCase(input)\n ? (input.toUpperCase() as T)\n : (getWords(input).join(\"_\").toUpperCase() as T);\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"constant-case.mjs","names":[],"sources":["../src/constant-case.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { getWords } from \"./get-words\";\nimport { isSnakeCase } from \"./snake-case\";\n\n/**\n * Check if the input string is in constant case.\n *\n * @remarks\n * Constant case is defined as all uppercase letters with underscores separating words - \"THIS_IS_AN_EXAMPLE\".\n *\n * @param input - The input string to check.\n * @returns True if the input is in constant case, false otherwise.\n */\nexport function isConstantCase(input: string | undefined): boolean {\n return input ? /^[A-Z0-9_]+$/.test(input) : false;\n}\n\n/**\n * Convert the input string to constant case.\n *\n * @remarks\n * Constant case is defined as all uppercase letters with underscores separating words - \"THIS_IS_AN_EXAMPLE\".\n *\n * @param input - The input string.\n * @returns The constant-cased string.\n */\nexport function constantCase<T extends string | undefined>(input: T): T {\n return isConstantCase(input) || input === undefined\n ? input\n : isSnakeCase(input)\n ? (input.toUpperCase() as T)\n : (getWords(input).join(\"_\").toUpperCase() as T);\n}\n"],"mappings":";;;;;;;;;;;;;AA8BA,SAAgB,eAAe,OAAoC;AACjE,QAAO,QAAQ,eAAe,KAAK,MAAM,GAAG;;;;;;;;;;;AAY9C,SAAgB,aAA2C,OAAa;AACtE,QAAO,eAAe,MAAM,IAAI,UAAU,SACtC,QACA,YAAY,MAAM,GACf,MAAM,aAAa,GACnB,SAAS,MAAM,CAAC,KAAK,IAAI,CAAC,aAAa"}
|
package/dist/deburr.cjs
CHANGED
|
@@ -1 +1,28 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_remove_accents = require('./helpers/src/remove-accents.cjs');
|
|
2
|
+
|
|
3
|
+
//#region src/deburr.ts
|
|
4
|
+
/**
|
|
5
|
+
* Converts a string by replacing special characters and diacritical marks with their ASCII equivalents.
|
|
6
|
+
* For example, "Crème brûlée" becomes "Creme brulee".
|
|
7
|
+
*
|
|
8
|
+
* @param str - The input string to be deburred.
|
|
9
|
+
* @returns The deburred string with special characters replaced by their ASCII equivalents.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* // Basic usage:
|
|
13
|
+
* deburr('Æthelred') // returns 'Aethelred'
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* // Handling diacritical marks:
|
|
17
|
+
* deburr('München') // returns 'Munchen'
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* // Special characters:
|
|
21
|
+
* deburr('Crème brûlée') // returns 'Creme brulee'
|
|
22
|
+
*/
|
|
23
|
+
function deburr(str) {
|
|
24
|
+
return require_remove_accents.removeAccents(str.normalize("NFD"));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
exports.deburr = deburr;
|
package/dist/deburr.mjs
CHANGED
|
@@ -1,2 +1,29 @@
|
|
|
1
|
-
import{removeAccents
|
|
1
|
+
import { removeAccents } from "./helpers/src/remove-accents.mjs";
|
|
2
|
+
|
|
3
|
+
//#region src/deburr.ts
|
|
4
|
+
/**
|
|
5
|
+
* Converts a string by replacing special characters and diacritical marks with their ASCII equivalents.
|
|
6
|
+
* For example, "Crème brûlée" becomes "Creme brulee".
|
|
7
|
+
*
|
|
8
|
+
* @param str - The input string to be deburred.
|
|
9
|
+
* @returns The deburred string with special characters replaced by their ASCII equivalents.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* // Basic usage:
|
|
13
|
+
* deburr('Æthelred') // returns 'Aethelred'
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* // Handling diacritical marks:
|
|
17
|
+
* deburr('München') // returns 'Munchen'
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* // Special characters:
|
|
21
|
+
* deburr('Crème brûlée') // returns 'Creme brulee'
|
|
22
|
+
*/
|
|
23
|
+
function deburr(str) {
|
|
24
|
+
return removeAccents(str.normalize("NFD"));
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
//#endregion
|
|
28
|
+
export { deburr };
|
|
2
29
|
//# sourceMappingURL=deburr.mjs.map
|
package/dist/deburr.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"deburr.mjs","names":[],"sources":["../src/deburr.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { removeAccents } from \"@stryke/helpers/remove-accents\";\n\n/**\n * Converts a string by replacing special characters and diacritical marks with their ASCII equivalents.\n * For example, \"Crème brûlée\" becomes \"Creme brulee\".\n *\n * @param str - The input string to be deburred.\n * @returns The deburred string with special characters replaced by their ASCII equivalents.\n *\n * @example\n * // Basic usage:\n * deburr('Æthelred') // returns 'Aethelred'\n *\n * @example\n * // Handling diacritical marks:\n * deburr('München') // returns 'Munchen'\n *\n * @example\n * // Special characters:\n * deburr('Crème brûlée') // returns 'Creme brulee'\n */\nexport function deburr(str: string): string {\n return removeAccents(str.normalize(\"NFD\"));\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"deburr.mjs","names":[],"sources":["../src/deburr.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nimport { removeAccents } from \"@stryke/helpers/remove-accents\";\n\n/**\n * Converts a string by replacing special characters and diacritical marks with their ASCII equivalents.\n * For example, \"Crème brûlée\" becomes \"Creme brulee\".\n *\n * @param str - The input string to be deburred.\n * @returns The deburred string with special characters replaced by their ASCII equivalents.\n *\n * @example\n * // Basic usage:\n * deburr('Æthelred') // returns 'Aethelred'\n *\n * @example\n * // Handling diacritical marks:\n * deburr('München') // returns 'Munchen'\n *\n * @example\n * // Special characters:\n * deburr('Crème brûlée') // returns 'Creme brulee'\n */\nexport function deburr(str: string): string {\n return removeAccents(str.normalize(\"NFD\"));\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAuCA,SAAgB,OAAO,KAAqB;AAC1C,QAAO,cAAc,IAAI,UAAU,MAAM,CAAC"}
|
package/dist/decamelize.cjs
CHANGED
|
@@ -1 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
//#region src/decamelize.ts
|
|
3
|
+
/**
|
|
4
|
+
* Convert a camelCase or PascalCase string to a snake_case string.
|
|
5
|
+
*
|
|
6
|
+
* @param value - The camelCase or PascalCase string to convert.
|
|
7
|
+
* @returns The converted snake_case string.
|
|
8
|
+
*/
|
|
9
|
+
function decamelize(value) {
|
|
10
|
+
return value.replace(/([a-z\d])([A-Z])/g, "$1_$2").replace(/([A-Z]+)([A-Z][a-z\d]+)/g, "$1_$2").toLowerCase();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
//#endregion
|
|
14
|
+
exports.decamelize = decamelize;
|
package/dist/decamelize.mjs
CHANGED
|
@@ -1,2 +1,14 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/decamelize.ts
|
|
2
|
+
/**
|
|
3
|
+
* Convert a camelCase or PascalCase string to a snake_case string.
|
|
4
|
+
*
|
|
5
|
+
* @param value - The camelCase or PascalCase string to convert.
|
|
6
|
+
* @returns The converted snake_case string.
|
|
7
|
+
*/
|
|
8
|
+
function decamelize(value) {
|
|
9
|
+
return value.replace(/([a-z\d])([A-Z])/g, "$1_$2").replace(/([A-Z]+)([A-Z][a-z\d]+)/g, "$1_$2").toLowerCase();
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
//#endregion
|
|
13
|
+
export { decamelize };
|
|
2
14
|
//# sourceMappingURL=decamelize.mjs.map
|
package/dist/decamelize.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"decamelize.mjs","names":[],"sources":["../src/decamelize.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\n/**\n * Convert a camelCase or PascalCase string to a snake_case string.\n *\n * @param value - The camelCase or PascalCase string to convert.\n * @returns The converted snake_case string.\n */\nexport function decamelize(value: string): string {\n return value\n .replace(/([a-z\\d])([A-Z])/g, \"$1_$2\")\n .replace(/([A-Z]+)([A-Z][a-z\\d]+)/g, \"$1_$2\")\n .toLowerCase();\n}\n"],"mappings":"AAwBA,SAAgB,
|
|
1
|
+
{"version":3,"file":"decamelize.mjs","names":[],"sources":["../src/decamelize.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\n/**\n * Convert a camelCase or PascalCase string to a snake_case string.\n *\n * @param value - The camelCase or PascalCase string to convert.\n * @returns The converted snake_case string.\n */\nexport function decamelize(value: string): string {\n return value\n .replace(/([a-z\\d])([A-Z])/g, \"$1_$2\")\n .replace(/([A-Z]+)([A-Z][a-z\\d]+)/g, \"$1_$2\")\n .toLowerCase();\n}\n"],"mappings":";;;;;;;AAwBA,SAAgB,WAAW,OAAuB;AAChD,QAAO,MACJ,QAAQ,qBAAqB,QAAQ,CACrC,QAAQ,4BAA4B,QAAQ,CAC5C,aAAa"}
|
package/dist/escape.cjs
CHANGED
|
@@ -1 +1,49 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
2
|
+
//#region src/escape.ts
|
|
3
|
+
const htmlEscapes = {
|
|
4
|
+
"&": "&",
|
|
5
|
+
"<": "<",
|
|
6
|
+
">": ">",
|
|
7
|
+
"\"": """,
|
|
8
|
+
"'": "'"
|
|
9
|
+
};
|
|
10
|
+
/**
|
|
11
|
+
* Converts the characters "&", "\<", "\>", '"', and "'" in `str` to their corresponding HTML entities.
|
|
12
|
+
* For example, "\<" becomes "<".
|
|
13
|
+
*
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* ```ts
|
|
17
|
+
* escapeHtml('This is a <div> element.'); // returns 'This is a <div> element.'
|
|
18
|
+
* escapeHtml('This is a "quote"'); // returns 'This is a "quote"'
|
|
19
|
+
* escapeHtml("This is a 'quote'"); // returns 'This is a 'quote''
|
|
20
|
+
* escapeHtml('This is a & symbol'); // returns 'This is a & symbol'
|
|
21
|
+
* ```
|
|
22
|
+
*
|
|
23
|
+
* @param str - The string to escape.
|
|
24
|
+
* @returns Returns the escaped string.
|
|
25
|
+
*/
|
|
26
|
+
function escapeHtml(str) {
|
|
27
|
+
return str.replace(/["&'<>]/g, (match) => htmlEscapes[match] || "");
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Escapes RegExp special characters in the given string.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* ```ts
|
|
34
|
+
* escapeRegExp('what'); // returns 'what'
|
|
35
|
+
* escapeRegExp('what?'); // returns 'what\?'
|
|
36
|
+
* escapeRegExp('Price is $5.00'); // returns 'Price is \$5\.00'
|
|
37
|
+
* escapeRegExp('Use * as a wildcard'); // returns 'Use \* as a wildcard'
|
|
38
|
+
* ```
|
|
39
|
+
*
|
|
40
|
+
* @param str - The string to escape.
|
|
41
|
+
* @returns Returns the escaped string.
|
|
42
|
+
*/
|
|
43
|
+
function escapeRegExp(str) {
|
|
44
|
+
return str.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/-/g, "\\x2d");
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
//#endregion
|
|
48
|
+
exports.escapeHtml = escapeHtml;
|
|
49
|
+
exports.escapeRegExp = escapeRegExp;
|
package/dist/escape.mjs
CHANGED
|
@@ -1,2 +1,48 @@
|
|
|
1
|
-
|
|
1
|
+
//#region src/escape.ts
|
|
2
|
+
const htmlEscapes = {
|
|
3
|
+
"&": "&",
|
|
4
|
+
"<": "<",
|
|
5
|
+
">": ">",
|
|
6
|
+
"\"": """,
|
|
7
|
+
"'": "'"
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Converts the characters "&", "\<", "\>", '"', and "'" in `str` to their corresponding HTML entities.
|
|
11
|
+
* For example, "\<" becomes "<".
|
|
12
|
+
*
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```ts
|
|
16
|
+
* escapeHtml('This is a <div> element.'); // returns 'This is a <div> element.'
|
|
17
|
+
* escapeHtml('This is a "quote"'); // returns 'This is a "quote"'
|
|
18
|
+
* escapeHtml("This is a 'quote'"); // returns 'This is a 'quote''
|
|
19
|
+
* escapeHtml('This is a & symbol'); // returns 'This is a & symbol'
|
|
20
|
+
* ```
|
|
21
|
+
*
|
|
22
|
+
* @param str - The string to escape.
|
|
23
|
+
* @returns Returns the escaped string.
|
|
24
|
+
*/
|
|
25
|
+
function escapeHtml(str) {
|
|
26
|
+
return str.replace(/["&'<>]/g, (match) => htmlEscapes[match] || "");
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Escapes RegExp special characters in the given string.
|
|
30
|
+
*
|
|
31
|
+
* @example
|
|
32
|
+
* ```ts
|
|
33
|
+
* escapeRegExp('what'); // returns 'what'
|
|
34
|
+
* escapeRegExp('what?'); // returns 'what\?'
|
|
35
|
+
* escapeRegExp('Price is $5.00'); // returns 'Price is \$5\.00'
|
|
36
|
+
* escapeRegExp('Use * as a wildcard'); // returns 'Use \* as a wildcard'
|
|
37
|
+
* ```
|
|
38
|
+
*
|
|
39
|
+
* @param str - The string to escape.
|
|
40
|
+
* @returns Returns the escaped string.
|
|
41
|
+
*/
|
|
42
|
+
function escapeRegExp(str) {
|
|
43
|
+
return str.replace(/[|\\{}()[\]^$+*?.]/g, "\\$&").replace(/-/g, "\\x2d");
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
//#endregion
|
|
47
|
+
export { escapeHtml, escapeRegExp };
|
|
2
48
|
//# sourceMappingURL=escape.mjs.map
|
package/dist/escape.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"escape.mjs","names":["htmlEscapes: Record<string, string>"],"sources":["../src/escape.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nconst htmlEscapes: Record<string, string> = {\n \"&\": \"&\",\n \"<\": \"<\",\n \">\": \">\",\n '\"': \""\",\n \"'\": \"'\"\n};\n\n/**\n * Converts the characters \"&\", \"\\<\", \"\\>\", '\"', and \"'\" in `str` to their corresponding HTML entities.\n * For example, \"\\<\" becomes \"<\".\n *\n *\n * @example\n * ```ts\n * escapeHtml('This is a <div> element.'); // returns 'This is a <div> element.'\n * escapeHtml('This is a \"quote\"'); // returns 'This is a "quote"'\n * escapeHtml(\"This is a 'quote'\"); // returns 'This is a 'quote''\n * escapeHtml('This is a & symbol'); // returns 'This is a & symbol'\n * ```\n *\n * @param str - The string to escape.\n * @returns Returns the escaped string.\n */\nexport function escapeHtml(str: string): string {\n return str.replace(/[\"&'<>]/g, match => htmlEscapes[match] || \"\");\n}\n\n/**\n * Escapes RegExp special characters in the given string.\n *\n * @example\n * ```ts\n * escapeRegExp('what'); // returns 'what'\n * escapeRegExp('what?'); // returns 'what\\?'\n * escapeRegExp('Price is $5.00'); // returns 'Price is \\$5\\.00'\n * escapeRegExp('Use * as a wildcard'); // returns 'Use \\* as a wildcard'\n * ```\n *\n * @param str - The string to escape.\n * @returns Returns the escaped string.\n */\nexport function escapeRegExp(str: string) {\n // Escape characters with special meaning either inside or outside character sets.\n // Use a simple backslash escape when it’s always valid, and a `\\xnn` escape when\n // the simpler form would be disallowed by Unicode patterns’ stricter grammar.\n return str.replace(/[|\\\\{}()[\\]^$+*?.]/g, \"\\\\$&\").replace(/-/g, \"\\\\x2d\");\n}\n"],"mappings":"AAkBA,MAAMA,
|
|
1
|
+
{"version":3,"file":"escape.mjs","names":["htmlEscapes: Record<string, string>"],"sources":["../src/escape.ts"],"sourcesContent":["/* -------------------------------------------------------------------\n\n ⚡ Storm Software - Stryke\n\n This code was released as part of the Stryke project. Stryke\n is maintained by Storm Software under the Apache-2.0 license, and is\n free for commercial and private use. For more information, please visit\n our licensing page at https://stormsoftware.com/licenses/projects/stryke.\n\n Website: https://stormsoftware.com\n Repository: https://github.com/storm-software/stryke\n Documentation: https://docs.stormsoftware.com/projects/stryke\n Contact: https://stormsoftware.com/contact\n\n SPDX-License-Identifier: Apache-2.0\n\n ------------------------------------------------------------------- */\n\nconst htmlEscapes: Record<string, string> = {\n \"&\": \"&\",\n \"<\": \"<\",\n \">\": \">\",\n '\"': \""\",\n \"'\": \"'\"\n};\n\n/**\n * Converts the characters \"&\", \"\\<\", \"\\>\", '\"', and \"'\" in `str` to their corresponding HTML entities.\n * For example, \"\\<\" becomes \"<\".\n *\n *\n * @example\n * ```ts\n * escapeHtml('This is a <div> element.'); // returns 'This is a <div> element.'\n * escapeHtml('This is a \"quote\"'); // returns 'This is a "quote"'\n * escapeHtml(\"This is a 'quote'\"); // returns 'This is a 'quote''\n * escapeHtml('This is a & symbol'); // returns 'This is a & symbol'\n * ```\n *\n * @param str - The string to escape.\n * @returns Returns the escaped string.\n */\nexport function escapeHtml(str: string): string {\n return str.replace(/[\"&'<>]/g, match => htmlEscapes[match] || \"\");\n}\n\n/**\n * Escapes RegExp special characters in the given string.\n *\n * @example\n * ```ts\n * escapeRegExp('what'); // returns 'what'\n * escapeRegExp('what?'); // returns 'what\\?'\n * escapeRegExp('Price is $5.00'); // returns 'Price is \\$5\\.00'\n * escapeRegExp('Use * as a wildcard'); // returns 'Use \\* as a wildcard'\n * ```\n *\n * @param str - The string to escape.\n * @returns Returns the escaped string.\n */\nexport function escapeRegExp(str: string) {\n // Escape characters with special meaning either inside or outside character sets.\n // Use a simple backslash escape when it’s always valid, and a `\\xnn` escape when\n // the simpler form would be disallowed by Unicode patterns’ stricter grammar.\n return str.replace(/[|\\\\{}()[\\]^$+*?.]/g, \"\\\\$&\").replace(/-/g, \"\\\\x2d\");\n}\n"],"mappings":";AAkBA,MAAMA,cAAsC;CAC1C,KAAK;CACL,KAAK;CACL,KAAK;CACL,MAAK;CACL,KAAK;CACN;;;;;;;;;;;;;;;;;AAkBD,SAAgB,WAAW,KAAqB;AAC9C,QAAO,IAAI,QAAQ,aAAY,UAAS,YAAY,UAAU,GAAG;;;;;;;;;;;;;;;;AAiBnE,SAAgB,aAAa,KAAa;AAIxC,QAAO,IAAI,QAAQ,uBAAuB,OAAO,CAAC,QAAQ,MAAM,QAAQ"}
|
|
@@ -1 +1,33 @@
|
|
|
1
|
-
const
|
|
1
|
+
const require_acronyms = require('./acronyms.cjs');
|
|
2
|
+
const require_articles = require('./articles.cjs');
|
|
3
|
+
const require_conjunctions = require('./conjunctions.cjs');
|
|
4
|
+
const require_prepositions = require('./prepositions.cjs');
|
|
5
|
+
const require_special_cases = require('./special-cases.cjs');
|
|
6
|
+
|
|
7
|
+
//#region src/format-special-cases.ts
|
|
8
|
+
/**
|
|
9
|
+
* Handle special words in a title.
|
|
10
|
+
*
|
|
11
|
+
* @see https://apastyle.apa.org/style-grammar-guidelines/capitalization/title-case
|
|
12
|
+
*
|
|
13
|
+
* @param value - The word to handle
|
|
14
|
+
* @param index - The index of the word in the title
|
|
15
|
+
* @param words - The full title as an array of words
|
|
16
|
+
* @returns The formatted word
|
|
17
|
+
*/
|
|
18
|
+
function formatSpecialCases(value, index, words, options) {
|
|
19
|
+
const lowercaseStr = value.toLowerCase();
|
|
20
|
+
const uppercaseStr = value.toUpperCase();
|
|
21
|
+
for (const special of require_special_cases.SPECIAL_CASES) if (special.toLowerCase() === lowercaseStr) return special;
|
|
22
|
+
if (require_acronyms.ACRONYMS[uppercaseStr]) return options?.useDescriptions !== false ? require_acronyms.ACRONYMS[uppercaseStr].description : require_acronyms.ACRONYMS[uppercaseStr].display || uppercaseStr;
|
|
23
|
+
if (index === 0) return value;
|
|
24
|
+
if (index === words.length - 1) return value;
|
|
25
|
+
if (value.length >= 4) return value;
|
|
26
|
+
if (require_prepositions.PREPOSITIONS.includes(lowercaseStr)) return lowercaseStr;
|
|
27
|
+
if (require_conjunctions.CONJUNCTIONS.includes(lowercaseStr)) return lowercaseStr;
|
|
28
|
+
if (require_articles.ARTICLES.includes(lowercaseStr)) return lowercaseStr;
|
|
29
|
+
return value;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
//#endregion
|
|
33
|
+
exports.formatSpecialCases = formatSpecialCases;
|
|
@@ -1,2 +1,34 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { ACRONYMS } from "./acronyms.mjs";
|
|
2
|
+
import { ARTICLES } from "./articles.mjs";
|
|
3
|
+
import { CONJUNCTIONS } from "./conjunctions.mjs";
|
|
4
|
+
import { PREPOSITIONS } from "./prepositions.mjs";
|
|
5
|
+
import { SPECIAL_CASES } from "./special-cases.mjs";
|
|
6
|
+
|
|
7
|
+
//#region src/format-special-cases.ts
|
|
8
|
+
/**
|
|
9
|
+
* Handle special words in a title.
|
|
10
|
+
*
|
|
11
|
+
* @see https://apastyle.apa.org/style-grammar-guidelines/capitalization/title-case
|
|
12
|
+
*
|
|
13
|
+
* @param value - The word to handle
|
|
14
|
+
* @param index - The index of the word in the title
|
|
15
|
+
* @param words - The full title as an array of words
|
|
16
|
+
* @returns The formatted word
|
|
17
|
+
*/
|
|
18
|
+
function formatSpecialCases(value, index, words, options) {
|
|
19
|
+
const lowercaseStr = value.toLowerCase();
|
|
20
|
+
const uppercaseStr = value.toUpperCase();
|
|
21
|
+
for (const special of SPECIAL_CASES) if (special.toLowerCase() === lowercaseStr) return special;
|
|
22
|
+
if (ACRONYMS[uppercaseStr]) return options?.useDescriptions !== false ? ACRONYMS[uppercaseStr].description : ACRONYMS[uppercaseStr].display || uppercaseStr;
|
|
23
|
+
if (index === 0) return value;
|
|
24
|
+
if (index === words.length - 1) return value;
|
|
25
|
+
if (value.length >= 4) return value;
|
|
26
|
+
if (PREPOSITIONS.includes(lowercaseStr)) return lowercaseStr;
|
|
27
|
+
if (CONJUNCTIONS.includes(lowercaseStr)) return lowercaseStr;
|
|
28
|
+
if (ARTICLES.includes(lowercaseStr)) return lowercaseStr;
|
|
29
|
+
return value;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
//#endregion
|
|
33
|
+
export { formatSpecialCases };
|
|
2
34
|
//# sourceMappingURL=format-special-cases.mjs.map
|