Skip to content

Commit 0377ff1

Browse files
authored
fix(casing): Make camelCase, kebabCase, lowerCase, snakeCase, startCase, upperCase match lodash (toss#1525)
1 parent e00c448 commit 0377ff1

File tree

16 files changed

+77
-11
lines changed

16 files changed

+77
-11
lines changed

.scripts/docs/operations/render/en.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,14 @@ function returns(item: DocumentationItem) {
5656

5757
if (item.returns.type == null) {
5858
return `
59-
### Returns
59+
#### Returns
6060
6161
(\`${item.returns.type}\`): ${item.returns.document}
6262
`.trim();
6363
}
6464

6565
return `
66-
### Returns
66+
#### Returns
6767
6868
(\`${item.returns.type}\`): ${item.returns.document}
6969
`.trim();

.scripts/docs/operations/render/ja.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ function returns(item: DocumentationItem) {
5757
}
5858

5959
return `
60-
### 戻り値
60+
#### 戻り値
6161
6262
(\`${item.returns.type}\`): ${item.returns.document}
6363
`.trim();

.scripts/docs/operations/render/ko.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ function returns(item: DocumentationItem) {
5555
}
5656

5757
return `
58-
### 반환 값
58+
#### 반환 값
5959
6060
(\`${item.returns.type}\`): ${item.returns.document}
6161
`.trim();

.scripts/docs/operations/render/zh_hans.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ function returns(item: DocumentationItem) {
5555
}
5656

5757
return `
58-
### 返回值
58+
#### 返回值
5959
6060
(\`${item.returns.type}\`): ${item.returns.document}
6161
`.trim();

src/compat/string/camelCase.spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,16 @@ describe('camelCase', () => {
3636
expect(actual).toEqual(expected);
3737
});
3838

39+
it('should convert string to camel case, identical to lodash', () => {
40+
expect(camelCase('åäöÅÄÖ')).toBe('aaoAao');
41+
expect(camelCase('helloÅäöWorld')).toBe('helloAaoWorld');
42+
expect(camelCase('café')).toBe('cafe');
43+
expect(camelCase('naïve')).toBe('naive');
44+
expect(camelCase('Zürich')).toBe('zurich');
45+
expect(camelCase('São Paulo')).toBe('saoPaulo');
46+
expect(camelCase('Москва')).toBe('москва');
47+
});
48+
3949
it('should handle double-converting strings', () => {
4050
const actual = strings.map(str => camelCase(camelCase(str)));
4151
const expected = strings.map(() => 'fooBar');

src/compat/string/camelCase.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { deburr } from './deburr.ts';
12
import { camelCase as camelCaseToolkit } from '../../string/camelCase.ts';
23
import { normalizeForCase } from '../_internal/normalizeForCase.ts';
34

@@ -18,5 +19,5 @@ import { normalizeForCase } from '../_internal/normalizeForCase.ts';
1819
*/
1920

2021
export function camelCase(str?: string): string {
21-
return camelCaseToolkit(normalizeForCase(str));
22+
return camelCaseToolkit(normalizeForCase(deburr(str)));
2223
}

src/compat/string/kebabCase.spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@ describe('kebabCase', () => {
1313
expect(actual).toEqual(expected);
1414
});
1515

16+
it('should convert string to snake case, identical to lodash', () => {
17+
expect(kebabCase('åäöÅÄÖ')).toBe('aao-aao');
18+
expect(kebabCase('helloÅäöWorld')).toBe('hello-aao-world');
19+
expect(kebabCase('café')).toBe('cafe');
20+
expect(kebabCase('naïve')).toBe('naive');
21+
expect(kebabCase('Zürich')).toBe('zurich');
22+
expect(kebabCase('São Paulo')).toBe('sao-paulo');
23+
expect(kebabCase('Москва')).toBe('москва');
24+
});
25+
1626
it(`should handle double-converting strings`, () => {
1727
const actual = strings.map(string => kebabCase(kebabCase(string)));
1828

src/compat/string/kebabCase.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { deburr } from './deburr.ts';
12
import { kebabCase as kebabCaseToolkit } from '../../string/kebabCase.ts';
23
import { normalizeForCase } from '../_internal/normalizeForCase.ts';
34

@@ -16,5 +17,5 @@ import { normalizeForCase } from '../_internal/normalizeForCase.ts';
1617
* const convertedStr4 = kebabCase('HTTPRequest') // returns 'http-request'
1718
*/
1819
export function kebabCase(str?: string): string {
19-
return kebabCaseToolkit(normalizeForCase(str));
20+
return kebabCaseToolkit(normalizeForCase(deburr(str)));
2021
}

src/compat/string/lowerCase.spec.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,16 @@ describe('lowerCase', () => {
1313
expect(actual).toEqual(expected);
1414
});
1515

16+
it('should convert string to lower case, identical to lodash', () => {
17+
expect(lowerCase('åäöÅÄÖ')).toBe('aao aao');
18+
expect(lowerCase('helloÅäöWorld')).toBe('hello aao world');
19+
expect(lowerCase('café')).toBe('cafe');
20+
expect(lowerCase('naïve')).toBe('naive');
21+
expect(lowerCase('Zürich')).toBe('zurich');
22+
expect(lowerCase('São Paulo')).toBe('sao paulo');
23+
expect(lowerCase('Москва')).toBe('москва');
24+
});
25+
1626
it(`should handle double-converting strings`, () => {
1727
const actual = strings.map(string => lowerCase(lowerCase(string)));
1828

src/compat/string/lowerCase.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { deburr } from './deburr.ts';
12
import { lowerCase as lowerCaseToolkit } from '../../string/lowerCase.ts';
23
import { normalizeForCase } from '../_internal/normalizeForCase.ts';
34

@@ -16,5 +17,5 @@ import { normalizeForCase } from '../_internal/normalizeForCase.ts';
1617
* const convertedStr4 = lowerCase('HTTPRequest') // returns 'http request'
1718
*/
1819
export function lowerCase(str?: string): string {
19-
return lowerCaseToolkit(normalizeForCase(str));
20+
return lowerCaseToolkit(normalizeForCase(deburr(str)));
2021
}

0 commit comments

Comments
 (0)