forked from FoundKeyGang/FoundKey
Add capitalize function (#2651)
This commit is contained in:
parent
769960f29e
commit
c6ff6939a5
2 changed files with 6 additions and 1 deletions
|
@ -1,3 +1,5 @@
|
||||||
|
import { capitalize } from "../../../prelude/string";
|
||||||
|
|
||||||
function escape(text: string) {
|
function escape(text: string) {
|
||||||
return text
|
return text
|
||||||
.replace(/>/g, '>')
|
.replace(/>/g, '>')
|
||||||
|
@ -89,7 +91,7 @@ const _keywords = [
|
||||||
];
|
];
|
||||||
|
|
||||||
const keywords = _keywords
|
const keywords = _keywords
|
||||||
.concat(_keywords.map(k => k[0].toUpperCase() + k.substr(1)))
|
.concat(_keywords.map(capitalize))
|
||||||
.concat(_keywords.map(k => k.toUpperCase()))
|
.concat(_keywords.map(k => k.toUpperCase()))
|
||||||
.sort((a, b) => b.length - a.length);
|
.sort((a, b) => b.length - a.length);
|
||||||
|
|
||||||
|
|
3
src/prelude/string.ts
Normal file
3
src/prelude/string.ts
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
export function capitalize(s: string): string {
|
||||||
|
return s.charAt(0).toUpperCase() + s.slice(1).toLowerCase();
|
||||||
|
}
|
Loading…
Reference in a new issue