@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.
Files changed (94) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/acronyms.cjs +411 -1
  3. package/dist/acronyms.mjs +407 -1
  4. package/dist/acronyms.mjs.map +1 -1
  5. package/dist/articles.cjs +10 -1
  6. package/dist/articles.mjs +9 -1
  7. package/dist/articles.mjs.map +1 -1
  8. package/dist/camel-case.cjs +32 -1
  9. package/dist/camel-case.mjs +31 -1
  10. package/dist/camel-case.mjs.map +1 -1
  11. package/dist/combine.cjs +15 -1
  12. package/dist/combine.mjs +14 -1
  13. package/dist/combine.mjs.map +1 -1
  14. package/dist/conjunctions.cjs +32 -1
  15. package/dist/conjunctions.mjs +31 -1
  16. package/dist/conjunctions.mjs.map +1 -1
  17. package/dist/constant-case.cjs +32 -1
  18. package/dist/constant-case.mjs +31 -1
  19. package/dist/constant-case.mjs.map +1 -1
  20. package/dist/deburr.cjs +28 -1
  21. package/dist/deburr.mjs +28 -1
  22. package/dist/deburr.mjs.map +1 -1
  23. package/dist/decamelize.cjs +14 -1
  24. package/dist/decamelize.mjs +13 -1
  25. package/dist/decamelize.mjs.map +1 -1
  26. package/dist/escape.cjs +49 -1
  27. package/dist/escape.mjs +47 -1
  28. package/dist/escape.mjs.map +1 -1
  29. package/dist/format-special-cases.cjs +33 -1
  30. package/dist/format-special-cases.mjs +33 -1
  31. package/dist/format-special-cases.mjs.map +1 -1
  32. package/dist/get-words.cjs +40 -1
  33. package/dist/get-words.mjs +37 -1
  34. package/dist/get-words.mjs.map +1 -1
  35. package/dist/helpers/src/remove-accents.cjs +415 -1
  36. package/dist/helpers/src/remove-accents.mjs +414 -1
  37. package/dist/helpers/src/remove-accents.mjs.map +1 -1
  38. package/dist/index.cjs +75 -1
  39. package/dist/index.mjs +30 -1
  40. package/dist/kebab-case.cjs +34 -1
  41. package/dist/kebab-case.mjs +33 -1
  42. package/dist/kebab-case.mjs.map +1 -1
  43. package/dist/lower-case-first.cjs +17 -1
  44. package/dist/lower-case-first.mjs +16 -1
  45. package/dist/lower-case-first.mjs.map +1 -1
  46. package/dist/normalize-email.cjs +31 -1
  47. package/dist/normalize-email.mjs +30 -1
  48. package/dist/normalize-email.mjs.map +1 -1
  49. package/dist/package.cjs +124 -1
  50. package/dist/package.mjs +120 -1
  51. package/dist/package.mjs.map +1 -1
  52. package/dist/pad.cjs +25 -1
  53. package/dist/pad.mjs +24 -1
  54. package/dist/pad.mjs.map +1 -1
  55. package/dist/pascal-case.cjs +32 -1
  56. package/dist/pascal-case.mjs +31 -1
  57. package/dist/pascal-case.mjs.map +1 -1
  58. package/dist/period-split.cjs +38 -1
  59. package/dist/period-split.mjs +37 -1
  60. package/dist/period-split.mjs.map +1 -1
  61. package/dist/prepositions.cjs +68 -1
  62. package/dist/prepositions.mjs +67 -1
  63. package/dist/prepositions.mjs.map +1 -1
  64. package/dist/pretty-bytes.cjs +129 -1
  65. package/dist/pretty-bytes.mjs +127 -1
  66. package/dist/pretty-bytes.mjs.map +1 -1
  67. package/dist/snake-case.cjs +42 -1
  68. package/dist/snake-case.mjs +41 -1
  69. package/dist/snake-case.mjs.map +1 -1
  70. package/dist/special-cases.cjs +53 -1
  71. package/dist/special-cases.mjs +52 -1
  72. package/dist/special-cases.mjs.map +1 -1
  73. package/dist/start-case.cjs +46 -1
  74. package/dist/start-case.mjs +45 -1
  75. package/dist/start-case.mjs.map +1 -1
  76. package/dist/strip-indents.cjs +24 -3
  77. package/dist/strip-indents.mjs +23 -3
  78. package/dist/strip-indents.mjs.map +1 -1
  79. package/dist/title-case.cjs +19 -1
  80. package/dist/title-case.mjs +19 -1
  81. package/dist/title-case.mjs.map +1 -1
  82. package/dist/types/src/base.cjs +6 -1
  83. package/dist/types/src/base.mjs +5 -1
  84. package/dist/types/src/base.mjs.map +1 -1
  85. package/dist/unescape.cjs +30 -1
  86. package/dist/unescape.mjs +29 -1
  87. package/dist/unescape.mjs.map +1 -1
  88. package/dist/upper-case-first.cjs +17 -1
  89. package/dist/upper-case-first.mjs +16 -1
  90. package/dist/upper-case-first.mjs.map +1 -1
  91. package/dist/vowels.cjs +40 -1
  92. package/dist/vowels.mjs +38 -1
  93. package/dist/vowels.mjs.map +1 -1
  94. package/package.json +2 -2
