@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":"kebab-case.mjs","names":[],"sources":["../src/kebab-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\";\n\n/**\n * Check if the input string is in kebab case.\n *\n * @remarks\n * Kebab case is defined as all lowercase letters with hyphens separating words - \"this-is-an-example\".\n *\n * @param input - The input string to check.\n * @returns True if the input is in kebab case, false otherwise.\n */\nexport function isKebabCase(input: string | undefined): boolean {\n return input ? /^[a-z]+(?:-[a-z0-9]+)*$/.test(input) : false;\n}\n\n/**\n * Convert the input string to kebab case.\n *\n * @remarks\n * Kebab case is defined as all lowercase letters with hyphens separating words - \"this-is-an-example\".\n *\n * @param input - The input string.\n * @returns The kebab-cased string.\n */\nexport function kebabCase<T extends string | undefined>(input: T): T {\n if (isKebabCase(input) || input === undefined) {\n return input;\n }\n\n const parts = input ? getWords(input) : [];\n if (parts.length === 0) {\n return \"\" as T;\n }\n\n return parts.join(\"-\").toLowerCase() as T;\n}\n"],"mappings":"2CA6BA,SAAgB,EAAY,EAAoC,CAC9D,OAAO,EAAQ,0BAA0B,KAAK,EAAM,CAAG,GAYzD,SAAgB,EAAwC,EAAa,CACnE,GAAI,EAAY,EAAM,EAAI,IAAU,IAAA,GAClC,OAAO,EAGT,IAAM,EAAQ,EAAQ,EAAS,EAAM,CAAG,EAAE,CAK1C,OAJI,EAAM,SAAW,EACZ,GAGF,EAAM,KAAK,IAAI,CAAC,aAAa"}
1
+ {"version":3,"file":"kebab-case.mjs","names":[],"sources":["../src/kebab-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\";\n\n/**\n * Check if the input string is in kebab case.\n *\n * @remarks\n * Kebab case is defined as all lowercase letters with hyphens separating words - \"this-is-an-example\".\n *\n * @param input - The input string to check.\n * @returns True if the input is in kebab case, false otherwise.\n */\nexport function isKebabCase(input: string | undefined): boolean {\n return input ? /^[a-z]+(?:-[a-z0-9]+)*$/.test(input) : false;\n}\n\n/**\n * Convert the input string to kebab case.\n *\n * @remarks\n * Kebab case is defined as all lowercase letters with hyphens separating words - \"this-is-an-example\".\n *\n * @param input - The input string.\n * @returns The kebab-cased string.\n */\nexport function kebabCase<T extends string | undefined>(input: T): T {\n if (isKebabCase(input) || input === undefined) {\n return input;\n }\n\n const parts = input ? getWords(input) : [];\n if (parts.length === 0) {\n return \"\" as T;\n }\n\n return parts.join(\"-\").toLowerCase() as T;\n}\n"],"mappings":";;;;;;;;;;;;AA6BA,SAAgB,YAAY,OAAoC;AAC9D,QAAO,QAAQ,0BAA0B,KAAK,MAAM,GAAG;;;;;;;;;;;AAYzD,SAAgB,UAAwC,OAAa;AACnE,KAAI,YAAY,MAAM,IAAI,UAAU,OAClC,QAAO;CAGT,MAAM,QAAQ,QAAQ,SAAS,MAAM,GAAG,EAAE;AAC1C,KAAI,MAAM,WAAW,EACnB,QAAO;AAGT,QAAO,MAAM,KAAK,IAAI,CAAC,aAAa"}
@@ -1 +1,17 @@
1
- function e(e){return e&&e.charAt(0).toLowerCase()+e.slice(1)}exports.lowerCaseFirst=e;
1
+
2
+ //#region src/lower-case-first.ts
3
+ /**
4
+ * Lower case the first character of an input string.
5
+ *
6
+ * @remarks
7
+ * "tHISISANEXAMPLE"
8
+ *
9
+ * @param input - The input string.
10
+ * @returns The lower-cased string.
11
+ */
12
+ function lowerCaseFirst(input) {
13
+ return input ? input.charAt(0).toLowerCase() + input.slice(1) : input;
14
+ }
15
+
16
+ //#endregion
17
+ exports.lowerCaseFirst = lowerCaseFirst;
@@ -1,2 +1,17 @@
1
- function e(e){return e&&e.charAt(0).toLowerCase()+e.slice(1)}export{e as lowerCaseFirst};
1
+ //#region src/lower-case-first.ts
2
+ /**
3
+ * Lower case the first character of an input string.
4
+ *
5
+ * @remarks
6
+ * "tHISISANEXAMPLE"
7
+ *
8
+ * @param input - The input string.
9
+ * @returns The lower-cased string.
10
+ */
11
+ function lowerCaseFirst(input) {
12
+ return input ? input.charAt(0).toLowerCase() + input.slice(1) : input;
13
+ }
14
+
15
+ //#endregion
16
+ export { lowerCaseFirst };
2
17
  //# sourceMappingURL=lower-case-first.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"lower-case-first.mjs","names":[],"sources":["../src/lower-case-first.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 * Lower case the first character of an input string.\n *\n * @remarks\n * \"tHISISANEXAMPLE\"\n *\n * @param input - The input string.\n * @returns The lower-cased string.\n */\nexport function lowerCaseFirst<T extends string | undefined>(input?: T): T {\n return (input ? input.charAt(0).toLowerCase() + input.slice(1) : input) as T;\n}\n"],"mappings":"AA2BA,SAAgB,EAA6C,EAAc,CACzE,OAAQ,GAAQ,EAAM,OAAO,EAAE,CAAC,aAAa,CAAG,EAAM,MAAM,EAAE"}
