Change Case
Wrapper for change-case.
โก๏ธ Prerequisites
- Install the change-case package:
๐ฌ Usage
<script>
import {change_case} from "@sveu/extend/change_case"
let value = "Svelte Action"
</script>
<h1>{change_case(value, "snakeCase")}</h1>
<input bind:value>
๐ฉโ๐ปAPI
๐ป Arguments
Name | Description | Type | Required |
---|---|---|---|
input | The string to convert | string | Yes |
type | The type of conversion to perform | string | Yes |
๐ Options
Read the change-case documentation for more information.
โฉ๏ธ Returns
The converted string.
๐งช Playground
Source Code ๐
Source Code
import type { Options } from "change-case"
import * as _changeCase from "./changeCase"
export type ChangeCaseType = keyof typeof _changeCase
/**
* Wrapper for change-case
*
* @param input - Input string
*
* @param type - Type of change case
*
* @param options - [Change-case options](https://github.com/blakeembrey/change-case#options)
*
* @returns Changed string
*/
export function change_case(
input: string,
type: ChangeCaseType,
options?: Options | undefined
) {
return _changeCase[type](input, options)
}
Last update: 2023-02-17
Authors: Mohamed-Kaizen