forked from shmuelie/Humanizer.Js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
casingExtensions.ts
33 lines (30 loc) · 941 Bytes
/
casingExtensions.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
interface String
{
applyCasing(casing: Humanizer.LetterCasing): string;
}
module Humanizer
{
"use strict";
/**
* Changes the casing of the provided input
*/
String.prototype.applyCasing = function (casing: Humanizer.LetterCasing): string
{
/// <summary>
/// Changes the casing of the provided input
/// </summary>
switch (casing)
{
case Humanizer.LetterCasing.Title:
return this.transform(Humanizer.To.TitleCase);
case Humanizer.LetterCasing.LowerCase:
return this.transform(Humanizer.To.LowerCase);
case Humanizer.LetterCasing.AllCaps:
return this.transform(Humanizer.To.UpperCase);
case Humanizer.LetterCasing.Sentence:
return this.transform(Humanizer.To.SentenceCase);
default:
throw new Error();
}
};
}