@kubb/studio 5.12.4 → 5.12.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -31,12 +31,23 @@ import { gzipSync } from "node:zlib";
31
31
  *
32
32
  * When `pascal` is `true` the first word is also capitalized (PascalCase), otherwise only subsequent words are.
33
33
  */
34
- function toCamelOrPascal(text, pascal) {
34
+ function convert(text, pascal) {
35
35
  return text.trim().replace(/([a-z\d])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").replace(/(\d)([a-z])/g, "$1 $2").split(/[\s\-_./\\:]+/).filter(Boolean).map((word, i) => {
36
36
  if (word.length > 1 && word === word.toUpperCase()) return word;
37
37
  return (i === 0 && !pascal ? word.charAt(0).toLowerCase() : word.charAt(0).toUpperCase()) + word.slice(1);
38
38
  }).join("").replace(/[^a-zA-Z0-9]/g, "");
39
39
  }
40
+ const cache = /* @__PURE__ */ new Map();
41
+ const cacheLimit = 1e4;
42
+ function toCamelOrPascal(text, pascal) {
43
+ const key = `${pascal ? "P" : "c"}${text}`;
44
+ const cached = cache.get(key);
45
+ if (cached !== void 0) return cached;
46
+ const result = convert(text, pascal);
47
+ if (cache.size >= cacheLimit) cache.clear();
48
+ cache.set(key, result);
49
+ return result;
50
+ }
40
51
  /**
41
52
  * Converts `text` to camelCase.
42
53
  *
@@ -202,7 +213,7 @@ function getElapsedMs(hrStart) {
202
213
  }
203
214
  //#endregion
204
215
  //#region package.json
205
- var version = "5.12.4";
216
+ var version = "5.12.5";
206
217
  //#endregion
207
218
  //#region src/resolveConfig.ts
208
219
  /**