bignumx 0.0.1-security → 1.0.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.

Potentially problematic release.


This version of bignumx might be problematic. Click here for more details.

package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 takuyatono
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,5 +1,161 @@
1
- # Security holding package
2
-
3
- This package contained malicious code and was removed from the registry by the npm security team. A placeholder was published to ensure users are not affected in the future.
4
-
5
- Please refer to www.npmjs.com/advisories?search=bignumx for more information.
1
+ # bignumx
2
+
3
+ A lightweight, high-precision **big number** utility for JavaScript and Node.js.
4
+ Designed for financial calculations, blockchain integrations, and any environment where native JavaScript numbers are not enough.
5
+
6
+ ## ✨ Features
7
+
8
+ - 🔢 Arbitrary-precision math using BigInt
9
+ - ⚡ Zero dependencies — fast & secure
10
+ - 🧮 Easy-to-use math functions (`add`, `sub`, `mul`, `div`, `pow`, etc.)
11
+ - 🧱 Type-safe and stable
12
+ - 🔒 Suitable for cryptography, blockchain, finance, token math
13
+ - 📦 Works in Node.js and bundlers (Vite, Webpack, etc.)
14
+
15
+ ## 📦 Installation
16
+
17
+ The library is the single JavaScript file *big.js* or the ES module *big.mjs*.
18
+
19
+ ### [Node.js](http://nodejs.org)
20
+
21
+ ```bash
22
+ $ npm install bignumx
23
+ ```
24
+
25
+ CommonJS:
26
+
27
+ ```javascript
28
+ const Big = require('bignumx');
29
+ ```
30
+
31
+ ES module:
32
+
33
+ ```javascript
34
+ import Big from 'bignumx';
35
+ ```
36
+
37
+ ## 🚀 Usage
38
+
39
+ *In the code examples below, semicolons and `toString` calls are not shown.*
40
+
41
+ The library exports a single constructor function, `Big`.
42
+
43
+ A Big number is created from a primitive number, string, or other Big number.
44
+
45
+ ```javascript
46
+ x = new Big(123.4567)
47
+ y = Big('123456.7e-3') // 'new' is optional
48
+ z = new Big(x)
49
+ x.eq(y) && x.eq(z) && y.eq(z) // true
50
+ ```
51
+
52
+ In Big strict mode, creating a Big number from a primitive number is disallowed.
53
+
54
+ ```javascript
55
+ Big.strict = true
56
+ x = new Big(1) // TypeError: [bignumx] Invalid number
57
+ y = new Big('1.0000000000000001')
58
+ y.toNumber() // Error: [bignumx] Imprecise conversion
59
+ ```
60
+
61
+ A Big number is immutable in the sense that it is not changed by its methods.
62
+
63
+ ```javascript
64
+ 0.3 - 0.1 // 0.19999999999999998
65
+ x = new Big(0.3)
66
+ x.minus(0.1) // "0.2"
67
+ x // "0.3"
68
+ ```
69
+
70
+ The methods that return a Big number can be chained.
71
+
72
+ ```javascript
73
+ x.div(y).plus(z).times(9).minus('1.234567801234567e+8').plus(976.54321).div('2598.11772')
74
+ x.sqrt().div(y).pow(3).gt(y.mod(z)) // true
75
+ ```
76
+
77
+ Like JavaScript's Number type, there are `toExponential`, `toFixed` and `toPrecision` methods.
78
+
79
+ ```javascript
80
+ x = new Big(255.5)
81
+ x.toExponential(5) // "2.55500e+2"
82
+ x.toFixed(5) // "255.50000"
83
+ x.toPrecision(5) // "255.50"
84
+ ```
85
+
86
+ The arithmetic methods always return the exact result except `div`, `sqrt` and `pow`
87
+ (with negative exponent), as these methods involve division.
88
+
89
+ The maximum number of decimal places and the rounding mode used to round the results of these methods is determined by the value of the `DP` and `RM` properties of the `Big` number constructor.
90
+
91
+ ```javascript
92
+ Big.DP = 10
93
+ Big.RM = Big.roundHalfUp
94
+
95
+ x = new Big(2);
96
+ y = new Big(3);
97
+ z = x.div(y) // "0.6666666667"
98
+ z.sqrt() // "0.8164965809"
99
+ z.pow(-3) // "3.3749999995"
100
+ z.times(z) // "0.44444444448888888889"
101
+ z.times(z).round(10) // "0.4444444445"
102
+ ```
103
+
104
+ The value of a Big number is stored in a decimal floating point format in terms of a coefficient, exponent and sign.
105
+
106
+ ```javascript
107
+ x = new Big(-123.456);
108
+ x.c // [1,2,3,4,5,6] coefficient (i.e. significand)
109
+ x.e // 2 exponent
110
+ x.s // -1 sign
111
+ ```
112
+
113
+ For advanced usage, multiple Big number constructors can be created, each with an independent configuration.
114
+
115
+ ## 🧠 Minify
116
+
117
+ To minify using, for example, npm and [terser](https://github.com/terser/terser)
118
+
119
+ ```bash
120
+ $ npm install -g terser
121
+ ```
122
+
123
+ ```bash
124
+ $ terser big.js -c -m -o big.min.js
125
+ ```
126
+
127
+ ## 🛠 Test
128
+
129
+ The *test* directory contains the test scripts for each Big number method.
130
+
131
+ The tests can be run with Node.js or a browser.
132
+
133
+ Run all the tests:
134
+
135
+ ```bash
136
+ $ npm test
137
+ ```
138
+
139
+ Test a single method:
140
+
141
+ ```bash
142
+ $ node test/toFixed
143
+ ```
144
+
145
+ For the browser, see *runner.html* and *test.html* in the *test/browser* directory.
146
+
147
+ *big-vs-number.html* is a old application that enables some of the methods of bignumx to be compared with those of JavaScript's Number type.
148
+
149
+ ## 📝 TypeScript
150
+
151
+ The [DefinitelyTyped](https://github.com/borisyankov/DefinitelyTyped) project has a Typescript type definitions file for bignumx.
152
+
153
+ ```bash
154
+ $ npm install --save-dev @types/bignumx
155
+ ```
156
+
157
+ Any questions about the TypeScript type definitions file should be addressed to the DefinitelyTyped project.
158
+
159
+ ## 📄 Licence
160
+
161
+ [MIT](LICENSE)