@@ -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,EAAW,CAAC,IAAK,KAAM,MAAM"}
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"}
@@ -1 +1,32 @@
1
- const e=require(`./acronyms.cjs`),t=require(`./get-words.cjs`);function n(t){return t?/^[a-z][a-z0-9]*$/.test(t)&&e.ACRONYM_LIST.includes(t.trim().toUpperCase())||/^(?:[a-z][a-z0-9]*[A-Z]+)*$/.test(t):!1}function r(r){return n(r)||r===void 0?r:t.getWords(r).map((t,n)=>n===0?t.trim().toLowerCase():e.ACRONYM_LIST.includes(t.trim().toUpperCase())?e.ACRONYMS[t.trim().toUpperCase()]?.display||t.trim().toUpperCase():t.trim().charAt(0).toUpperCase()+t.trim().slice(1).toLowerCase()).join(``)}exports.camelCase=r,exports.isCamelCase=n;
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;
@@ -1,2 +1,32 @@
1
- import{ACRONYMS as e,ACRONYM_LIST as t}from"./acronyms.mjs";import{getWords as n}from"./get-words.mjs";function r(e){return e?/^[a-z][a-z0-9]*$/.test(e)&&t.includes(e.trim().toUpperCase())||/^(?:[a-z][a-z0-9]*[A-Z]+)*$/.test(e):!1}function i(i){return r(i)||i===void 0?i:n(i).map((n,r)=>r===0?n.trim().toLowerCase():t.includes(n.trim().toUpperCase())?e[n.trim().toUpperCase()]?.display||n.trim().toUpperCase():n.trim().charAt(0).toUpperCase()+n.trim().slice(1).toLowerCase()).join(``)}export{i as camelCase,r as isCamelCase};
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
@@ -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":"uGA8BA,SAAgB,EAAY,EAAoC,CAC9D,OAAO,EACF,mBAAmB,KAAK,EAAM,EAC7B,EAAa,SAAS,EAAM,MAAM,CAAC,aAAa,CAAC,EACjD,8BAA8B,KAAK,EAAM,CAC3C,GAYN,SAAgB,EAAwC,EAAa,CACnE,OACE,EAAY,EAAM,EAAI,IAAU,IAAA,GAC5B,EACA,EAAS,EAAM,CACZ,KAAK,EAAM,IACV,IAAU,EACN,EAAK,MAAM,CAAC,aAAa,CACzB,EAAa,SAAS,EAAK,MAAM,CAAC,aAAa,CAAC,CAC9C,EAAS,EAAK,MAAM,CAAC,aAAa,GAAG,SACrC,EAAK,MAAM,CAAC,aAAa,CACzB,EAAK,MAAM,CAAC,OAAO,EAAE,CAAC,aAAa,CACnC,EAAK,MAAM,CAAC,MAAM,EAAE,CAAC,aAAa,CACzC,CACA,KAAK,GAAG"}
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
- function e(e,t){return`${e} ${t}`}exports.combine=e;
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
- function e(e,t){return`${e} ${t}`}export{e as combine};
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
@@ -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,EAAQ,EAAa,EAAqB,CACxD,MAAO,GAAG,EAAI,GAAG"}
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"}
@@ -1 +1,32 @@
1
- const e=[`and`,`that`,`but`,`or`,`as`,`if`,`when`,`than`,`because`,`while`,`where`,`after`,`so`,`though`,`since`,`until`,`whether`,`before`,`although`,`nor`,`like`,`once`,`unless`,`now`,`except`];exports.CONJUNCTIONS=e;
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;
@@ -1,2 +1,32 @@
1
- const e=[`and`,`that`,`but`,`or`,`as`,`if`,`when`,`than`,`because`,`while`,`where`,`after`,`so`,`though`,`since`,`until`,`whether`,`before`,`although`,`nor`,`like`,`once`,`unless`,`now`,`except`];export{e as CONJUNCTIONS};
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,EAAe,CAC1B,MACA,OACA,MACA,KACA,KACA,KACA,OACA,OACA,UACA,QACA,QACA,QACA,KACA,SACA,QACA,QACA,UACA,SACA,WACA,MACA,OACA,OACA,SACA,MACA,SACD"}
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"}
@@ -1 +1,32 @@
1
- const e=require(`./get-words.cjs`),t=require(`./snake-case.cjs`);function n(e){return e?/^[A-Z0-9_]+$/.test(e):!1}function r(r){return n(r)||r===void 0?r:t.isSnakeCase(r)?r.toUpperCase():e.getWords(r).join(`_`).toUpperCase()}exports.constantCase=r,exports.isConstantCase=n;
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;
@@ -1,2 +1,32 @@
1
- import{getWords as e}from"./get-words.mjs";import{isSnakeCase as t}from"./snake-case.mjs";function n(e){return e?/^[A-Z0-9_]+$/.test(e):!1}function r(r){return n(r)||r===void 0?r:t(r)?r.toUpperCase():e(r).join(`_`).toUpperCase()}export{r as constantCase,n as isConstantCase};
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":"0FA8BA,SAAgB,EAAe,EAAoC,CACjE,OAAO,EAAQ,eAAe,KAAK,EAAM,CAAG,GAY9C,SAAgB,EAA2C,EAAa,CACtE,OAAO,EAAe,EAAM,EAAI,IAAU,IAAA,GACtC,EACA,EAAY,EAAM,CACf,EAAM,aAAa,CACnB,EAAS,EAAM,CAAC,KAAK,IAAI,CAAC,aAAa"}
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 e=require(`./helpers/src/remove-accents.cjs`);function t(t){return e.removeAccents(t.normalize(`NFD`))}exports.deburr=t;
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 as e}from"./helpers/src/remove-accents.mjs";function t(t){return e(t.normalize(`NFD`))}export{t as deburr};
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
@@ -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":"iEAuCA,SAAgB,EAAO,EAAqB,CAC1C,OAAO,EAAc,EAAI,UAAU,MAAM,CAAC"}
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"}
@@ -1 +1,14 @@
1
- function e(e){return e.replace(/([a-z\d])([A-Z])/g,`$1_$2`).replace(/([A-Z]+)([A-Z][a-z\d]+)/g,`$1_$2`).toLowerCase()}exports.decamelize=e;
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;
@@ -1,2 +1,14 @@
1
- function e(e){return e.replace(/([a-z\d])([A-Z])/g,`$1_$2`).replace(/([A-Z]+)([A-Z][a-z\d]+)/g,`$1_$2`).toLowerCase()}export{e as decamelize};
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
@@ -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,EAAW,EAAuB,CAChD,OAAO,EACJ,QAAQ,oBAAqB,QAAQ,CACrC,QAAQ,2BAA4B,QAAQ,CAC5C,aAAa"}
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
- const e={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`};function t(t){return t.replace(/["&'<>]/g,t=>e[t]||``)}function n(e){return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}exports.escapeHtml=t,exports.escapeRegExp=n;
1
+
2
+ //#region src/escape.ts
3
+ const htmlEscapes = {
4
+ "&": "&amp;",
5
+ "<": "&lt;",
6
+ ">": "&gt;",
7
+ "\"": "&quot;",
8
+ "'": "&#39;"
9
+ };
10
+ /**
11
+ * Converts the characters "&", "\<", "\>", '"', and "'" in `str` to their corresponding HTML entities.
12
+ * For example, "\<" becomes "&lt;".
13
+ *
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * escapeHtml('This is a <div> element.'); // returns 'This is a &lt;div&gt; element.'
18
+ * escapeHtml('This is a "quote"'); // returns 'This is a &quot;quote&quot;'
19
+ * escapeHtml("This is a 'quote'"); // returns 'This is a &#39;quote&#39;'
20
+ * escapeHtml('This is a & symbol'); // returns 'This is a &amp; 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
- const e={"&":`&amp;`,"<":`&lt;`,">":`&gt;`,'"':`&quot;`,"'":`&#39;`};function t(t){return t.replace(/["&'<>]/g,t=>e[t]||``)}function n(e){return e.replace(/[|\\{}()[\]^$+*?.]/g,`\\$&`).replace(/-/g,`\\x2d`)}export{t as escapeHtml,n as escapeRegExp};
1
+ //#region src/escape.ts
2
+ const htmlEscapes = {
3
+ "&": "&amp;",
4
+ "<": "&lt;",
5
+ ">": "&gt;",
6
+ "\"": "&quot;",
7
+ "'": "&#39;"
8
+ };
9
+ /**
10
+ * Converts the characters "&", "\<", "\>", '"', and "'" in `str` to their corresponding HTML entities.
11
+ * For example, "\<" becomes "&lt;".
12
+ *
13
+ *
14
+ * @example
15
+ * ```ts
16
+ * escapeHtml('This is a <div> element.'); // returns 'This is a &lt;div&gt; element.'
17
+ * escapeHtml('This is a "quote"'); // returns 'This is a &quot;quote&quot;'
18
+ * escapeHtml("This is a 'quote'"); // returns 'This is a &#39;quote&#39;'
19
+ * escapeHtml('This is a & symbol'); // returns 'This is a &amp; 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
@@ -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 \"&\": \"&amp;\",\n \"<\": \"&lt;\",\n \">\": \"&gt;\",\n '\"': \"&quot;\",\n \"'\": \"&#39;\"\n};\n\n/**\n * Converts the characters \"&\", \"\\<\", \"\\>\", '\"', and \"'\" in `str` to their corresponding HTML entities.\n * For example, \"\\<\" becomes \"&lt;\".\n *\n *\n * @example\n * ```ts\n * escapeHtml('This is a <div> element.'); // returns 'This is a &lt;div&gt; element.'\n * escapeHtml('This is a \"quote\"'); // returns 'This is a &quot;quote&quot;'\n * escapeHtml(\"This is a 'quote'\"); // returns 'This is a &#39;quote&#39;'\n * escapeHtml('This is a & symbol'); // returns 'This is a &amp; 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,EAAsC,CAC1C,IAAK,QACL,IAAK,OACL,IAAK,OACL,IAAK,SACL,IAAK,QACN,CAkBD,SAAgB,EAAW,EAAqB,CAC9C,OAAO,EAAI,QAAQ,WAAY,GAAS,EAAY,IAAU,GAAG,CAiBnE,SAAgB,EAAa,EAAa,CAIxC,OAAO,EAAI,QAAQ,sBAAuB,OAAO,CAAC,QAAQ,KAAM,QAAQ"}
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 \"&\": \"&amp;\",\n \"<\": \"&lt;\",\n \">\": \"&gt;\",\n '\"': \"&quot;\",\n \"'\": \"&#39;\"\n};\n\n/**\n * Converts the characters \"&\", \"\\<\", \"\\>\", '\"', and \"'\" in `str` to their corresponding HTML entities.\n * For example, \"\\<\" becomes \"&lt;\".\n *\n *\n * @example\n * ```ts\n * escapeHtml('This is a <div> element.'); // returns 'This is a &lt;div&gt; element.'\n * escapeHtml('This is a \"quote\"'); // returns 'This is a &quot;quote&quot;'\n * escapeHtml(\"This is a 'quote'\"); // returns 'This is a &#39;quote&#39;'\n * escapeHtml('This is a & symbol'); // returns 'This is a &amp; 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 e=require(`./acronyms.cjs`),t=require(`./articles.cjs`),n=require(`./conjunctions.cjs`),r=require(`./prepositions.cjs`),i=require(`./special-cases.cjs`);function a(a,o,s,c){let l=a.toLowerCase(),u=a.toUpperCase();for(let e of i.SPECIAL_CASES)if(e.toLowerCase()===l)return e;return e.ACRONYMS[u]?c?.useDescriptions===!1?e.ACRONYMS[u].display||u:e.ACRONYMS[u].description:o===0||o===s.length-1||a.length>=4?a:r.PREPOSITIONS.includes(l)||n.CONJUNCTIONS.includes(l)||t.ARTICLES.includes(l)?l:a}exports.formatSpecialCases=a;
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{ACRONYMS as e}from"./acronyms.mjs";import{ARTICLES as t}from"./articles.mjs";import{CONJUNCTIONS as n}from"./conjunctions.mjs";import{PREPOSITIONS as r}from"./prepositions.mjs";import{SPECIAL_CASES as i}from"./special-cases.mjs";function a(a,o,s,c){let l=a.toLowerCase(),u=a.toUpperCase();for(let e of i)if(e.toLowerCase()===l)return e;return e[u]?c?.useDescriptions===!1?e[u].display||u:e[u].description:o===0||o===s.length-1||a.length>=4?a:r.includes(l)||n.includes(l)||t.includes(l)?l:a}export{a as formatSpecialCases};
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