n2words 1.9.0 → 1.11.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/i18n/TR.mjs CHANGED
@@ -1,352 +1,357 @@
1
1
  import N2WordsBase from '../classes/N2WordsBase.mjs';
2
2
 
3
- export default function(options) {
4
- N2WordsBase.call(this);
3
+ export class N2WordsTR extends N2WordsBase {
4
+ constructor(options) {
5
+ super();
5
6
 
6
- let defaultOptions = { dropSpaces: false };
7
- let localOptions = Object.assign({}, defaultOptions, options);
7
+ this.options = Object.assign({
8
+ dropSpaces: false,
9
+ }, options);
8
10
 
9
- this.negative_word = 'eksi';
10
- this.separator_word = 'virgül';
11
- this.ZERO = 'sıfır';
12
- this.space_separator = (localOptions.dropSpaces) ? '' : ' ';
13
- this.precision = 2;
14
- this.splitnum = (value) => {
15
- const float_digits = JSON.stringify(value * 10 ** this.precision);
11
+ this.negativeWord = 'eksi';
12
+ this.separatorWord = 'virgül';
13
+ this.zero = 'sıfır';
14
+ this.spaceSeparator = (this.options.dropSpaces) ? '' : ' ';
15
+ this.precision = 2;
16
+
17
+ this.cardinalOnes = {
18
+ 1: 'bir',
19
+ 2: 'iki',
20
+ 3: 'üç',
21
+ 4: 'dört',
22
+ 5: 'beş',
23
+ 6: 'altı',
24
+ 7: 'yedi',
25
+ 8: 'sekiz',
26
+ 9: 'dokuz',
27
+ };
28
+ this.cardinalTens = {
29
+ 1: 'on',
30
+ 2: 'yirmi',
31
+ 3: 'otuz',
32
+ 4: 'kırk',
33
+ 5: 'elli',
34
+ 6: 'altmış',
35
+ 7: 'yetmiş',
36
+ 8: 'seksen',
37
+ 9: 'doksan',
38
+ };
39
+ this.hundreds = {
40
+ 2: 'iki',
41
+ 3: 'üç',
42
+ 4: 'dört',
43
+ 5: 'beş',
44
+ 6: 'altı',
45
+ 7: 'yedi',
46
+ 8: 'sekiz',
47
+ 9: 'dokuz',
48
+ };
49
+ this.cardinalHundred = ['yüz', ''];
50
+ this.cardinalTriplets = {
51
+ 1: 'bin',
52
+ 2: 'milyon',
53
+ 3: 'milyar',
54
+ 4: 'trilyon',
55
+ 5: 'katrilyon',
56
+ 6: 'kentilyon',
57
+ };
58
+ this.integersToRead = [];
59
+ this.totalTripletsToRead = 0;
60
+ this.totalDigitsOutsideTriplets = 0;
61
+ this.lastZeroDigitOrder = 0;
62
+ }
63
+
64
+ splitNum(value) {
65
+ const floatDigits = JSON.stringify(value * 10 ** this.precision);
16
66
  if (parseInt(value) != 0) {
17
- this.integers_to_read = [
67
+ this.integersToRead = [
18
68
  JSON.stringify(parseInt(value)),
19
- float_digits.slice(float_digits.length - this.precision, float_digits.length),
69
+ floatDigits.slice(floatDigits.length - this.precision, floatDigits.length),
20
70
  ];
21
71
  } else {
22
- this.integers_to_read = [
72
+ this.integersToRead = [
23
73
  '0',
24
- '0'.repeat(this.precision - float_digits.length) +
25
- float_digits.slice(float_digits.length - this.precision, float_digits.length),
74
+ '0'.repeat(this.precision - floatDigits.length) +
75
+ floatDigits.slice(floatDigits.length - this.precision, floatDigits.length),
26
76
  ];
27
77
  }
28
- if (this.integers_to_read[0].length % 3 > 0) {
29
- this.total_triplets_to_read = Math.floor(this.integers_to_read[0].length / 3) + 1;
30
- } else if (this.integers_to_read[0].length % 3 == 0) {
31
- this.total_triplets_to_read = Math.floor(this.integers_to_read[0].length / 3);
78
+ if (this.integersToRead[0].length % 3 > 0) {
79
+ this.totalTripletsToRead = Math.floor(this.integersToRead[0].length / 3) + 1;
80
+ } else if (this.integersToRead[0].length % 3 == 0) {
81
+ this.totalTripletsToRead = Math.floor(this.integersToRead[0].length / 3);
32
82
  }
33
- this.total_digits_outside_triplets = this.integers_to_read[0].length % 3;
83
+ this.totalDigitsOutsideTriplets = this.integersToRead[0].length % 3;
34
84
 
35
- const okunacak = this.integers_to_read[0].split('').reverse();
36
- this.order_of_last_zero_digit = 0;
85
+ const okunacak = this.integersToRead[0].split('').reverse();
86
+ this.lastZeroDigitOrder = 0;
37
87
  let found = 0;
38
88
  for (let i = 0; i < okunacak.length; i++) {
39
89
  if (parseInt(okunacak[i]) == 0 && found == 0) {
40
- this.order_of_last_zero_digit = i + 1;
90
+ this.lastZeroDigitOrder = i + 1;
41
91
  } else {
42
92
  found = 1;
43
93
  }
44
94
  }
45
- };
95
+ }
46
96
 
47
- this.CARDINAL_ONES = {
48
- 1: 'bir',
49
- 2: 'iki',
50
- 3: 'üç',
51
- 4: 'dört',
52
- 5: 'beş',
53
- 6: 'altı',
54
- 7: 'yedi',
55
- 8: 'sekiz',
56
- 9: 'dokuz',
57
- };
58
- this.CARDINAL_TENS = {
59
- 1: 'on',
60
- 2: 'yirmi',
61
- 3: 'otuz',
62
- 4: 'kırk',
63
- 5: 'elli',
64
- 6: 'altmış',
65
- 7: 'yetmiş',
66
- 8: 'seksen',
67
- 9: 'doksan',
68
- };
69
- this.HUNDREDS = {
70
- 2: 'iki',
71
- 3: 'üç',
72
- 4: 'dört',
73
- 5: 'beş',
74
- 6: 'altı',
75
- 7: 'yedi',
76
- 8: 'sekiz',
77
- 9: 'dokuz',
78
- };
79
- this.CARDINAL_HUNDRED = ['yüz', ''];
80
- this.CARDINAL_TRIPLETS = {
81
- 1: 'bin',
82
- 2: 'milyon',
83
- 3: 'milyar',
84
- 4: 'trilyon',
85
- 5: 'katrilyon',
86
- 6: 'kentilyon',
87
- };
88
- this.integers_to_read = [];
89
- this.total_triplets_to_read = 0;
90
- this.total_digits_outside_triplets = 0;
91
- this.order_of_last_zero_digit = 0;
92
- this.joinWords = (wordArray) => {
93
- return wordArray.join(this.space_separator).trim();
97
+ joinWords(wordArray) {
98
+ return wordArray.join(this.spaceSeparator).trim();
94
99
  }
95
100
 
96
- this.toCardinal = (value) => {
101
+ toCardinal(value) {
97
102
  if (parseInt(value) == 0) {
98
103
  return 'sıfır';
99
104
  }
100
- this.splitnum(value);
105
+ this.splitNum(value);
101
106
  let wordArray = [];
102
- if (this.order_of_last_zero_digit >= this.integers_to_read[0].length) {
107
+ if (this.lastZeroDigitOrder >= this.integersToRead[0].length) {
103
108
  return this.joinWords(wordArray);
104
109
  }
105
- if (this.total_triplets_to_read == 1) {
106
- if (this.total_digits_outside_triplets == 2) {
107
- if (this.order_of_last_zero_digit == 1) {
108
- if(this.CARDINAL_TENS[this.integers_to_read[0][0]]) {
109
- wordArray.push(this.CARDINAL_TENS[this.integers_to_read[0][0]]);
110
+ if (this.totalTripletsToRead == 1) {
111
+ if (this.totalDigitsOutsideTriplets == 2) {
112
+ if (this.lastZeroDigitOrder == 1) {
113
+ if(this.cardinalTens[this.integersToRead[0][0]]) {
114
+ wordArray.push(this.cardinalTens[this.integersToRead[0][0]]);
110
115
  }
111
116
  return this.joinWords(wordArray);
112
117
  }
113
- if (this.order_of_last_zero_digit == 0) {
114
- if(this.CARDINAL_TENS[this.integers_to_read[0][0]]) {
115
- wordArray.push(this.CARDINAL_TENS[this.integers_to_read[0][0]]);
118
+ if (this.lastZeroDigitOrder == 0) {
119
+ if(this.cardinalTens[this.integersToRead[0][0]]) {
120
+ wordArray.push(this.cardinalTens[this.integersToRead[0][0]]);
116
121
  }
117
- if(this.CARDINAL_ONES[this.integers_to_read[0][1]]) {
118
- wordArray.push(this.CARDINAL_ONES[this.integers_to_read[0][1]]);
122
+ if(this.cardinalOnes[this.integersToRead[0][1]]) {
123
+ wordArray.push(this.cardinalOnes[this.integersToRead[0][1]]);
119
124
  }
120
125
  }
121
126
  return this.joinWords(wordArray);
122
127
  }
123
- if (this.total_digits_outside_triplets == 1) {
124
- if (this.order_of_last_zero_digit == 0) {
125
- if(this.CARDINAL_ONES[this.integers_to_read[0][0]]) {
126
- wordArray.push(this.CARDINAL_ONES[this.integers_to_read[0][0]]);
128
+ if (this.totalDigitsOutsideTriplets == 1) {
129
+ if (this.lastZeroDigitOrder == 0) {
130
+ if(this.cardinalOnes[this.integersToRead[0][0]]) {
131
+ wordArray.push(this.cardinalOnes[this.integersToRead[0][0]]);
127
132
  }
128
133
  return this.joinWords(wordArray);
129
134
  }
130
135
  }
131
- if (this.total_digits_outside_triplets == 0) {
132
- if (this.order_of_last_zero_digit == 2) {
133
- if(this.HUNDREDS[this.integers_to_read[0][0]]) {
134
- wordArray.push(this.HUNDREDS[this.integers_to_read[0][0]]);
136
+ if (this.totalDigitsOutsideTriplets == 0) {
137
+ if (this.lastZeroDigitOrder == 2) {
138
+ if(this.hundreds[this.integersToRead[0][0]]) {
139
+ wordArray.push(this.hundreds[this.integersToRead[0][0]]);
135
140
  }
136
- wordArray.push(this.CARDINAL_HUNDRED[0]);
141
+ wordArray.push(this.cardinalHundred[0]);
137
142
  return this.joinWords(wordArray);
138
143
  }
139
- if (this.order_of_last_zero_digit == 1) {
140
- if(this.HUNDREDS[this.integers_to_read[0][0]]) {
141
- wordArray.push(this.HUNDREDS[this.integers_to_read[0][0]]);
144
+ if (this.lastZeroDigitOrder == 1) {
145
+ if(this.hundreds[this.integersToRead[0][0]]) {
146
+ wordArray.push(this.hundreds[this.integersToRead[0][0]]);
142
147
  }
143
- wordArray.push(this.CARDINAL_HUNDRED[0]);
144
- if(this.CARDINAL_TENS[this.integers_to_read[0][1]]) {
145
- wordArray.push(this.CARDINAL_TENS[this.integers_to_read[0][1]]);
148
+ wordArray.push(this.cardinalHundred[0]);
149
+ if(this.cardinalTens[this.integersToRead[0][1]]) {
150
+ wordArray.push(this.cardinalTens[this.integersToRead[0][1]]);
146
151
  }
147
152
  return this.joinWords(wordArray);
148
153
  }
149
- if (this.order_of_last_zero_digit == 0) {
150
- if(this.HUNDREDS[this.integers_to_read[0][0]]) {
151
- wordArray.push(this.HUNDREDS[this.integers_to_read[0][0]]);
154
+ if (this.lastZeroDigitOrder == 0) {
155
+ if(this.hundreds[this.integersToRead[0][0]]) {
156
+ wordArray.push(this.hundreds[this.integersToRead[0][0]]);
152
157
  }
153
- wordArray.push(this.CARDINAL_HUNDRED[0]);
154
- if(this.CARDINAL_TENS[this.integers_to_read[0][1]]) {
155
- wordArray.push(this.CARDINAL_TENS[this.integers_to_read[0][1]]);
158
+ wordArray.push(this.cardinalHundred[0]);
159
+ if(this.cardinalTens[this.integersToRead[0][1]]) {
160
+ wordArray.push(this.cardinalTens[this.integersToRead[0][1]]);
156
161
  }
157
- if(this.CARDINAL_ONES[this.integers_to_read[0][2]]) {
158
- wordArray.push(this.CARDINAL_ONES[this.integers_to_read[0][2]]);
162
+ if(this.cardinalOnes[this.integersToRead[0][2]]) {
163
+ wordArray.push(this.cardinalOnes[this.integersToRead[0][2]]);
159
164
  }
160
165
  return this.joinWords(wordArray);
161
166
  }
162
167
  }
163
168
  }
164
- if (this.total_triplets_to_read >= 2) {
165
- if (this.total_digits_outside_triplets == 2) {
166
- if (this.order_of_last_zero_digit == this.integers_to_read[0].length - 1) {
167
- if(this.CARDINAL_TENS[this.integers_to_read[0][0]]) {
168
- wordArray.push(this.CARDINAL_TENS[this.integers_to_read[0][0]]);
169
+ if (this.totalTripletsToRead >= 2) {
170
+ if (this.totalDigitsOutsideTriplets == 2) {
171
+ if (this.lastZeroDigitOrder == this.integersToRead[0].length - 1) {
172
+ if(this.cardinalTens[this.integersToRead[0][0]]) {
173
+ wordArray.push(this.cardinalTens[this.integersToRead[0][0]]);
169
174
  }
170
- wordArray.push(this.CARDINAL_TRIPLETS[this.total_triplets_to_read - 1]);
175
+ wordArray.push(this.cardinalTriplets[this.totalTripletsToRead - 1]);
171
176
  return this.joinWords(wordArray);
172
177
  }
173
- if (this.order_of_last_zero_digit == this.integers_to_read[0].length - 2) {
174
- if(this.CARDINAL_TENS[this.integers_to_read[0][0]]) {
175
- wordArray.push(this.CARDINAL_TENS[this.integers_to_read[0][0]]);
178
+ if (this.lastZeroDigitOrder == this.integersToRead[0].length - 2) {
179
+ if(this.cardinalTens[this.integersToRead[0][0]]) {
180
+ wordArray.push(this.cardinalTens[this.integersToRead[0][0]]);
176
181
  }
177
- if(this.CARDINAL_ONES[this.integers_to_read[0][1]]) {
178
- wordArray.push(this.CARDINAL_ONES[this.integers_to_read[0][1]]);
182
+ if(this.cardinalOnes[this.integersToRead[0][1]]) {
183
+ wordArray.push(this.cardinalOnes[this.integersToRead[0][1]]);
179
184
  }
180
- wordArray.push(this.CARDINAL_TRIPLETS[this.total_triplets_to_read - 1]);
185
+ wordArray.push(this.cardinalTriplets[this.totalTripletsToRead - 1]);
181
186
  return this.joinWords(wordArray);
182
187
  }
183
- if (this.order_of_last_zero_digit < this.integers_to_read[0].length - 2) {
184
- if(this.CARDINAL_TENS[this.integers_to_read[0][0]]) {
185
- wordArray.push(this.CARDINAL_TENS[this.integers_to_read[0][0]]);
188
+ if (this.lastZeroDigitOrder < this.integersToRead[0].length - 2) {
189
+ if(this.cardinalTens[this.integersToRead[0][0]]) {
190
+ wordArray.push(this.cardinalTens[this.integersToRead[0][0]]);
186
191
  }
187
- if(this.CARDINAL_ONES[this.integers_to_read[0][1]]) {
188
- wordArray.push(this.CARDINAL_ONES[this.integers_to_read[0][1]]);
192
+ if(this.cardinalOnes[this.integersToRead[0][1]]) {
193
+ wordArray.push(this.cardinalOnes[this.integersToRead[0][1]]);
189
194
  }
190
- wordArray.push(this.CARDINAL_TRIPLETS[this.total_triplets_to_read - 1]);
195
+ wordArray.push(this.cardinalTriplets[this.totalTripletsToRead - 1]);
191
196
  }
192
197
  }
193
- if (this.total_digits_outside_triplets == 1) {
194
- if (this.order_of_last_zero_digit == this.integers_to_read[0].length - 1) {
195
- if (!(this.total_triplets_to_read == 2 && this.integers_to_read[0][0] == '1')) {
196
- if(this.CARDINAL_ONES[this.integers_to_read[0][0]]) {
197
- wordArray.push(this.CARDINAL_ONES[this.integers_to_read[0][0]]);
198
+ if (this.totalDigitsOutsideTriplets == 1) {
199
+ if (this.lastZeroDigitOrder == this.integersToRead[0].length - 1) {
200
+ if (!(this.totalTripletsToRead == 2 && this.integersToRead[0][0] == '1')) {
201
+ if(this.cardinalOnes[this.integersToRead[0][0]]) {
202
+ wordArray.push(this.cardinalOnes[this.integersToRead[0][0]]);
198
203
  }
199
204
  }
200
- wordArray.push(this.CARDINAL_TRIPLETS[this.total_triplets_to_read - 1]);
205
+ wordArray.push(this.cardinalTriplets[this.totalTripletsToRead - 1]);
201
206
  return this.joinWords(wordArray);
202
207
  }
203
- if (this.order_of_last_zero_digit < this.integers_to_read[0].length - 1) {
204
- if (!(this.total_triplets_to_read == 2 && this.integers_to_read[0][0] == '1')) {
205
- if(this.CARDINAL_ONES[this.integers_to_read[0][0]]) {
206
- wordArray.push(this.CARDINAL_ONES[this.integers_to_read[0][0]]);
208
+ if (this.lastZeroDigitOrder < this.integersToRead[0].length - 1) {
209
+ if (!(this.totalTripletsToRead == 2 && this.integersToRead[0][0] == '1')) {
210
+ if(this.cardinalOnes[this.integersToRead[0][0]]) {
211
+ wordArray.push(this.cardinalOnes[this.integersToRead[0][0]]);
207
212
  }
208
213
  }
209
- wordArray.push(this.CARDINAL_TRIPLETS[this.total_triplets_to_read - 1]);
214
+ wordArray.push(this.cardinalTriplets[this.totalTripletsToRead - 1]);
210
215
  }
211
216
  }
212
- if (this.total_digits_outside_triplets == 0) {
213
- if (this.order_of_last_zero_digit == this.integers_to_read[0].length - 1) {
214
- if(this.HUNDREDS[this.integers_to_read[0][0]]) {
215
- wordArray.push(this.HUNDREDS[this.integers_to_read[0][0]]);
217
+ if (this.totalDigitsOutsideTriplets == 0) {
218
+ if (this.lastZeroDigitOrder == this.integersToRead[0].length - 1) {
219
+ if(this.hundreds[this.integersToRead[0][0]]) {
220
+ wordArray.push(this.hundreds[this.integersToRead[0][0]]);
216
221
  }
217
- wordArray.push(this.CARDINAL_HUNDRED[0]);
218
- wordArray.push(this.CARDINAL_TRIPLETS[this.total_triplets_to_read - 1]);
222
+ wordArray.push(this.cardinalHundred[0]);
223
+ wordArray.push(this.cardinalTriplets[this.totalTripletsToRead - 1]);
219
224
  return this.joinWords(wordArray);
220
225
  }
221
- if (this.order_of_last_zero_digit == this.integers_to_read[0].length - 2) {
222
- if(this.HUNDREDS[this.integers_to_read[0][0]]) {
223
- wordArray.push(this.HUNDREDS[this.integers_to_read[0][0]]);
226
+ if (this.lastZeroDigitOrder == this.integersToRead[0].length - 2) {
227
+ if(this.hundreds[this.integersToRead[0][0]]) {
228
+ wordArray.push(this.hundreds[this.integersToRead[0][0]]);
224
229
  }
225
- wordArray.push(this.CARDINAL_HUNDRED[0]);
226
- if(this.CARDINAL_TENS[this.integers_to_read[0][1]]) {
227
- wordArray.push(this.CARDINAL_TENS[this.integers_to_read[0][1]]);
230
+ wordArray.push(this.cardinalHundred[0]);
231
+ if(this.cardinalTens[this.integersToRead[0][1]]) {
232
+ wordArray.push(this.cardinalTens[this.integersToRead[0][1]]);
228
233
  }
229
- wordArray.push(this.CARDINAL_TRIPLETS[this.total_triplets_to_read - 1]);
234
+ wordArray.push(this.cardinalTriplets[this.totalTripletsToRead - 1]);
230
235
  return this.joinWords(wordArray);
231
236
  }
232
- if (this.order_of_last_zero_digit == this.integers_to_read[0].length - 3) {
233
- if(this.HUNDREDS[this.integers_to_read[0][0]]) {
234
- wordArray.push(this.HUNDREDS[this.integers_to_read[0][0]]);
237
+ if (this.lastZeroDigitOrder == this.integersToRead[0].length - 3) {
238
+ if(this.hundreds[this.integersToRead[0][0]]) {
239
+ wordArray.push(this.hundreds[this.integersToRead[0][0]]);
235
240
  }
236
- wordArray.push(this.CARDINAL_HUNDRED[0]);
237
- if(this.CARDINAL_TENS[this.integers_to_read[0][1]]) {
238
- wordArray.push(this.CARDINAL_TENS[this.integers_to_read[0][1]]);
241
+ wordArray.push(this.cardinalHundred[0]);
242
+ if(this.cardinalTens[this.integersToRead[0][1]]) {
243
+ wordArray.push(this.cardinalTens[this.integersToRead[0][1]]);
239
244
  }
240
- if(this.CARDINAL_ONES[this.integers_to_read[0][2]]) {
241
- wordArray.push(this.CARDINAL_ONES[this.integers_to_read[0][2]]);
245
+ if(this.cardinalOnes[this.integersToRead[0][2]]) {
246
+ wordArray.push(this.cardinalOnes[this.integersToRead[0][2]]);
242
247
  }
243
- wordArray.push(this.CARDINAL_TRIPLETS[this.total_triplets_to_read - 1]);
248
+ wordArray.push(this.cardinalTriplets[this.totalTripletsToRead - 1]);
244
249
  return this.joinWords(wordArray);
245
250
  }
246
- if (this.order_of_last_zero_digit < this.integers_to_read[0].length - 3) {
247
- if(this.HUNDREDS[this.integers_to_read[0][0]]) {
248
- wordArray.push(this.HUNDREDS[this.integers_to_read[0][0]]);
251
+ if (this.lastZeroDigitOrder < this.integersToRead[0].length - 3) {
252
+ if(this.hundreds[this.integersToRead[0][0]]) {
253
+ wordArray.push(this.hundreds[this.integersToRead[0][0]]);
249
254
  }
250
- wordArray.push(this.CARDINAL_HUNDRED[0]);
251
- if(this.CARDINAL_TENS[this.integers_to_read[0][1]]) {
252
- wordArray.push(this.CARDINAL_TENS[this.integers_to_read[0][1]]);
255
+ wordArray.push(this.cardinalHundred[0]);
256
+ if(this.cardinalTens[this.integersToRead[0][1]]) {
257
+ wordArray.push(this.cardinalTens[this.integersToRead[0][1]]);
253
258
  }
254
- if (!(this.total_triplets_to_read == 2 && this.integers_to_read[0][2] == '1')) {
255
- if(this.CARDINAL_ONES[this.integers_to_read[0][2]]) {
256
- wordArray.push(this.CARDINAL_ONES[this.integers_to_read[0][2]]);
259
+ if (!(this.totalTripletsToRead == 2 && this.integersToRead[0][2] == '1')) {
260
+ if(this.cardinalOnes[this.integersToRead[0][2]]) {
261
+ wordArray.push(this.cardinalOnes[this.integersToRead[0][2]]);
257
262
  }
258
263
  }
259
- wordArray.push(this.CARDINAL_TRIPLETS[this.total_triplets_to_read - 1]);
264
+ wordArray.push(this.cardinalTriplets[this.totalTripletsToRead - 1]);
260
265
  }
261
266
  }
262
- for (let i = this.total_triplets_to_read - 1; i > 0; i--) {
263
- const reading_triplet_order = this.total_triplets_to_read - i;
264
- let last_read_digit_order;
265
- if (this.total_digits_outside_triplets == 0) {
266
- last_read_digit_order = reading_triplet_order * 3;
267
+ for (let i = this.totalTripletsToRead - 1; i > 0; i--) {
268
+ const readingTripletOrder = this.totalTripletsToRead - i;
269
+ let lastReadDigitOrder;
270
+ if (this.totalDigitsOutsideTriplets == 0) {
271
+ lastReadDigitOrder = readingTripletOrder * 3;
267
272
  } else {
268
- last_read_digit_order = (reading_triplet_order - 1) * 3 + this.total_digits_outside_triplets;
273
+ lastReadDigitOrder = (readingTripletOrder - 1) * 3 + this.totalDigitsOutsideTriplets;
269
274
  }
270
- if (this.integers_to_read[0].slice(last_read_digit_order, last_read_digit_order + 3) != '000') {
271
- if (this.integers_to_read[0][last_read_digit_order] != '0') {
272
- if(this.HUNDREDS[this.integers_to_read[0][last_read_digit_order]]) {
273
- wordArray.push(this.HUNDREDS[this.integers_to_read[0][last_read_digit_order]]);
275
+ if (this.integersToRead[0].slice(lastReadDigitOrder, lastReadDigitOrder + 3) != '000') {
276
+ if (this.integersToRead[0][lastReadDigitOrder] != '0') {
277
+ if(this.hundreds[this.integersToRead[0][lastReadDigitOrder]]) {
278
+ wordArray.push(this.hundreds[this.integersToRead[0][lastReadDigitOrder]]);
274
279
  }
275
- if (this.order_of_last_zero_digit == this.integers_to_read[0].length - last_read_digit_order - 1) {
280
+ if (this.lastZeroDigitOrder == this.integersToRead[0].length - lastReadDigitOrder - 1) {
276
281
  if (i == 1) {
277
- wordArray.push(this.CARDINAL_HUNDRED[0]);
282
+ wordArray.push(this.cardinalHundred[0]);
278
283
  return this.joinWords(wordArray);
279
284
  } else if (i > 1) {
280
- wordArray.push(this.CARDINAL_HUNDRED[0]);
281
- wordArray.push(this.CARDINAL_TRIPLETS[i - 1]);
285
+ wordArray.push(this.cardinalHundred[0]);
286
+ wordArray.push(this.cardinalTriplets[i - 1]);
282
287
  return this.joinWords(wordArray);
283
288
  }
284
289
  } else {
285
- wordArray.push(this.CARDINAL_HUNDRED[0]);
290
+ wordArray.push(this.cardinalHundred[0]);
286
291
  }
287
292
  }
288
- if (this.integers_to_read[0][last_read_digit_order + 1] != '0') {
289
- if (this.order_of_last_zero_digit == this.integers_to_read[0].length - last_read_digit_order - 2) {
293
+ if (this.integersToRead[0][lastReadDigitOrder + 1] != '0') {
294
+ if (this.lastZeroDigitOrder == this.integersToRead[0].length - lastReadDigitOrder - 2) {
290
295
  if (i == 1) {
291
- if(this.CARDINAL_TENS[this.integers_to_read[0][last_read_digit_order + 1]]) {
292
- wordArray.push(this.CARDINAL_TENS[this.integers_to_read[0][last_read_digit_order + 1]]);
296
+ if(this.cardinalTens[this.integersToRead[0][lastReadDigitOrder + 1]]) {
297
+ wordArray.push(this.cardinalTens[this.integersToRead[0][lastReadDigitOrder + 1]]);
293
298
  }
294
299
  return this.joinWords(wordArray);
295
300
  } else if (i > 1) {
296
- if(this.CARDINAL_TENS[this.integers_to_read[0][last_read_digit_order + 1]]) {
297
- wordArray.push(this.CARDINAL_TENS[this.integers_to_read[0][last_read_digit_order + 1]]);
301
+ if(this.cardinalTens[this.integersToRead[0][lastReadDigitOrder + 1]]) {
302
+ wordArray.push(this.cardinalTens[this.integersToRead[0][lastReadDigitOrder + 1]]);
298
303
  }
299
- wordArray.push(this.CARDINAL_TRIPLETS[i - 1]);
304
+ wordArray.push(this.cardinalTriplets[i - 1]);
300
305
  return this.joinWords(wordArray);
301
306
  }
302
307
  } else {
303
- if(this.CARDINAL_TENS[this.integers_to_read[0][last_read_digit_order + 1]]) {
304
- wordArray.push(this.CARDINAL_TENS[this.integers_to_read[0][last_read_digit_order + 1]]);
308
+ if(this.cardinalTens[this.integersToRead[0][lastReadDigitOrder + 1]]) {
309
+ wordArray.push(this.cardinalTens[this.integersToRead[0][lastReadDigitOrder + 1]]);
305
310
  }
306
311
  }
307
312
  }
308
- if (this.integers_to_read[0][last_read_digit_order + 2] != '0') {
309
- if (this.order_of_last_zero_digit == this.integers_to_read[0].length - last_read_digit_order - 3) {
313
+ if (this.integersToRead[0][lastReadDigitOrder + 2] != '0') {
314
+ if (this.lastZeroDigitOrder == this.integersToRead[0].length - lastReadDigitOrder - 3) {
310
315
  if (i == 1) {
311
- if(this.CARDINAL_ONES[this.integers_to_read[0][last_read_digit_order + 2]]) {
312
- wordArray.push(this.CARDINAL_ONES[this.integers_to_read[0][last_read_digit_order + 2]]);
316
+ if(this.cardinalOnes[this.integersToRead[0][lastReadDigitOrder + 2]]) {
317
+ wordArray.push(this.cardinalOnes[this.integersToRead[0][lastReadDigitOrder + 2]]);
313
318
  }
314
319
  return this.joinWords(wordArray);
315
320
  }
316
321
  if (i == 2) {
317
- if (this.integers_to_read[0].slice(last_read_digit_order, last_read_digit_order + 2) != '00') {
318
- if(this.CARDINAL_ONES[this.integers_to_read[0][last_read_digit_order + 2]]) {
319
- wordArray.push(this.CARDINAL_ONES[this.integers_to_read[0][last_read_digit_order + 2]]);
322
+ if (this.integersToRead[0].slice(lastReadDigitOrder, lastReadDigitOrder + 2) != '00') {
323
+ if(this.cardinalOnes[this.integersToRead[0][lastReadDigitOrder + 2]]) {
324
+ wordArray.push(this.cardinalOnes[this.integersToRead[0][lastReadDigitOrder + 2]]);
320
325
  }
321
- } else if (this.integers_to_read[0][last_read_digit_order + 2] != '1') {
322
- if(this.CARDINAL_ONES[this.integers_to_read[0][last_read_digit_order + 2]]) {
323
- wordArray.push(this.CARDINAL_ONES[this.integers_to_read[0][last_read_digit_order + 2]]);
326
+ } else if (this.integersToRead[0][lastReadDigitOrder + 2] != '1') {
327
+ if(this.cardinalOnes[this.integersToRead[0][lastReadDigitOrder + 2]]) {
328
+ wordArray.push(this.cardinalOnes[this.integersToRead[0][lastReadDigitOrder + 2]]);
324
329
  }
325
330
  }
326
- wordArray.push(this.CARDINAL_TRIPLETS[i - 1]);
331
+ wordArray.push(this.cardinalTriplets[i - 1]);
327
332
  return this.joinWords(wordArray);
328
333
  }
329
334
  if (i > 2) {
330
- if(this.CARDINAL_ONES[this.integers_to_read[0][last_read_digit_order + 2]]) {
331
- wordArray.push(this.CARDINAL_ONES[this.integers_to_read[0][last_read_digit_order + 2]]);
335
+ if(this.cardinalOnes[this.integersToRead[0][lastReadDigitOrder + 2]]) {
336
+ wordArray.push(this.cardinalOnes[this.integersToRead[0][lastReadDigitOrder + 2]]);
332
337
  }
333
- wordArray.push(this.CARDINAL_TRIPLETS[i - 1]);
338
+ wordArray.push(this.cardinalTriplets[i - 1]);
334
339
  return this.joinWords(wordArray);
335
340
  }
336
341
  } else {
337
- if (this.integers_to_read[0].slice(last_read_digit_order, last_read_digit_order + 2) != '00') {
338
- if(this.CARDINAL_ONES[this.integers_to_read[0][last_read_digit_order + 2]]) {
339
- wordArray.push(this.CARDINAL_ONES[this.integers_to_read[0][last_read_digit_order + 2]]);
342
+ if (this.integersToRead[0].slice(lastReadDigitOrder, lastReadDigitOrder + 2) != '00') {
343
+ if(this.cardinalOnes[this.integersToRead[0][lastReadDigitOrder + 2]]) {
344
+ wordArray.push(this.cardinalOnes[this.integersToRead[0][lastReadDigitOrder + 2]]);
340
345
  }
341
346
  } else {
342
347
  if (i == 2) {
343
- if (this.integers_to_read[0].slice(last_read_digit_order, last_read_digit_order + 2) != '00') {
344
- if(this.CARDINAL_ONES[this.integers_to_read[0][last_read_digit_order + 2]]) {
345
- wordArray.push(this.CARDINAL_ONES[this.integers_to_read[0][last_read_digit_order + 2]]);
348
+ if (this.integersToRead[0].slice(lastReadDigitOrder, lastReadDigitOrder + 2) != '00') {
349
+ if(this.cardinalOnes[this.integersToRead[0][lastReadDigitOrder + 2]]) {
350
+ wordArray.push(this.cardinalOnes[this.integersToRead[0][lastReadDigitOrder + 2]]);
346
351
  }
347
- } else if (this.integers_to_read[0][last_read_digit_order + 2] != '1') {
348
- if(this.CARDINAL_ONES[this.integers_to_read[0][last_read_digit_order + 2]]) {
349
- wordArray.push(this.CARDINAL_ONES[this.integers_to_read[0][last_read_digit_order + 2]]);
352
+ } else if (this.integersToRead[0][lastReadDigitOrder + 2] != '1') {
353
+ if(this.cardinalOnes[this.integersToRead[0][lastReadDigitOrder + 2]]) {
354
+ wordArray.push(this.cardinalOnes[this.integersToRead[0][lastReadDigitOrder + 2]]);
350
355
  }
351
356
  }
352
357
  }
@@ -354,10 +359,14 @@ export default function(options) {
354
359
  }
355
360
  }
356
361
 
357
- wordArray.push(this.CARDINAL_TRIPLETS[i - 1]);
362
+ wordArray.push(this.cardinalTriplets[i - 1]);
358
363
  }
359
364
  }
360
365
  }
361
366
  return this.joinWords(wordArray);
362
- };
367
+ }
368
+ }
369
+
370
+ export default function(n, options = {}) {
371
+ return new N2WordsTR(options).floatToCardinal(n);
363
372
  }