1
+ {"version":3,"file":"lower-case-first.mjs","names":[],"sources":["../src/lower-case-first.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 * Lower case the first character of an input string.\n *\n * @remarks\n * \"tHISISANEXAMPLE\"\n *\n * @param input - The input string.\n * @returns The lower-cased string.\n */\nexport function lowerCaseFirst<T extends string | undefined>(input?: T): T {\n return (input ? input.charAt(0).toLowerCase() + input.slice(1) : input) as T;\n}\n"],"mappings":";;;;;;;;;;AA2BA,SAAgB,eAA6C,OAAc;AACzE,QAAQ,QAAQ,MAAM,OAAO,EAAE,CAAC,aAAa,GAAG,MAAM,MAAM,EAAE,GAAG"}
@@ -1 +1,31 @@
1
- const e=/\./g,t=t=>{if(!t.includes(`@`)&&!t.includes(`+`))throw Error(`invalid_email_format`);let n=t.split(`@`).filter(Boolean);if(n.length>1)throw Error(`invalid_email_format`);let[r,i]=n,[a]=r.split(`+`);if(!a)throw Error(`invalid_email_format`);return a=a.replace(e,``),`${a.toLowerCase()}@${i.toLowerCase()}`};exports.normalizeEmail=t;
1
+
2
+ //#region src/normalize-email.ts
3
+ const DOT_REG = /\./g;
4
+ /**
5
+ * 1. Lower-cases whole email.
6
+ * 2. Removes dots ".".
7
+ * 3. Remotes name part after "+".
8
+ * 4. Throws if cannot parse the email.
9
+ *
10
+ * For example, this email
11
+ *
12
+ * Mike.Johnson+twitter\@Gmail.com
13
+ *
14
+ * will be normalized to
15
+ *
16
+ * mikejohnson\@gmail.com
17
+ *
18
+ */
19
+ const normalizeEmail = (email) => {
20
+ if (!email.includes("@") && !email.includes("+")) throw new Error("invalid_email_format");
21
+ const split = email.split("@").filter(Boolean);
22
+ if (split.length > 1) throw new Error("invalid_email_format");
23
+ const [name, host] = split;
24
+ let [beforePlus] = name.split("+");
25
+ if (!beforePlus) throw new Error("invalid_email_format");
26
+ beforePlus = beforePlus.replace(DOT_REG, "");
27
+ return `${beforePlus.toLowerCase()}@${host.toLowerCase()}`;
28
+ };
29
+
30
+ //#endregion
31
+ exports.normalizeEmail = normalizeEmail;
@@ -1,2 +1,31 @@
1
- const e=/\./g,t=t=>{if(!t.includes(`@`)&&!t.includes(`+`))throw Error(`invalid_email_format`);let n=t.split(`@`).filter(Boolean);if(n.length>1)throw Error(`invalid_email_format`);let[r,i]=n,[a]=r.split(`+`);if(!a)throw Error(`invalid_email_format`);return a=a.replace(e,``),`${a.toLowerCase()}@${i.toLowerCase()}`};export{t as normalizeEmail};
1
+ //#region src/normalize-email.ts
2
+ const DOT_REG = /\./g;
3
+ /**
4
+ * 1. Lower-cases whole email.
5
+ * 2. Removes dots ".".
6
+ * 3. Remotes name part after "+".
7
+ * 4. Throws if cannot parse the email.
8
+ *
9
+ * For example, this email
10
+ *
11
+ * Mike.Johnson+twitter\@Gmail.com
12
+ *
13
+ * will be normalized to
14
+ *
15
+ * mikejohnson\@gmail.com
16
+ *
17
+ */
18
+ const normalizeEmail = (email) => {
19
+ if (!email.includes("@") && !email.includes("+")) throw new Error("invalid_email_format");
20
+ const split = email.split("@").filter(Boolean);
21
+ if (split.length > 1) throw new Error("invalid_email_format");
22
+ const [name, host] = split;
23
+ let [beforePlus] = name.split("+");
24
+ if (!beforePlus) throw new Error("invalid_email_format");
25
+ beforePlus = beforePlus.replace(DOT_REG, "");
26
+ return `${beforePlus.toLowerCase()}@${host.toLowerCase()}`;
27
+ };
28
+
29
+ //#endregion
30
+ export { normalizeEmail };
2
31
  //# sourceMappingURL=normalize-email.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"normalize-email.mjs","names":[],"sources":["../src/normalize-email.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 DOT_REG = /\\./g;\n\n/**\n * 1. Lower-cases whole email.\n * 2. Removes dots \".\".\n * 3. Remotes name part after \"+\".\n * 4. Throws if cannot parse the email.\n *\n * For example, this email\n *\n * Mike.Johnson+twitter\\@Gmail.com\n *\n * will be normalized to\n *\n * mikejohnson\\@gmail.com\n *\n */\nexport const normalizeEmail = (email: string) => {\n if (!email.includes(\"@\") && !email.includes(\"+\")) {\n throw new Error(\"invalid_email_format\");\n }\n\n const split = email.split(\"@\").filter(Boolean);\n if (split.length > 1) {\n throw new Error(\"invalid_email_format\");\n }\n\n const [name, host] = split;\n\n let [beforePlus] = name!.split(\"+\");\n if (!beforePlus) {\n throw new Error(\"invalid_email_format\");\n }\n\n beforePlus = beforePlus.replace(DOT_REG, \"\");\n const result = `${beforePlus.toLowerCase()}@${host!.toLowerCase()}`;\n Number(result);\n\n return result;\n};\n"],"mappings":"AAkBA,MAAM,EAAU,MAiBH,EAAkB,GAAkB,CAC/C,GAAI,CAAC,EAAM,SAAS,IAAI,EAAI,CAAC,EAAM,SAAS,IAAI,CAC9C,MAAU,MAAM,uBAAuB,CAGzC,IAAM,EAAQ,EAAM,MAAM,IAAI,CAAC,OAAO,QAAQ,CAC9C,GAAI,EAAM,OAAS,EACjB,MAAU,MAAM,uBAAuB,CAGzC,GAAM,CAAC,EAAM,GAAQ,EAEjB,CAAC,GAAc,EAAM,MAAM,IAAI,CACnC,GAAI,CAAC,EACH,MAAU,MAAM,uBAAuB,CAOzC,MAJA,GAAa,EAAW,QAAQ,EAAS,GAAG,CAC7B,GAAG,EAAW,aAAa,CAAC,GAAG,EAAM,aAAa"}
