refactor(case converter): using nocase to convert to upper and lower case
This commit is contained in:
parent
8485a0842f
commit
325f27b547
@ -19,7 +19,10 @@ const baseConfig = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const input = ref('lorem ipsum dolor sit amet');
|
const input = ref('lorem ipsum dolor sit amet');
|
||||||
const strippedInput = computed(() => input.value.split(' ').map(x => x.replace(baseConfig.stripRegexp, '')).join(' '));
|
|
||||||
|
// Using noCase to convert to lowercase and uppercase to ensure consistent splitting
|
||||||
|
const toLowerCase = (str: string) => noCase(str, baseConfig).toLocaleLowerCase();
|
||||||
|
const toUpperCase = (str: string) => noCase(str, baseConfig).toLocaleUpperCase();
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
@ -33,10 +36,10 @@ const strippedInput = computed(() => input.value.split(' ').map(x => x.replace(b
|
|||||||
<n-divider />
|
<n-divider />
|
||||||
|
|
||||||
<n-form-item label="Lowercase:">
|
<n-form-item label="Lowercase:">
|
||||||
<InputCopyable :value="strippedInput.toLowerCase()" />
|
<InputCopyable :value="toLowerCase(input)" />
|
||||||
</n-form-item>
|
</n-form-item>
|
||||||
<n-form-item label="Uppercase:">
|
<n-form-item label="Uppercase:">
|
||||||
<InputCopyable :value="strippedInput.toUpperCase()" />
|
<InputCopyable :value="toUpperCase(input)" />
|
||||||
</n-form-item>
|
</n-form-item>
|
||||||
<n-form-item label="Camelcase:">
|
<n-form-item label="Camelcase:">
|
||||||
<InputCopyable :value="camelCase(input, baseConfig)" />
|
<InputCopyable :value="camelCase(input, baseConfig)" />
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user