soff-money 0.1.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.
Files changed (44) hide show
  1. package/README.md +75 -0
  2. package/dist/core/index.cjs +244 -0
  3. package/dist/core/index.cjs.map +1 -0
  4. package/dist/core/index.d.cts +181 -0
  5. package/dist/core/index.d.ts +181 -0
  6. package/dist/core/index.js +242 -0
  7. package/dist/core/index.js.map +1 -0
  8. package/dist/index.cjs +309 -0
  9. package/dist/index.cjs.map +1 -0
  10. package/dist/index.d.cts +6 -0
  11. package/dist/index.d.ts +6 -0
  12. package/dist/index.js +301 -0
  13. package/dist/index.js.map +1 -0
  14. package/dist/locales/ar.cjs +16 -0
  15. package/dist/locales/ar.cjs.map +1 -0
  16. package/dist/locales/ar.d.cts +9 -0
  17. package/dist/locales/ar.d.ts +9 -0
  18. package/dist/locales/ar.js +14 -0
  19. package/dist/locales/ar.js.map +1 -0
  20. package/dist/locales/br.cjs +16 -0
  21. package/dist/locales/br.cjs.map +1 -0
  22. package/dist/locales/br.d.cts +9 -0
  23. package/dist/locales/br.d.ts +9 -0
  24. package/dist/locales/br.js +14 -0
  25. package/dist/locales/br.js.map +1 -0
  26. package/dist/locales/co.cjs +21 -0
  27. package/dist/locales/co.cjs.map +1 -0
  28. package/dist/locales/co.d.cts +14 -0
  29. package/dist/locales/co.d.ts +14 -0
  30. package/dist/locales/co.js +18 -0
  31. package/dist/locales/co.js.map +1 -0
  32. package/dist/locales/mx.cjs +16 -0
  33. package/dist/locales/mx.cjs.map +1 -0
  34. package/dist/locales/mx.d.cts +9 -0
  35. package/dist/locales/mx.d.ts +9 -0
  36. package/dist/locales/mx.js +14 -0
  37. package/dist/locales/mx.js.map +1 -0
  38. package/dist/locales/us.cjs +16 -0
  39. package/dist/locales/us.cjs.map +1 -0
  40. package/dist/locales/us.d.cts +9 -0
  41. package/dist/locales/us.d.ts +9 -0
  42. package/dist/locales/us.js +14 -0
  43. package/dist/locales/us.js.map +1 -0
  44. package/package.json +135 -0
