๐Ÿ“ฆ justjavac / moonbit-case

๐Ÿ“„ README.md ยท 56 lines
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56# moonbit-case

Transform strings between different cases: `camelCase`, `PascalCase`, `snake_case`, `kebab-case`, `CONSTANT_CASE`, and many more.

## Installation

```bash
moon update
moon add justjavac/case
```

## Quick Start

```moonbit
// Core case conversions
@case.camel_case("hello world")       // "helloWorld"
@case.pascal_case("hello world")      // "HelloWorld"
@case.snake_case("hello world")       // "hello_world"
@case.kebab_case("hello world")       // "hello-world"
@case.constant_case("hello world")    // "HELLO_WORLD"

// Additional transformations
@case.swap_case("Hello World")        // "hELLO wORLD"
@case.title_case("the lord of rings") // "The Lord of Rings"
@case.reverse_case("hello")           // "olleh"
```

## Real-world Use Cases

```moonbit
// API endpoint conversion
let apiEndpoint = "getUserProfile"
@case.kebab_case(apiEndpoint)        // "get-user-profile" (for URLs)
@case.snake_case(apiEndpoint)        // "get_user_profile" (for database)
@case.constant_case(apiEndpoint)     // "GET_USER_PROFILE" (for constants)

// Configuration keys
let configKey = "databaseConnectionString"
@case.constant_case(configKey)       // "DATABASE_CONNECTION_STRING"
@case.dot_case(configKey)            // "database.connection.string"
```

## Testing

Run the test suite:

```bash
moon test
```

All functions include comprehensive test coverage with edge cases and complex scenarios.

## License

MIT License