decamelize 0.1.1

Convert a camelCase string to a separated lower-case string (e.g. fooBar -> foo_bar). A faithful, zero-dependency port of the decamelize npm package.
Documentation
  • Coverage
  • 100%
    3 out of 3 items documented3 out of 3 items with examples
  • Size
  • Source code size: 28.02 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 131.65 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 2s Average build duration of successful builds.
  • all releases: 2s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • Homepage
  • trananhtung/decamelize
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • trananhtung

decamelize

All Contributors

crates.io docs.rs CI license

Convert a camelCase string to a separated lower-case string.

fooBarfoo_bar, unicornsAndRainbowsunicorns_and_rainbows, XMLHttpRequestxml_http_request. A faithful Rust port of the widely-used decamelize npm package.

  • Zero dependencies, #![no_std]
  • Custom separator and a preserveConsecutiveUppercase mode
  • Differential-tested against the reference decamelize implementation

Install

[dependencies]
decamelize = "0.1"

Usage

use decamelize::{decamelize, decamelize_with};

assert_eq!(decamelize("unicornsAndRainbows"), "unicorns_and_rainbows");
assert_eq!(decamelize("testGUILabel"), "test_gui_label");
assert_eq!(decamelize("p2pNetwork"), "p2p_network");

// Custom separator:
assert_eq!(decamelize_with("fooBar", "-", false), "foo-bar");
assert_eq!(decamelize_with("unicornsAndRainbows", " ", false), "unicorns and rainbows");

// Preserve consecutive uppercase runs:
assert_eq!(decamelize_with("testGUILabel", "_", true), "test_GUI_label");
assert_eq!(decamelize_with("XMLHttpRequest", "_", true), "XML_http_request");

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:

License

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