package/dist/index.cjs ADDED
@@ -0,0 +1,309 @@
1
+ 'use strict';
2
+
3
+ // src/core/money.ts
4
+ var Money = class _Money {
5
+ constructor(cents, currency) {
6
+ if (!Number.isInteger(cents)) {
7
+ throw new Error("Money must be created with an integer number of cents");
8
+ }
9
+ this.cents = cents;
10
+ this.currency = currency;
11
+ Object.freeze(this);
12
+ }
13
+ /**
14
+ * Create money from cents (smallest unit)
15
+ */
16
+ static fromCents(cents, currency) {
17
+ return new _Money(Math.round(cents), currency);
18
+ }
19
+ /**
20
+ * Create money from a decimal amount
21
+ * @example Money.fromDecimal(100.50, USD) creates $100.50
22
+ */
23
+ static fromDecimal(amount, currency) {
24
+ const multiplier = Math.pow(10, currency.decimals);
25
+ const cents = Math.round(amount * multiplier);
26
+ return new _Money(cents, currency);
27
+ }
28
+ /**
29
+ * Create zero money
30
+ */
31
+ static zero(currency) {
32
+ return new _Money(0, currency);
33
+ }
34
+ /**
35
+ * Add another money value (must be same currency)
36
+ */
37
+ add(other) {
38
+ this.assertSameCurrency(other);
39
+ return new _Money(this.cents + other.cents, this.currency);
40
+ }
41
+ /**
42
+ * Subtract another money value (must be same currency)
43
+ */
44
+ subtract(other) {
45
+ this.assertSameCurrency(other);
46
+ return new _Money(this.cents - other.cents, this.currency);
47
+ }
48
+ /**
49
+ * Multiply by a factor (rounds to nearest cent)
50
+ */
51
+ multiply(factor) {
52
+ return new _Money(Math.round(this.cents * factor), this.currency);
53
+ }
54
+ /**
55
+ * Divide by a divisor (rounds to nearest cent)
56
+ */
57
+ divide(divisor) {
58
+ if (divisor === 0) {
59
+ throw new Error("Cannot divide by zero");
60
+ }
61
+ return new _Money(Math.round(this.cents / divisor), this.currency);
62
+ }
63
+ /**
64
+ * Distribute money evenly without losing cents
65
+ * The remainder is distributed to the first parts
66
+ * @example $100 / 3 = [$33.34, $33.33, $33.33]
67
+ */
68
+ distribute(parts) {
69
+ if (parts <= 0 || !Number.isInteger(parts)) {
70
+ throw new Error("Parts must be a positive integer");
71
+ }
72
+ const quotient = Math.floor(this.cents / parts);
73
+ const remainder = this.cents % parts;
74
+ const result = [];
75
+ for (let i = 0; i < parts; i++) {
76
+ const extra = i < remainder ? 1 : 0;
77
+ result.push(new _Money(quotient + extra, this.currency));
78
+ }
79
+ return result;
80
+ }
81
+ /**
82
+ * Distribute money according to ratios
83
+ * @example $100 with ratios [1, 2, 2] = [$20, $40, $40]
84
+ */
85
+ distributeByRatios(ratios) {
86
+ if (ratios.length === 0) {
87
+ throw new Error("Ratios array cannot be empty");
88
+ }
89
+ const total = ratios.reduce((sum, r) => sum + r, 0);
90
+ if (total <= 0) {
91
+ throw new Error("Sum of ratios must be positive");
92
+ }
93
+ let remaining = this.cents;
94
+ const result = [];
95
+ for (let i = 0; i < ratios.length; i++) {
96
+ if (i === ratios.length - 1) {
97
+ result.push(new _Money(remaining, this.currency));
98
+ } else {
99
+ const share = Math.round(this.cents * ratios[i] / total);
100
+ result.push(new _Money(share, this.currency));
101
+ remaining -= share;
102
+ }
103
+ }
104
+ return result;
105
+ }
106
+ /**
107
+ * Format money for display
108
+ */
109
+ format(options = {}) {
110
+ const { showSymbol = true, showDecimals = true, symbolPosition } = options;
111
+ const decimal = this.toDecimal();
112
+ const absValue = Math.abs(decimal);
113
+ const isNegative = decimal < 0;
114
+ let formatted;
115
+ if (showDecimals && this.currency.decimals > 0) {
116
+ const [intPart, decPart] = absValue.toFixed(this.currency.decimals).split(".");
117
+ const intFormatted = this.formatInteger(intPart);
118
+ formatted = `${intFormatted}${this.currency.decimalSeparator}${decPart}`;
119
+ } else {
120
+ formatted = this.formatInteger(Math.round(absValue).toString());
121
+ }
122
+ if (isNegative) {
123
+ formatted = `-${formatted}`;
124
+ }
125
+ if (showSymbol) {
126
+ const pos = symbolPosition ?? this.currency.symbolPosition;
127
+ const space = this.currency.symbolSpacing ? " " : "";
128
+ if (pos === "before") {
129
+ formatted = `${this.currency.symbol}${space}${formatted}`;
130
+ } else {
131
+ formatted = `${formatted}${space}${this.currency.symbol}`;
132
+ }
133
+ }
134
+ return formatted;
135
+ }
136
+ /**
137
+ * Get the decimal representation
138
+ */
139
+ toDecimal() {
140
+ return this.cents / Math.pow(10, this.currency.decimals);
141
+ }
142
+ /**
143
+ * Check equality with another money value
144
+ */
145
+ equals(other) {
146
+ return this.cents === other.cents && this.currency.code === other.currency.code;
147
+ }
148
+ /**
149
+ * Check if greater than another money value
150
+ */
151
+ greaterThan(other) {
152
+ this.assertSameCurrency(other);
153
+ return this.cents > other.cents;
154
+ }
155
+ /**
156
+ * Check if less than another money value
157
+ */
158
+ lessThan(other) {
159
+ this.assertSameCurrency(other);
160
+ return this.cents < other.cents;
161
+ }
162
+ /**
163
+ * Check if greater than or equal
164
+ */
165
+ greaterThanOrEqual(other) {
166
+ this.assertSameCurrency(other);
167
+ return this.cents >= other.cents;
168
+ }
169
+ /**
170
+ * Check if less than or equal
171
+ */
172
+ lessThanOrEqual(other) {
173
+ this.assertSameCurrency(other);
174
+ return this.cents <= other.cents;
175
+ }
176
+ /**
177
+ * Check if zero
178
+ */
179
+ isZero() {
180
+ return this.cents === 0;
181
+ }
182
+ /**
183
+ * Check if positive
184
+ */
185
+ isPositive() {
186
+ return this.cents > 0;
187
+ }
188
+ /**
189
+ * Check if negative
190
+ */
191
+ isNegative() {
192
+ return this.cents < 0;
193
+ }
194
+ /**
195
+ * Get absolute value
196
+ */
197
+ abs() {
198
+ return new _Money(Math.abs(this.cents), this.currency);
199
+ }
200
+ /**
201
+ * Negate the value
202
+ */
203
+ negate() {
204
+ return new _Money(-this.cents, this.currency);
205
+ }
206
+ /**
207
+ * Convert to JSON-serializable object
208
+ */
209
+ toJSON() {
210
+ return {
211
+ cents: this.cents,
212
+ currency: this.currency.code
213
+ };
214
+ }
215
+ /**
216
+ * String representation
217
+ */
218
+ toString() {
219
+ return this.format();
220
+ }
221
+ formatInteger(intStr) {
222
+ const parts = [];
223
+ let remaining = intStr;
224
+ while (remaining.length > 3) {
225
+ parts.unshift(remaining.slice(-3));
226
+ remaining = remaining.slice(0, -3);
227
+ }
228
+ if (remaining) {
229
+ parts.unshift(remaining);
230
+ }
231
+ return parts.join(this.currency.thousandsSeparator);
232
+ }
233
+ assertSameCurrency(other) {
234
+ if (this.currency.code !== other.currency.code) {
235
+ throw new Error(
236
+ `Cannot perform operation with different currencies: ${this.currency.code} and ${other.currency.code}`
237
+ );
238
+ }
239
+ }
240
+ };
241
+
242
+ // src/locales/co.ts
243
+ var COP = {
244
+ code: "COP",
245
+ symbol: "$",
246
+ decimals: 2,
247
+ thousandsSeparator: ".",
248
+ decimalSeparator: ",",
249
+ symbolPosition: "before",
250
+ symbolSpacing: true
251
+ };
252
+ var COP_NO_DECIMALS = {
253
+ ...COP,
254
+ decimals: 0
255
+ };
256
+
257
+ // src/locales/mx.ts
258
+ var MXN = {
259
+ code: "MXN",
260
+ symbol: "$",
261
+ decimals: 2,
262
+ thousandsSeparator: ",",
263
+ decimalSeparator: ".",
264
+ symbolPosition: "before",
265
+ symbolSpacing: false
266
+ };
267
+
268
+ // src/locales/ar.ts
269
+ var ARS = {
270
+ code: "ARS",
271
+ symbol: "$",
272
+ decimals: 2,
273
+ thousandsSeparator: ".",
274
+ decimalSeparator: ",",
275
+ symbolPosition: "before",
276
+ symbolSpacing: true
277
+ };
278
+
279
+ // src/locales/br.ts
280
+ var BRL = {
281
+ code: "BRL",
282
+ symbol: "R$",
283
+ decimals: 2,
284
+ thousandsSeparator: ".",
285
+ decimalSeparator: ",",
286
+ symbolPosition: "before",
287
+ symbolSpacing: true
288
+ };
289
+
290
+ // src/locales/us.ts
291
+ var USD = {
292
+ code: "USD",
293
+ symbol: "$",
294
+ decimals: 2,
295
+ thousandsSeparator: ",",
296
+ decimalSeparator: ".",
297
+ symbolPosition: "before",
298
+ symbolSpacing: false
299
+ };
300
+
301
+ exports.ARS = ARS;
302
+ exports.BRL = BRL;
303
+ exports.COP = COP;
304
+ exports.COP_NO_DECIMALS = COP_NO_DECIMALS;
305
+ exports.MXN = MXN;
306
+ exports.Money = Money;
307
+ exports.USD = USD;
308
+ //# sourceMappingURL=index.cjs.map
309
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/core/money.ts","../src/locales/co.ts","../src/locales/mx.ts","../src/locales/ar.ts","../src/locales/br.ts","../src/locales/us.ts"],"names":[],"mappings":";;;AAKO,IAAM,KAAA,GAAN,MAAM,MAAA,CAAwB;AAAA,EAI3B,WAAA,CAAY,OAAe,QAAA,EAAoB;AACrD,IAAA,IAAI,CAAC,MAAA,CAAO,SAAA,CAAU,KAAK,CAAA,EAAG;AAC5B,MAAA,MAAM,IAAI,MAAM,uDAAuD,CAAA;AAAA,IACzE;AACA,IAAA,IAAA,CAAK,KAAA,GAAQ,KAAA;AACb,IAAA,IAAA,CAAK,QAAA,GAAW,QAAA;AAChB,IAAA,MAAA,CAAO,OAAO,IAAI,CAAA;AAAA,EACpB;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,SAAA,CAAU,KAAA,EAAe,QAAA,EAA2B;AACzD,IAAA,OAAO,IAAI,MAAA,CAAM,IAAA,CAAK,KAAA,CAAM,KAAK,GAAG,QAAQ,CAAA;AAAA,EAC9C;AAAA;AAAA;AAAA;AAAA;AAAA,EAMA,OAAO,WAAA,CAAY,MAAA,EAAgB,QAAA,EAA2B;AAC5D,IAAA,MAAM,UAAA,GAAa,IAAA,CAAK,GAAA,CAAI,EAAA,EAAI,SAAS,QAAQ,CAAA;AACjD,IAAA,MAAM,KAAA,GAAQ,IAAA,CAAK,KAAA,CAAM,MAAA,GAAS,UAAU,CAAA;AAC5C,IAAA,OAAO,IAAI,MAAA,CAAM,KAAA,EAAO,QAAQ,CAAA;AAAA,EAClC;AAAA;AAAA;AAAA;AAAA,EAKA,OAAO,KAAK,QAAA,EAA2B;AACrC,IAAA,OAAO,IAAI,MAAA,CAAM,CAAA,EAAG,QAAQ,CAAA;AAAA,EAC9B;AAAA;AAAA;A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A;AAAA,EAChB,aAAA,EAAe;AACjB;;;ACRO,IAAM,GAAA,GAAgB;AAAA,EAC3B,IAAA,EAAM,KAAA;AAAA,EACN,MAAA,EAAQ,IAAA;AAAA,EACR,QAAA,EAAU,CAAA;AAAA,EACV,kBAAA,EAAoB,GAAA;AAAA,EACpB,gBAAA,EAAkB,GAAA;AAAA,EAClB,cAAA,EAAgB,QAAA;AAAA,EAChB,aAAA,EAAe;AACjB;;;ACRO,IAAM,GAAA,GAAgB;AAAA,EAC3B,IAAA,EAAM,KAAA;AAAA,EACN,MAAA,EAAQ,GAAA;AAAA,EACR,QAAA,EAAU,CAAA;AAAA,EACV,kBAAA,EAAoB,GAAA;AAAA,EACpB,gBAAA,EAAkB,GAAA;AAAA,EAClB,cAAA,EAAgB,QAAA;AAAA,EAChB,aAAA,EAAe;AACjB","file":"index.cjs","sourcesContent":["import type { Currency, FormatOptions, IMoney } from './types.js';\n\n/**\n * Immutable Money class that uses integer arithmetic for precision\n */\nexport class Money implements IMoney {\n readonly cents: number;\n readonly currency: Currency;\n\n private constructor(cents: number, currency: Currency) {\n if (!Number.isInteger(cents)) {\n throw new Error('Money must be created with an integer number of cents');\n }\n this.cents = cents;\n this.currency = currency;\n Object.freeze(this);\n }\n\n /**\n * Create money from cents (smallest unit)\n */\n static fromCents(cents: number, currency: Currency): Money {\n return new Money(Math.round(cents), currency);\n }\n\n /**\n * Create money from a decimal amount\n * @example Money.fromDecimal(100.50, USD) creates $100.50\n */\n static fromDecimal(amount: number, currency: Currency): Money {\n const multiplier = Math.pow(10, currency.decimals);\n const cents = Math.round(amount * multiplier);\n return new Money(cents, currency);\n }\n\n /**\n * Create zero money\n */\n static zero(currency: Currency): Money {\n return new Money(0, currency);\n }\n\n /**\n * Add another money value (must be same currency)\n */\n add(other: IMoney): Money {\n this.assertSameCurrency(other);\n return new Money(this.cents + other.cents, this.currency);\n }\n\n /**\n * Subtract another money value (must be same currency)\n */\n subtract(other: IMoney): Money {\n this.assertSameCurrency(other);\n return new Money(this.cents - other.cents, this.currency);\n }\n\n /**\n * Multiply by a factor (rounds to nearest cent)\n */\n multiply(factor: number): Money {\n return new Money(Math.round(this.cents * factor), this.currency);\n }\n\n /**\n * Divide by a divisor (rounds to nearest cent)\n */\n divide(divisor: number): Money {\n if (divisor === 0) {\n throw new Error('Cannot divide by zero');\n }\n return new Money(Math.round(this.cents / divisor), this.currency);\n }\n\n /**\n * Distribute money evenly without losing cents\n * The remainder is distributed to the first parts\n * @example $100 / 3 = [$33.34, $33.33, $33.33]\n */\n distribute(parts: number): Money[] {\n if (parts <= 0 || !Number.isInteger(parts)) {\n throw new Error('Parts must be a positive integer');\n }\n\n const quotient = Math.floor(this.cents / parts);\n const remainder = this.cents % parts;\n\n const result: Money[] = [];\n for (let i = 0; i < parts; i++) {\n // Add 1 cent to the first 'remainder' parts\n const extra = i < remainder ? 1 : 0;\n result.push(new Money(quotient + extra, this.currency));\n }\n\n return result;\n }\n\n /**\n * Distribute money according to ratios\n * @example $100 with ratios [1, 2, 2] = [$20, $40, $40]\n */\n distributeByRatios(ratios: number[]): Money[] {\n if (ratios.length === 0) {\n throw new Error('Ratios array cannot be empty');\n }\n\n const total = ratios.reduce((sum, r) => sum + r, 0);\n if (total <= 0) {\n throw new Error('Sum of ratios must be positive');\n }\n\n let remaining = this.cents;\n const result: Money[] = [];\n\n for (let i = 0; i < ratios.length; i++) {\n if (i === ratios.length - 1) {\n // Last part gets whatever is remaining to avoid rounding errors\n result.push(new Money(remaining, this.currency));\n } else {\n const share = Math.round((this.cents * ratios[i]) / total);\n result.push(new Money(share, this.currency));\n remaining -= share;\n }\n }\n\n return result;\n }\n\n /**\n * Format money for display\n */\n format(options: FormatOptions = {}): string {\n const { showSymbol = true, showDecimals = true, symbolPosition } = options;\n\n const decimal = this.toDecimal();\n const absValue = Math.abs(decimal);\n const isNegative = decimal < 0;\n\n // Format the number\n let formatted: string;\n if (showDecimals && this.currency.decimals > 0) {\n const [intPart, decPart] = absValue.toFixed(this.currency.decimals).split('.');\n const intFormatted = this.formatInteger(intPart);\n formatted = `${intFormatted}${this.currency.decimalSeparator}${decPart}`;\n } else {\n formatted = this.formatInteger(Math.round(absValue).toString());\n }\n\n // Add negative sign\n if (isNegative) {\n formatted = `-${formatted}`;\n }\n\n // Add symbol\n if (showSymbol) {\n const pos = symbolPosition ?? this.currency.symbolPosition;\n const space = this.currency.symbolSpacing ? ' ' : '';\n\n if (pos === 'before') {\n formatted = `${this.currency.symbol}${space}${formatted}`;\n } else {\n formatted = `${formatted}${space}${this.currency.symbol}`;\n }\n }\n\n return formatted;\n }\n\n /**\n * Get the decimal representation\n */\n toDecimal(): number {\n return this.cents / Math.pow(10, this.currency.decimals);\n }\n\n /**\n * Check equality with another money value\n */\n equals(other: IMoney): boolean {\n return this.cents === other.cents && this.currency.code === other.currency.code;\n }\n\n /**\n * Check if greater than another money value\n */\n greaterThan(other: IMoney): boolean {\n this.assertSameCurrency(other);\n return this.cents > other.cents;\n }\n\n /**\n * Check if less than another money value\n */\n lessThan(other: IMoney): boolean {\n this.assertSameCurrency(other);\n return this.cents < other.cents;\n }\n\n /**\n * Check if greater than or equal\n */\n greaterThanOrEqual(other: IMoney): boolean {\n this.assertSameCurrency(other);\n return this.cents >= other.cents;\n }\n\n /**\n * Check if less than or equal\n */\n lessThanOrEqual(other: IMoney): boolean {\n this.assertSameCurrency(other);\n return this.cents <= other.cents;\n }\n\n /**\n * Check if zero\n */\n isZero(): boolean {\n return this.cents === 0;\n }\n\n /**\n * Check if positive\n */\n isPositive(): boolean {\n return this.cents > 0;\n }\n\n /**\n * Check if negative\n */\n isNegative(): boolean {\n return this.cents < 0;\n }\n\n /**\n * Get absolute value\n */\n abs(): Money {\n return new Money(Math.abs(this.cents), this.currency);\n }\n\n /**\n * Negate the value\n */\n negate(): Money {\n return new Money(-this.cents, this.currency);\n }\n\n /**\n * Convert to JSON-serializable object\n */\n toJSON(): { cents: number; currency: string } {\n return {\n cents: this.cents,\n currency: this.currency.code,\n };\n }\n\n /**\n * String representation\n */\n toString(): string {\n return this.format();\n }\n\n private formatInteger(intStr: string): string {\n const parts: string[] = [];\n let remaining = intStr;\n\n while (remaining.length > 3) {\n parts.unshift(remaining.slice(-3));\n remaining = remaining.slice(0, -3);\n }\n\n if (remaining) {\n parts.unshift(remaining);\n }\n\n return parts.join(this.currency.thousandsSeparator);\n }\n\n private assertSameCurrency(other: IMoney): void {\n if (this.currency.code !== other.currency.code) {\n throw new Error(\n `Cannot perform operation with different currencies: ${this.currency.code} and ${other.currency.code}`\n );\n }\n }\n}\n","import type { Currency } from '../core/types.js';\n\n/**\n * Colombian Peso (COP)\n * Format: $ 1.000,00\n */\nexport const COP: Currency = {\n code: 'COP',\n symbol: '$',\n decimals: 2,\n thousandsSeparator: '.',\n decimalSeparator: ',',\n symbolPosition: 'before',\n symbolSpacing: true,\n};\n\n/**\n * Colombian Peso without decimals (common usage)\n * Format: $ 1.000\n */\nexport const COP_NO_DECIMALS: Currency = {\n ...COP,\n decimals: 0,\n};\n","import type { Currency } from '../core/types.js';\n\n/**\n * Mexican Peso (MXN)\n * Format: $1,000.00\n */\nexport const MXN: Currency = {\n code: 'MXN',\n symbol: '$',\n decimals: 2,\n thousandsSeparator: ',',\n decimalSeparator: '.',\n symbolPosition: 'before',\n symbolSpacing: false,\n};\n","import type { Currency } from '../core/types.js';\n\n/**\n * Argentine Peso (ARS)\n * Format: $ 1.000,00\n */\nexport const ARS: Currency = {\n code: 'ARS',\n symbol: '$',\n decimals: 2,\n thousandsSeparator: '.',\n decimalSeparator: ',',\n symbolPosition: 'before',\n symbolSpacing: true,\n};\n","import type { Currency } from '../core/types.js';\n\n/**\n * Brazilian Real (BRL)\n * Format: R$ 1.000,00\n */\nexport const BRL: Currency = {\n code: 'BRL',\n symbol: 'R$',\n decimals: 2,\n thousandsSeparator: '.',\n decimalSeparator: ',',\n symbolPosition: 'before',\n symbolSpacing: true,\n};\n","import type { Currency } from '../core/types.js';\n\n/**\n * US Dollar (USD)\n * Format: $1,000.00\n */\nexport const USD: Currency = {\n code: 'USD',\n symbol: '$',\n decimals: 2,\n thousandsSeparator: ',',\n decimalSeparator: '.',\n symbolPosition: 'before',\n symbolSpacing: false,\n};\n"]}
@@ -0,0 +1,6 @@
1
+ export { Currency, DistributionResult, FormatOptions, IMoney, Money } from './core/index.cjs';
2
+ export { COP, COP_NO_DECIMALS } from './locales/co.cjs';
3
+ export { MXN } from './locales/mx.cjs';
4
+ export { ARS } from './locales/ar.cjs';
5
+ export { BRL } from './locales/br.cjs';
6
+ export { USD } from './locales/us.cjs';
@@ -0,0 +1,6 @@
1
+ export { Currency, DistributionResult, FormatOptions, IMoney, Money } from './core/index.js';
2
+ export { COP, COP_NO_DECIMALS } from './locales/co.js';
3
+ export { MXN } from './locales/mx.js';
4
+ export { ARS } from './locales/ar.js';
5
+ export { BRL } from './locales/br.js';
6
+ export { USD } from './locales/us.js';
package/dist/index.js ADDED
@@ -0,0 +1,301 @@
1
+ // src/core/money.ts
2
+ var Money = class _Money {
3
+ constructor(cents, currency) {
4
+ if (!Number.isInteger(cents)) {
5
+ throw new Error("Money must be created with an integer number of cents");
6
+ }
7
+ this.cents = cents;
8
+ this.currency = currency;
9
+ Object.freeze(this);
10
+ }
11
+ /**
12
+ * Create money from cents (smallest unit)
13
+ */
14
+ static fromCents(cents, currency) {
15
+ return new _Money(Math.round(cents), currency);
16
+ }
17
+ /**
18
+ * Create money from a decimal amount
19
+ * @example Money.fromDecimal(100.50, USD) creates $100.50
20
+ */
21
+ static fromDecimal(amount, currency) {
22
+ const multiplier = Math.pow(10, currency.decimals);
23
+ const cents = Math.round(amount * multiplier);
24
+ return new _Money(cents, currency);
25
+ }
26
+ /**
27
+ * Create zero money
28
+ */
29
+ static zero(currency) {
30
+ return new _Money(0, currency);
31
+ }
32
+ /**
33
+ * Add another money value (must be same currency)
34
+ */
35
+ add(other) {
36
+ this.assertSameCurrency(other);
37
+ return new _Money(this.cents + other.cents, this.currency);
38
+ }
39
+ /**
40
+ * Subtract another money value (must be same currency)
41
+ */
42
+ subtract(other) {
43
+ this.assertSameCurrency(other);
44
+ return new _Money(this.cents - other.cents, this.currency);
45
+ }
46
+ /**
47
+ * Multiply by a factor (rounds to nearest cent)
48
+ */
49
+ multiply(factor) {
50
+ return new _Money(Math.round(this.cents * factor), this.currency);
51
+ }
52
+ /**
53
+ * Divide by a divisor (rounds to nearest cent)
54
+ */
55
+ divide(divisor) {
56
+ if (divisor === 0) {
57
+ throw new Error("Cannot divide by zero");
58
+ }
59
+ return new _Money(Math.round(this.cents / divisor), this.currency);
60
+ }
61
+ /**
62
+ * Distribute money evenly without losing cents
63
+ * The remainder is distributed to the first parts
64
+ * @example $100 / 3 = [$33.34, $33.33, $33.33]
65
+ */
66
+ distribute(parts) {
67
+ if (parts <= 0 || !Number.isInteger(parts)) {
68
+ throw new Error("Parts must be a positive integer");
69
+ }
70
+ const quotient = Math.floor(this.cents / parts);
71
+ const remainder = this.cents % parts;
72
+ const result = [];
73
+ for (let i = 0; i < parts; i++) {
74
+ const extra = i < remainder ? 1 : 0;
75
+ result.push(new _Money(quotient + extra, this.currency));
76
+ }
77
+ return result;
78
+ }
79
+ /**
80
+ * Distribute money according to ratios
81
+ * @example $100 with ratios [1, 2, 2] = [$20, $40, $40]
82
+ */
83
+ distributeByRatios(ratios) {
84
+ if (ratios.length === 0) {
85
+ throw new Error("Ratios array cannot be empty");
86
+ }
87
+ const total = ratios.reduce((sum, r) => sum + r, 0);
88
+ if (total <= 0) {
89
+ throw new Error("Sum of ratios must be positive");
90
+ }
91
+ let remaining = this.cents;
92
+ const result = [];
93
+ for (let i = 0; i < ratios.length; i++) {
94
+ if (i === ratios.length - 1) {
95
+ result.push(new _Money(remaining, this.currency));
96
+ } else {
97
+ const share = Math.round(this.cents * ratios[i] / total);
98
+ result.push(new _Money(share, this.currency));
99
+ remaining -= share;
100
+ }
101
+ }
102
+ return result;
103
+ }
104
+ /**
105
+ * Format money for display
106
+ */
107
+ format(options = {}) {
108
+ const { showSymbol = true, showDecimals = true, symbolPosition } = options;
109
+ const decimal = this.toDecimal();
110
+ const absValue = Math.abs(decimal);
111
+ const isNegative = decimal < 0;
112
+ let formatted;
113
+ if (showDecimals && this.currency.decimals > 0) {
114
+ const [intPart, decPart] = absValue.toFixed(this.currency.decimals).split(".");
115
+ const intFormatted = this.formatInteger(intPart);
116
+ formatted = `${intFormatted}${this.currency.decimalSeparator}${decPart}`;
117
+ } else {
118
+ formatted = this.formatInteger(Math.round(absValue).toString());
119
+ }
120
+ if (isNegative) {
121
+ formatted = `-${formatted}`;
122
+ }
123
+ if (showSymbol) {
124
+ const pos = symbolPosition ?? this.currency.symbolPosition;
125
+ const space = this.currency.symbolSpacing ? " " : "";
126
+ if (pos === "before") {
127
+ formatted = `${this.currency.symbol}${space}${formatted}`;
128
+ } else {
129
+ formatted = `${formatted}${space}${this.currency.symbol}`;
130
+ }
131
+ }
132
+ return formatted;
133
+ }
134
+ /**
135
+ * Get the decimal representation
136
+ */
137
+ toDecimal() {
138
+ return this.cents / Math.pow(10, this.currency.decimals);
139
+ }
140
+ /**
141
+ * Check equality with another money value
142
+ */
143
+ equals(other) {
144
+ return this.cents === other.cents && this.currency.code === other.currency.code;
145
+ }
146
+ /**
147
+ * Check if greater than another money value
148
+ */
149
+ greaterThan(other) {
150
+ this.assertSameCurrency(other);
151
+ return this.cents > other.cents;
152
+ }
153
+ /**
154
+ * Check if less than another money value
155
+ */
156
+ lessThan(other) {
157
+ this.assertSameCurrency(other);
158
+ return this.cents < other.cents;
159
+ }
160
+ /**
161
+ * Check if greater than or equal
162
+ */
163
+ greaterThanOrEqual(other) {
164
+ this.assertSameCurrency(other);
165
+ return this.cents >= other.cents;
166
+ }
167
+ /**
168
+ * Check if less than or equal
169
+ */
170
+ lessThanOrEqual(other) {
171
+ this.assertSameCurrency(other);
172
+ return this.cents <= other.cents;
173
+ }
174
+ /**
175
+ * Check if zero
176
+ */
177
+ isZero() {
178
+ return this.cents === 0;
179
+ }
180
+ /**
181
+ * Check if positive
182
+ */
183
+ isPositive() {
184
+ return this.cents > 0;
185
+ }
186
+ /**
187
+ * Check if negative
188
+ */
189
+ isNegative() {
190
+ return this.cents < 0;
191
+ }
192
+ /**
193
+ * Get absolute value
194
+ */
195
+ abs() {
196
+ return new _Money(Math.abs(this.cents), this.currency);
197
+ }
198
+ /**
199
+ * Negate the value
200
+ */
201
+ negate() {
202
+ return new _Money(-this.cents, this.currency);
203
+ }
204
+ /**
205
+ * Convert to JSON-serializable object
206
+ */
207
+ toJSON() {
208
+ return {
209
+ cents: this.cents,
210
+ currency: this.currency.code
211
+ };
212
+ }
213
+ /**
214
+ * String representation
215
+ */
216
+ toString() {
217
+ return this.format();
218
+ }
219
+ formatInteger(intStr) {
220
+ const parts = [];
221
+ let remaining = intStr;
222
+ while (remaining.length > 3) {
223
+ parts.unshift(remaining.slice(-3));
224
+ remaining = remaining.slice(0, -3);
225
+ }
226
+ if (remaining) {
227
+ parts.unshift(remaining);
228
+ }
229
+ return parts.join(this.currency.thousandsSeparator);
230
+ }
231
+ assertSameCurrency(other) {
232
+ if (this.currency.code !== other.currency.code) {
233
+ throw new Error(
234
+ `Cannot perform operation with different currencies: ${this.currency.code} and ${other.currency.code}`
235
+ );
236
+ }
237
+ }
238
+ };
239
+
240
+ // src/locales/co.ts
241
+ var COP = {
242
+ code: "COP",
243
+ symbol: "$",
244
+ decimals: 2,
245
+ thousandsSeparator: ".",
246
+ decimalSeparator: ",",
247
+ symbolPosition: "before",
248
+ symbolSpacing: true
249
+ };
250
+ var COP_NO_DECIMALS = {
251
+ ...COP,
252
+ decimals: 0
253
+ };
254
+
255
+ // src/locales/mx.ts
256
+ var MXN = {
257
+ code: "MXN",
258
+ symbol: "$",
259
+ decimals: 2,
260
+ thousandsSeparator: ",",
261
+ decimalSeparator: ".",
262
+ symbolPosition: "before",
263
+ symbolSpacing: false
264
+ };
265
+
266
+ // src/locales/ar.ts
267
+ var ARS = {
268
+ code: "ARS",
269
+ symbol: "$",
270
+ decimals: 2,
271
+ thousandsSeparator: ".",
272
+ decimalSeparator: ",",
273
+ symbolPosition: "before",
274
+ symbolSpacing: true
275
+ };
276
+
277
+ // src/locales/br.ts
278
+ var BRL = {
279
+ code: "BRL",
280
+ symbol: "R$",
281
+ decimals: 2,
282
+ thousandsSeparator: ".",
283
+ decimalSeparator: ",",
284
+ symbolPosition: "before",
285
+ symbolSpacing: true
286
+ };
287
+
288
+ // src/locales/us.ts
289
+ var USD = {
290
+ code: "USD",
291
+ symbol: "$",
292
+ decimals: 2,
293
+ thousandsSeparator: ",",
294
+ decimalSeparator: ".",
295
+ symbolPosition: "before",
296
+ symbolSpacing: false
297
+ };
298
+
299
+ export { ARS, BRL, COP, COP_NO_DECIMALS, MXN, Money, USD };
300
+ //# sourceMappingURL=index.js.map
301
+ //# sourceMappingURL=index.js.map