What is no-case?
The no-case npm package is a utility for converting strings to lower case with spaces between words. It is useful for transforming strings into a more readable format, especially for user interfaces or data processing.
What are no-case's main functionalities?
Convert camelCase to no-case
This feature converts a camelCase string into a no-case string, where words are separated by spaces and all letters are in lower case.
const noCase = require('no-case');
const result = noCase('camelCaseString');
console.log(result); // Output: 'camel case string'
Convert snake_case to no-case
This feature converts a snake_case string into a no-case string, where underscores are replaced by spaces and all letters are in lower case.
const noCase = require('no-case');
const result = noCase('snake_case_string');
console.log(result); // Output: 'snake case string'
Convert kebab-case to no-case
This feature converts a kebab-case string into a no-case string, where hyphens are replaced by spaces and all letters are in lower case.
const noCase = require('no-case');
const result = noCase('kebab-case-string');
console.log(result); // Output: 'kebab case string'
Other packages similar to no-case
change-case
The change-case package provides a set of utilities for converting strings between different cases, such as camelCase, snake_case, and kebab-case. It offers more comprehensive functionality compared to no-case, as it supports multiple case transformations.
lodash
Lodash is a utility library that provides a wide range of functions for manipulating arrays, objects, and strings. It includes methods for case conversion, such as _.camelCase, _.snakeCase, and _.kebabCase, making it a versatile alternative to no-case.
voca
Voca is a string manipulation library that offers a variety of functions for working with strings, including case conversion. It provides methods like voca.camelCase, voca.snakeCase, and voca.kebabCase, similar to the functionality provided by no-case.
No Case
Transform any case string into a lower case string with a space between each word.
Example: foo_bar
=> fooBar
Installation
npm install no-case --save
Usage
import { noCase } from "no-case";
noCase("string");
noCase("dot.case");
noCase("PascalCase");
noCase("version 1.2.10");
Optional options
as the second argument:
separateNumbers: boolean
- Splits numbers apart from letters, e.g. V1
-> v 1
.locale: string | false
- Lower case according to a specific locale
, defaulting to the current system locale.
License
MIT