@jscrpt/common 6.0.0 → 6.1.0-beta.20240529033427

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.
Files changed (47) hide show
  1. package/numeral/package.json +8 -0
  2. package/numeral/src/formats/bps.js +34 -0
  3. package/numeral/src/formats/bytes.js +79 -0
  4. package/numeral/src/formats/currency.js +62 -0
  5. package/numeral/src/formats/exponential.js +34 -0
  6. package/numeral/src/formats/ordinal.js +21 -0
  7. package/numeral/src/formats/percentage.js +40 -0
  8. package/numeral/src/formats/time.js +35 -0
  9. package/numeral/src/index.js +89 -0
  10. package/numeral/src/locales/bg.js +28 -0
  11. package/numeral/src/locales/chs.js +20 -0
  12. package/numeral/src/locales/cs.js +20 -0
  13. package/numeral/src/locales/da-dk.js +20 -0
  14. package/numeral/src/locales/de-ch.js +20 -0
  15. package/numeral/src/locales/de.js +20 -0
  16. package/numeral/src/locales/en-au.js +24 -0
  17. package/numeral/src/locales/en-gb.js +24 -0
  18. package/numeral/src/locales/en-za.js +24 -0
  19. package/numeral/src/locales/es-es.js +25 -0
  20. package/numeral/src/locales/es.js +25 -0
  21. package/numeral/src/locales/et.js +20 -0
  22. package/numeral/src/locales/fi.js +20 -0
  23. package/numeral/src/locales/fr-ca.js +20 -0
  24. package/numeral/src/locales/fr-ch.js +20 -0
  25. package/numeral/src/locales/fr.js +20 -0
  26. package/numeral/src/locales/hu.js +20 -0
  27. package/numeral/src/locales/it.js +20 -0
  28. package/numeral/src/locales/ja.js +20 -0
  29. package/numeral/src/locales/lv.js +20 -0
  30. package/numeral/src/locales/nl-be.js +22 -0
  31. package/numeral/src/locales/nl-nl.js +21 -0
  32. package/numeral/src/locales/no.js +20 -0
  33. package/numeral/src/locales/pl.js +20 -0
  34. package/numeral/src/locales/pt-br.js +20 -0
  35. package/numeral/src/locales/pt-pt.js +20 -0
  36. package/numeral/src/locales/ru-ua.js +23 -0
  37. package/numeral/src/locales/ru.js +23 -0
  38. package/numeral/src/locales/sk.js +20 -0
  39. package/numeral/src/locales/sl.js +20 -0
  40. package/numeral/src/locales/th.js +20 -0
  41. package/numeral/src/locales/tr.js +54 -0
  42. package/numeral/src/locales/uk-ua.js +23 -0
  43. package/numeral/src/locales/vi.js +21 -0
  44. package/numeral/src/numeral.js +677 -0
  45. package/package.json +11 -2
  46. package/typings/numeral/index.d.ts +141 -0
  47. package/version.bak +1 -1
