@agrozyme/numeric 1.0.11 → 1.0.13
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/.prettierrc.yml +8 -0
- package/package.json +23 -17
- package/root/index.ts +139 -368
- package/tsc-multi.json +4 -3
- package/tsconfig.json +24 -11
- package/out/index.d.ts +0 -158
- package/out/index.js +0 -471
- package/out/index.mjs +0 -455
package/root/index.ts
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
// noinspection JSUnusedGlobalSymbols
|
|
2
|
+
|
|
1
3
|
import { BigNumber, BigNumberish } from '@ethersproject/bignumber';
|
|
2
4
|
import { hexlify, isBytesLike } from '@ethersproject/bytes';
|
|
3
5
|
import * as constants from '@ethersproject/constants';
|
|
@@ -6,7 +8,7 @@ import BN from 'bn.js';
|
|
|
6
8
|
import { isNode } from 'browser-or-node';
|
|
7
9
|
import { Decimal } from 'decimal.js';
|
|
8
10
|
import formatter from 'format-number';
|
|
9
|
-
import { InspectOptionsStylized } from 'util';
|
|
11
|
+
import { InspectOptionsStylized } from 'node:util';
|
|
10
12
|
|
|
11
13
|
// const inspect = Symbol.for('nodejs.util.inspect.custom');
|
|
12
14
|
|
|
@@ -29,8 +31,10 @@ export interface IFormatNumberOptions {
|
|
|
29
31
|
truncate?: number;
|
|
30
32
|
}
|
|
31
33
|
|
|
32
|
-
//noinspection
|
|
34
|
+
// noinspection LocalVariableNamingConventionJS
|
|
33
35
|
export class Numeric extends Decimal {
|
|
36
|
+
// private readonly toStringTag: string = 'Decimal';
|
|
37
|
+
|
|
34
38
|
constructor(value: NumericValue) {
|
|
35
39
|
if (value instanceof Decimal) {
|
|
36
40
|
super(value);
|
|
@@ -56,514 +60,281 @@ export class Numeric extends Decimal {
|
|
|
56
60
|
}
|
|
57
61
|
}
|
|
58
62
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
// }
|
|
62
|
-
|
|
63
|
-
static abs(value: NumericValue) {
|
|
64
|
-
return new Numeric(value).abs();
|
|
63
|
+
get [Symbol.toStringTag]() {
|
|
64
|
+
return 'Numeric';
|
|
65
65
|
}
|
|
66
66
|
|
|
67
|
-
static
|
|
68
|
-
return new Numeric(value).acos();
|
|
69
|
-
}
|
|
67
|
+
static abs = (value: NumericValue) => new Numeric(value).abs();
|
|
70
68
|
|
|
71
|
-
static
|
|
72
|
-
return new Numeric(value).acosh();
|
|
73
|
-
}
|
|
69
|
+
static acos = (value: NumericValue) => new Numeric(value).acos();
|
|
74
70
|
|
|
75
|
-
static
|
|
76
|
-
return new Numeric(x).add(y);
|
|
77
|
-
}
|
|
71
|
+
static acosh = (value: NumericValue) => new Numeric(value).acosh();
|
|
78
72
|
|
|
79
|
-
static
|
|
80
|
-
return new Numeric(value).asin();
|
|
81
|
-
}
|
|
73
|
+
static add = (x: NumericValue, y: NumericValue) => new Numeric(x).add(y);
|
|
82
74
|
|
|
83
|
-
static
|
|
84
|
-
return new Numeric(value).asinh();
|
|
85
|
-
}
|
|
75
|
+
static asin = (value: NumericValue) => new Numeric(value).asin();
|
|
86
76
|
|
|
87
|
-
static
|
|
88
|
-
return new Numeric(value).atan();
|
|
89
|
-
}
|
|
77
|
+
static asinh = (value: NumericValue) => new Numeric(value).asinh();
|
|
90
78
|
|
|
91
|
-
static
|
|
92
|
-
return new Numeric(Decimal.atan2(new Numeric(x), new Numeric(y)));
|
|
93
|
-
}
|
|
79
|
+
static atan = (value: NumericValue) => new Numeric(value).atan();
|
|
94
80
|
|
|
95
|
-
static
|
|
96
|
-
return new Numeric(value).atanh();
|
|
97
|
-
}
|
|
81
|
+
static atan2 = (x: NumericValue, y: NumericValue) => new Numeric(Decimal.atan2(new Numeric(x), new Numeric(y)));
|
|
98
82
|
|
|
99
|
-
static
|
|
100
|
-
return new Numeric(value).cbrt();
|
|
101
|
-
}
|
|
83
|
+
static atanh = (value: NumericValue) => new Numeric(value).atanh();
|
|
102
84
|
|
|
103
|
-
static
|
|
104
|
-
return new Numeric(value).ceil();
|
|
105
|
-
}
|
|
85
|
+
static cbrt = (value: NumericValue) => new Numeric(value).cbrt();
|
|
106
86
|
|
|
107
|
-
static
|
|
108
|
-
return new Numeric(value).cos();
|
|
109
|
-
}
|
|
87
|
+
static ceil = (value: NumericValue) => new Numeric(value).ceil();
|
|
110
88
|
|
|
111
|
-
static
|
|
112
|
-
return new Numeric(value).cosh();
|
|
113
|
-
}
|
|
89
|
+
static cos = (value: NumericValue) => new Numeric(value).cos();
|
|
114
90
|
|
|
115
|
-
static
|
|
116
|
-
return new Numeric(x).div(y);
|
|
117
|
-
}
|
|
91
|
+
static cosh = (value: NumericValue) => new Numeric(value).cosh();
|
|
118
92
|
|
|
119
|
-
static
|
|
120
|
-
return new Numeric(value).exp();
|
|
121
|
-
}
|
|
93
|
+
static div = (x: NumericValue, y: NumericValue) => new Numeric(x).div(y);
|
|
122
94
|
|
|
123
|
-
static
|
|
124
|
-
return new Numeric(value).floor();
|
|
125
|
-
}
|
|
95
|
+
static exp = (value: NumericValue) => new Numeric(value).exp();
|
|
126
96
|
|
|
127
|
-
static
|
|
128
|
-
return new Numeric(Decimal.hypot(...toNumerics(values)));
|
|
129
|
-
}
|
|
97
|
+
static floor = (value: NumericValue) => new Numeric(value).floor();
|
|
130
98
|
|
|
131
|
-
static
|
|
132
|
-
return new Numeric(value).ln();
|
|
133
|
-
}
|
|
99
|
+
static hypot = (...values: NumericValue[]) => new Numeric(Decimal.hypot(...toNumerics(values)));
|
|
134
100
|
|
|
135
|
-
static
|
|
136
|
-
return new Numeric(value).log(base);
|
|
137
|
-
}
|
|
101
|
+
static ln = (value: NumericValue) => new Numeric(value).ln();
|
|
138
102
|
|
|
139
|
-
static
|
|
140
|
-
return new Numeric(value).log(10);
|
|
141
|
-
}
|
|
103
|
+
static log = (value: NumericValue, base?: NumericValue) => new Numeric(value).log(base);
|
|
142
104
|
|
|
143
|
-
static
|
|
144
|
-
return new Numeric(value).log(2);
|
|
145
|
-
}
|
|
105
|
+
static log10 = (value: NumericValue) => new Numeric(value).log(10);
|
|
146
106
|
|
|
147
|
-
static
|
|
148
|
-
return new Numeric(Decimal.max(...toNumerics(values)));
|
|
149
|
-
}
|
|
107
|
+
static log2 = (value: NumericValue) => new Numeric(value).log(2);
|
|
150
108
|
|
|
151
|
-
static
|
|
152
|
-
return new Numeric(Decimal.min(...toNumerics(values)));
|
|
153
|
-
}
|
|
109
|
+
static max = (...values: NumericValue[]) => new Numeric(Decimal.max(...toNumerics(values)));
|
|
154
110
|
|
|
155
|
-
static
|
|
156
|
-
return new Numeric(x).mod(y);
|
|
157
|
-
}
|
|
111
|
+
static min = (...values: NumericValue[]) => new Numeric(Decimal.min(...toNumerics(values)));
|
|
158
112
|
|
|
159
|
-
static
|
|
160
|
-
return new Numeric(x).mul(y);
|
|
161
|
-
}
|
|
113
|
+
static mod = (x: NumericValue, y: NumericValue) => new Numeric(x).mod(y);
|
|
162
114
|
|
|
163
|
-
static
|
|
164
|
-
return new Numeric(base).pow(exponent);
|
|
165
|
-
}
|
|
115
|
+
static mul = (x: NumericValue, y: NumericValue) => new Numeric(x).mul(y);
|
|
166
116
|
|
|
167
|
-
static
|
|
168
|
-
return new Numeric(Decimal.random(significantDigits));
|
|
169
|
-
}
|
|
117
|
+
static pow = (base: NumericValue, exponent: NumericValue) => new Numeric(base).pow(exponent);
|
|
170
118
|
|
|
171
|
-
static
|
|
172
|
-
return new Numeric(value).round();
|
|
173
|
-
}
|
|
119
|
+
static random = (significantDigits?: number) => new Numeric(Decimal.random(significantDigits));
|
|
174
120
|
|
|
175
|
-
static
|
|
176
|
-
return Decimal.set(object);
|
|
177
|
-
}
|
|
121
|
+
static round = (value: NumericValue) => new Numeric(value).round();
|
|
178
122
|
|
|
179
|
-
static
|
|
180
|
-
return new Numeric(Decimal.sign(new Numeric(value)));
|
|
181
|
-
}
|
|
123
|
+
static set = (object: Decimal.Config) => Decimal.set(object);
|
|
182
124
|
|
|
183
|
-
static
|
|
184
|
-
return new Numeric(value).sin();
|
|
185
|
-
}
|
|
125
|
+
static sign = (value: NumericValue) => Decimal.sign(new Numeric(value));
|
|
186
126
|
|
|
187
|
-
static
|
|
188
|
-
return new Numeric(value).sinh();
|
|
189
|
-
}
|
|
127
|
+
static sin = (value: NumericValue) => new Numeric(value).sin();
|
|
190
128
|
|
|
191
|
-
static
|
|
192
|
-
return new Numeric(value).sqrt();
|
|
193
|
-
}
|
|
129
|
+
static sinh = (value: NumericValue) => new Numeric(value).sinh();
|
|
194
130
|
|
|
195
|
-
static
|
|
196
|
-
return new Numeric(x).sub(y);
|
|
197
|
-
}
|
|
131
|
+
static sqrt = (value: NumericValue) => new Numeric(value).sqrt();
|
|
198
132
|
|
|
199
|
-
static
|
|
200
|
-
return new Numeric(value).tan();
|
|
201
|
-
}
|
|
133
|
+
static sub = (x: NumericValue, y: NumericValue) => new Numeric(x).sub(y);
|
|
202
134
|
|
|
203
|
-
static
|
|
204
|
-
return new Numeric(value).tanh();
|
|
205
|
-
}
|
|
135
|
+
static tan = (value: NumericValue) => new Numeric(value).tan();
|
|
206
136
|
|
|
207
|
-
static
|
|
208
|
-
return new Numeric(value).trunc();
|
|
209
|
-
}
|
|
137
|
+
static tanh = (value: NumericValue) => new Numeric(value).tanh();
|
|
210
138
|
|
|
211
|
-
|
|
212
|
-
return new Numeric(super.abs());
|
|
213
|
-
}
|
|
139
|
+
static trunc = (value: NumericValue) => new Numeric(value).trunc();
|
|
214
140
|
|
|
215
|
-
|
|
216
|
-
return new Numeric(super.absoluteValue());
|
|
217
|
-
}
|
|
141
|
+
abs = () => new Numeric(super.abs());
|
|
218
142
|
|
|
219
|
-
|
|
220
|
-
return new Numeric(super.acos());
|
|
221
|
-
}
|
|
143
|
+
absoluteValue = () => new Numeric(super.absoluteValue());
|
|
222
144
|
|
|
223
|
-
|
|
224
|
-
return new Numeric(super.acosh());
|
|
225
|
-
}
|
|
145
|
+
acos = () => new Numeric(super.acos());
|
|
226
146
|
|
|
227
|
-
|
|
228
|
-
return new Numeric(super.add(new Numeric(value)));
|
|
229
|
-
}
|
|
147
|
+
acosh = () => new Numeric(super.acosh());
|
|
230
148
|
|
|
231
|
-
|
|
232
|
-
return new Numeric(super.asin());
|
|
233
|
-
}
|
|
149
|
+
add = (value: NumericValue) => new Numeric(super.add(new Numeric(value)));
|
|
234
150
|
|
|
235
|
-
|
|
236
|
-
return new Numeric(super.asinh());
|
|
237
|
-
}
|
|
151
|
+
asin = () => new Numeric(super.asin());
|
|
238
152
|
|
|
239
|
-
|
|
240
|
-
return new Numeric(super.atan());
|
|
241
|
-
}
|
|
153
|
+
asinh = () => new Numeric(super.asinh());
|
|
242
154
|
|
|
243
|
-
|
|
244
|
-
return new Numeric(super.atanh());
|
|
245
|
-
}
|
|
155
|
+
atan = () => new Numeric(super.atan());
|
|
246
156
|
|
|
247
|
-
|
|
248
|
-
return new Numeric(super.cbrt());
|
|
249
|
-
}
|
|
157
|
+
atanh = () => new Numeric(super.atanh());
|
|
250
158
|
|
|
251
|
-
|
|
252
|
-
return new Numeric(super.ceil());
|
|
253
|
-
}
|
|
159
|
+
cbrt = () => new Numeric(super.cbrt());
|
|
254
160
|
|
|
255
|
-
|
|
256
|
-
return super.cmp(new Numeric(value));
|
|
257
|
-
}
|
|
161
|
+
ceil = () => new Numeric(super.ceil());
|
|
258
162
|
|
|
259
|
-
|
|
260
|
-
return super.comparedTo(new Numeric(value));
|
|
261
|
-
}
|
|
163
|
+
cmp = (value: NumericValue) => super.cmp(new Numeric(value));
|
|
262
164
|
|
|
263
|
-
|
|
264
|
-
return new Numeric(super.cos());
|
|
265
|
-
}
|
|
165
|
+
comparedTo = (value: NumericValue) => super.comparedTo(new Numeric(value));
|
|
266
166
|
|
|
267
|
-
|
|
268
|
-
return new Numeric(super.cosh());
|
|
269
|
-
}
|
|
167
|
+
cos = () => new Numeric(super.cos());
|
|
270
168
|
|
|
271
|
-
|
|
272
|
-
return new Numeric(super.cosine());
|
|
273
|
-
}
|
|
169
|
+
cosh = () => new Numeric(super.cosh());
|
|
274
170
|
|
|
275
|
-
|
|
276
|
-
return new Numeric(super.cubeRoot());
|
|
277
|
-
}
|
|
171
|
+
cosine = () => new Numeric(super.cosine());
|
|
278
172
|
|
|
279
|
-
|
|
280
|
-
return new Numeric(super.div(new Numeric(value)));
|
|
281
|
-
}
|
|
173
|
+
cubeRoot = () => new Numeric(super.cubeRoot());
|
|
282
174
|
|
|
283
|
-
|
|
284
|
-
return new Numeric(super.divToInt(new Numeric(value)));
|
|
285
|
-
}
|
|
175
|
+
div = (value: NumericValue) => new Numeric(super.div(new Numeric(value)));
|
|
286
176
|
|
|
287
|
-
|
|
288
|
-
return new Numeric(super.dividedBy(new Numeric(value)));
|
|
289
|
-
}
|
|
177
|
+
divToInt = (value: NumericValue) => new Numeric(super.divToInt(new Numeric(value)));
|
|
290
178
|
|
|
291
|
-
|
|
292
|
-
return new Numeric(super.dividedToIntegerBy(new Numeric(value)));
|
|
293
|
-
}
|
|
179
|
+
dividedBy = (value: NumericValue) => new Numeric(super.dividedBy(new Numeric(value)));
|
|
294
180
|
|
|
295
|
-
|
|
296
|
-
return super.eq(new Numeric(value));
|
|
297
|
-
}
|
|
181
|
+
dividedToIntegerBy = (value: NumericValue) => new Numeric(super.dividedToIntegerBy(new Numeric(value)));
|
|
298
182
|
|
|
299
|
-
|
|
300
|
-
return super.equals(new Numeric(value));
|
|
301
|
-
}
|
|
183
|
+
eq = (value: NumericValue) => super.eq(new Numeric(value));
|
|
302
184
|
|
|
303
|
-
|
|
304
|
-
return new Numeric(super.exp());
|
|
305
|
-
}
|
|
185
|
+
equals = (value: NumericValue) => super.equals(new Numeric(value));
|
|
306
186
|
|
|
307
|
-
|
|
308
|
-
return new Numeric(super.floor());
|
|
309
|
-
}
|
|
187
|
+
exp = () => new Numeric(super.exp());
|
|
310
188
|
|
|
311
|
-
|
|
312
|
-
return super.greaterThan(new Numeric(value));
|
|
313
|
-
}
|
|
189
|
+
floor = () => new Numeric(super.floor());
|
|
314
190
|
|
|
315
|
-
|
|
316
|
-
return super.greaterThanOrEqualTo(new Numeric(value));
|
|
317
|
-
}
|
|
191
|
+
greaterThan = (value: NumericValue) => super.greaterThan(new Numeric(value));
|
|
318
192
|
|
|
319
|
-
|
|
320
|
-
return super.gt(new Numeric(value));
|
|
321
|
-
}
|
|
193
|
+
greaterThanOrEqualTo = (value: NumericValue) => super.greaterThanOrEqualTo(new Numeric(value));
|
|
322
194
|
|
|
323
|
-
|
|
324
|
-
return super.gte(new Numeric(value));
|
|
325
|
-
}
|
|
195
|
+
gt = (value: NumericValue) => super.gt(new Numeric(value));
|
|
326
196
|
|
|
327
|
-
|
|
328
|
-
return new Numeric(super.hyperbolicCosine());
|
|
329
|
-
}
|
|
197
|
+
gte = (value: NumericValue) => super.gte(new Numeric(value));
|
|
330
198
|
|
|
331
|
-
|
|
332
|
-
return new Numeric(super.hyperbolicSine());
|
|
333
|
-
}
|
|
199
|
+
hyperbolicCosine = () => new Numeric(super.hyperbolicCosine());
|
|
334
200
|
|
|
335
|
-
|
|
336
|
-
return new Numeric(super.hyperbolicTangent());
|
|
337
|
-
}
|
|
201
|
+
hyperbolicSine = () => new Numeric(super.hyperbolicSine());
|
|
338
202
|
|
|
339
|
-
|
|
340
|
-
return new Numeric(super.inverseCosine());
|
|
341
|
-
}
|
|
203
|
+
hyperbolicTangent = () => new Numeric(super.hyperbolicTangent());
|
|
342
204
|
|
|
343
|
-
|
|
344
|
-
return new Numeric(super.inverseHyperbolicCosine());
|
|
345
|
-
}
|
|
205
|
+
inverseCosine = () => new Numeric(super.inverseCosine());
|
|
346
206
|
|
|
347
|
-
|
|
348
|
-
return new Numeric(super.inverseHyperbolicSine());
|
|
349
|
-
}
|
|
207
|
+
inverseHyperbolicCosine = () => new Numeric(super.inverseHyperbolicCosine());
|
|
350
208
|
|
|
351
|
-
|
|
352
|
-
return new Numeric(super.inverseHyperbolicTangent());
|
|
353
|
-
}
|
|
209
|
+
inverseHyperbolicSine = () => new Numeric(super.inverseHyperbolicSine());
|
|
354
210
|
|
|
355
|
-
|
|
356
|
-
return new Numeric(super.inverseSine());
|
|
357
|
-
}
|
|
211
|
+
inverseHyperbolicTangent = () => new Numeric(super.inverseHyperbolicTangent());
|
|
358
212
|
|
|
359
|
-
|
|
360
|
-
return new Numeric(super.inverseTangent());
|
|
361
|
-
}
|
|
213
|
+
inverseSine = () => new Numeric(super.inverseSine());
|
|
362
214
|
|
|
363
|
-
|
|
364
|
-
return super.lessThan(new Numeric(value));
|
|
365
|
-
}
|
|
215
|
+
inverseTangent = () => new Numeric(super.inverseTangent());
|
|
366
216
|
|
|
367
|
-
|
|
368
|
-
return super.lessThanOrEqualTo(new Numeric(value));
|
|
369
|
-
}
|
|
217
|
+
lessThan = (value: NumericValue) => super.lessThan(new Numeric(value));
|
|
370
218
|
|
|
371
|
-
|
|
372
|
-
return new Numeric(super.ln());
|
|
373
|
-
}
|
|
219
|
+
lessThanOrEqualTo = (value: NumericValue) => super.lessThanOrEqualTo(new Numeric(value));
|
|
374
220
|
|
|
375
|
-
|
|
376
|
-
return new Numeric(super.log(undefined === value ? undefined : new Numeric(value)));
|
|
377
|
-
}
|
|
221
|
+
ln = () => new Numeric(super.ln());
|
|
378
222
|
|
|
379
|
-
|
|
380
|
-
return new Numeric(super.logarithm(undefined === value ? undefined : new Numeric(value)));
|
|
381
|
-
}
|
|
223
|
+
log = (value?: NumericValue) => new Numeric(super.log(undefined === value ? undefined : new Numeric(value)));
|
|
382
224
|
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
}
|
|
225
|
+
logarithm = (value?: NumericValue) =>
|
|
226
|
+
new Numeric(super.logarithm(undefined === value ? undefined : new Numeric(value)));
|
|
386
227
|
|
|
387
|
-
|
|
388
|
-
return super.lte(new Numeric(value));
|
|
389
|
-
}
|
|
228
|
+
lt = (value: NumericValue) => super.lt(new Numeric(value));
|
|
390
229
|
|
|
391
|
-
|
|
392
|
-
return new Numeric(super.minus(new Numeric(value)));
|
|
393
|
-
}
|
|
230
|
+
lte = (value: NumericValue) => super.lte(new Numeric(value));
|
|
394
231
|
|
|
395
|
-
|
|
396
|
-
return new Numeric(super.mod(new Numeric(value)));
|
|
397
|
-
}
|
|
232
|
+
minus = (value: NumericValue) => new Numeric(super.minus(new Numeric(value)));
|
|
398
233
|
|
|
399
|
-
|
|
400
|
-
return new Numeric(super.modulo(new Numeric(value)));
|
|
401
|
-
}
|
|
234
|
+
mod = (value: NumericValue) => new Numeric(super.mod(new Numeric(value)));
|
|
402
235
|
|
|
403
|
-
|
|
404
|
-
return new Numeric(super.mul(new Numeric(value)));
|
|
405
|
-
}
|
|
236
|
+
modulo = (value: NumericValue) => new Numeric(super.modulo(new Numeric(value)));
|
|
406
237
|
|
|
407
|
-
|
|
408
|
-
return new Numeric(super.naturalExponential());
|
|
409
|
-
}
|
|
238
|
+
mul = (value: NumericValue) => new Numeric(super.mul(new Numeric(value)));
|
|
410
239
|
|
|
411
|
-
|
|
412
|
-
return new Numeric(super.naturalLogarithm());
|
|
413
|
-
}
|
|
240
|
+
naturalExponential = () => new Numeric(super.naturalExponential());
|
|
414
241
|
|
|
415
|
-
|
|
416
|
-
return new Numeric(super.neg());
|
|
417
|
-
}
|
|
242
|
+
naturalLogarithm = () => new Numeric(super.naturalLogarithm());
|
|
418
243
|
|
|
419
|
-
|
|
420
|
-
return new Numeric(super.negated());
|
|
421
|
-
}
|
|
244
|
+
neg = () => new Numeric(super.neg());
|
|
422
245
|
|
|
423
|
-
|
|
424
|
-
return new Numeric(super.plus(new Numeric(value)));
|
|
425
|
-
}
|
|
246
|
+
negated = () => new Numeric(super.negated());
|
|
426
247
|
|
|
427
|
-
|
|
428
|
-
return new Numeric(super.pow(new Numeric(value)));
|
|
429
|
-
}
|
|
248
|
+
plus = (value: NumericValue) => new Numeric(super.plus(new Numeric(value)));
|
|
430
249
|
|
|
431
|
-
|
|
432
|
-
return new Numeric(super.round());
|
|
433
|
-
}
|
|
250
|
+
pow = (value: NumericValue) => new Numeric(super.pow(new Numeric(value)));
|
|
434
251
|
|
|
435
|
-
|
|
436
|
-
return new Numeric(super.sin());
|
|
437
|
-
}
|
|
252
|
+
round = () => new Numeric(super.round());
|
|
438
253
|
|
|
439
|
-
|
|
440
|
-
return new Numeric(super.sine());
|
|
441
|
-
}
|
|
254
|
+
sin = () => new Numeric(super.sin());
|
|
442
255
|
|
|
443
|
-
|
|
444
|
-
return new Numeric(super.sinh());
|
|
445
|
-
}
|
|
256
|
+
sine = () => new Numeric(super.sine());
|
|
446
257
|
|
|
447
|
-
|
|
448
|
-
return new Numeric(super.sqrt());
|
|
449
|
-
}
|
|
258
|
+
sinh = () => new Numeric(super.sinh());
|
|
450
259
|
|
|
451
|
-
|
|
452
|
-
return new Numeric(super.squareRoot());
|
|
453
|
-
}
|
|
260
|
+
sqrt = () => new Numeric(super.sqrt());
|
|
454
261
|
|
|
455
|
-
|
|
456
|
-
return new Numeric(super.sub(new Numeric(value)));
|
|
457
|
-
}
|
|
262
|
+
squareRoot = () => new Numeric(super.squareRoot());
|
|
458
263
|
|
|
459
|
-
|
|
460
|
-
return new Numeric(super.tan());
|
|
461
|
-
}
|
|
264
|
+
sub = (value: NumericValue) => new Numeric(super.sub(new Numeric(value)));
|
|
462
265
|
|
|
463
|
-
|
|
464
|
-
return new Numeric(super.tangent());
|
|
465
|
-
}
|
|
266
|
+
tan = () => new Numeric(super.tan());
|
|
466
267
|
|
|
467
|
-
|
|
468
|
-
return new Numeric(super.tanh());
|
|
469
|
-
}
|
|
268
|
+
tangent = () => new Numeric(super.tangent());
|
|
470
269
|
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
270
|
+
tanh = () => new Numeric(super.tanh());
|
|
271
|
+
|
|
272
|
+
times = (value: NumericValue) => new Numeric(super.times(new Numeric(value)));
|
|
474
273
|
|
|
475
|
-
toDP(decimalPlaces?: number, rounding?: Decimal.Rounding)
|
|
476
|
-
|
|
274
|
+
toDP = (decimalPlaces?: number, rounding?: Decimal.Rounding) =>
|
|
275
|
+
new Numeric(
|
|
477
276
|
undefined !== rounding && undefined !== decimalPlaces
|
|
478
277
|
? super.toDP(decimalPlaces, rounding)
|
|
479
278
|
: super.toDP(decimalPlaces)
|
|
480
279
|
);
|
|
481
|
-
}
|
|
482
280
|
|
|
483
|
-
toDecimalPlaces(decimalPlaces?: number, rounding?: Decimal.Rounding)
|
|
484
|
-
|
|
281
|
+
toDecimalPlaces = (decimalPlaces?: number, rounding?: Decimal.Rounding) =>
|
|
282
|
+
new Numeric(
|
|
485
283
|
undefined !== rounding && undefined !== decimalPlaces
|
|
486
284
|
? super.toDecimalPlaces(decimalPlaces, rounding)
|
|
487
285
|
: super.toDecimalPlaces(decimalPlaces)
|
|
488
286
|
);
|
|
489
|
-
}
|
|
490
287
|
|
|
491
|
-
toFraction(maxDenominator?: NumericValue)
|
|
492
|
-
|
|
493
|
-
}
|
|
288
|
+
toFraction = (maxDenominator?: NumericValue) =>
|
|
289
|
+
toNumerics(super.toFraction(undefined === maxDenominator ? undefined : new Numeric(maxDenominator)));
|
|
494
290
|
|
|
495
|
-
toNearest(value: NumericValue, rounding?: Decimal.Rounding)
|
|
496
|
-
|
|
497
|
-
}
|
|
291
|
+
toNearest = (value: NumericValue, rounding?: Decimal.Rounding) =>
|
|
292
|
+
new Numeric(super.toNearest(new Numeric(value), rounding));
|
|
498
293
|
|
|
499
|
-
toPower(value: NumericValue)
|
|
500
|
-
return new Numeric(super.toPower(new Numeric(value)));
|
|
501
|
-
}
|
|
294
|
+
toPower = (value: NumericValue) => new Numeric(super.toPower(new Numeric(value)));
|
|
502
295
|
|
|
503
|
-
toSD(decimalPlaces?: number, rounding?: Decimal.Rounding)
|
|
504
|
-
|
|
296
|
+
toSD = (decimalPlaces?: number, rounding?: Decimal.Rounding) =>
|
|
297
|
+
new Numeric(
|
|
505
298
|
undefined !== rounding && undefined !== decimalPlaces
|
|
506
299
|
? super.toSD(decimalPlaces, rounding)
|
|
507
300
|
: super.toSD(decimalPlaces)
|
|
508
301
|
);
|
|
509
|
-
}
|
|
510
302
|
|
|
511
|
-
toSignificantDigits(decimalPlaces?: number, rounding?: Decimal.Rounding)
|
|
512
|
-
|
|
303
|
+
toSignificantDigits = (decimalPlaces?: number, rounding?: Decimal.Rounding) =>
|
|
304
|
+
new Numeric(
|
|
513
305
|
undefined !== rounding && undefined !== decimalPlaces
|
|
514
306
|
? super.toSignificantDigits(decimalPlaces, rounding)
|
|
515
307
|
: super.toSignificantDigits(decimalPlaces)
|
|
516
308
|
);
|
|
517
|
-
}
|
|
518
309
|
|
|
519
|
-
trunc()
|
|
520
|
-
return new Numeric(super.trunc());
|
|
521
|
-
}
|
|
310
|
+
trunc = () => new Numeric(super.trunc());
|
|
522
311
|
|
|
523
|
-
truncated()
|
|
524
|
-
return new Numeric(super.truncated());
|
|
525
|
-
}
|
|
312
|
+
truncated = () => new Numeric(super.truncated());
|
|
526
313
|
|
|
527
|
-
inspect(depth: number, options: InspectOptionsStylized) {
|
|
314
|
+
inspect = (depth: number, options: InspectOptionsStylized) => {
|
|
528
315
|
const value = this.toFixed();
|
|
529
316
|
return isNode ? options.stylize(value, 'bigint') : value;
|
|
530
|
-
}
|
|
317
|
+
};
|
|
531
318
|
}
|
|
532
319
|
|
|
533
|
-
export const toNumeric = (value: NumericValue) =>
|
|
534
|
-
return new Numeric(value);
|
|
535
|
-
};
|
|
320
|
+
export const toNumeric = (value: NumericValue) => new Numeric(value);
|
|
536
321
|
|
|
537
|
-
export const toNumerics = (values: NumericValue[]) =>
|
|
538
|
-
return values.map(toNumeric);
|
|
539
|
-
};
|
|
322
|
+
export const toNumerics = (values: NumericValue[]) => values.map(toNumeric);
|
|
540
323
|
|
|
541
|
-
export const toIntegerString = (value: NumericValue) =>
|
|
542
|
-
return toNumeric(value).toFixed(0);
|
|
543
|
-
};
|
|
324
|
+
export const toIntegerString = (value: NumericValue) => toNumeric(value).toFixed(0);
|
|
544
325
|
|
|
545
|
-
export const toBigInt = (value: NumericValue) =>
|
|
546
|
-
return BigInt(toIntegerString(value));
|
|
547
|
-
};
|
|
326
|
+
export const toBigInt = (value: NumericValue) => BigInt(toIntegerString(value));
|
|
548
327
|
|
|
549
|
-
export const toBN = (value: NumericValue) =>
|
|
550
|
-
return new BN(toIntegerString(value));
|
|
551
|
-
};
|
|
328
|
+
export const toBN = (value: NumericValue) => new BN(toIntegerString(value));
|
|
552
329
|
|
|
553
|
-
export const toBigInteger = (value: NumericValue) =>
|
|
554
|
-
return bigInt(toIntegerString(value));
|
|
555
|
-
};
|
|
330
|
+
export const toBigInteger = (value: NumericValue) => bigInt(toIntegerString(value));
|
|
556
331
|
|
|
557
|
-
export const toBigNumber = (value: NumericValue) =>
|
|
558
|
-
return BigNumber.from(toIntegerString(value));
|
|
559
|
-
};
|
|
332
|
+
export const toBigNumber = (value: NumericValue) => BigNumber.from(toIntegerString(value));
|
|
560
333
|
|
|
561
|
-
export const createArrayCompareFunction = (ascending: boolean = true) =>
|
|
562
|
-
|
|
563
|
-
return ascending
|
|
334
|
+
export const createArrayCompareFunction = (ascending: boolean = true) =>
|
|
335
|
+
ascending
|
|
564
336
|
? (left: NumericValue, right: NumericValue) => Numeric.sub(left, right).toNumber()
|
|
565
337
|
: (left: NumericValue, right: NumericValue) => Numeric.sub(right, left).toNumber();
|
|
566
|
-
};
|
|
567
338
|
|
|
568
339
|
export const formatValue = (value: NumericValue, options?: IFormatNumberOptions) => {
|
|
569
340
|
const format = formatter(options);
|
package/tsc-multi.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"targets": [
|
|
3
|
-
{ "extname": ".mjs", "module": "
|
|
4
|
-
{ "extname": ".js", "module": "
|
|
5
|
-
]
|
|
3
|
+
{ "extname": ".mjs", "module": "ESNext", "moduleResolution": "NodeNext" },
|
|
4
|
+
{ "extname": ".js", "module": "CommonJS", "moduleResolution": "Node" }
|
|
5
|
+
],
|
|
6
|
+
"projects": ["."]
|
|
6
7
|
}
|