What is path-case?
The path-case npm package is used to convert strings to path case, which is a lowercase format with words separated by slashes. This is particularly useful for creating URL paths or file paths in a consistent format.
What are path-case's main functionalities?
Convert string to path case
This feature converts a given string to path case, where each word is separated by a slash and all characters are in lowercase.
const pathCase = require('path-case');
const result = pathCase('Hello World');
console.log(result); // Output: 'hello/world'
Other packages similar to path-case
lodash.kebabcase
The lodash.kebabcase package converts strings to kebab case, which is similar to path case but uses hyphens instead of slashes. It is part of the larger Lodash utility library, which offers a wide range of functions for manipulating arrays, objects, and strings.
change-case
The change-case package provides a variety of string case transformations, including camel case, snake case, and path case. It is a versatile library that can handle multiple case conversions, making it more comprehensive compared to path-case.
param-case
The param-case package converts strings to param case, which is similar to path case but uses hyphens instead of slashes. It is part of the change-case family of packages, which offers various string case transformations.
Path Case
Path case a string.
Supports Unicode (non-ASCII characters) and non-string entities, such as objects with a toString
property, numbers and booleans. Empty values (null
and undefined
) will result in an empty string.
Installation
npm install path-case --save
Usage
var pathCase = require('path-case')
pathCase('string')
pathCase('camelCase')
pathCase('sentence case')
pathCase('MY STRING', 'tr')
Typings
Includes a TypeScript definition.
License
MIT