Skip to content

Commit

Permalink
Add README to root of repo
Browse files Browse the repository at this point in the history
  • Loading branch information
rossmacarthur committed Jul 7, 2024
1 parent 2577e80 commit 85ffaaf
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 4 deletions.
68 changes: 68 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# cases

💼 A case conversion library

![cases](https://github.com/rossmacarthur/cases/assets/17109887/ab3a4c71-6090-49f3-a67f-b1ab395999c6)

This repository provides a

- [**Go module**](./go)

Install using

```sh
go get -u github.com/rossmacarthur/cases
```

Now convert a string using the relevant function.

```go
import "github.com/rossmacarthur/cases/go"

cases.ToSnake("XMLHttpRequest") // returns "xml_http_request"
```

- [**Python package**](./python)

Install using

```sh
pip install pycases
```

Now convert a string using the relevant function.

```python
import cases

cases.to_snake("XMLHttpRequest") # returns "xml_http_request"
```

Each language implementation is identical and use the same underlying
implementation which does the following:

- Divide the input string into words
- Convert each word as required
- Join the words back together optionally with a separator

Word boundaries are defined as follows:

- A set of consecutive Unicode non-letter and non-number characters.

For example: 'foo _bar' is two words (foo and bar)

- A transition from a lowercase letter to an uppercase letter.

For example: fooBar is two words (foo and Bar)

- A transition from multiple uppercase letters to a single uppercase letter
followed by lowercase letters.

For example: FOOBar is two words (FOO and Bar)

## License

This project is distributed under the terms of both the MIT license and the
Apache License (Version 2.0).

See [LICENSE-APACHE](LICENSE-APACHE) and [LICENSE-MIT](LICENSE-MIT) for details.
7 changes: 4 additions & 3 deletions go/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,13 @@ Word boundaries are defined as follows:
Install using

```sh
go get -u github.com/rossmacarthur/cases
go get -u github.com/rossmacarthur/cases/go"
```
Now convert a string using the relevant function.
```go
import "github.com/rossmacarthur/cases"
import "github.com/rossmacarthur/cases/go"
cases.ToSnake("XMLHttpRequest") // returns "xml_http_request"
```
Expand Down Expand Up @@ -96,4 +96,5 @@ cases.Transform("xml_http_request", writeFn, nil) // returns "XMLHTTPRequest"
This project is distributed under the terms of both the MIT license and the
Apache License (Version 2.0).
See [LICENSE-APACHE](LICENSE-APACHE) and [LICENSE-MIT](LICENSE-MIT) for details.
See [LICENSE-APACHE](../LICENSE-APACHE) and [LICENSE-MIT](../LICENSE-MIT) for
details.
2 changes: 1 addition & 1 deletion python/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,4 @@ Macbook M2 Max.
## License

This project is licensed under the terms of the MIT license. See
[LICENSE](LICENSE) for more details.
[LICENSE-MIT](../LICENSE-MIT) for more details.

0 comments on commit 85ffaaf

Please sign in to comment.