@@ -0,0 +1,8 @@
1
+ {
2
+ "name": "@jscrpt/common-numeral",
3
+ "sideEffects": false,
4
+ "main": "./index.js",
5
+ "module": "./index.js",
6
+ "browser": "./index.js",
7
+ "typings": "./src/index.d.ts"
8
+ }
@@ -0,0 +1,34 @@
1
+ export default function formatFactory(numeral) {
2
+ numeral.register('format', 'bps', {
3
+ regexps: {
4
+ format: /(BPS)/,
5
+ unformat: /(BPS)/
6
+ },
7
+ format: function(value, format, roundingFunction) {
8
+ var space = numeral._.includes(format, ' BPS') ? ' ' : '',
9
+ output;
10
+
11
+ value = value * 10000;
12
+
13
+ // check for space before BPS
14
+ format = format.replace(/\s?BPS/, '');
15
+
16
+ output = numeral._.numberToFormat(value, format, roundingFunction);
17
+
18
+ if (numeral._.includes(output, ')')) {
19
+ output = output.split('');
20
+
21
+ output.splice(-1, 0, space + 'BPS');
22
+
23
+ output = output.join('');
24
+ } else {
25
+ output = output + space + 'BPS';
26
+ }
27
+
28
+ return output;
29
+ },
30
+ unformat: function(string) {
31
+ return +(numeral._.stringToNumber(string) * 0.0001).toFixed(15);
32
+ }
33
+ });
34
+ };
@@ -0,0 +1,79 @@
1
+ export default function formatFactory(numeral) {
2
+ var decimal = {
3
+ base: 1000,
4
+ suffixes: ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']
5
+ },
6
+ binary = {
7
+ base: 1024,
8
+ suffixes: ['B', 'KiB', 'MiB', 'GiB', 'TiB', 'PiB', 'EiB', 'ZiB', 'YiB']
9
+ };
10
+
11
+ var allSuffixes = decimal.suffixes.concat(binary.suffixes.filter(function (item) {
12
+ return decimal.suffixes.indexOf(item) < 0;
13
+ }));
14
+ var unformatRegex = allSuffixes.join('|');
15
+ // Allow support for BPS (http://www.investopedia.com/terms/b/basispoint.asp)
16
+ unformatRegex = '(' + unformatRegex.replace('B', 'B(?!PS)') + ')';
17
+
18
+ numeral.register('format', 'bytes', {
19
+ regexps: {
20
+ format: /([0\s]i?b)/,
21
+ unformat: new RegExp(unformatRegex)
22
+ },
23
+ format: function(value, format, roundingFunction) {
24
+ var output,
25
+ bytes = numeral._.includes(format, 'ib') ? binary : decimal,
26
+ suffix = numeral._.includes(format, ' b') || numeral._.includes(format, ' ib') ? ' ' : '',
27
+ power,
28
+ min,
29
+ max;
30
+
31
+ // check for space before
32
+ format = format.replace(/\s?i?b/, '');
33
+
34
+ for (power = 0; power <= bytes.suffixes.length; power++) {
35
+ min = Math.pow(bytes.base, power);
36
+ max = Math.pow(bytes.base, power + 1);
37
+
38
+ if (value === null || value === 0 || value >= min && value < max) {
39
+ suffix += bytes.suffixes[power];
40
+
41
+ if (min > 0) {
42
+ value = value / min;
43
+ }
44
+
45
+ break;
46
+ }
47
+ }
48
+
49
+ output = numeral._.numberToFormat(value, format, roundingFunction);
50
+
51
+ return output + suffix;
52
+ },
53
+ unformat: function(string) {
54
+ var value = numeral._.stringToNumber(string),
55
+ power,
56
+ bytesMultiplier;
57
+
58
+ if (value) {
59
+ for (power = decimal.suffixes.length - 1; power >= 0; power--) {
60
+ if (numeral._.includes(string, decimal.suffixes[power])) {
61
+ bytesMultiplier = Math.pow(decimal.base, power);
62
+
63
+ break;
64
+ }
65
+
66
+ if (numeral._.includes(string, binary.suffixes[power])) {
67
+ bytesMultiplier = Math.pow(binary.base, power);
68
+
69
+ break;
70
+ }
71
+ }
72
+
73
+ value *= (bytesMultiplier || 1);
74
+ }
75
+
76
+ return value;
77
+ }
78
+ });
79
+ };
@@ -0,0 +1,62 @@
1
+ export default function formatFactory(numeral) {
2
+ numeral.register('format', 'currency', {
3
+ regexps: {
4
+ format: /(\$)/
5
+ },
6
+ format: function(value, format, roundingFunction) {
7
+ var locale = numeral.locales[numeral.options.currentLocale],
8
+ symbols = {
9
+ before: format.match(/^([\+|\-|\(|\s|\$]*)/)[0],
10
+ after: format.match(/([\+|\-|\)|\s|\$]*)$/)[0]
11
+ },
12
+ output,
13
+ symbol,
14
+ i;
15
+
16
+ // strip format of spaces and $
17
+ format = format.replace(/\s?\$\s?/, '');
18
+
19
+ // format the number
20
+ output = numeral._.numberToFormat(value, format, roundingFunction);
21
+
22
+ // update the before and after based on value
23
+ if (value >= 0) {
24
+ symbols.before = symbols.before.replace(/[\-\(]/, '');
25
+ symbols.after = symbols.after.replace(/[\-\)]/, '');
26
+ } else if (value < 0 && (!numeral._.includes(symbols.before, '-') && !numeral._.includes(symbols.before, '('))) {
27
+ symbols.before = '-' + symbols.before;
28
+ }
29
+
30
+ // loop through each before symbol
31
+ for (i = 0; i < symbols.before.length; i++) {
32
+ symbol = symbols.before[i];
33
+
34
+ switch (symbol) {
35
+ case '$':
36
+ output = numeral._.insert(output, locale.currency.symbol, i);
37
+ break;
38
+ case ' ':
39
+ output = numeral._.insert(output, ' ', i + locale.currency.symbol.length - 1);
40
+ break;
41
+ }
42
+ }
43
+
44
+ // loop through each after symbol
45
+ for (i = symbols.after.length - 1; i >= 0; i--) {
46
+ symbol = symbols.after[i];
47
+
48
+ switch (symbol) {
49
+ case '$':
50
+ output = i === symbols.after.length - 1 ? output + locale.currency.symbol : numeral._.insert(output, locale.currency.symbol, -(symbols.after.length - (1 + i)));
51
+ break;
52
+ case ' ':
53
+ output = i === symbols.after.length - 1 ? output + ' ' : numeral._.insert(output, ' ', -(symbols.after.length - (1 + i) + locale.currency.symbol.length - 1));
54
+ break;
55
+ }
56
+ }
57
+
58
+
59
+ return output;
60
+ }
61
+ });
62
+ };
@@ -0,0 +1,34 @@
1
+ export default function formatFactory(numeral) {
2
+ numeral.register('format', 'exponential', {
3
+ regexps: {
4
+ format: /(e\+|e-)/,
5
+ unformat: /(e\+|e-)/
6
+ },
7
+ format: function(value, format, roundingFunction) {
8
+ var output,
9
+ exponential = typeof value === 'number' && !numeral._.isNaN(value) ? value.toExponential() : '0e+0',
10
+ parts = exponential.split('e');
11
+
12
+ format = format.replace(/e[\+|\-]{1}0/, '');
13
+
14
+ output = numeral._.numberToFormat(Number(parts[0]), format, roundingFunction);
15
+
16
+ return output + 'e' + parts[1];
17
+ },
18
+ unformat: function(string) {
19
+ var parts = numeral._.includes(string, 'e+') ? string.split('e+') : string.split('e-'),
20
+ value = Number(parts[0]),
21
+ power = Number(parts[1]);
22
+
23
+ power = numeral._.includes(string, 'e-') ? power *= -1 : power;
24
+
25
+ function cback(accum, curr, currI, O) {
26
+ var corrFactor = numeral._.correctionFactor(accum, curr),
27
+ num = (accum * corrFactor) * (curr * corrFactor) / (corrFactor * corrFactor);
28
+ return num;
29
+ }
30
+
31
+ return numeral._.reduce([value, Math.pow(10, power)], cback, 1);
32
+ }
33
+ });
34
+ };
@@ -0,0 +1,21 @@
1
+ export default function formatFactory(numeral) {
2
+ numeral.register('format', 'ordinal', {
3
+ regexps: {
4
+ format: /(o)/
5
+ },
6
+ format: function(value, format, roundingFunction) {
7
+ var locale = numeral.locales[numeral.options.currentLocale],
8
+ output,
9
+ ordinal = numeral._.includes(format, ' o') ? ' ' : '';
10
+
11
+ // check for space before
12
+ format = format.replace(/\s?o/, '');
13
+
14
+ ordinal += locale.ordinal(value);
15
+
16
+ output = numeral._.numberToFormat(value, format, roundingFunction);
17
+
18
+ return output + ordinal;
19
+ }
20
+ });
21
+ };
@@ -0,0 +1,40 @@
1
+ export default function formatFactory(numeral) {
2
+ numeral.register('format', 'percentage', {
3
+ regexps: {
4
+ format: /(%)/,
5
+ unformat: /(%)/
6
+ },
7
+ format: function(value, format, roundingFunction) {
8
+ var space = numeral._.includes(format, ' %') ? ' ' : '',
9
+ output;
10
+
11
+ if (numeral.options.scalePercentBy100) {
12
+ value = value * 100;
13
+ }
14
+
15
+ // check for space before %
16
+ format = format.replace(/\s?\%/, '');
17
+
18
+ output = numeral._.numberToFormat(value, format, roundingFunction);
19
+
20
+ if (numeral._.includes(output, ')')) {
21
+ output = output.split('');
22
+
23
+ output.splice(-1, 0, space + '%');
24
+
25
+ output = output.join('');
26
+ } else {
27
+ output = output + space + '%';
28
+ }
29
+
30
+ return output;
31
+ },
32
+ unformat: function(string) {
33
+ var number = numeral._.stringToNumber(string);
34
+ if (numeral.options.scalePercentBy100) {
35
+ return number * 0.01;
36
+ }
37
+ return number;
38
+ }
39
+ });
40
+ };
@@ -0,0 +1,35 @@
1
+ export default function formatFactory(numeral) {
2
+ numeral.register('format', 'time', {
3
+ regexps: {
4
+ format: /(:)/,
5
+ unformat: /(:)/
6
+ },
7
+ format: function(value, format, roundingFunction) {
8
+ var hours = Math.floor(value / 60 / 60),
9
+ minutes = Math.floor((value - (hours * 60 * 60)) / 60),
10
+ seconds = Math.round(value - (hours * 60 * 60) - (minutes * 60));
11
+
12
+ return hours + ':' + (minutes < 10 ? '0' + minutes : minutes) + ':' + (seconds < 10 ? '0' + seconds : seconds);
13
+ },
14
+ unformat: function(string) {
15
+ var timeArray = string.split(':'),
16
+ seconds = 0;
17
+
18
+ // turn hours and minutes into seconds and add them all up
19
+ if (timeArray.length === 3) {
20
+ // hours
21
+ seconds = seconds + (Number(timeArray[0]) * 60 * 60);
22
+ // minutes
23
+ seconds = seconds + (Number(timeArray[1]) * 60);
24
+ // seconds
25
+ seconds = seconds + Number(timeArray[2]);
26
+ } else if (timeArray.length === 2) {
27
+ // minutes
28
+ seconds = seconds + (Number(timeArray[0]) * 60);
29
+ // seconds
30
+ seconds = seconds + Number(timeArray[1]);
31
+ }
32
+ return Number(seconds);
33
+ }
34
+ });
35
+ };
@@ -0,0 +1,89 @@
1
+ export * from './numeral.js';
2
+ import numeral from './numeral.js';
3
+
4
+ import bpsFormatFactory from './formats/bps.js';
5
+ import bytesFormatFactory from './formats/bytes.js';
6
+ import currencyFormatFactory from './formats/currency.js';
7
+ import exponentialFormatFactory from './formats/exponential.js';
8
+ import ordinalFormatFactory from './formats/ordinal.js';
9
+ import percentageFormatFactory from './formats/percentage.js';
10
+ import timeFormatFactory from './formats/time.js';
11
+
12
+ import bgLocaleFactory from './locales/bg.js';
13
+ import csLocaleFactory from './locales/cs.js';
14
+ import daDkLocaleFactory from './locales/da-dk.js';
15
+ import deLocaleFactory from './locales/de.js';
16
+ import deChLocaleFactory from './locales/de-ch.js';
17
+ import enAuLocaleFactory from './locales/en-au.js';
18
+ import enGbLocaleFactory from './locales/en-gb.js';
19
+ import enZaLocaleFactory from './locales/en-za.js';
20
+ import esLocaleFactory from './locales/es.js';
21
+ import esEsLocaleFactory from './locales/es-es.js';
22
+ import etLocaleFactory from './locales/et.js';
23
+ import fiLocaleFactory from './locales/fi.js';
24
+ import frLocaleFactory from './locales/fr.js';
25
+ import frCaLocaleFactory from './locales/fr-ca.js';
26
+ import frChLocaleFactory from './locales/fr-ch.js';
27
+ import huLocaleFactory from './locales/hu.js';
28
+ import chsLocaleFactory from './locales/chs.js';
29
+ import itLocaleFactory from './locales/it.js';
30
+ import jaLocaleFactory from './locales/ja.js';
31
+ import lvLocaleFactory from './locales/lv.js';
32
+ import nlBeLocaleFactory from './locales/nl-be.js';
33
+ import nlNlLocaleFactory from './locales/nl-nl.js';
34
+ import noLocaleFactory from './locales/no.js';
35
+ import plLocaleFactory from './locales/pl.js';
36
+ import ptBrLocaleFactory from './locales/pt-br.js';
37
+ import ptPtLocaleFactory from './locales/pt-pt.js';
38
+ import ruLocaleFactory from './locales/ru.js';
39
+ import ruUaLocaleFactory from './locales/ru-ua.js';
40
+ import skLocaleFactory from './locales/sk.js';
41
+ import slLocaleFactory from './locales/sl.js';
42
+ import thLocaleFactory from './locales/th.js';
43
+ import trLocaleFactory from './locales/tr.js';
44
+ import ukUaLocaleFactory from './locales/uk-ua.js';
45
+ import viLocaleFactory from './locales/vi.js';
46
+
47
+
48
+ bpsFormatFactory(numeral);
49
+ bytesFormatFactory(numeral);
50
+ currencyFormatFactory(numeral);
51
+ exponentialFormatFactory(numeral);
52
+ ordinalFormatFactory(numeral);
53
+ percentageFormatFactory(numeral);
54
+ timeFormatFactory(numeral);
55
+
56
+ bgLocaleFactory(numeral);
57
+ csLocaleFactory(numeral);
58
+ daDkLocaleFactory(numeral);
59
+ deLocaleFactory(numeral);
60
+ deChLocaleFactory(numeral);
61
+ enAuLocaleFactory(numeral);
62
+ enGbLocaleFactory(numeral);
63
+ enZaLocaleFactory(numeral);
64
+ esLocaleFactory(numeral);
65
+ esEsLocaleFactory(numeral);
66
+ etLocaleFactory(numeral);
67
+ fiLocaleFactory(numeral);
68
+ frLocaleFactory(numeral);
69
+ frCaLocaleFactory(numeral);
70
+ frChLocaleFactory(numeral);
71
+ huLocaleFactory(numeral);
72
+ chsLocaleFactory(numeral);
73
+ itLocaleFactory(numeral);
74
+ jaLocaleFactory(numeral);
75
+ lvLocaleFactory(numeral);
76
+ nlBeLocaleFactory(numeral);
77
+ nlNlLocaleFactory(numeral);
78
+ noLocaleFactory(numeral);
79
+ plLocaleFactory(numeral);
80
+ ptBrLocaleFactory(numeral);
81
+ ptPtLocaleFactory(numeral);
82
+ ruLocaleFactory(numeral);
83
+ ruUaLocaleFactory(numeral);
84
+ skLocaleFactory(numeral);
85
+ slLocaleFactory(numeral);
86
+ thLocaleFactory(numeral);
87
+ trLocaleFactory(numeral);
88
+ ukUaLocaleFactory(numeral);
89
+ viLocaleFactory(numeral);
@@ -0,0 +1,28 @@
1
+ export default function localeFactory(numeral) {
2
+ numeral.register('locale', 'bg', {
3
+ delimiters: {
4
+ thousands: ' ',
5
+ decimal: ','
6
+ },
7
+ abbreviations: { // I found these here http://www.unicode.org/cldr/charts/28/verify/numbers/bg.html
8
+ thousand: 'хил',
9
+ million: 'млн',
10
+ billion: 'млрд',
11
+ trillion: 'трлн'
12
+ },
13
+ ordinal: function (number) {
14
+ // google translate suggests:
15
+ // 1st=1-ви; 2nd=2-ри; 7th=7-ми;
16
+ // 8th=8-ми and many others end with -ти
17
+ // for example 3rd=3-ти
18
+ // However since I've seen suggestions that in
19
+ // Bulgarian the ordinal can be taken in
20
+ // different forms (masculine, feminine, neuter)
21
+ // I've opted to wimp out on commiting that to code
22
+ return '';
23
+ },
24
+ currency: {
25
+ symbol: 'лв'
26
+ }
27
+ });
28
+ };
@@ -0,0 +1,20 @@
1
+ export default function localeFactory(numeral) {
2
+ numeral.register('locale', 'chs', {
3
+ delimiters: {
4
+ thousands: ',',
5
+ decimal: '.'
6
+ },
7
+ abbreviations: {
8
+ thousand: '千',
9
+ million: '百万',
10
+ billion: '十亿',
11
+ trillion: '兆'
12
+ },
13
+ ordinal: function (number) {
14
+ return '.';
15
+ },
16
+ currency: {
17
+ symbol: '¥'
18
+ }
19
+ });
20
+ };
@@ -0,0 +1,20 @@
1
+ export default function localeFactory(numeral) {
2
+ numeral.register('locale', 'cs', {
3
+ delimiters: {
4
+ thousands: ' ',
5
+ decimal: ','
6
+ },
7
+ abbreviations: {
8
+ thousand: 'tis.',
9
+ million: 'mil.',
10
+ billion: 'b',
11
+ trillion: 't'
12
+ },
13
+ ordinal: function () {
14
+ return '.';
15
+ },
16
+ currency: {
17
+ symbol: 'Kč'
18
+ }
19
+ });
20
+ };
@@ -0,0 +1,20 @@
1
+ export default function localeFactory(numeral) {
2
+ numeral.register('locale', 'da-dk', {
3
+ delimiters: {
4
+ thousands: '.',
5
+ decimal: ','
6
+ },
7
+ abbreviations: {
8
+ thousand: 'k',
9
+ million: 'mio',
10
+ billion: 'mia',
11
+ trillion: 'b'
12
+ },
13
+ ordinal: function (number) {
14
+ return '.';
15
+ },
16
+ currency: {
17
+ symbol: 'DKK'
18
+ }
19
+ });
20
+ };
@@ -0,0 +1,20 @@
1
+ export default function localeFactory(numeral) {
2
+ numeral.register('locale', 'de-ch', {
3
+ delimiters: {
4
+ thousands: ' ',
5
+ decimal: ','
6
+ },
7
+ abbreviations: {
8
+ thousand: 'k',
9
+ million: 'm',
10
+ billion: 'b',
11
+ trillion: 't'
12
+ },
13
+ ordinal: function (number) {
14
+ return '.';
15
+ },
16
+ currency: {
17
+ symbol: 'CHF'
18
+ }
19
+ });
20
+ };
@@ -0,0 +1,20 @@
1
+ export default function localeFactory(numeral) {
2
+ numeral.register('locale', 'de', {
3
+ delimiters: {
4
+ thousands: ' ',
5
+ decimal: ','
6
+ },
7
+ abbreviations: {
8
+ thousand: 'k',
9
+ million: 'm',
10
+ billion: 'b',
11
+ trillion: 't'
12
+ },
13
+ ordinal: function (number) {
14
+ return '.';
15
+ },
16
+ currency: {
17
+ symbol: '€'
18
+ }
19
+ });
20
+ };
@@ -0,0 +1,24 @@
1
+ export default function localeFactory(numeral) {
2
+ numeral.register('locale', 'en-au', {
3
+ delimiters: {
4
+ thousands: ',',
5
+ decimal: '.'
6
+ },
7
+ abbreviations: {
8
+ thousand: 'k',
9
+ million: 'm',
10
+ billion: 'b',
11
+ trillion: 't'
12
+ },
13
+ ordinal: function (number) {
14
+ var b = number % 10;
15
+ return (~~ (number % 100 / 10) === 1) ? 'th' :
16
+ (b === 1) ? 'st' :
17
+ (b === 2) ? 'nd' :
18
+ (b === 3) ? 'rd' : 'th';
19
+ },
20
+ currency: {
21
+ symbol: '$'
22
+ }
23
+ });
24
+ };
@@ -0,0 +1,24 @@
1
+ export default function localeFactory(numeral) {
2
+ numeral.register('locale', 'en-gb', {
3
+ delimiters: {
4
+ thousands: ',',
5
+ decimal: '.'
6
+ },
7
+ abbreviations: {
8
+ thousand: 'k',
9
+ million: 'm',
10
+ billion: 'b',
11
+ trillion: 't'
12
+ },
13
+ ordinal: function (number) {
14
+ var b = number % 10;
15
+ return (~~ (number % 100 / 10) === 1) ? 'th' :
16
+ (b === 1) ? 'st' :
17
+ (b === 2) ? 'nd' :
18
+ (b === 3) ? 'rd' : 'th';
19
+ },
20
+ currency: {
21
+ symbol: '£'
22
+ }
23
+ });
24
+ };
@@ -0,0 +1,24 @@
1
+ export default function localeFactory(numeral) {
2
+ numeral.register('locale', 'en-za', {
3
+ delimiters: {
4
+ thousands: ' ',
5
+ decimal: ','
6
+ },
7
+ abbreviations: {
8
+ thousand: 'k',
9
+ million: 'm',
10
+ billion: 'b',
11
+ trillion: 't'
12
+ },
13
+ ordinal: function (number) {
14
+ var b = number % 10;
15
+ return (~~ (number % 100 / 10) === 1) ? 'th' :
16
+ (b === 1) ? 'st' :
17
+ (b === 2) ? 'nd' :
18
+ (b === 3) ? 'rd' : 'th';
19
+ },
20
+ currency: {
21
+ symbol: 'R'
22
+ }
23
+ });
24
+ };
@@ -0,0 +1,25 @@
1
+ export default function localeFactory(numeral) {
2
+ numeral.register('locale', 'es-es', {
3
+ delimiters: {
4
+ thousands: '.',
5
+ decimal: ','
6
+ },
7
+ abbreviations: {
8
+ thousand: 'k',
9
+ million: 'mm',
10
+ billion: 'b',
11
+ trillion: 't'
12
+ },
13
+ ordinal: function (number) {
14
+ var b = number % 10;
15
+ return (b === 1 || b === 3) ? 'er' :
16
+ (b === 2) ? 'do' :
17
+ (b === 7 || b === 0) ? 'mo' :
18
+ (b === 8) ? 'vo' :
19
+ (b === 9) ? 'no' : 'to';
20
+ },
21
+ currency: {
22
+ symbol: '€'
23
+ }
24
+ });
25
+ };
@@ -0,0 +1,25 @@
1
+ export default function localeFactory(numeral) {
2
+ numeral.register('locale', 'es', {
3
+ delimiters: {
4
+ thousands: '.',
5
+ decimal: ','
6
+ },
7
+ abbreviations: {
8
+ thousand: 'k',
9
+ million: 'mm',
10
+ billion: 'b',
11
+ trillion: 't'
12
+ },
13
+ ordinal: function (number) {
14
+ var b = number % 10;
15
+ return (b === 1 || b === 3) ? 'er' :
16
+ (b === 2) ? 'do' :
17
+ (b === 7 || b === 0) ? 'mo' :
18
+ (b === 8) ? 'vo' :
19
+ (b === 9) ? 'no' : 'to';
20
+ },
21
+ currency: {
22
+ symbol: '$'
23
+ }
24
+ });
25
+ };