|
Last change
on this file since e4c61dd was e4c61dd, checked in by istevanoska <ilinastevanoska@…>, 6 months ago |
|
Prototype 1.1
|
-
Property mode
set to
100644
|
|
File size:
475 bytes
|
| Rev | Line | |
|---|
| [e4c61dd] | 1 | export default function(grouping, thousands) {
|
|---|
| 2 | return function(value, width) {
|
|---|
| 3 | var i = value.length,
|
|---|
| 4 | t = [],
|
|---|
| 5 | j = 0,
|
|---|
| 6 | g = grouping[0],
|
|---|
| 7 | length = 0;
|
|---|
| 8 |
|
|---|
| 9 | while (i > 0 && g > 0) {
|
|---|
| 10 | if (length + g + 1 > width) g = Math.max(1, width - length);
|
|---|
| 11 | t.push(value.substring(i -= g, i + g));
|
|---|
| 12 | if ((length += g + 1) > width) break;
|
|---|
| 13 | g = grouping[j = (j + 1) % grouping.length];
|
|---|
| 14 | }
|
|---|
| 15 |
|
|---|
| 16 | return t.reverse().join(thousands);
|
|---|
| 17 | };
|
|---|
| 18 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.