@dominik1905/string-toolkit 1.0.0 → 1.1.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.
package/README.md CHANGED
@@ -16,6 +16,17 @@ yarn add @dominik1905/string-toolkit
16
16
 
17
17
  [cite_start]Here are detailed examples of how to use the available functions.
18
18
 
19
+ ### toKebabCase
20
+ Converts a string to kebab-case (lowercase words separated by dashes).
21
+
22
+ ```javascript
23
+ const { toKebabCase } = require('@dein_npm_benutzername/string-toolkit');
24
+
25
+ const result = toKebabCase("Hello World");
26
+ console.log(result); // Output: "hello-world"
27
+
28
+ ```
29
+
19
30
  ### toSnakeCase
20
31
  [cite_start]Converts a string to snake_case (lowercase words separated by underscores)[cite: 9].
21
32
 
@@ -23,4 +34,7 @@ yarn add @dominik1905/string-toolkit
23
34
  const { toSnakeCase } = require('@dominik1905/string-toolkit');
24
35
 
25
36
  const result = toSnakeCase("Hello World");
26
- console.log(result); [cite_start]// Output: "hello_world" [cite: 9, 10]
37
+ console.log(result); [cite_start]// Output: "hello_world" [cite: 9, 10]
38
+
39
+ ```
40
+
package/index.js CHANGED
@@ -1,11 +1,14 @@
1
-
2
1
  function toSnakeCase(str) {
3
2
  if (!str) return '';
4
- // Wandelt alles in Kleinbuchstaben um und ersetzt Leerzeichen durch Unterstriche
5
3
  return str.toLowerCase().split(' ').join('_');
6
4
  }
7
5
 
8
- // Damit die Funktion von anderen Dateien (und unseren Tests) genutzt werden kann:
6
+ function toKebabCase(str) {
7
+ if (!str) return '';
8
+ return str.toLowerCase().split(' ').join('-');
9
+ }
10
+
9
11
  module.exports = {
10
- toSnakeCase
12
+ toSnakeCase,
13
+ toKebabCase
11
14
  };
package/index.test.js CHANGED
@@ -1,5 +1,9 @@
1
- const { toSnakeCase } = require('./index');
1
+ const { toSnakeCase, toKebabCase } = require('./index');
2
2
 
3
3
  test('converts "Hello World" to "hello_world"', () => {
4
4
  expect(toSnakeCase('Hello World')).toBe('hello_world');
5
+ });
6
+
7
+ test('converts "Hello World" to "hello-world"', () => {
8
+ expect(toKebabCase('Hello World')).toBe('hello-world');
5
9
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dominik1905/string-toolkit",
3
- "version": "1.0.0",
3
+ "version": "1.1.0",
4
4
  "description": "",
5
5
  "license": "ISC",
6
6
  "author": "",