Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

case-anything

Package Overview
Dependencies
Maintainers
1
Versions
34
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

case-anything - npm Package Compare versions

Comparing version 0.1.0 to 0.2.0

.github/FUNDING.yml

36

dist/index.cjs.js

@@ -97,6 +97,41 @@ 'use strict';

}
/**
* converts strings to Capital Case (with spaces)
*
* @export
* @param {string} string
* @returns {string} in Capital Case (with spaces)
*/
function capitalCase(string) {
return spaceCase(pascalCase(string));
}
/**
* converts strings to lower case (with spaces)
*
* @export
* @param {string} string
* @returns {string} in lower case (with spaces)
*/
function lowerCase(string) {
return getParts(string)
.join(' ').toLowerCase();
}
/**
* converts strings to UPPER CASE (with spaces)
*
* @export
* @param {string} string
* @returns {string} in UPPER CASE (with spaces)
*/
function upperCase(string) {
return getParts(string)
.join(' ').toUpperCase();
}
exports.camelCase = camelCase;
exports.capitalCase = capitalCase;
exports.constantCase = constantCase;
exports.getParts = getParts;
exports.kebabCase = kebabCase;
exports.lowerCase = lowerCase;
exports.pascalCase = pascalCase;

@@ -106,1 +141,2 @@ exports.pathCase = pathCase;

exports.spaceCase = spaceCase;
exports.upperCase = upperCase;

34

dist/index.esm.js

@@ -93,3 +93,35 @@ /**

}
/**
* converts strings to Capital Case (with spaces)
*
* @export
* @param {string} string
* @returns {string} in Capital Case (with spaces)
*/
function capitalCase(string) {
return spaceCase(pascalCase(string));
}
/**
* converts strings to lower case (with spaces)
*
* @export
* @param {string} string
* @returns {string} in lower case (with spaces)
*/
function lowerCase(string) {
return getParts(string)
.join(' ').toLowerCase();
}
/**
* converts strings to UPPER CASE (with spaces)
*
* @export
* @param {string} string
* @returns {string} in UPPER CASE (with spaces)
*/
function upperCase(string) {
return getParts(string)
.join(' ').toUpperCase();
}
export { camelCase, constantCase, kebabCase, pascalCase, pathCase, snakeCase, spaceCase };
export { camelCase, capitalCase, constantCase, getParts, kebabCase, lowerCase, pascalCase, pathCase, snakeCase, spaceCase, upperCase };

2

