
Security News
npm Adopts OIDC for Trusted Publishing in CI/CD Workflows
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Transform a string by swapping every character from upper to lower case, or lower to upper case
The swap-case npm package is designed to transform text by swapping the case of each character in a string. It converts lowercase letters to uppercase and vice versa, providing a simple and effective way to manipulate text case in JavaScript applications.
Swap Case
This feature allows you to swap the case of each character in a string. Lowercase letters become uppercase, and uppercase letters become lowercase. It's useful for text formatting and styling in applications.
const swapCase = require('swap-case');
let text = 'Hello World';
let swappedText = swapCase(text);
console.log(swappedText); // Outputs: 'hELLO wORLD'
The change-case package is a comprehensive text transformation library that includes various case conversion utilities such as camelCase, capitalCase, constantCase, dotCase, headerCase, noCase, paramCase, pascalCase, pathCase, sentenceCase, snakeCase, and swapCase. It offers more extensive functionality compared to swap-case, which focuses solely on swapping the case of characters.
The upper-case package is specifically designed to convert all characters in a string to uppercase. While it serves a different specific purpose, it is related in the broader category of case manipulation. Unlike swap-case, it does not provide the functionality to swap cases but rather converts all characters to a single case.
Similar to upper-case, the lower-case package converts all characters in a string to lowercase. It is another example of a case manipulation package but, like upper-case, does not offer the swapping functionality found in swap-case.
Transform a string by swapping every character from upper to lower case, or lower to upper case.
npm install swap-case --save
import { swapCase } from "swap-case";
swapCase("string"); //=> "STRING"
swapCase("dot.case"); //=> "DOT.CASE"
swapCase("PascalCase"); //=> "pASCALcASE"
This package is a pure ESM package and ships with TypeScript definitions. It cannot be require
'd or used with CommonJS module resolution in TypeScript.
MIT
FAQs
Transform a string by swapping every character from upper to lower case, or lower to upper case
The npm package swap-case receives a total of 4,900,837 weekly downloads. As such, swap-case popularity was classified as popular.
We found that swap-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
npm now supports Trusted Publishing with OIDC, enabling secure package publishing directly from CI/CD workflows without relying on long-lived tokens.
Research
/Security News
A RubyGems malware campaign used 60 malicious packages posing as automation tools to steal credentials from social media and marketing tool users.
Security News
The CNA Scorecard ranks CVE issuers by data completeness, revealing major gaps in patch info and software identifiers across thousands of vulnerabilities.