@canonical/utils 0.4.0-experimental.0 → 0.7.0-experimental.0

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.
@@ -0,0 +1,50 @@
1
+ /**
2
+ * Convert a string to PascalCase
3
+ * @param s - The string to convert
4
+ * @returns The PascalCase string
5
+ * @example
6
+ * toPascalCase("my-component") // "MyComponent"
7
+ */
8
+ const toPascalCase = (s) => {
9
+ if (!s)
10
+ return "";
11
+ const camelCased = toCamelCase(s);
12
+ return camelCased.charAt(0).toUpperCase() + camelCased.slice(1);
13
+ };
14
+ /**
15
+ * Convert a string to kebab-case
16
+ * @param s - The string to convert
17
+ * @returns The kebab-case string
18
+ * @example
19
+ * toKebabCase("MyComponent") // "my-component"
20
+ */
21
+ const toKebabCase = (s) => {
22
+ if (!s)
23
+ return "";
24
+ return s
25
+ .trim()
26
+ .replace(/([a-z0-9])([A-Z])/g, "$1-$2")
27
+ .toLowerCase();
28
+ };
29
+ /**
30
+ * Convert a string to camelCase
31
+ * @param s - The string to convert
32
+ * @returns The camelCase string
33
+ * @example
34
+ * toCamelCase("my-component") // "myComponent"
35
+ */
36
+ const toCamelCase = (s) => {
37
+ if (!s)
38
+ return "";
39
+ return s
40
+ .replace(/-([a-z])/g, (g) => g[1].toUpperCase())
41
+ .replaceAll("-", "")
42
+ .replaceAll("_", "")
43
+ .replaceAll(" ", "");
44
+ };
45
+ export default {
46
+ toPascalCase,
47
+ toKebabCase,
48
+ toCamelCase,
49
+ };
50
+ //# sourceMappingURL=casing.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"casing.js","sourceRoot":"","sources":["../../src/casing.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,MAAM,YAAY,GAAG,CAAC,CAAS,EAAU,EAAE;IACzC,IAAI,CAAC,CAAC;QAAE,OAAO,EAAE,CAAC;IAElB,MAAM,UAAU,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC;IAElC,OAAO,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;AAClE,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,WAAW,GAAG,CAAC,CAAS,EAAU,EAAE;IACxC,IAAI,CAAC,CAAC;QAAE,OAAO,EAAE,CAAC;IAElB,OAAO,CAAC;SACL,IAAI,EAAE;SACN,OAAO,CAAC,oBAAoB,EAAE,OAAO,CAAC;SACtC,WAAW,EAAE,CAAC;AACnB,CAAC,CAAC;AAEF;;;;;;GAMG;AACH,MAAM,WAAW,GAAG,CAAC,CAAS,EAAU,EAAE;IACxC,IAAI,CAAC,CAAC;QAAE,OAAO,EAAE,CAAC;IAElB,OAAO,CAAC;SACL,OAAO,CAAC,WAAW,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC;SAC/C,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC;SACnB,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC;SACnB,UAAU,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AACzB,CAAC,CAAC;AAEF,eAAe;IACb,YAAY;IACZ,WAAW;IACX,WAAW;CACZ,CAAC"}
package/dist/esm/index.js CHANGED
@@ -1,3 +1,4 @@
1
1
  export { default as debounce } from "./debounce.js";
2
2
  export { default as throttle } from "./throttle.js";
3
+ export { default as casing } from "./casing.js";
3
4
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC"}
@@ -0,0 +1,7 @@
1
+ declare const _default: {
2
+ toPascalCase: (s: string) => string;
3
+ toKebabCase: (s: string) => string;
4
+ toCamelCase: (s: string) => string;
5
+ };
6
+ export default _default;
7
+ //# sourceMappingURL=casing.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"casing.d.ts","sourceRoot":"","sources":["../../src/casing.ts"],"names":[],"mappings":";sBAOyB,MAAM,KAAG,MAAM;qBAehB,MAAM,KAAG,MAAM;qBAgBf,MAAM,KAAG,MAAM;;AAUvC,wBAIE"}
@@ -1,3 +1,4 @@
1
1
  export { default as debounce } from "./debounce.js";
2
2
  export { default as throttle } from "./throttle.js";
3
+ export { default as casing } from "./casing.js";
3
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,eAAe,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,eAAe,CAAC;AACpD,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@canonical/utils",
3
3
  "description": "Standard utility functions for Canonical's Web Engineering team",
4
- "version": "0.4.0-experimental.0",
4
+ "version": "0.7.0-experimental.0",
5
5
  "type": "module",
6
6
  "module": "dist/esm/index.js",
7
7
  "types": "dist/types/index.d.ts",
@@ -35,5 +35,5 @@
35
35
  "@canonical/typescript-config-base": "^0.4.0-experimental.0",
36
36
  "typescript": "^5.7.2"
37
37
  },
38
- "gitHead": "c1d4c3d77c4d7a522359babd05186dbf65aca801"
38
+ "gitHead": "11146c000439508767e3122e80b7a1703889e8a7"
39
39
  }