@thi.ng/strings 3.8.13 → 3.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2024-12-27T14:11:37Z
3
+ - **Last updated**: 2025-01-21T11:16:50Z
4
4
  - **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
5
5
 
6
6
  All notable changes to this project will be documented in this file.
@@ -9,6 +9,12 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
9
9
  **Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
10
10
  and/or version bumps of transitive dependencies.
11
11
 
12
+ ## [3.9.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/strings@3.9.0) (2025-01-04)
13
+
14
+ #### 🚀 Features
15
+
16
+ - add `pascal()` case conversion ([2c3f4f4](https://github.com/thi-ng/umbrella/commit/2c3f4f4))
17
+
12
18
  ### [3.8.7](https://github.com/thi-ng/umbrella/tree/@thi.ng/strings@3.8.7) (2024-10-31)
13
19
 
14
20
  #### ♻️ Refactoring
package/README.md CHANGED
@@ -151,7 +151,7 @@ For Node.js REPL:
151
151
  const str = await import("@thi.ng/strings");
152
152
  ```
153
153
 
154
- Package sizes (brotli'd, pre-treeshake): ESM: 5.52 KB
154
+ Package sizes (brotli'd, pre-treeshake): ESM: 5.51 KB
155
155
 
156
156
  ## Dependencies
157
157
 
@@ -223,4 +223,4 @@ If this project contributes to an academic publication, please cite it as:
223
223
 
224
224
  ## License
225
225
 
226
- © 2015 - 2024 Karsten Schmidt // Apache License 2.0
226
+ © 2015 - 2025 Karsten Schmidt // Apache License 2.0
package/case.d.ts CHANGED
@@ -21,13 +21,14 @@ export declare const capitalize: FnS;
21
21
  * Converts a CamelCase string into kebab case, with optional custom
22
22
  * delimiter (`-` by default).
23
23
  *
24
+ * @remarks
25
+ * See {@link snake} for alternative.
26
+ *
24
27
  * @example
25
28
  * ```ts tangle:../export/kebab.ts
26
29
  * import { kebab } from "@thi.ng/strings";
27
30
  *
28
- * console.log(
29
- * kebab("FooBar23Baz")
30
- * );
31
+ * console.log(kebab("FooBar23Baz"));
31
32
  * // "foo-bar23-baz"
32
33
  * ```
33
34
  *
@@ -38,21 +39,68 @@ export declare const kebab: Stringer<string>;
38
39
  /**
39
40
  * Short for {@link kebab} using `_` as delimiter.
40
41
  *
42
+ * @remarks
43
+ * Also see {@link upperSnake} for alternative.
44
+ *
45
+ * @example
46
+ * ```ts tangle:../export/snake.ts
47
+ * import { snake } from "@thi.ng/strings";
48
+ *
49
+ * console.log(snake("FooBar23Baz"));
50
+ * // "foo_bar23_baz"
51
+ * ```
52
+ *
41
53
  * @param x -
42
54
  */
43
55
  export declare const snake: FnS;
44
56
  /**
45
57
  * Uppercase version of {@link snake}.
46
58
  *
59
+ * @remarks
60
+ * Also see {@link snake} for alternative.
61
+ *
47
62
  * @param x -
48
63
  */
49
64
  export declare const upperSnake: FnS;
50
65
  /**
51
- * Converts a kebab-case or snake_case string into CamelCase. Uses `-`
52
- * as default delimiter.
66
+ * Converts a kebab-case or snake_case string into camelCase. Uses `-` as
67
+ * default delimiter.
68
+ *
69
+ * @remarks
70
+ * Alse see {@link pascal} for alternative.
71
+ *
72
+ * @example
73
+ * ```ts tangle:../export/camel.ts
74
+ * import { camel } from "@thi.ng/strings";
75
+ *
76
+ * console.log(camel("foo-bar23-baz"));
77
+ * // fooBar23Baz
78
+ *
79
+ * console.log(camel("FOO_BAR23_BAZ", "_"));
80
+ * // fooBar23Baz
81
+ * ```
53
82
  *
54
83
  * @param x -
55
84
  * @param delim -
56
85
  */
57
86
  export declare const camel: Stringer<string>;
87
+ /**
88
+ * Converts a kebab-case or snake_case string into PascalCase. Uses `-` as
89
+ * default delimiter.
90
+ *
91
+ * @example
92
+ * ```ts tangle:../export/pascal.ts
93
+ * import { pascal } from "@thi.ng/strings";
94
+ *
95
+ * console.log(pascal("foo-bar23-baz"));
96
+ * // FooBar23Baz
97
+ *
98
+ * console.log(pascal("FOO_BAR23_BAZ", "_"));
99
+ * // FooBar23Baz
100
+ * ```
101
+ *
102
+ * @param x
103
+ * @param delim
104
+ */
105
+ export declare const pascal: Stringer<string>;
58
106
  //# sourceMappingURL=case.d.ts.map
package/case.js CHANGED
@@ -3,9 +3,6 @@ const lower = (x) => x.toLowerCase();
3
3
  const capitalize = (x) => x.length ? x[0].toUpperCase() + x.substring(1) : x;
4
4
  const kebab = (x, delim = "-") => lower(
5
5
  x.replace(
6
- // TC39
7
- // /(?<=[a-z0-9\u00e0-\u00fd])(?=[A-Z\u00c0-\u00dd])/g,
8
- // (_, i) => (i ? delim : "")
9
6
  /([a-z0-9\u00e0-\u00fd])([A-Z\u00c0-\u00dd])/g,
10
7
  (_, a, b) => a + delim + b
11
8
  )
@@ -13,11 +10,13 @@ const kebab = (x, delim = "-") => lower(
13
10
  const snake = (x) => kebab(x, "_");
14
11
  const upperSnake = (x) => snake(x).toUpperCase();
15
12
  const camel = (x, delim = "-") => lower(x).replace(new RegExp(`\\${delim}+(\\w)`, "g"), (_, c) => upper(c));
13
+ const pascal = (x, delim = "-") => capitalize(camel(x, delim));
16
14
  export {
17
15
  camel,
18
16
  capitalize,
19
17
  kebab,
20
18
  lower,
19
+ pascal,
21
20
  snake,
22
21
  upper,
23
22
  upperSnake
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/strings",
3
- "version": "3.8.13",
3
+ "version": "3.9.1",
4
4
  "description": "Various string formatting & utility functions",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -40,10 +40,10 @@
40
40
  "tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
41
41
  },
42
42
  "dependencies": {
43
- "@thi.ng/api": "^8.11.15",
44
- "@thi.ng/errors": "^2.5.21",
45
- "@thi.ng/hex": "^2.3.59",
46
- "@thi.ng/memoize": "^4.0.5"
43
+ "@thi.ng/api": "^8.11.16",
44
+ "@thi.ng/errors": "^2.5.22",
45
+ "@thi.ng/hex": "^2.3.60",
46
+ "@thi.ng/memoize": "^4.0.6"
47
47
  },
48
48
  "devDependencies": {
49
49
  "@microsoft/api-extractor": "^7.48.1",
@@ -212,5 +212,5 @@
212
212
  "thi.ng": {
213
213
  "year": 2015
214
214
  },
215
- "gitHead": "48bf4c22bf23f88ac99f435106af2214f79a0be1\n"
215
+ "gitHead": "56e7a1724e7b0cb5c41119f60320b6ff0e8a3c1c\n"
216
216
  }