
Security News
Crates.io Implements Trusted Publishing Support
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
constant-case
Advanced tools
The constant-case npm package is used to convert strings into constant case format, typically used for defining constants in programming. This format involves converting all letters to uppercase and replacing spaces and other special characters with underscores.
String Conversion to Constant Case
Converts a given string into constant case, making all characters uppercase and replacing spaces and special characters with underscores. Useful for creating identifiers in code that are typically constants.
const constantCase = require('constant-case');
console.log(constantCase('string to convert')); // 'STRING_TO_CONVERT'
A comprehensive toolkit for converting text between different cases. It includes constant-case as one of its many functions, along with other cases like camel case, capital case, and more. This makes change-case more versatile compared to constant-case, which specializes in only constant case conversion.
Converts a string to uppercase. It is similar to constant-case in that it affects the letter casing, but it does not replace spaces or special characters with underscores, thus it's less suitable for creating constant identifiers but useful for general uppercasing needs.
Transform into upper case string with an underscore between words.
npm install constant-case --save
import { constantCase } from "constant-case";
constantCase("string"); //=> "STRING"
constantCase("dot.case"); //=> "DOT_CASE"
constantCase("PascalCase"); //=> "PASCAL_CASE"
constantCase("version 1.2.10"); //=> "VERSION_1_2_10"
The function also accepts options
.
MIT
FAQs
Transform into upper case string with an underscore between words
The npm package constant-case receives a total of 5,436,007 weekly downloads. As such, constant-case popularity was classified as popular.
We found that constant-case demonstrated a not healthy version release cadence and project activity because the last version was released 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
Crates.io adds Trusted Publishing support, enabling secure GitHub Actions-based crate releases without long-lived API tokens.
Research
/Security News
Undocumented protestware found in 28 npm packages disrupts UI for Russian-language users visiting Russian and Belarusian domains.
Research
/Security News
North Korean threat actors deploy 67 malicious npm packages using the newly discovered XORIndex malware loader.