humanize-string 0.1.0

Convert a camelCase / snake_case / dash-case string into a human-readable one (fooBar -> Foo bar). A faithful port of the humanize-string npm package.
Documentation
# humanize-string

[![All Contributors](https://img.shields.io/badge/all_contributors-1-orange.svg?style=flat-square)](#contributors-)

[![crates.io](https://img.shields.io/crates/v/humanize-string.svg)](https://crates.io/crates/humanize-string)
[![docs.rs](https://docs.rs/humanize-string/badge.svg)](https://docs.rs/humanize-string)
[![CI](https://github.com/trananhtung/humanize-string/actions/workflows/ci.yml/badge.svg)](https://github.com/trananhtung/humanize-string/actions/workflows/ci.yml)
[![license](https://img.shields.io/crates/l/humanize-string.svg)](#license)

**Make a machine string human-readable.**

Convert a `camelCase`, `snake_case`, or `dash-case` string into a readable phrase:
`fooBar` → `Foo bar`, `background-color` → `Background color`,
`XMLHttpRequest` → `Xml http request`. A faithful Rust port of the
[`humanize-string`](https://www.npmjs.com/package/humanize-string) npm package.

- Built on [`decamelize`]https://crates.io/crates/decamelize
- Optional `preserve_case` mode
- Differential-tested against the reference `humanize-string` implementation

## Install

```toml
[dependencies]
humanize-string = "0.1"
```

## Usage

```rust
use humanize_string::{humanize_string, humanize_string_with};

assert_eq!(humanize_string("fooBar"), "Foo bar");
assert_eq!(humanize_string("background-color"), "Background color");
assert_eq!(humanize_string("HELLO_WORLD"), "Hello world");
assert_eq!(humanize_string("backgroundColorURL"), "Background color url");

// Keep the original casing (only normalize whitespace + capitalize the first letter):
assert_eq!(humanize_string_with("fooBar", true), "FooBar");
assert_eq!(humanize_string_with("HELLO_WORLD", true), "HELLO WORLD");
```

## Contributors ✨

This project follows the [all-contributors](https://github.com/all-contributors/all-contributors) specification. Contributions of any kind are welcome — code, docs, bug reports, ideas, reviews! See the [emoji key](https://allcontributors.org/docs/en/emoji-key) for how each contribution is recognized, and open a PR or issue to get involved.

Thanks goes to these wonderful people:

<!-- ALL-CONTRIBUTORS-LIST:START - Do not remove or modify this section -->
<!-- prettier-ignore-start -->
<!-- markdownlint-disable -->
<table>
  <tbody>
    <tr>
      <td align="center" valign="top" width="14.28%"><a href="https://github.com/trananhtung"><img src="https://avatars.githubusercontent.com/u/30992229?v=4?s=100" width="100px;" alt="Tung Tran"/><br /><sub><b>Tung Tran</b></sub></a><br /><a href="https://github.com/trananhtung/./commits?author=trananhtung" title="Code">💻</a> <a href="#maintenance-trananhtung" title="Maintenance">🚧</a></td>
    </tr>
  </tbody>
</table>

<!-- markdownlint-restore -->
<!-- prettier-ignore-end -->

<!-- ALL-CONTRIBUTORS-LIST:END -->

## License

Licensed under either of [MIT](LICENSE-MIT) or [Apache-2.0](LICENSE-APACHE) at your option.