1
+ {"version":3,"file":"normalize-email.mjs","names":[],"sources":["../src/normalize-email.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 DOT_REG = /\\./g;\n\n/**\n * 1. Lower-cases whole email.\n * 2. Removes dots \".\".\n * 3. Remotes name part after \"+\".\n * 4. Throws if cannot parse the email.\n *\n * For example, this email\n *\n * Mike.Johnson+twitter\\@Gmail.com\n *\n * will be normalized to\n *\n * mikejohnson\\@gmail.com\n *\n */\nexport const normalizeEmail = (email: string) => {\n if (!email.includes(\"@\") && !email.includes(\"+\")) {\n throw new Error(\"invalid_email_format\");\n }\n\n const split = email.split(\"@\").filter(Boolean);\n if (split.length > 1) {\n throw new Error(\"invalid_email_format\");\n }\n\n const [name, host] = split;\n\n let [beforePlus] = name!.split(\"+\");\n if (!beforePlus) {\n throw new Error(\"invalid_email_format\");\n }\n\n beforePlus = beforePlus.replace(DOT_REG, \"\");\n const result = `${beforePlus.toLowerCase()}@${host!.toLowerCase()}`;\n Number(result);\n\n return result;\n};\n"],"mappings":";AAkBA,MAAM,UAAU;;;;;;;;;;;;;;;;AAiBhB,MAAa,kBAAkB,UAAkB;AAC/C,KAAI,CAAC,MAAM,SAAS,IAAI,IAAI,CAAC,MAAM,SAAS,IAAI,CAC9C,OAAM,IAAI,MAAM,uBAAuB;CAGzC,MAAM,QAAQ,MAAM,MAAM,IAAI,CAAC,OAAO,QAAQ;AAC9C,KAAI,MAAM,SAAS,EACjB,OAAM,IAAI,MAAM,uBAAuB;CAGzC,MAAM,CAAC,MAAM,QAAQ;CAErB,IAAI,CAAC,cAAc,KAAM,MAAM,IAAI;AACnC,KAAI,CAAC,WACH,OAAM,IAAI,MAAM,uBAAuB;AAGzC,cAAa,WAAW,QAAQ,SAAS,GAAG;AAI5C,QAHe,GAAG,WAAW,aAAa,CAAC,GAAG,KAAM,aAAa"}
package/dist/package.cjs CHANGED
@@ -1 +1,124 @@
1
- function e(e){return/^.[^\n\r@\u2028\u2029]*@.*$/.test(e)}function t(t){return e(t)?t.substring(0,t.lastIndexOf(`@`)):t}function n(e){return/^[^\n\r/\u2028\u2029]*\/.[^\n\r/\u2028\u2029]*\/.*$/.test(e)?e.substring(0,e.lastIndexOf(`/`)):t(e)}function r(t){return e(t)?t.replace(/^.+@/,``):void 0}exports.getPackageName=n,exports.getPackageVersion=r,exports.hasPackageVersion=e,exports.removePackageVersion=t;
1
+
2
+ //#region src/package.ts
3
+ /**
4
+ * Check if a package name has a version
5
+ *
6
+ * @example
7
+ * ```typescript
8
+ * hasPackageVersion("lodash@4.17.21");
9
+ * // => true
10
+ * hasPackageVersion("@stryke/core@4.17.21");
11
+ * // => true
12
+ * hasPackageVersion("lodash");
13
+ * // => false
14
+ * hasPackageVersion("@stryke/core");
15
+ * // => false
16
+ * hasPackageVersion("lodash/module");
17
+ * // => false
18
+ * hasPackageVersion("@stryke/core/module");
19
+ * // => false
20
+ * hasPackageVersion("lodash/module@4.17.21");
21
+ * // => true
22
+ * hasPackageVersion("@stryke/core/module@4.17.21");
23
+ * // => true
24
+ * ```
25
+ *
26
+ * @param value - The package name with version
27
+ * @returns Whether the package name has a version
28
+ */
29
+ function hasPackageVersion(value) {
30
+ return /^.[^\n\r@\u2028\u2029]*@.*$/.test(value);
31
+ }
32
+ /**
33
+ * Remove the version from a package name (if it exists)
34
+ *
35
+ * @example
36
+ * ```typescript
37
+ * removePackageVersion("lodash@4.17.21");
38
+ * // => "lodash"
39
+ * removePackageVersion("@stryke/core@4.17.21");
40
+ * // => "@stryke/core"
41
+ * removePackageVersion("lodash");
42
+ * // => "lodash"
43
+ * removePackageVersion("@stryke/core");
44
+ * // => "@stryke/core"
45
+ * getPackageName("lodash/module");
46
+ * // => "lodash/module"
47
+ * getPackageName("@stryke/core/module");
48
+ * // => "@stryke/core/module"
49
+ * getPackageName("lodash/module@4.17.21");
50
+ * // => "lodash/module"
51
+ * getPackageName("@stryke/core/module@4.17.21");
52
+ * // => "@stryke/core/module"
53
+ * ```
54
+ *
55
+ * @param value - The package name with version
56
+ * @returns The package name without version
57
+ */
58
+ function removePackageVersion(value) {
59
+ return hasPackageVersion(value) ? value.substring(0, value.lastIndexOf("@")) : value;
60
+ }
61
+ /**
62
+ * Get the package name from a scoped package string
63
+ *
64
+ * @example
65
+ * ```typescript
66
+ * getPackageName("lodash@4.17.21");
67
+ * // => "lodash"
68
+ * getPackageName("@stryke/core@4.17.21");
69
+ * // => "@stryke/core"
70
+ * getPackageName("lodash");
71
+ * // => "lodash"
72
+ * getPackageName("@stryke/core");
73
+ * // => "@stryke/core"
74
+ * getPackageName("lodash/module");
75
+ * // => "lodash"
76
+ * getPackageName("@stryke/core/module");
77
+ * // => "@stryke/core"
78
+ * getPackageName("lodash/module@4.17.21");
79
+ * // => "lodash"
80
+ * getPackageName("@stryke/core/module@4.17.21");
81
+ * // => "@stryke/core"
82
+ * ```
83
+ *
84
+ * @param value - The scoped package string
85
+ * @returns The package name without the scope
86
+ */
87
+ function getPackageName(value) {
88
+ return /^[^\n\r/\u2028\u2029]*\/.[^\n\r/\u2028\u2029]*\/.*$/.test(value) ? value.substring(0, value.lastIndexOf("/")) : removePackageVersion(value);
89
+ }
90
+ /**
91
+ * Get the package version from a scoped package string
92
+ *
93
+ * @example
94
+ * ```typescript
95
+ * getPackageName("lodash@4.17.21");
96
+ * // => "4.17.21"
97
+ * getPackageName("@stryke/core@4.17.21");
98
+ * // => "4.17.21"
99
+ * getPackageName("lodash");
100
+ * // => undefined
101
+ * getPackageName("@stryke/core");
102
+ * // => undefined
103
+ * getPackageName("lodash/module");
104
+ * // => undefined
105
+ * getPackageName("@stryke/core/module");
106
+ * // => undefined
107
+ * getPackageName("lodash/module@4.17.21");
108
+ * // => "4.17.21"
109
+ * getPackageName("@stryke/core/module@4.17.21");
110
+ * // => "4.17.21"
111
+ * ```
112
+ *
113
+ * @param value - The scoped package string
114
+ * @returns The package version without the package name if it exists. If not, returns undefined.
115
+ */
116
+ function getPackageVersion(value) {
117
+ return hasPackageVersion(value) ? value.replace(/^.+@/, "") : void 0;
118
+ }
119
+
120
+ //#endregion
121
+ exports.getPackageName = getPackageName;
122
+ exports.getPackageVersion = getPackageVersion;
123
+ exports.hasPackageVersion = hasPackageVersion;
124
+ exports.removePackageVersion = removePackageVersion;
package/dist/package.mjs CHANGED
@@ -1,2 +1,121 @@
1
- function e(e){return/^.[^\n\r@\u2028\u2029]*@.*$/.test(e)}function t(t){return e(t)?t.substring(0,t.lastIndexOf(`@`)):t}function n(e){return/^[^\n\r/\u2028\u2029]*\/.[^\n\r/\u2028\u2029]*\/.*$/.test(e)?e.substring(0,e.lastIndexOf(`/`)):t(e)}function r(t){return e(t)?t.replace(/^.+@/,``):void 0}export{n as getPackageName,r as getPackageVersion,e as hasPackageVersion,t as removePackageVersion};
1
+ //#region src/package.ts
2
+ /**
3
+ * Check if a package name has a version
4
+ *
5
+ * @example
6
+ * ```typescript
7
+ * hasPackageVersion("lodash@4.17.21");
8
+ * // => true
9
+ * hasPackageVersion("@stryke/core@4.17.21");
10
+ * // => true
11
+ * hasPackageVersion("lodash");
12
+ * // => false
13
+ * hasPackageVersion("@stryke/core");
14
+ * // => false
15
+ * hasPackageVersion("lodash/module");
16
+ * // => false
17
+ * hasPackageVersion("@stryke/core/module");
18
+ * // => false
19
+ * hasPackageVersion("lodash/module@4.17.21");
20
+ * // => true
21
+ * hasPackageVersion("@stryke/core/module@4.17.21");
22
+ * // => true
23
+ * ```
24
+ *
25
+ * @param value - The package name with version
26
+ * @returns Whether the package name has a version
27
+ */
28
+ function hasPackageVersion(value) {
29
+ return /^.[^\n\r@\u2028\u2029]*@.*$/.test(value);
30
+ }
31
+ /**
32
+ * Remove the version from a package name (if it exists)
33
+ *
34
+ * @example
35
+ * ```typescript
36
+ * removePackageVersion("lodash@4.17.21");
37
+ * // => "lodash"
38
+ * removePackageVersion("@stryke/core@4.17.21");
39
+ * // => "@stryke/core"
40
+ * removePackageVersion("lodash");
41
+ * // => "lodash"
42
+ * removePackageVersion("@stryke/core");
43
+ * // => "@stryke/core"
44
+ * getPackageName("lodash/module");
45
+ * // => "lodash/module"
46
+ * getPackageName("@stryke/core/module");
47
+ * // => "@stryke/core/module"
48
+ * getPackageName("lodash/module@4.17.21");
49
+ * // => "lodash/module"
50
+ * getPackageName("@stryke/core/module@4.17.21");
51
+ * // => "@stryke/core/module"
52
+ * ```
53
+ *
54
+ * @param value - The package name with version
55
+ * @returns The package name without version
56
+ */
57
+ function removePackageVersion(value) {
58
+ return hasPackageVersion(value) ? value.substring(0, value.lastIndexOf("@")) : value;
59
+ }
60
+ /**
61
+ * Get the package name from a scoped package string
62
+ *
63
+ * @example
64
+ * ```typescript
65
+ * getPackageName("lodash@4.17.21");
66
+ * // => "lodash"
67
+ * getPackageName("@stryke/core@4.17.21");
68
+ * // => "@stryke/core"
69
+ * getPackageName("lodash");
70
+ * // => "lodash"
71
+ * getPackageName("@stryke/core");
72
+ * // => "@stryke/core"
73
+ * getPackageName("lodash/module");
74
+ * // => "lodash"
75
+ * getPackageName("@stryke/core/module");
76
+ * // => "@stryke/core"
77
+ * getPackageName("lodash/module@4.17.21");
78
+ * // => "lodash"
79
+ * getPackageName("@stryke/core/module@4.17.21");
80
+ * // => "@stryke/core"
81
+ * ```
82
+ *
83
+ * @param value - The scoped package string
84
+ * @returns The package name without the scope
85
+ */
86
+ function getPackageName(value) {
87
+ return /^[^\n\r/\u2028\u2029]*\/.[^\n\r/\u2028\u2029]*\/.*$/.test(value) ? value.substring(0, value.lastIndexOf("/")) : removePackageVersion(value);
88
+ }
89
+ /**
90
+ * Get the package version from a scoped package string
91
+ *
92
+ * @example
93
+ * ```typescript
94
+ * getPackageName("lodash@4.17.21");
95
+ * // => "4.17.21"
96
+ * getPackageName("@stryke/core@4.17.21");
97
+ * // => "4.17.21"
98
+ * getPackageName("lodash");
99
+ * // => undefined
100
+ * getPackageName("@stryke/core");
101
+ * // => undefined
102
+ * getPackageName("lodash/module");
103
+ * // => undefined
104
+ * getPackageName("@stryke/core/module");
105
+ * // => undefined
106
+ * getPackageName("lodash/module@4.17.21");
107
+ * // => "4.17.21"
108
+ * getPackageName("@stryke/core/module@4.17.21");
109
+ * // => "4.17.21"
110
+ * ```
111
+ *
112
+ * @param value - The scoped package string
113
+ * @returns The package version without the package name if it exists. If not, returns undefined.
114
+ */
115
+ function getPackageVersion(value) {
116
+ return hasPackageVersion(value) ? value.replace(/^.+@/, "") : void 0;
117
+ }
118
+
119
+ //#endregion
120
+ export { getPackageName, getPackageVersion, hasPackageVersion, removePackageVersion };
2
121
  //# sourceMappingURL=package.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"package.mjs","names":[],"sources":["../src/package.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 * Check if a package name has a version\n *\n * @example\n * ```typescript\n * hasPackageVersion(\"lodash@4.17.21\");\n * // => true\n * hasPackageVersion(\"@stryke/core@4.17.21\");\n * // => true\n * hasPackageVersion(\"lodash\");\n * // => false\n * hasPackageVersion(\"@stryke/core\");\n * // => false\n * hasPackageVersion(\"lodash/module\");\n * // => false\n * hasPackageVersion(\"@stryke/core/module\");\n * // => false\n * hasPackageVersion(\"lodash/module@4.17.21\");\n * // => true\n * hasPackageVersion(\"@stryke/core/module@4.17.21\");\n * // => true\n * ```\n *\n * @param value - The package name with version\n * @returns Whether the package name has a version\n */\nexport function hasPackageVersion(value: string): boolean {\n return /^.[^\\n\\r@\\u2028\\u2029]*@.*$/.test(value);\n}\n\n/**\n * Remove the version from a package name (if it exists)\n *\n * @example\n * ```typescript\n * removePackageVersion(\"lodash@4.17.21\");\n * // => \"lodash\"\n * removePackageVersion(\"@stryke/core@4.17.21\");\n * // => \"@stryke/core\"\n * removePackageVersion(\"lodash\");\n * // => \"lodash\"\n * removePackageVersion(\"@stryke/core\");\n * // => \"@stryke/core\"\n * getPackageName(\"lodash/module\");\n * // => \"lodash/module\"\n * getPackageName(\"@stryke/core/module\");\n * // => \"@stryke/core/module\"\n * getPackageName(\"lodash/module@4.17.21\");\n * // => \"lodash/module\"\n * getPackageName(\"@stryke/core/module@4.17.21\");\n * // => \"@stryke/core/module\"\n * ```\n *\n * @param value - The package name with version\n * @returns The package name without version\n */\nexport function removePackageVersion(value: string) {\n return hasPackageVersion(value)\n ? value.substring(0, value.lastIndexOf(\"@\"))\n : value;\n}\n\n/**\n * Get the package name from a scoped package string\n *\n * @example\n * ```typescript\n * getPackageName(\"lodash@4.17.21\");\n * // => \"lodash\"\n * getPackageName(\"@stryke/core@4.17.21\");\n * // => \"@stryke/core\"\n * getPackageName(\"lodash\");\n * // => \"lodash\"\n * getPackageName(\"@stryke/core\");\n * // => \"@stryke/core\"\n * getPackageName(\"lodash/module\");\n * // => \"lodash\"\n * getPackageName(\"@stryke/core/module\");\n * // => \"@stryke/core\"\n * getPackageName(\"lodash/module@4.17.21\");\n * // => \"lodash\"\n * getPackageName(\"@stryke/core/module@4.17.21\");\n * // => \"@stryke/core\"\n * ```\n *\n * @param value - The scoped package string\n * @returns The package name without the scope\n */\nexport function getPackageName(value: string) {\n return /^[^\\n\\r/\\u2028\\u2029]*\\/.[^\\n\\r/\\u2028\\u2029]*\\/.*$/.test(value)\n ? value.substring(0, value.lastIndexOf(\"/\"))\n : removePackageVersion(value);\n}\n\n/**\n * Get the package version from a scoped package string\n *\n * @example\n * ```typescript\n * getPackageName(\"lodash@4.17.21\");\n * // => \"4.17.21\"\n * getPackageName(\"@stryke/core@4.17.21\");\n * // => \"4.17.21\"\n * getPackageName(\"lodash\");\n * // => undefined\n * getPackageName(\"@stryke/core\");\n * // => undefined\n * getPackageName(\"lodash/module\");\n * // => undefined\n * getPackageName(\"@stryke/core/module\");\n * // => undefined\n * getPackageName(\"lodash/module@4.17.21\");\n * // => \"4.17.21\"\n * getPackageName(\"@stryke/core/module@4.17.21\");\n * // => \"4.17.21\"\n * ```\n *\n * @param value - The scoped package string\n * @returns The package version without the package name if it exists. If not, returns undefined.\n */\nexport function getPackageVersion(value: string): string | undefined {\n return hasPackageVersion(value) ? value.replace(/^.+@/, \"\") : undefined;\n}\n"],"mappings":"AA4CA,SAAgB,EAAkB,EAAwB,CACxD,MAAO,8BAA8B,KAAK,EAAM,CA6BlD,SAAgB,EAAqB,EAAe,CAClD,OAAO,EAAkB,EAAM,CAC3B,EAAM,UAAU,EAAG,EAAM,YAAY,IAAI,CAAC,CAC1C,EA6BN,SAAgB,EAAe,EAAe,CAC5C,MAAO,sDAAsD,KAAK,EAAM,CACpE,EAAM,UAAU,EAAG,EAAM,YAAY,IAAI,CAAC,CAC1C,EAAqB,EAAM,CA6BjC,SAAgB,EAAkB,EAAmC,CACnE,OAAO,EAAkB,EAAM,CAAG,EAAM,QAAQ,OAAQ,GAAG,CAAG,IAAA"}