package.json
{
"name": "case-anything",
"version": "0.1.0",
"version": "0.2.0",
"description": "camelCase, kebab-case, PascalCase... a simple integration with nano package size. (SMALL footprint!)",

@@ -5,0 +5,0 @@ "main": "dist/index.cjs.js",

@@ -65,2 +65,17 @@ # Case anything 🐫

There is also upper, lower and capital case. These will all add spaces.
```js
import { upperCase, lowerCase, capitalCase } from 'case-anything'
const testString = 'PonytaVaporeon_poliwrath-BUTTERFREE'
upperCase(testString)
=== 'PONYTA VAPOREON POLIWRATH BUTTERFREE'
lowerCase(testString)
=== 'ponyta vaporeon poliwrath butterfree'
capitalCase(testString)
=== 'Ponyta Vaporeon Poliwrath Butterfree'
```
## Package size

@@ -67,0 +82,0 @@

@@ -8,3 +8,3 @@

*/
function getParts (string) {
export function getParts (string: string): any[] {
return string.match(/^[a-z]+|[A-Z][a-z]+|[A-Z]+|[a-z]+/g)

@@ -20,3 +20,3 @@ }

*/
export function camelCase (string) {
export function camelCase (string: string): string {
return getParts(string)

@@ -37,3 +37,3 @@ .reduce((result, match, index) => {

*/
export function pascalCase (string) {
export function pascalCase (string: string): string {
return getParts(string)

@@ -52,3 +52,3 @@ .reduce((result, match) => {

*/
export function kebabCase (string) {
export function kebabCase (string: string): string {
return getParts(string)

@@ -65,3 +65,3 @@ .join('-').toLowerCase()

*/
export function snakeCase (string) {
export function snakeCase (string: string): string {
return getParts(string)

@@ -78,3 +78,3 @@ .join('_').toLowerCase()

*/
export function constantCase (string) {
export function constantCase (string: string): string {
return getParts(string)

@@ -91,3 +91,3 @@ .join('_').toUpperCase()

*/
export function pathCase (string) {
export function pathCase (string: string): string {
return getParts(string)

@@ -104,5 +104,40 @@ .join('/')

*/
export function spaceCase (string) {
export function spaceCase (string: string): string {
return getParts(string)
.join(' ')
}
/**
* converts strings to Capital Case (with spaces)
*
* @export
* @param {string} string
* @returns {string} in Capital Case (with spaces)
*/
export function capitalCase (string: string): string {
return spaceCase(pascalCase(string))
}
/**
* converts strings to lower case (with spaces)
*
* @export
* @param {string} string
* @returns {string} in lower case (with spaces)
*/
export function lowerCase (string: string): string {
return getParts(string)
.join(' ').toLowerCase()
}
/**
* converts strings to UPPER CASE (with spaces)
*
* @export
* @param {string} string
* @returns {string} in UPPER CASE (with spaces)
*/
export function upperCase (string: string): string {
return getParts(string)
.join(' ').toUpperCase()
}
import test from 'ava'
import { spaceCase, camelCase, pascalCase, kebabCase, snakeCase, constantCase, pathCase } from '../dist/index.cjs'
import {
spaceCase,
camelCase,
pascalCase,
kebabCase,
snakeCase,
constantCase,
pathCase,
capitalCase,
upperCase,
lowerCase,
} from '../dist/index.cjs'

@@ -26,2 +37,38 @@ const tests = [

test('capitalCase', t => {
t.deepEqual(tests.map(capitalCase), [
'Ponyta Vaporeon Poliwrath Butterfree A',
'Ponyta Vaporeon Poliwrath Butterfree A',
'Ponyta Vaporeon Poliwrath Butterfree A',
'Ponyta Vaporeon Poliwrath Butterfree A',
'Ponyta Vaporeon Poliwrath Butterfree A',
'Ponyta Vaporeon Poliwrath Butterfree A',
'Ponyta Vaporeon Poliwrath Butterfree A',
])
})
test('upperCase', t => {
t.deepEqual(tests.map(upperCase), [
'PONYTA VAPOREON POLIWRATH BUTTERFREE A',
'PONYTA VAPOREON POLIWRATH BUTTERFREE A',
'PONYTA VAPOREON POLIWRATH BUTTERFREE A',
'PONYTA VAPOREON POLIWRATH BUTTERFREE A',
'PONYTA VAPOREON POLIWRATH BUTTERFREE A',
'PONYTA VAPOREON POLIWRATH BUTTERFREE A',
'PONYTA VAPOREON POLIWRATH BUTTERFREE A',
])
})
test('lowerCase', t => {
t.deepEqual(tests.map(lowerCase), [
'ponyta vaporeon poliwrath butterfree a',
'ponyta vaporeon poliwrath butterfree a',
'ponyta vaporeon poliwrath butterfree a',
'ponyta vaporeon poliwrath butterfree a',
'ponyta vaporeon poliwrath butterfree a',
'ponyta vaporeon poliwrath butterfree a',
'ponyta vaporeon poliwrath butterfree a',
])
})
test('camelCase', t => {

@@ -28,0 +75,0 @@ tests.forEach(w => {

/**
* A string.match function that will return an array of "string parts"
*
* @param {string} string
* @returns {string[]}
*/
export declare function getParts(string: string): any[];
/**
* converts strings to camelCase

@@ -8,3 +15,3 @@ *

*/
export declare function camelCase(string: any): any;
export declare function camelCase(string: string): string;
/**

@@ -17,3 +24,3 @@ * converts strings to PascalCase

*/
export declare function pascalCase(string: any): any;
export declare function pascalCase(string: string): string;
/**

@@ -26,3 +33,3 @@ * converts strings to kebab-case

*/
export declare function kebabCase(string: any): any;
export declare function kebabCase(string: string): string;
/**

@@ -35,3 +42,3 @@ * converts strings to snake_case

*/
export declare function snakeCase(string: any): any;
export declare function snakeCase(string: string): string;
/**

@@ -44,3 +51,3 @@ * converts strings to CONSTANT_CASE

*/
export declare function constantCase(string: any): any;
export declare function constantCase(string: string): string;
/**

@@ -53,3 +60,3 @@ * converts strings to path/case

*/
export declare function pathCase(string: any): any;
export declare function pathCase(string: string): string;
/**

@@ -62,2 +69,26 @@ * converts strings to space case (will add spaces but not change casing)

*/
export declare function spaceCase(string: any): any;
export declare function spaceCase(string: string): string;
/**
* converts strings to Capital Case (with spaces)
*
* @export
* @param {string} string
* @returns {string} in Capital Case (with spaces)
*/
export declare function capitalCase(string: string): string;
/**
* converts strings to lower case (with spaces)
*
* @export
* @param {string} string
* @returns {string} in lower case (with spaces)
*/
export declare function lowerCase(string: string): string;
/**
* converts strings to UPPER CASE (with spaces)
*
* @export
* @param {string} string
* @returns {string} in UPPER CASE (with spaces)
*/
export declare function upperCase(string: string): string;
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc