@storepass/money 0.1.2 → 0.1.5
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/LICENSE +1 -1
- package/README.md +7 -24
- package/dist/index.cjs +18 -8
- package/package.json +4 -4
- /package/dist/{index.js → index.mjs} +0 -0
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -9,41 +9,24 @@ Safe, consistent, deterministic money operations.
|
|
|
9
9
|
|
|
10
10
|
## Install
|
|
11
11
|
|
|
12
|
-
Package name: `@atlas-alpha/sp-money`
|
|
13
|
-
|
|
14
|
-
### Current publish target
|
|
15
|
-
|
|
16
|
-
This package is currently configured for GitHub Packages.
|
|
17
|
-
|
|
18
12
|
```bash
|
|
19
13
|
# npm
|
|
20
|
-
npm install @
|
|
14
|
+
npm install @storepass/money
|
|
21
15
|
|
|
22
16
|
# pnpm
|
|
23
|
-
pnpm add @
|
|
17
|
+
pnpm add @storepass/money
|
|
24
18
|
|
|
25
19
|
# yarn
|
|
26
|
-
yarn add @
|
|
20
|
+
yarn add @storepass/money
|
|
27
21
|
|
|
28
22
|
# bun
|
|
29
|
-
bun add @
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
If your org requires explicit registry config:
|
|
33
|
-
|
|
34
|
-
```ini
|
|
35
|
-
# .npmrc
|
|
36
|
-
@atlas-alpha:registry=https://npm.pkg.github.com
|
|
23
|
+
bun add @storepass/money
|
|
37
24
|
```
|
|
38
25
|
|
|
39
|
-
### Open-source transition
|
|
40
|
-
|
|
41
|
-
The project is being prepared for a public open-source release.
|
|
42
|
-
|
|
43
26
|
## Quick Start
|
|
44
27
|
|
|
45
28
|
```ts
|
|
46
|
-
import { Currency, Money } from "@
|
|
29
|
+
import { Currency, Money } from "@storepass/money";
|
|
47
30
|
|
|
48
31
|
const price = Money.fromMinor(Currency.USD, 1234); // $12.34
|
|
49
32
|
const fee = Money.fromNumber(Currency.USD, 1.25);
|
|
@@ -59,7 +42,7 @@ console.log(total.currency.code); // "USD"
|
|
|
59
42
|
### Money creation
|
|
60
43
|
|
|
61
44
|
```ts
|
|
62
|
-
import { Currency, Money } from "@
|
|
45
|
+
import { Currency, Money } from "@storepass/money";
|
|
63
46
|
|
|
64
47
|
Money.fromMinor(Currency.USD, 1234); // $12.34
|
|
65
48
|
Money.fromNumber(Currency.USD, 12.345, { rounding: "round" }); // $12.35
|
|
@@ -112,7 +95,7 @@ subtotal.decrementByPercent(10).toNumber(); // 90
|
|
|
112
95
|
### Custom currencies
|
|
113
96
|
|
|
114
97
|
```ts
|
|
115
|
-
import { defineCurrency, Money } from "@
|
|
98
|
+
import { defineCurrency, Money } from "@storepass/money";
|
|
116
99
|
|
|
117
100
|
const XAU = defineCurrency("XAU", 4);
|
|
118
101
|
const gold = Money.fromNumber(XAU, 1.2345);
|
package/dist/index.cjs
CHANGED
|
@@ -2,27 +2,37 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
-
|
|
5
|
+
function __accessProp(key) {
|
|
6
|
+
return this[key];
|
|
7
|
+
}
|
|
6
8
|
var __toCommonJS = (from) => {
|
|
7
|
-
var entry = __moduleCache.get(from), desc;
|
|
9
|
+
var entry = (__moduleCache ??= new WeakMap).get(from), desc;
|
|
8
10
|
if (entry)
|
|
9
11
|
return entry;
|
|
10
12
|
entry = __defProp({}, "__esModule", { value: true });
|
|
11
|
-
if (from && typeof from === "object" || typeof from === "function")
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
14
|
+
for (var key of __getOwnPropNames(from))
|
|
15
|
+
if (!__hasOwnProp.call(entry, key))
|
|
16
|
+
__defProp(entry, key, {
|
|
17
|
+
get: __accessProp.bind(from, key),
|
|
18
|
+
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
19
|
+
});
|
|
20
|
+
}
|
|
16
21
|
__moduleCache.set(from, entry);
|
|
17
22
|
return entry;
|
|
18
23
|
};
|
|
24
|
+
var __moduleCache;
|
|
25
|
+
var __returnValue = (v) => v;
|
|
26
|
+
function __exportSetter(name, newValue) {
|
|
27
|
+
this[name] = __returnValue.bind(null, newValue);
|
|
28
|
+
}
|
|
19
29
|
var __export = (target, all) => {
|
|
20
30
|
for (var name in all)
|
|
21
31
|
__defProp(target, name, {
|
|
22
32
|
get: all[name],
|
|
23
33
|
enumerable: true,
|
|
24
34
|
configurable: true,
|
|
25
|
-
set: (
|
|
35
|
+
set: __exportSetter.bind(all, name)
|
|
26
36
|
});
|
|
27
37
|
};
|
|
28
38
|
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@storepass/money",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"description": "Money primitive library",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
|
-
"module": "./dist/index.
|
|
6
|
+
"module": "./dist/index.mjs",
|
|
7
7
|
"types": "./dist/index.d.ts",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
10
|
"import": {
|
|
11
11
|
"types": "./dist/index.d.ts",
|
|
12
|
-
"default": "./dist/index.
|
|
12
|
+
"default": "./dist/index.mjs"
|
|
13
13
|
},
|
|
14
14
|
"require": {
|
|
15
15
|
"types": "./dist/index.d.ts",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
],
|
|
23
23
|
"scripts": {
|
|
24
24
|
"build": "bun run build:esm && bun run build:cjs && bun run build:types",
|
|
25
|
-
"build:esm": "bun build ./src/index.ts --outfile ./dist/index.
|
|
25
|
+
"build:esm": "bun build ./src/index.ts --outfile ./dist/index.mjs --format esm --target node",
|
|
26
26
|
"build:cjs": "bun build ./src/index.ts --outfile ./dist/index.cjs --format cjs --target node",
|
|
27
27
|
"build:types": "tsc -p tsconfig.build.json",
|
|
28
28
|
"test": "bun test",
|
|
File without changes
|