1
+ {"version":3,"file":"package.mjs","names":[],"sources":["../src/package.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 * Check if a package name has a version\n *\n * @example\n * ```typescript\n * hasPackageVersion(\"lodash@4.17.21\");\n * // => true\n * hasPackageVersion(\"@stryke/core@4.17.21\");\n * // => true\n * hasPackageVersion(\"lodash\");\n * // => false\n * hasPackageVersion(\"@stryke/core\");\n * // => false\n * hasPackageVersion(\"lodash/module\");\n * // => false\n * hasPackageVersion(\"@stryke/core/module\");\n * // => false\n * hasPackageVersion(\"lodash/module@4.17.21\");\n * // => true\n * hasPackageVersion(\"@stryke/core/module@4.17.21\");\n * // => true\n * ```\n *\n * @param value - The package name with version\n * @returns Whether the package name has a version\n */\nexport function hasPackageVersion(value: string): boolean {\n return /^.[^\\n\\r@\\u2028\\u2029]*@.*$/.test(value);\n}\n\n/**\n * Remove the version from a package name (if it exists)\n *\n * @example\n * ```typescript\n * removePackageVersion(\"lodash@4.17.21\");\n * // => \"lodash\"\n * removePackageVersion(\"@stryke/core@4.17.21\");\n * // => \"@stryke/core\"\n * removePackageVersion(\"lodash\");\n * // => \"lodash\"\n * removePackageVersion(\"@stryke/core\");\n * // => \"@stryke/core\"\n * getPackageName(\"lodash/module\");\n * // => \"lodash/module\"\n * getPackageName(\"@stryke/core/module\");\n * // => \"@stryke/core/module\"\n * getPackageName(\"lodash/module@4.17.21\");\n * // => \"lodash/module\"\n * getPackageName(\"@stryke/core/module@4.17.21\");\n * // => \"@stryke/core/module\"\n * ```\n *\n * @param value - The package name with version\n * @returns The package name without version\n */\nexport function removePackageVersion(value: string) {\n return hasPackageVersion(value)\n ? value.substring(0, value.lastIndexOf(\"@\"))\n : value;\n}\n\n/**\n * Get the package name from a scoped package string\n *\n * @example\n * ```typescript\n * getPackageName(\"lodash@4.17.21\");\n * // => \"lodash\"\n * getPackageName(\"@stryke/core@4.17.21\");\n * // => \"@stryke/core\"\n * getPackageName(\"lodash\");\n * // => \"lodash\"\n * getPackageName(\"@stryke/core\");\n * // => \"@stryke/core\"\n * getPackageName(\"lodash/module\");\n * // => \"lodash\"\n * getPackageName(\"@stryke/core/module\");\n * // => \"@stryke/core\"\n * getPackageName(\"lodash/module@4.17.21\");\n * // => \"lodash\"\n * getPackageName(\"@stryke/core/module@4.17.21\");\n * // => \"@stryke/core\"\n * ```\n *\n * @param value - The scoped package string\n * @returns The package name without the scope\n */\nexport function getPackageName(value: string) {\n return /^[^\\n\\r/\\u2028\\u2029]*\\/.[^\\n\\r/\\u2028\\u2029]*\\/.*$/.test(value)\n ? value.substring(0, value.lastIndexOf(\"/\"))\n : removePackageVersion(value);\n}\n\n/**\n * Get the package version from a scoped package string\n *\n * @example\n * ```typescript\n * getPackageName(\"lodash@4.17.21\");\n * // => \"4.17.21\"\n * getPackageName(\"@stryke/core@4.17.21\");\n * // => \"4.17.21\"\n * getPackageName(\"lodash\");\n * // => undefined\n * getPackageName(\"@stryke/core\");\n * // => undefined\n * getPackageName(\"lodash/module\");\n * // => undefined\n * getPackageName(\"@stryke/core/module\");\n * // => undefined\n * getPackageName(\"lodash/module@4.17.21\");\n * // => \"4.17.21\"\n * getPackageName(\"@stryke/core/module@4.17.21\");\n * // => \"4.17.21\"\n * ```\n *\n * @param value - The scoped package string\n * @returns The package version without the package name if it exists. If not, returns undefined.\n */\nexport function getPackageVersion(value: string): string | undefined {\n return hasPackageVersion(value) ? value.replace(/^.+@/, \"\") : undefined;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;AA4CA,SAAgB,kBAAkB,OAAwB;AACxD,QAAO,8BAA8B,KAAK,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BlD,SAAgB,qBAAqB,OAAe;AAClD,QAAO,kBAAkB,MAAM,GAC3B,MAAM,UAAU,GAAG,MAAM,YAAY,IAAI,CAAC,GAC1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BN,SAAgB,eAAe,OAAe;AAC5C,QAAO,sDAAsD,KAAK,MAAM,GACpE,MAAM,UAAU,GAAG,MAAM,YAAY,IAAI,CAAC,GAC1C,qBAAqB,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6BjC,SAAgB,kBAAkB,OAAmC;AACnE,QAAO,kBAAkB,MAAM,GAAG,MAAM,QAAQ,QAAQ,GAAG,GAAG"}
package/dist/pad.cjs CHANGED
@@ -1 +1,25 @@
1
- function e(e,t,n=` `){return e.padStart(Math.floor((t-e.length)/2)+e.length,n).padEnd(t,n)}exports.pad=e;
1
+
2
+ //#region src/pad.ts
3
+ /**
4
+ * Pads string on the left and right sides if it's shorter than length. Padding characters are truncated if they can't be evenly divided by length.
5
+ * If the length is less than or equal to the original string's length, or if the padding character is an empty string, the original string is returned unchanged.
6
+ *
7
+ * @param str - The string to pad.
8
+ * @param length - The length of the resulting string once padded.
9
+ * @param chars - The character(s) to use for padding.
10
+ * @returns The padded string, or the original string if padding is not required.
11
+ *
12
+ * @example
13
+ * ```ts
14
+ * const result1 = pad('abc', 8); // result will be ' abc '
15
+ * const result2 = pad('abc', 8, '_-'); // result will be '_-abc_-_'
16
+ * const result3 = pad('abc', 3); // result will be 'abc'
17
+ * const result4 = pad('abc', 2); // result will be 'abc'
18
+ * ```
19
+ */
20
+ function pad(str, length, chars = " ") {
21
+ return str.padStart(Math.floor((length - str.length) / 2) + str.length, chars).padEnd(length, chars);
22
+ }
23
+
24
+ //#endregion
25
+ exports.pad = pad;
package/dist/pad.mjs CHANGED
@@ -1,2 +1,25 @@
1
- function e(e,t,n=` `){return e.padStart(Math.floor((t-e.length)/2)+e.length,n).padEnd(t,n)}export{e as pad};
1
+ //#region src/pad.ts
2
+ /**
3
+ * Pads string on the left and right sides if it's shorter than length. Padding characters are truncated if they can't be evenly divided by length.
4
+ * If the length is less than or equal to the original string's length, or if the padding character is an empty string, the original string is returned unchanged.
5
+ *
6
+ * @param str - The string to pad.
7
+ * @param length - The length of the resulting string once padded.
8
+ * @param chars - The character(s) to use for padding.
9
+ * @returns The padded string, or the original string if padding is not required.
10
+ *
11
+ * @example
12
+ * ```ts
13
+ * const result1 = pad('abc', 8); // result will be ' abc '
14
+ * const result2 = pad('abc', 8, '_-'); // result will be '_-abc_-_'
15
+ * const result3 = pad('abc', 3); // result will be 'abc'
16
+ * const result4 = pad('abc', 2); // result will be 'abc'
17
+ * ```
18
+ */
19
+ function pad(str, length, chars = " ") {
20
+ return str.padStart(Math.floor((length - str.length) / 2) + str.length, chars).padEnd(length, chars);
21
+ }
22
+
23
+ //#endregion
24
+ export { pad };
2
25
  //# sourceMappingURL=pad.mjs.map
package/dist/pad.mjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"pad.mjs","names":[],"sources":["../src/pad.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 * Pads string on the left and right sides if it's shorter than length. Padding characters are truncated if they can't be evenly divided by length.\n * If the length is less than or equal to the original string's length, or if the padding character is an empty string, the original string is returned unchanged.\n *\n * @param str - The string to pad.\n * @param length - The length of the resulting string once padded.\n * @param chars - The character(s) to use for padding.\n * @returns The padded string, or the original string if padding is not required.\n *\n * @example\n * ```ts\n * const result1 = pad('abc', 8); // result will be ' abc '\n * const result2 = pad('abc', 8, '_-'); // result will be '_-abc_-_'\n * const result3 = pad('abc', 3); // result will be 'abc'\n * const result4 = pad('abc', 2); // result will be 'abc'\n * ```\n */\nexport function pad(str: string, length: number, chars = \" \"): string {\n return str\n .padStart(Math.floor((length - str.length) / 2) + str.length, chars)\n .padEnd(length, chars);\n}\n"],"mappings":"AAmCA,SAAgB,EAAI,EAAa,EAAgB,EAAQ,IAAa,CACpE,OAAO,EACJ,SAAS,KAAK,OAAO,EAAS,EAAI,QAAU,EAAE,CAAG,EAAI,OAAQ,EAAM,CACnE,OAAO,EAAQ,EAAM"}
1
+ {"version":3,"file":"pad.mjs","names":[],"sources":["../src/pad.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 * Pads string on the left and right sides if it's shorter than length. Padding characters are truncated if they can't be evenly divided by length.\n * If the length is less than or equal to the original string's length, or if the padding character is an empty string, the original string is returned unchanged.\n *\n * @param str - The string to pad.\n * @param length - The length of the resulting string once padded.\n * @param chars - The character(s) to use for padding.\n * @returns The padded string, or the original string if padding is not required.\n *\n * @example\n * ```ts\n * const result1 = pad('abc', 8); // result will be ' abc '\n * const result2 = pad('abc', 8, '_-'); // result will be '_-abc_-_'\n * const result3 = pad('abc', 3); // result will be 'abc'\n * const result4 = pad('abc', 2); // result will be 'abc'\n * ```\n */\nexport function pad(str: string, length: number, chars = \" \"): string {\n return str\n .padStart(Math.floor((length - str.length) / 2) + str.length, chars)\n .padEnd(length, chars);\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAmCA,SAAgB,IAAI,KAAa,QAAgB,QAAQ,KAAa;AACpE,QAAO,IACJ,SAAS,KAAK,OAAO,SAAS,IAAI,UAAU,EAAE,GAAG,IAAI,QAAQ,MAAM,CACnE,OAAO,QAAQ,MAAM"}
@@ -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=>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.isPascalCase=n,exports.pascalCase=r;
1
+ const require_acronyms = require('./acronyms.cjs');
2
+ const require_get_words = require('./get-words.cjs');
3
+
4
+ //#region src/pascal-case.ts
5
+ /**
6
+ * Check if the input string is in pascal case.
7
+ *
8
+ * @remarks
9
+ * Pascal case is defined as an uppercase first letter followed by any number of lowercase letters and digits - "ThisIsAnExample".
10
+ *
11
+ * @param input - The input string to check.
12
+ * @returns True if the input is in pascal case, false otherwise.
13
+ */
14
+ function isPascalCase(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 pascal case.
19
+ *
20
+ * @remarks
21
+ * Pascal case is defined as an uppercase first letter followed by any number of lowercase letters and digits - "ThisIsAnExample".
22
+ *
23
+ * @param input - The input string.
24
+ * @returns The pascal-cased string.
25
+ */
26
+ function pascalCase(input) {
27
+ return isPascalCase(input) || input === void 0 ? input : require_get_words.getWords(input).map((word) => 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.isPascalCase = isPascalCase;
32
+ exports.pascalCase = pascalCase;
@@ -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=>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{r as isPascalCase,i as pascalCase};
1
+ import { ACRONYMS, ACRONYM_LIST } from "./acronyms.mjs";
2
+ import { getWords } from "./get-words.mjs";
3
+
4
+ //#region src/pascal-case.ts
5
+ /**
6
+ * Check if the input string is in pascal case.
7
+ *
8
+ * @remarks
9
+ * Pascal case is defined as an uppercase first letter followed by any number of lowercase letters and digits - "ThisIsAnExample".
10
+ *
11
+ * @param input - The input string to check.
12
+ * @returns True if the input is in pascal case, false otherwise.
13
+ */
14
+ function isPascalCase(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 pascal case.
19
+ *
20
+ * @remarks
21
+ * Pascal case is defined as an uppercase first letter followed by any number of lowercase letters and digits - "ThisIsAnExample".
22
+ *
23
+ * @param input - The input string.
24
+ * @returns The pascal-cased string.
25
+ */
26
+ function pascalCase(input) {
27
+ return isPascalCase(input) || input === void 0 ? input : getWords(input).map((word) => 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 { isPascalCase, pascalCase };
2
32
  //# sourceMappingURL=pascal-case.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"pascal-case.mjs","names":[],"sources":["../src/pascal-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 pascal case.\n *\n * @remarks\n * Pascal case is defined as an uppercase first letter followed by any number of lowercase letters and digits - \"ThisIsAnExample\".\n *\n * @param input - The input string to check.\n * @returns True if the input is in pascal case, false otherwise.\n */\nexport function isPascalCase(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 pascal case.\n *\n * @remarks\n * Pascal case is defined as an uppercase first letter followed by any number of lowercase letters and digits - \"ThisIsAnExample\".\n *\n * @param input - The input string.\n * @returns The pascal-cased string.\n */\nexport function pascalCase<T extends string | undefined>(input?: T): T {\n return (\n isPascalCase(input) || input === undefined\n ? input\n : getWords(input)\n .map(word =>\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,EAAa,EAAoC,CAC/D,OAAO,EACF,mBAAmB,KAAK,EAAM,EAC7B,EAAa,SAAS,EAAM,MAAM,CAAC,aAAa,CAAC,EACjD,8BAA8B,KAAK,EAAM,CAC3C,GAYN,SAAgB,EAAyC,EAAc,CACrE,OACE,EAAa,EAAM,EAAI,IAAU,IAAA,GAC7B,EACA,EAAS,EAAM,CACZ,IAAI,GACH,EAAa,SAAS,EAAK,MAAM,CAAC,aAAa,CAAC,CAC5C,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,CACvC,CACA,KAAK,GAAG"}
1
+ {"version":3,"file":"pascal-case.mjs","names":[],"sources":["../src/pascal-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 pascal case.\n *\n * @remarks\n * Pascal case is defined as an uppercase first letter followed by any number of lowercase letters and digits - \"ThisIsAnExample\".\n *\n * @param input - The input string to check.\n * @returns True if the input is in pascal case, false otherwise.\n */\nexport function isPascalCase(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 pascal case.\n *\n * @remarks\n * Pascal case is defined as an uppercase first letter followed by any number of lowercase letters and digits - \"ThisIsAnExample\".\n *\n * @param input - The input string.\n * @returns The pascal-cased string.\n */\nexport function pascalCase<T extends string | undefined>(input?: T): T {\n return (\n isPascalCase(input) || input === undefined\n ? input\n : getWords(input)\n .map(word =>\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,aAAa,OAAoC;AAC/D,QAAO,QACF,mBAAmB,KAAK,MAAM,IAC7B,aAAa,SAAS,MAAM,MAAM,CAAC,aAAa,CAAC,IACjD,8BAA8B,KAAK,MAAM,GAC3C;;;;;;;;;;;AAYN,SAAgB,WAAyC,OAAc;AACrE,QACE,aAAa,MAAM,IAAI,UAAU,SAC7B,QACA,SAAS,MAAM,CACZ,KAAI,SACH,aAAa,SAAS,KAAK,MAAM,CAAC,aAAa,CAAC,GAC5C,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,CACvC,CACA,KAAK,GAAG"}
@@ -1 +1,38 @@
1
- const e=require(`./types/src/base.cjs`),t=require(`./upper-case-first.cjs`);function n(e){return e?/^[a-z]+(?:\.[a-z0-9]+)*$/.test(e):!1}function r(r){if(!r||n(r))return r;let i=r?.replace(/[A-Z]+/g,n=>t.upperCaseFirst(n)??e.EMPTY_STRING)?.split(/(?=[A-Z])|[\s._-]/).map(e=>e.toLowerCase())??[];return i.length===0?``:i.length===1?i[0]:i.reduce((e,t)=>`${e}.${t.toLowerCase()}`.toLowerCase())}exports.isPeriodSplit=n,exports.periodSplit=r;
1
+ const require_base = require('./types/src/base.cjs');
2
+ const require_upper_case_first = require('./upper-case-first.cjs');
3
+
4
+ //#region src/period-split.ts
5
+ /**
6
+ * Check if the input string is in snake case.
7
+ *
8
+ * @remarks
9
+ * Snake case is defined as all lowercase 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 snake case, false otherwise.
13
+ */
14
+ function isPeriodSplit(input) {
15
+ return input ? /^[a-z]+(?:\.[a-z0-9]+)*$/.test(input) : false;
16
+ }
17
+ /**
18
+ * Make all characters lowercase and add a period in between each word
19
+ *
20
+ * @remarks
21
+ * "this.is.an.example"
22
+ *
23
+ * @param input - The input string.
24
+ * @returns The period-split string.
25
+ */
26
+ function periodSplit(input) {
27
+ if (!input || isPeriodSplit(input)) return input;
28
+ const parts = input?.replace(/[A-Z]+/g, (input$1) => require_upper_case_first.upperCaseFirst(input$1) ?? require_base.EMPTY_STRING)?.split(/(?=[A-Z])|[\s._-]/).map((x) => x.toLowerCase()) ?? [];
29
+ if (parts.length === 0) return "";
30
+ if (parts.length === 1) return parts[0];
31
+ return parts.reduce((ret, part) => {
32
+ return `${ret}.${part.toLowerCase()}`.toLowerCase();
33
+ });
34
+ }
35
+
36
+ //#endregion
37
+ exports.isPeriodSplit = isPeriodSplit;
38
+ exports.periodSplit = periodSplit;