soff-money 0.2.1 → 0.2.3

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 (2) hide show
  1. package/README.md +32 -9
  2. package/package.json +10 -6
package/README.md CHANGED
@@ -41,35 +41,58 @@
41
41
  - [License](#license)
42
42
  - [Documentation](#documentation)
43
43
 
44
- ## Why?
44
+ ## 🤔 Why?
45
45
 
46
- In JavaScript, `0.1 + 0.2 === 0.30000000000000004`. This is fatal for e-commerce or financial applications. Additionally, formatting currencies in Latin America is painful - does the symbol go before or after? Dots or commas for thousands?
46
+ In JavaScript, `0.1 + 0.2 === 0.30000000000000004`. This is **fatal** for e-commerce or financial applications. 🚨
47
47
 
48
- This library handles money using integers (Safe Money pattern) and formats according to the country's locale.
48
+ Additionally, formatting currencies in Latin America is painful:
49
49
 
50
- ## Install
50
+ - Does the symbol go before or after? 🤔
51
+ - Dots or commas for thousands?
52
+ - How many decimals?
53
+
54
+ This library solves both problems:
55
+
56
+ | Problem | Solution |
57
+ | ---------------------------- | -------------------------------------------------- |
58
+ | 🐞 **Floating point errors** | Uses **Safe Money Pattern** (integer cents) |
59
+ | 🌎 **LATAM formatting** | Locale-aware formatting (COP, MXN, ARS, BRL, etc.) |
60
+ | 🧩 **Lost cents** | Fair distribution algorithm (no money lost!) |
61
+ | ⚔️ **Math operations** | Immutable Money objects with safe arithmetic |
62
+
63
+ ## 📦 Install
51
64
 
52
65
  ```bash
66
+ # npm
53
67
  npm install soff-money
68
+
69
+ # pnpm
70
+ pnpm add soff-money
71
+
72
+ # yarn
73
+ yarn add soff-money
74
+
75
+ # bun
76
+ bun add soff-money
54
77
  ```
55
78
 
56
- ## Quick Start
79
+ ## 🚀 Quick Start
57
80
 
58
81
  ```typescript
59
82
  import { Money, COP, USD } from 'soff-money';
60
83
 
61
- // Create money from decimal (safe - converted to cents internally)
84
+ // 💵 Create money from decimal (safe - converted to cents internally)
62
85
  const price = Money.fromDecimal(1500000, COP);
63
86
 
64
- // Arithmetic operations (all return new Money instances)
87
+ // 🧮 Arithmetic operations (all return new Money instances)
65
88
  const withTax = price.addPercentage(19); // Add 19% tax
66
89
  const discounted = withTax.subtractPercentage(10); // 10% discount
67
90
 
68
- // Format for display
91
+ // 🎨 Format for display
69
92
  console.log(price.format()); // "$ 1.500.000,00"
70
93
  console.log(discounted.format()); // "$ 1.606.500,00"
71
94
 
72
- // Safe comparisons
95
+ // ⚖️ Safe comparisons
73
96
  price.equals(Money.fromDecimal(1500000, COP)); // true
74
97
  price.greaterThan(discounted); // false
75
98
  ```
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "soff-money",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "Safe money handling for JavaScript with integer-based arithmetic and LATAM locale formatting",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -127,7 +127,7 @@
127
127
  "dev": "tsup --watch",
128
128
  "test": "vitest run",
129
129
  "test:watch": "vitest",
130
- "test:coverage": "vitest --coverage",
130
+ "test:coverage": "vitest run --coverage",
131
131
  "type-check": "tsc --noEmit",
132
132
  "lint": "eslint .",
133
133
  "lint:fix": "eslint . --fix",
@@ -162,14 +162,18 @@
162
162
  "devDependencies": {
163
163
  "@eslint/js": "^9.39.1",
164
164
  "@soff/tsconfig": "*",
165
- "@vitest/coverage-v8": "^4.0.14",
165
+ "@vitest/coverage-v8": "^4.0.15",
166
166
  "eslint": "^9.39.1",
167
167
  "eslint-config-prettier": "^10.1.8",
168
168
  "globals": "^16.5.0",
169
- "rimraf": "^6.0.1",
169
+ "rimraf": "^6.1.2",
170
170
  "tsup": "^8.5.1",
171
171
  "typescript": "^5.9.3",
172
- "typescript-eslint": "^8.48.0",
173
- "vitest": "^4.0.14"
172
+ "typescript-eslint": "^8.49.0",
173
+ "vitest": "^4.0.15"
174
+ },
175
+ "publishConfig": {
176
+ "access": "public",
177
+ "provenance": true
174
178
  }
175
179
  }