Skip to content

trananhtung/humanize-string

Repository files navigation

humanize-string

All Contributors

crates.io docs.rs CI license

Make a machine string human-readable.

Convert a camelCase, snake_case, or dash-case string into a readable phrase: fooBarFoo bar, background-colorBackground color, XMLHttpRequestXml http request. A faithful Rust port of the humanize-string npm package.

  • Built on decamelize
  • Optional preserve_case mode
  • Differential-tested against the reference humanize-string implementation

Install

[dependencies]
humanize-string = "0.1"

Usage

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 specification. Contributions of any kind are welcome — code, docs, bug reports, ideas, reviews! See the emoji key for how each contribution is recognized, and open a PR or issue to get involved.

Thanks goes to these wonderful people:

Tung Tran
Tung Tran

💻 🚧

License

Licensed under either of MIT or Apache-2.0 at your option.

About

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

Resources

License

Apache-2.0, MIT licenses found

Licenses found

Apache-2.0
LICENSE-APACHE
MIT
LICENSE-MIT

Stars

0 stars

Watchers

0 watching

Forks

Packages

 
 
 

Contributors

Languages