forked from shmuelie/Humanizer.Js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ordinalizeExtensions.ts
69 lines (64 loc) · 2.52 KB
/
ordinalizeExtensions.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
interface String
{
ordinalize(gender: Humanizer.GrammaticalGender): string;
ordinalize(): string;
}
interface Number
{
ordinalize(gender: Humanizer.GrammaticalGender): string;
ordinalize(): string;
}
module Humanizer
{
"use strict";
/** Turns a number into an ordinal string used to denote the position in an ordered sequence such as 1st, 2nd, 3rd, 4th. */
String.prototype.ordinalize = function (gender?: Humanizer.GrammaticalGender): string
{
/// <signature>
/// <summary>
/// Turns a number into an ordinal string used to denote the position in an ordered sequence such as 1st, 2nd, 3rd, 4th.
/// </summary>
/// </signature>
/// <signature>
/// <summary>
/// Turns a number into an ordinal string used to denote the position in an ordered sequence such as 1st, 2nd, 3rd, 4th.
/// </summary>
/// <param name="gender" type="Humanizer.GrammaticalGender">
/// The grammatical gender to use for output words
/// </param>
/// </signature>
if (gender === undefined)
{
return Configuration.Configurator.getOrdinalizer().convert(parseInt(this, 10), this);
}
else
{
return Configuration.Configurator.getOrdinalizer().convert(parseInt(this, 10), this, gender);
}
};
/** Turns a number into an ordinal number used to denote the position in an ordered sequence such as 1st, 2nd, 3rd, 4th. */
Number.prototype.ordinalize = function (gender?: Humanizer.GrammaticalGender): string
{
/// <signature>
/// <summary>
/// Turns a number into an ordinal string used to denote the position in an ordered sequence such as 1st, 2nd, 3rd, 4th.
/// </summary>
/// </signature>
/// <signature>
/// <summary>
/// Turns a number into an ordinal string used to denote the position in an ordered sequence such as 1st, 2nd, 3rd, 4th.
/// </summary>
/// <param name="gender" type="Humanizer.GrammaticalGender">
/// The grammatical gender to use for output words
/// </param>
/// </signature>
if (gender === undefined)
{
return Configuration.Configurator.getOrdinalizer().convert(this, this.toString());
}
else
{
return Configuration.Configurator.getOrdinalizer().convert(this, this.String(), gender);
}
};
}