
Security News
Crates.io Users Targeted by Phishing Emails
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
@kristiandupont/recase
Advanced tools
Change and detect the casing of a string.
npm i @kristiandupont/recase
const { recase, detectCasing } = require("@kristiandupont/recase");
const initialCase = "snake";
const toCamel = recase(initialCase, "camel");
const toDash = recase(initialCase, "dash");
const s = "some_string_initially_set_with_snake_case";
console.log("Camel cased version:", toCamel(s));
// prints: "Camel cased version: someStringInitiallySetWithSnakeCase"
console.log("Dash cased version:", toDash(s));
// prints: "Dash cased version: some-string-initially-set-with-snake-case"
console.log("Casing detected:", detectCasing(s));
// prints: "Casing detected: snake"
recase(from, to, str);
Takes two casing parameters which can both be one of dash
, snake
, camel
or pascal
. Additionally,
from
can be mixed
or null which will make all word boundaries considered.
The third parameter is the string to recase.
This function is curried which means that if you call it with fewer than three parameters, the return value
will be a new function, with the initial parameters bound. So if you want to have a function that converts
any string to a pascal-cased one, you can create it like so:
const toPascal = recase(null, "pascal");
console.log(toPascal("snake_case"));
// Prints: "SnakeCase"
detectCasing(str);
Takes a string that has been formatted. It will attempt to detect the casing.
dash
: example-string
screamingDash
: EXAMPLE-STRING
snake
: example_string
screamingSnake
: EXAMPLE_STRING
camel
: exampleString
pascal
: ExampleString
prose
: example string
capitalProse
: Example String
FAQs
Change and detect the casing of a string.
We found that @kristiandupont/recase demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
The Rust Security Response WG is warning of phishing emails from rustfoundation.dev targeting crates.io users.
Product
Socket now lets you customize pull request alert headers, helping security teams share clear guidance right in PRs to speed reviews and reduce back-and-forth.
Product
Socket's Rust support is moving to Beta: all users can scan Cargo projects and generate SBOMs, including Cargo.toml-only crates, with Rust-aware supply chain checks.