lowerCase

源码

https://github.com/ddzy/ts-utility-plugins/tree/master/src/ddzy/utility/string/lowerCase

说明

转换字符串string以空格分开单词, 并转换为小写

用法

lowerCase.ts
lowerCase.test.ts
lowerCase.ts
import { lowerCase } from "./ddzy/utility/string/lowerCase";
// ? 空字符串
const s1 = '';
const p1 = lowerCase(s1);
console.log(p1);
console.log('----------------------');
// ?
const s2 = '--Duan-Zhao--';
const p2 = lowerCase(s2);
console.log(p2);
console.log('-----------------------');
// ?
const s3 = 'alioeDuan';
const p3 = lowerCase(s3);
console.log(p3);
console.log('-------------------------');
// ?
const s4 = '__DUAN_ZHAO_YANG__';
const p4 = lowerCase(s4);
console.log(p4);
lowerCase.test.ts
import { lowerCase } from "../../utility/string/lowerCase";
describe('lowerCase tests...', () => {
test('lowerCase should return `` when receive an empty string', () => {
const received = '';
const expected = '';
const result = lowerCase(received);
expect(result).toBe(expected);
});
test('lowerCase should return the converted string correctly', () => {
const received = ['--Duan-Zhao--', 'alioeDuan', '__DUAN_ZHAO_YANG__'];
const expected = ['duan zhao', 'alioeduan', 'duan zhao yang'];
received.forEach((v, i) => {
const result = lowerCase(v);
expect(result).toBe(expected[i]);
});
});
});