bn-eslint.js 8.0.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.
Files changed (5) hide show
  1. package/LICENCE.md +26 -0
  2. package/README.md +209 -0
  3. package/big.js +1048 -0
  4. package/big.mjs +1048 -0
  5. package/package.json +60 -0
package/LICENCE.md ADDED
@@ -0,0 +1,26 @@
1
+ The MIT License (MIT)
2
+ =====================
3
+
4
+ Copyright © `<2025>` `Michael Mclaughlin`
5
+
6
+ Permission is hereby granted, free of charge, to any person
7
+ obtaining a copy of this software and associated documentation
8
+ files (the “Software”), to deal in the Software without
9
+ restriction, including without limitation the rights to use,
10
+ copy, modify, merge, publish, distribute, sublicense, and/or sell
11
+ copies of the Software, and to permit persons to whom the
12
+ Software is furnished to do so, subject to the following
13
+ conditions:
14
+
15
+ The above copyright notice and this permission notice shall be
16
+ included in all copies or substantial portions of the Software.
17
+
18
+ THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND,
19
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
20
+ OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
21
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
22
+ HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
23
+ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24
+ FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25
+ OTHER DEALINGS IN THE SOFTWARE.
26
+
package/README.md ADDED
@@ -0,0 +1,209 @@
1
+ # big.js
2
+
3
+ **A small, fast JavaScript library for arbitrary-precision decimal arithmetic.**
4
+
5
+ [![npm version](https://img.shields.io/npm/v/big.js.svg)](https://www.npmjs.com/package/big.js)
6
+ [![npm downloads](https://img.shields.io/npm/dw/big.js)](https://www.npmjs.com/package/big.js)
7
+ [![CI](https://github.com/MikeMcl/big.js/actions/workflows/ci.yml/badge.svg)](https://github.com/MikeMcl/big.js/actions/workflows/ci.yml)
8
+
9
+ ## Features
10
+
11
+ - Simple API
12
+ - Faster, smaller and easier-to-use than JavaScript versions of Java's BigDecimal
13
+ - Only 6 KB minified
14
+ - Replicates the `toExponential`, `toFixed` and `toPrecision` methods of JavaScript Numbers
15
+ - Stores values in an accessible decimal floating point format
16
+ - Comprehensive [documentation](http://mikemcl.github.io/big.js/) and test set
17
+ - No dependencies
18
+ - Uses ECMAScript 3 only, so works in all browsers
19
+
20
+ The little sister to [bignumber.js](https://github.com/MikeMcl/bignumber.js/) and [decimal.js](https://github.com/MikeMcl/decimal.js/). See [here](https://github.com/MikeMcl/big.js/wiki) for some notes on the difference between them.
21
+
22
+ ## Install
23
+
24
+ The library is the single JavaScript file *big.js* or the ES module *big.mjs*.
25
+
26
+ ### Browsers
27
+
28
+ Add Big to global scope:
29
+
30
+ ```html
31
+ <script src='path/to/big.js'></script>
32
+ ```
33
+
34
+ ES module:
35
+
36
+ ```html
37
+ <script type='module'>
38
+ import Big from './path/to/big.mjs';
39
+ </script>
40
+ ```
41
+
42
+ Get a minified version from a CDN:
43
+
44
+ ```html
45
+ <script src='https://cdn.jsdelivr.net/npm/big.js@7.0.1/big.min.js'></script>
46
+ ```
47
+
48
+ ### [Node.js](http://nodejs.org)
49
+
50
+ ```bash
51
+ $ npm install big.js
52
+ ```
53
+
54
+ CommonJS:
55
+
56
+ ```javascript
57
+ const Big = require('big.js');
58
+ ```
59
+
60
+ ES module:
61
+
62
+ ```javascript
63
+ import Big from 'big.js';
64
+ ```
65
+
66
+ ### [Deno](https://deno.land/)
67
+
68
+ ```javascript
69
+ import Big from 'https://raw.githubusercontent.com/mikemcl/big.js/v7.0.1/big.mjs';
70
+ import Big from 'https://unpkg.com/big.js@latest/big.mjs';
71
+ ```
72
+
73
+ ## Use
74
+
75
+ *In the code examples below, semicolons and `toString` calls are not shown.*
76
+
77
+ The library exports a single constructor function, `Big`.
78
+
79
+ A Big number is created from a primitive number, string, or other Big number.
80
+
81
+ ```javascript
82
+ x = new Big(123.4567)
83
+ y = Big('123456.7e-3') // 'new' is optional
84
+ z = new Big(x)
85
+ x.eq(y) && x.eq(z) && y.eq(z) // true
86
+ ```
87
+
88
+ In Big strict mode, creating a Big number from a primitive number is disallowed.
89
+
90
+ ```javascript
91
+ Big.strict = true
92
+ x = new Big(1) // TypeError: [big.js] Invalid number
93
+ y = new Big('1.0000000000000001')
94
+ y.toNumber() // Error: [big.js] Imprecise conversion
95
+ ```
96
+
97
+ A Big number is immutable in the sense that it is not changed by its methods.
98
+
99
+ ```javascript
100
+ 0.3 - 0.1 // 0.19999999999999998
101
+ x = new Big(0.3)
102
+ x.minus(0.1) // "0.2"
103
+ x // "0.3"
104
+ ```
105
+
106
+ The methods that return a Big number can be chained.
107
+
108
+ ```javascript
109
+ x.div(y).plus(z).times(9).minus('1.234567801234567e+8').plus(976.54321).div('2598.11772')
110
+ x.sqrt().div(y).pow(3).gt(y.mod(z)) // true
111
+ ```
112
+
113
+ Like JavaScript's Number type, there are `toExponential`, `toFixed` and `toPrecision` methods.
114
+
115
+ ```javascript
116
+ x = new Big(255.5)
117
+ x.toExponential(5) // "2.55500e+2"
118
+ x.toFixed(5) // "255.50000"
119
+ x.toPrecision(5) // "255.50"
120
+ ```
121
+
122
+ The arithmetic methods always return the exact result except `div`, `sqrt` and `pow`
123
+ (with negative exponent), as these methods involve division.
124
+
125
+ 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.
126
+
127
+ ```javascript
128
+ Big.DP = 10
129
+ Big.RM = Big.roundHalfUp
130
+
131
+ x = new Big(2);
132
+ y = new Big(3);
133
+ z = x.div(y) // "0.6666666667"
134
+ z.sqrt() // "0.8164965809"
135
+ z.pow(-3) // "3.3749999995"
136
+ z.times(z) // "0.44444444448888888889"
137
+ z.times(z).round(10) // "0.4444444445"
138
+ ```
139
+
140
+ The value of a Big number is stored in a decimal floating point format in terms of a coefficient, exponent and sign.
141
+
142
+ ```javascript
143
+ x = new Big(-123.456);
144
+ x.c // [1,2,3,4,5,6] coefficient (i.e. significand)
145
+ x.e // 2 exponent
146
+ x.s // -1 sign
147
+ ```
148
+
149
+ For advanced usage, multiple Big number constructors can be created, each with an independent configuration.
150
+
151
+ For further information see the [API](http://mikemcl.github.io/big.js/) reference documentation.
152
+
153
+ ## Minify
154
+
155
+ To minify using, for example, npm and [terser](https://github.com/terser/terser)
156
+
157
+ ```bash
158
+ $ npm install -g terser
159
+ ```
160
+
161
+ ```bash
162
+ $ terser big.js -c -m -o big.min.js
163
+ ```
164
+
165
+ ## Test
166
+
167
+ The *test* directory contains the test scripts for each Big number method.
168
+
169
+ The tests can be run with Node.js or a browser.
170
+
171
+ Run all the tests:
172
+
173
+ ```bash
174
+ $ npm test
175
+ ```
176
+
177
+ Test a single method:
178
+
179
+ ```bash
180
+ $ node test/toFixed
181
+ ```
182
+
183
+ For the browser, see *runner.html* and *test.html* in the *test/browser* directory.
184
+
185
+ *big-vs-number.html* is a old application that enables some of the methods of big.js to be compared with those of JavaScript's Number type.
186
+
187
+ ## TypeScript
188
+
189
+ The [DefinitelyTyped](https://github.com/borisyankov/DefinitelyTyped) project has a Typescript type definitions file for big.js.
190
+
191
+ ```bash
192
+ $ npm install --save-dev @types/big.js
193
+ ```
194
+
195
+ Any questions about the TypeScript type definitions file should be addressed to the DefinitelyTyped project.
196
+
197
+ ## Licence
198
+
199
+ [MIT](LICENCE.md)
200
+
201
+ ## Contributors
202
+
203
+ <a href="graphs/contributors"><img src="https://opencollective.com/bigjs/contributors.svg?width=890&button=false" /></a>
204
+
205
+ ## Financial supporters
206
+
207
+ Thank you to all who have supported this project via [Open Collective](https://opencollective.com/bigjs), particularly [Coinbase](https://www.coinbase.com/).
208
+
209
+ <img src="https://opencollective.com/bigjs/sponsor/0/avatar.svg">