@xylabs/decimal-precision 5.0.95 → 5.0.96
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/README.md +73 -73
- package/package.json +6 -9
package/README.md
CHANGED
|
@@ -1,56 +1,76 @@
|
|
|
1
1
|
# @xylabs/decimal-precision
|
|
2
2
|
|
|
3
|
-
[![
|
|
3
|
+
[![npm][npm-badge]][npm-link]
|
|
4
|
+
[![license][license-badge]][license-link]
|
|
4
5
|
|
|
5
|
-
|
|
6
|
-
[![npm-badge][]][npm-link]
|
|
7
|
-
[![npm-downloads-badge][]][npm-link]
|
|
8
|
-
[![jsdelivr-badge][]][jsdelivr-link]
|
|
9
|
-
[![npm-license-badge][]](LICENSE)
|
|
10
|
-
[![codacy-badge][]][codacy-link]
|
|
11
|
-
[![codeclimate-badge][]][codeclimate-link]
|
|
12
|
-
[![snyk-badge][]][snyk-link]
|
|
13
|
-
[![socket-badge][]][socket-link]
|
|
6
|
+
> Base functionality used throughout XY Labs TypeScript/JavaScript libraries
|
|
14
7
|
|
|
8
|
+
## Install
|
|
15
9
|
|
|
16
|
-
|
|
10
|
+
Using npm:
|
|
17
11
|
|
|
12
|
+
```sh
|
|
13
|
+
npm install {{name}}
|
|
14
|
+
```
|
|
18
15
|
|
|
16
|
+
Using yarn:
|
|
19
17
|
|
|
20
|
-
|
|
18
|
+
```sh
|
|
19
|
+
yarn add {{name}}
|
|
20
|
+
```
|
|
21
21
|
|
|
22
|
-
|
|
22
|
+
Using pnpm:
|
|
23
23
|
|
|
24
|
-
|
|
24
|
+
```sh
|
|
25
|
+
pnpm add {{name}}
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
Using bun:
|
|
29
|
+
|
|
30
|
+
```sh
|
|
31
|
+
bun add {{name}}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
## License
|
|
36
|
+
|
|
37
|
+
See the [LICENSE](LICENSE) file for license rights and limitations (LGPL-3.0-only).
|
|
38
|
+
|
|
39
|
+
## Reference
|
|
40
|
+
|
|
41
|
+
### packages
|
|
25
42
|
|
|
26
|
-
|
|
43
|
+
### decimal-precision
|
|
27
44
|
|
|
28
|
-
|
|
29
|
-
| ------ | ------ |
|
|
30
|
-
| [fromFixedPoint](#functions/fromFixedPoint) | Converts a fixed-point bigint back to a whole-number bigint by dividing out the decimal places. |
|
|
31
|
-
| [toDecimalPrecision](#functions/toDecimalPrecision) | Formats a number to the specified number of significant digits, returning a string with minimal trailing zeros. |
|
|
32
|
-
| [toFixedPoint](#functions/toFixedPoint) | Converts a bigint or decimal string to a fixed-point bigint representation. |
|
|
45
|
+
### .temp-typedoc
|
|
33
46
|
|
|
34
|
-
### functions
|
|
47
|
+
### functions
|
|
35
48
|
|
|
36
|
-
|
|
49
|
+
### <a id="fromFixedPoint"></a>fromFixedPoint
|
|
37
50
|
|
|
38
51
|
[**@xylabs/decimal-precision**](#../README)
|
|
39
52
|
|
|
40
53
|
***
|
|
41
54
|
|
|
42
55
|
```ts
|
|
43
|
-
function fromFixedPoint(value
|
|
56
|
+
function fromFixedPoint(value, places?): bigint;
|
|
44
57
|
```
|
|
45
58
|
|
|
46
59
|
Converts a fixed-point bigint back to a whole-number bigint by dividing out the decimal places.
|
|
47
60
|
|
|
48
61
|
## Parameters
|
|
49
62
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
63
|
+
### value
|
|
64
|
+
|
|
65
|
+
`bigint`
|
|
66
|
+
|
|
67
|
+
The fixed-point bigint value to convert
|
|
68
|
+
|
|
69
|
+
### places?
|
|
70
|
+
|
|
71
|
+
`number` = `18`
|
|
72
|
+
|
|
73
|
+
Number of decimal places (default 18)
|
|
54
74
|
|
|
55
75
|
## Returns
|
|
56
76
|
|
|
@@ -58,24 +78,31 @@ Converts a fixed-point bigint back to a whole-number bigint by dividing out the
|
|
|
58
78
|
|
|
59
79
|
The whole-number bigint result
|
|
60
80
|
|
|
61
|
-
|
|
81
|
+
### <a id="toDecimalPrecision"></a>toDecimalPrecision
|
|
62
82
|
|
|
63
83
|
[**@xylabs/decimal-precision**](#../README)
|
|
64
84
|
|
|
65
85
|
***
|
|
66
86
|
|
|
67
87
|
```ts
|
|
68
|
-
function toDecimalPrecision(value
|
|
88
|
+
function toDecimalPrecision(value, digits): string;
|
|
69
89
|
```
|
|
70
90
|
|
|
71
91
|
Formats a number to the specified number of significant digits, returning a string with minimal trailing zeros.
|
|
72
92
|
|
|
73
93
|
## Parameters
|
|
74
94
|
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
95
|
+
### value
|
|
96
|
+
|
|
97
|
+
`number`
|
|
98
|
+
|
|
99
|
+
The number to format
|
|
100
|
+
|
|
101
|
+
### digits
|
|
102
|
+
|
|
103
|
+
`number`
|
|
104
|
+
|
|
105
|
+
The number of significant digits
|
|
79
106
|
|
|
80
107
|
## Returns
|
|
81
108
|
|
|
@@ -83,67 +110,40 @@ Formats a number to the specified number of significant digits, returning a stri
|
|
|
83
110
|
|
|
84
111
|
A string representation of the number with the specified precision
|
|
85
112
|
|
|
86
|
-
|
|
113
|
+
### <a id="toFixedPoint"></a>toFixedPoint
|
|
87
114
|
|
|
88
115
|
[**@xylabs/decimal-precision**](#../README)
|
|
89
116
|
|
|
90
117
|
***
|
|
91
118
|
|
|
92
119
|
```ts
|
|
93
|
-
function toFixedPoint(value
|
|
120
|
+
function toFixedPoint(value, places?): bigint;
|
|
94
121
|
```
|
|
95
122
|
|
|
96
123
|
Converts a bigint or decimal string to a fixed-point bigint representation.
|
|
97
124
|
|
|
98
125
|
## Parameters
|
|
99
126
|
|
|
100
|
-
|
|
101
|
-
| ------ | ------ | ------ | ------ |
|
|
102
|
-
| `value` | `string` \| `bigint` | `undefined` | The value to convert (bigint or string with optional decimal point) |
|
|
103
|
-
| `places` | `number` | `18` | Number of decimal places (default 18) |
|
|
127
|
+
### value
|
|
104
128
|
|
|
105
|
-
|
|
129
|
+
`string` \| `bigint`
|
|
106
130
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
A bigint representing the value scaled by 10^places
|
|
131
|
+
The value to convert (bigint or string with optional decimal point)
|
|
110
132
|
|
|
133
|
+
### places?
|
|
111
134
|
|
|
112
|
-
|
|
135
|
+
`number` = `18`
|
|
113
136
|
|
|
114
|
-
|
|
137
|
+
Number of decimal places (default 18)
|
|
115
138
|
|
|
116
|
-
|
|
117
|
-
- [Matt Jones](https://github.com/jonesmac)
|
|
118
|
-
- [Joel Carter](https://github.com/JoelBCarter)
|
|
119
|
-
- [Jordan Trouw](https://github.com/jordantrouw)
|
|
120
|
-
|
|
121
|
-
## License
|
|
122
|
-
|
|
123
|
-
> See the [LICENSE](LICENSE) file for license details
|
|
139
|
+
## Returns
|
|
124
140
|
|
|
125
|
-
|
|
141
|
+
`bigint`
|
|
126
142
|
|
|
127
|
-
|
|
143
|
+
A bigint representing the value scaled by 10^places
|
|
128
144
|
|
|
129
|
-
[logo]: https://cdn.xy.company/img/brand/XYPersistentCompany_Logo_Icon_Colored.svg
|
|
130
145
|
|
|
131
|
-
[main-build]: https://github.com/xylabs/sdk-js/actions/workflows/build.yml/badge.svg
|
|
132
|
-
[main-build-link]: https://github.com/xylabs/sdk-js/actions/workflows/build.yml
|
|
133
146
|
[npm-badge]: https://img.shields.io/npm/v/@xylabs/decimal-precision.svg
|
|
134
147
|
[npm-link]: https://www.npmjs.com/package/@xylabs/decimal-precision
|
|
135
|
-
[
|
|
136
|
-
[
|
|
137
|
-
[codeclimate-badge]: https://api.codeclimate.com/v1/badges/c5eb068f806f0b047ea7/maintainability
|
|
138
|
-
[codeclimate-link]: https://codeclimate.com/github/xylabs/sdk-js/maintainability
|
|
139
|
-
[snyk-badge]: https://snyk.io/test/github/xylabs/sdk-js/badge.svg?targetFile=package.json
|
|
140
|
-
[snyk-link]: https://snyk.io/test/github/xylabs/sdk-js?targetFile=package.json
|
|
141
|
-
|
|
142
|
-
[npm-downloads-badge]: https://img.shields.io/npm/dw/@xylabs/decimal-precision
|
|
143
|
-
[npm-license-badge]: https://img.shields.io/npm/l/@xylabs/decimal-precision
|
|
144
|
-
|
|
145
|
-
[jsdelivr-badge]: https://data.jsdelivr.com/v1/package/npm/@xylabs/decimal-precision/badge
|
|
146
|
-
[jsdelivr-link]: https://www.jsdelivr.com/package/npm/@xylabs/decimal-precision
|
|
147
|
-
|
|
148
|
-
[socket-badge]: https://socket.dev/api/badge/npm/package/@xylabs/decimal-precision
|
|
149
|
-
[socket-link]: https://socket.dev/npm/package/@xylabs/decimal-precision
|
|
148
|
+
[license-badge]: https://img.shields.io/npm/l/@xylabs/decimal-precision.svg
|
|
149
|
+
[license-link]: https://github.com/xylabs/sdk-js/blob/main/LICENSE
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xylabs/decimal-precision",
|
|
3
|
-
"version": "5.0.
|
|
3
|
+
"version": "5.0.96",
|
|
4
4
|
"description": "Base functionality used throughout XY Labs TypeScript/JavaScript libraries",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"decimal",
|
|
@@ -30,12 +30,10 @@
|
|
|
30
30
|
"exports": {
|
|
31
31
|
".": {
|
|
32
32
|
"types": "./dist/neutral/index.d.ts",
|
|
33
|
-
"import": "./dist/neutral/index.mjs",
|
|
34
33
|
"default": "./dist/neutral/index.mjs"
|
|
35
34
|
},
|
|
36
35
|
"./package.json": "./package.json"
|
|
37
36
|
},
|
|
38
|
-
"types": "./dist/neutral/index.d.ts",
|
|
39
37
|
"files": [
|
|
40
38
|
"dist",
|
|
41
39
|
"!**/*.bench.*",
|
|
@@ -44,14 +42,13 @@
|
|
|
44
42
|
"README.md"
|
|
45
43
|
],
|
|
46
44
|
"devDependencies": {
|
|
47
|
-
"@types/node": "^25.
|
|
48
|
-
"@xylabs/
|
|
49
|
-
"@xylabs/
|
|
50
|
-
"@xylabs/tsconfig": "~7.8.4",
|
|
45
|
+
"@types/node": "^25.6.0",
|
|
46
|
+
"@xylabs/toolchain": "~7.10.4",
|
|
47
|
+
"@xylabs/tsconfig": "~7.10.4",
|
|
51
48
|
"esbuild": "^0.28.0",
|
|
52
49
|
"typescript": "^5",
|
|
53
|
-
"vite": "^8.0.
|
|
54
|
-
"vitest": "^4.1.
|
|
50
|
+
"vite": "^8.0.8",
|
|
51
|
+
"vitest": "^4.1.4"
|
|
55
52
|
},
|
|
56
53
|
"engines": {
|
|
57
54
|
"node": ">=18"
|