What is to-space-case?
The 'to-space-case' npm package is a utility that converts strings to space case. Space case is a format where words are separated by spaces, and it is useful for creating human-readable strings from various other formats like camelCase, snake_case, etc.
What are to-space-case's main functionalities?
Convert camelCase to space case
This feature converts a camelCase string to space case, making it more readable by separating words with spaces.
const toSpaceCase = require('to-space-case');
const result = toSpaceCase('camelCaseString');
console.log(result); // 'camel case string'
Convert snake_case to space case
This feature converts a snake_case string to space case, replacing underscores with spaces.
const toSpaceCase = require('to-space-case');
const result = toSpaceCase('snake_case_string');
console.log(result); // 'snake case string'
Convert kebab-case to space case
This feature converts a kebab-case string to space case, replacing hyphens with spaces.
const toSpaceCase = require('to-space-case');
const result = toSpaceCase('kebab-case-string');
console.log(result); // 'kebab case string'
Other packages similar to to-space-case
change-case
The 'change-case' package provides a comprehensive set of functions for converting strings between different cases, including camelCase, snake_case, kebab-case, and more. It offers more versatility compared to 'to-space-case' as it supports multiple case transformations.
lodash
Lodash is a utility library that offers a wide range of functions for manipulating arrays, objects, and strings. It includes methods like _.camelCase, _.snakeCase, and _.kebabCase, which can be used to convert strings between different cases. While it is more feature-rich, it is also larger in size compared to 'to-space-case'.
voca
Voca is a versatile string manipulation library that provides functions for changing string cases, among other string operations. It includes methods like voca.camelCase, voca.snakeCase, and voca.kebabCase, making it a good alternative to 'to-space-case' with additional string manipulation capabilities.
to-space-case
Convert a string to a space case.
Installation
$ npm install to-space-case
Example
var space = require('to-space-case');
space('camelCase');
space('snake_case');
space('dot.case');
space('-RAnDom -jUNk$__loL!')
API
toSpaceCase(string)
Returns the string
converted to space case.
License
The MIT License (MIT)
Copyright © 2016, Ian Storm Taylor
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.