@agrozyme/numeric 1.0.21 → 1.0.23
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/lib/index.d.ts +9 -4
- package/lib/index.js +16 -11
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +8 -3
- package/lib/index.mjs.map +1 -1
- package/lib/numeric.d.ts +50 -41
- package/lib/numeric.js +130 -106
- package/lib/numeric.js.map +1 -1
- package/lib/numeric.mjs +118 -101
- package/lib/numeric.mjs.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +10 -7
- package/src/numeric.ts +146 -122
- package/lib/convert.d.ts +0 -11
- package/lib/convert.js +0 -23
- package/lib/convert.js.map +0 -1
- package/lib/convert.mjs +0 -12
- package/lib/convert.mjs.map +0 -1
- package/src/convert.ts +0 -12
package/src/numeric.ts
CHANGED
|
@@ -3,15 +3,21 @@ import { hexlify, isBytesLike } from '@ethersproject/bytes';
|
|
|
3
3
|
import bigInt from 'big-integer';
|
|
4
4
|
import BN from 'bn.js';
|
|
5
5
|
import { isNode } from 'browser-or-node';
|
|
6
|
+
import 'decimal.js';
|
|
6
7
|
import { Decimal } from 'decimal.js';
|
|
7
8
|
import { InspectOptionsStylized } from 'node:util';
|
|
8
|
-
import { toNumerics } from './convert';
|
|
9
|
-
|
|
10
|
-
const inspect = Symbol.for('nodejs.util.inspect.custom');
|
|
11
9
|
|
|
12
10
|
export type NumericValue = Numeric | Decimal.Value | bigInt.BigNumber | BigNumberish;
|
|
13
11
|
|
|
14
|
-
|
|
12
|
+
export const toNumeric = (value: NumericValue) => new Numeric(value);
|
|
13
|
+
export const toNumerics = (values: NumericValue[]) => values.map(toNumeric);
|
|
14
|
+
export const toIntegerString = (value: NumericValue) => toNumeric(value).toFixed(0);
|
|
15
|
+
export const toBigInt = (value: NumericValue) => BigInt(toIntegerString(value));
|
|
16
|
+
export const toBN = (value: NumericValue) => new BN(toIntegerString(value));
|
|
17
|
+
export const toBigInteger = (value: NumericValue) => bigInt(toIntegerString(value));
|
|
18
|
+
export const toBigNumber = (value: NumericValue) => BigNumber.from(toIntegerString(value));
|
|
19
|
+
|
|
20
|
+
// noinspection JSUnusedGlobalSymbols
|
|
15
21
|
export class Numeric extends Decimal {
|
|
16
22
|
// private readonly toStringTag: string = 'Decimal';
|
|
17
23
|
|
|
@@ -40,9 +46,9 @@ export class Numeric extends Decimal {
|
|
|
40
46
|
}
|
|
41
47
|
}
|
|
42
48
|
|
|
43
|
-
get [Symbol.toStringTag]() {
|
|
44
|
-
|
|
45
|
-
}
|
|
49
|
+
// get [Symbol.toStringTag]() {
|
|
50
|
+
// return 'Numeric';
|
|
51
|
+
// }
|
|
46
52
|
|
|
47
53
|
static abs(value: NumericValue) {
|
|
48
54
|
return new Numeric(value).abs();
|
|
@@ -72,14 +78,14 @@ export class Numeric extends Decimal {
|
|
|
72
78
|
return new Numeric(value).atan();
|
|
73
79
|
}
|
|
74
80
|
|
|
75
|
-
static atan2(x: NumericValue, y: NumericValue) {
|
|
76
|
-
return new Numeric(Decimal.atan2(new Numeric(x), new Numeric(y)));
|
|
77
|
-
}
|
|
78
|
-
|
|
79
81
|
static atanh(value: NumericValue) {
|
|
80
82
|
return new Numeric(value).atanh();
|
|
81
83
|
}
|
|
82
84
|
|
|
85
|
+
static atan2(x: NumericValue, y: NumericValue) {
|
|
86
|
+
return new Numeric(Decimal.atan2(new Numeric(x), new Numeric(y)));
|
|
87
|
+
}
|
|
88
|
+
|
|
83
89
|
static cbrt(value: NumericValue) {
|
|
84
90
|
return new Numeric(value).cbrt();
|
|
85
91
|
}
|
|
@@ -88,6 +94,10 @@ export class Numeric extends Decimal {
|
|
|
88
94
|
return new Numeric(value).ceil();
|
|
89
95
|
}
|
|
90
96
|
|
|
97
|
+
static clamp(value: NumericValue, min: NumericValue, max: NumericValue) {
|
|
98
|
+
return new Numeric(Decimal.clamp(new Numeric(value), new Numeric(min), new Numeric(max)));
|
|
99
|
+
}
|
|
100
|
+
|
|
91
101
|
static cos(value: NumericValue) {
|
|
92
102
|
return new Numeric(value).cos();
|
|
93
103
|
}
|
|
@@ -120,14 +130,14 @@ export class Numeric extends Decimal {
|
|
|
120
130
|
return new Numeric(value).log(base);
|
|
121
131
|
}
|
|
122
132
|
|
|
123
|
-
static log10(value: NumericValue) {
|
|
124
|
-
return new Numeric(value).log(10);
|
|
125
|
-
}
|
|
126
|
-
|
|
127
133
|
static log2(value: NumericValue) {
|
|
128
134
|
return new Numeric(value).log(2);
|
|
129
135
|
}
|
|
130
136
|
|
|
137
|
+
static log10(value: NumericValue) {
|
|
138
|
+
return new Numeric(value).log(10);
|
|
139
|
+
}
|
|
140
|
+
|
|
131
141
|
static max(...values: NumericValue[]) {
|
|
132
142
|
return new Numeric(Decimal.max(...toNumerics(values)));
|
|
133
143
|
}
|
|
@@ -180,6 +190,10 @@ export class Numeric extends Decimal {
|
|
|
180
190
|
return new Numeric(x).sub(y);
|
|
181
191
|
}
|
|
182
192
|
|
|
193
|
+
static sum(...values: NumericValue[]) {
|
|
194
|
+
return new Numeric(Decimal.sum(...toNumerics(values)));
|
|
195
|
+
}
|
|
196
|
+
|
|
183
197
|
static tan(value: NumericValue) {
|
|
184
198
|
return new Numeric(value).tan();
|
|
185
199
|
}
|
|
@@ -192,100 +206,72 @@ export class Numeric extends Decimal {
|
|
|
192
206
|
return new Numeric(value).trunc();
|
|
193
207
|
}
|
|
194
208
|
|
|
195
|
-
abs() {
|
|
196
|
-
return new Numeric(super.abs());
|
|
197
|
-
}
|
|
198
|
-
|
|
199
209
|
absoluteValue() {
|
|
200
210
|
return new Numeric(super.absoluteValue());
|
|
201
211
|
}
|
|
202
212
|
|
|
203
|
-
|
|
204
|
-
return new Numeric(super.
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
acosh() {
|
|
208
|
-
return new Numeric(super.acosh());
|
|
209
|
-
}
|
|
210
|
-
|
|
211
|
-
add(value: NumericValue) {
|
|
212
|
-
return new Numeric(super.add(new Numeric(value)));
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
asin() {
|
|
216
|
-
return new Numeric(super.asin());
|
|
217
|
-
}
|
|
218
|
-
|
|
219
|
-
asinh() {
|
|
220
|
-
return new Numeric(super.asinh());
|
|
213
|
+
abs() {
|
|
214
|
+
return new Numeric(super.abs());
|
|
221
215
|
}
|
|
222
216
|
|
|
223
|
-
|
|
224
|
-
return new Numeric(super.
|
|
217
|
+
ceil() {
|
|
218
|
+
return new Numeric(super.ceil());
|
|
225
219
|
}
|
|
226
220
|
|
|
227
|
-
|
|
228
|
-
return new Numeric(super.
|
|
221
|
+
clampedTo(min: NumericValue, max: NumericValue) {
|
|
222
|
+
return new Numeric(super.clampedTo(new Numeric(min), new Numeric(max)));
|
|
229
223
|
}
|
|
230
224
|
|
|
231
|
-
|
|
232
|
-
return new Numeric(super.
|
|
225
|
+
clamp(min: NumericValue, max: NumericValue) {
|
|
226
|
+
return new Numeric(super.clamp(new Numeric(min), new Numeric(max)));
|
|
233
227
|
}
|
|
234
228
|
|
|
235
|
-
|
|
236
|
-
return new Numeric(
|
|
229
|
+
comparedTo(value: NumericValue) {
|
|
230
|
+
return super.comparedTo(new Numeric(value));
|
|
237
231
|
}
|
|
238
232
|
|
|
239
233
|
cmp(value: NumericValue) {
|
|
240
234
|
return super.cmp(new Numeric(value));
|
|
241
235
|
}
|
|
242
236
|
|
|
243
|
-
|
|
244
|
-
return
|
|
237
|
+
cosine() {
|
|
238
|
+
return new Numeric(super.cosine());
|
|
245
239
|
}
|
|
246
240
|
|
|
247
241
|
cos() {
|
|
248
242
|
return new Numeric(super.cos());
|
|
249
243
|
}
|
|
250
244
|
|
|
251
|
-
cosh() {
|
|
252
|
-
return new Numeric(super.cosh());
|
|
253
|
-
}
|
|
254
|
-
|
|
255
|
-
cosine() {
|
|
256
|
-
return new Numeric(super.cosine());
|
|
257
|
-
}
|
|
258
|
-
|
|
259
245
|
cubeRoot() {
|
|
260
246
|
return new Numeric(super.cubeRoot());
|
|
261
247
|
}
|
|
262
248
|
|
|
263
|
-
|
|
264
|
-
return new Numeric(super.
|
|
265
|
-
}
|
|
266
|
-
|
|
267
|
-
divToInt(value: NumericValue) {
|
|
268
|
-
return new Numeric(super.divToInt(new Numeric(value)));
|
|
249
|
+
cbrt() {
|
|
250
|
+
return new Numeric(super.cbrt());
|
|
269
251
|
}
|
|
270
252
|
|
|
271
253
|
dividedBy(value: NumericValue) {
|
|
272
254
|
return new Numeric(super.dividedBy(new Numeric(value)));
|
|
273
255
|
}
|
|
274
256
|
|
|
257
|
+
div(value: NumericValue) {
|
|
258
|
+
return new Numeric(super.div(new Numeric(value)));
|
|
259
|
+
}
|
|
260
|
+
|
|
275
261
|
dividedToIntegerBy(value: NumericValue) {
|
|
276
262
|
return new Numeric(super.dividedToIntegerBy(new Numeric(value)));
|
|
277
263
|
}
|
|
278
264
|
|
|
279
|
-
|
|
280
|
-
return super.
|
|
265
|
+
divToInt(value: NumericValue) {
|
|
266
|
+
return new Numeric(super.divToInt(new Numeric(value)));
|
|
281
267
|
}
|
|
282
268
|
|
|
283
269
|
equals(value: NumericValue) {
|
|
284
270
|
return super.equals(new Numeric(value));
|
|
285
271
|
}
|
|
286
272
|
|
|
287
|
-
|
|
288
|
-
return new Numeric(
|
|
273
|
+
eq(value: NumericValue) {
|
|
274
|
+
return super.eq(new Numeric(value));
|
|
289
275
|
}
|
|
290
276
|
|
|
291
277
|
floor() {
|
|
@@ -296,14 +282,14 @@ export class Numeric extends Decimal {
|
|
|
296
282
|
return super.greaterThan(new Numeric(value));
|
|
297
283
|
}
|
|
298
284
|
|
|
299
|
-
greaterThanOrEqualTo(value: NumericValue) {
|
|
300
|
-
return super.greaterThanOrEqualTo(new Numeric(value));
|
|
301
|
-
}
|
|
302
|
-
|
|
303
285
|
gt(value: NumericValue) {
|
|
304
286
|
return super.gt(new Numeric(value));
|
|
305
287
|
}
|
|
306
288
|
|
|
289
|
+
greaterThanOrEqualTo(value: NumericValue) {
|
|
290
|
+
return super.greaterThanOrEqualTo(new Numeric(value));
|
|
291
|
+
}
|
|
292
|
+
|
|
307
293
|
gte(value: NumericValue) {
|
|
308
294
|
return super.gte(new Numeric(value));
|
|
309
295
|
}
|
|
@@ -312,156 +298,180 @@ export class Numeric extends Decimal {
|
|
|
312
298
|
return new Numeric(super.hyperbolicCosine());
|
|
313
299
|
}
|
|
314
300
|
|
|
301
|
+
cosh() {
|
|
302
|
+
return new Numeric(super.cosh());
|
|
303
|
+
}
|
|
304
|
+
|
|
315
305
|
hyperbolicSine() {
|
|
316
306
|
return new Numeric(super.hyperbolicSine());
|
|
317
307
|
}
|
|
318
308
|
|
|
309
|
+
sinh() {
|
|
310
|
+
return new Numeric(super.sinh());
|
|
311
|
+
}
|
|
312
|
+
|
|
319
313
|
hyperbolicTangent() {
|
|
320
314
|
return new Numeric(super.hyperbolicTangent());
|
|
321
315
|
}
|
|
322
316
|
|
|
317
|
+
tanh() {
|
|
318
|
+
return new Numeric(super.tanh());
|
|
319
|
+
}
|
|
320
|
+
|
|
323
321
|
inverseCosine() {
|
|
324
322
|
return new Numeric(super.inverseCosine());
|
|
325
323
|
}
|
|
326
324
|
|
|
325
|
+
acos() {
|
|
326
|
+
return new Numeric(super.acos());
|
|
327
|
+
}
|
|
328
|
+
|
|
327
329
|
inverseHyperbolicCosine() {
|
|
328
330
|
return new Numeric(super.inverseHyperbolicCosine());
|
|
329
331
|
}
|
|
330
332
|
|
|
333
|
+
acosh() {
|
|
334
|
+
return new Numeric(super.acosh());
|
|
335
|
+
}
|
|
336
|
+
|
|
331
337
|
inverseHyperbolicSine() {
|
|
332
338
|
return new Numeric(super.inverseHyperbolicSine());
|
|
333
339
|
}
|
|
334
340
|
|
|
341
|
+
asinh() {
|
|
342
|
+
return new Numeric(super.asinh());
|
|
343
|
+
}
|
|
344
|
+
|
|
335
345
|
inverseHyperbolicTangent() {
|
|
336
346
|
return new Numeric(super.inverseHyperbolicTangent());
|
|
337
347
|
}
|
|
338
348
|
|
|
349
|
+
atanh() {
|
|
350
|
+
return new Numeric(super.atanh());
|
|
351
|
+
}
|
|
352
|
+
|
|
339
353
|
inverseSine() {
|
|
340
354
|
return new Numeric(super.inverseSine());
|
|
341
355
|
}
|
|
342
356
|
|
|
357
|
+
asin() {
|
|
358
|
+
return new Numeric(super.asin());
|
|
359
|
+
}
|
|
360
|
+
|
|
343
361
|
inverseTangent() {
|
|
344
362
|
return new Numeric(super.inverseTangent());
|
|
345
363
|
}
|
|
346
364
|
|
|
365
|
+
atan() {
|
|
366
|
+
return new Numeric(super.atan());
|
|
367
|
+
}
|
|
368
|
+
|
|
347
369
|
lessThan(value: NumericValue) {
|
|
348
370
|
return super.lessThan(new Numeric(value));
|
|
349
371
|
}
|
|
350
372
|
|
|
351
|
-
|
|
352
|
-
return super.
|
|
373
|
+
lt(value: NumericValue) {
|
|
374
|
+
return super.lt(new Numeric(value));
|
|
353
375
|
}
|
|
354
376
|
|
|
355
|
-
|
|
356
|
-
return new Numeric(
|
|
377
|
+
lessThanOrEqualTo(value: NumericValue) {
|
|
378
|
+
return super.lessThanOrEqualTo(new Numeric(value));
|
|
357
379
|
}
|
|
358
380
|
|
|
359
|
-
|
|
360
|
-
return
|
|
381
|
+
lte(value: NumericValue) {
|
|
382
|
+
return super.lte(new Numeric(value));
|
|
361
383
|
}
|
|
362
384
|
|
|
363
385
|
logarithm(value?: NumericValue) {
|
|
364
386
|
return new Numeric(super.logarithm(undefined === value ? undefined : new Numeric(value)));
|
|
365
387
|
}
|
|
366
388
|
|
|
367
|
-
|
|
368
|
-
return super.
|
|
369
|
-
}
|
|
370
|
-
|
|
371
|
-
lte(value: NumericValue) {
|
|
372
|
-
return super.lte(new Numeric(value));
|
|
389
|
+
log(value?: NumericValue) {
|
|
390
|
+
return new Numeric(super.log(undefined === value ? undefined : new Numeric(value)));
|
|
373
391
|
}
|
|
374
392
|
|
|
375
393
|
minus(value: NumericValue) {
|
|
376
394
|
return new Numeric(super.minus(new Numeric(value)));
|
|
377
395
|
}
|
|
378
396
|
|
|
379
|
-
|
|
380
|
-
return new Numeric(super.
|
|
397
|
+
sub(value: NumericValue) {
|
|
398
|
+
return new Numeric(super.sub(new Numeric(value)));
|
|
381
399
|
}
|
|
382
400
|
|
|
383
401
|
modulo(value: NumericValue) {
|
|
384
402
|
return new Numeric(super.modulo(new Numeric(value)));
|
|
385
403
|
}
|
|
386
404
|
|
|
387
|
-
|
|
388
|
-
return new Numeric(super.
|
|
405
|
+
mod(value: NumericValue) {
|
|
406
|
+
return new Numeric(super.mod(new Numeric(value)));
|
|
389
407
|
}
|
|
390
408
|
|
|
391
409
|
naturalExponential() {
|
|
392
410
|
return new Numeric(super.naturalExponential());
|
|
393
411
|
}
|
|
394
412
|
|
|
413
|
+
exp() {
|
|
414
|
+
return new Numeric(super.exp());
|
|
415
|
+
}
|
|
416
|
+
|
|
395
417
|
naturalLogarithm() {
|
|
396
418
|
return new Numeric(super.naturalLogarithm());
|
|
397
419
|
}
|
|
398
420
|
|
|
399
|
-
|
|
400
|
-
return new Numeric(super.
|
|
421
|
+
ln() {
|
|
422
|
+
return new Numeric(super.ln());
|
|
401
423
|
}
|
|
402
424
|
|
|
403
425
|
negated() {
|
|
404
426
|
return new Numeric(super.negated());
|
|
405
427
|
}
|
|
406
428
|
|
|
429
|
+
neg() {
|
|
430
|
+
return new Numeric(super.neg());
|
|
431
|
+
}
|
|
432
|
+
|
|
407
433
|
plus(value: NumericValue) {
|
|
408
434
|
return new Numeric(super.plus(new Numeric(value)));
|
|
409
435
|
}
|
|
410
436
|
|
|
411
|
-
|
|
412
|
-
return new Numeric(super.
|
|
437
|
+
add(value: NumericValue) {
|
|
438
|
+
return new Numeric(super.add(new Numeric(value)));
|
|
413
439
|
}
|
|
414
440
|
|
|
415
441
|
round() {
|
|
416
442
|
return new Numeric(super.round());
|
|
417
443
|
}
|
|
418
444
|
|
|
419
|
-
sin() {
|
|
420
|
-
return new Numeric(super.sin());
|
|
421
|
-
}
|
|
422
|
-
|
|
423
445
|
sine() {
|
|
424
446
|
return new Numeric(super.sine());
|
|
425
447
|
}
|
|
426
448
|
|
|
427
|
-
|
|
428
|
-
return new Numeric(super.
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
sqrt() {
|
|
432
|
-
return new Numeric(super.sqrt());
|
|
449
|
+
sin() {
|
|
450
|
+
return new Numeric(super.sin());
|
|
433
451
|
}
|
|
434
452
|
|
|
435
453
|
squareRoot() {
|
|
436
454
|
return new Numeric(super.squareRoot());
|
|
437
455
|
}
|
|
438
456
|
|
|
439
|
-
|
|
440
|
-
return new Numeric(super.
|
|
441
|
-
}
|
|
442
|
-
|
|
443
|
-
tan() {
|
|
444
|
-
return new Numeric(super.tan());
|
|
457
|
+
sqrt() {
|
|
458
|
+
return new Numeric(super.sqrt());
|
|
445
459
|
}
|
|
446
460
|
|
|
447
461
|
tangent() {
|
|
448
462
|
return new Numeric(super.tangent());
|
|
449
463
|
}
|
|
450
464
|
|
|
451
|
-
|
|
452
|
-
return new Numeric(super.
|
|
465
|
+
tan() {
|
|
466
|
+
return new Numeric(super.tan());
|
|
453
467
|
}
|
|
454
468
|
|
|
455
469
|
times(value: NumericValue) {
|
|
456
470
|
return new Numeric(super.times(new Numeric(value)));
|
|
457
471
|
}
|
|
458
472
|
|
|
459
|
-
|
|
460
|
-
return new Numeric(
|
|
461
|
-
undefined !== rounding && undefined !== decimalPlaces
|
|
462
|
-
? super.toDP(decimalPlaces, rounding)
|
|
463
|
-
: super.toDP(decimalPlaces)
|
|
464
|
-
);
|
|
473
|
+
mul(value: NumericValue) {
|
|
474
|
+
return new Numeric(super.mul(new Numeric(value)));
|
|
465
475
|
}
|
|
466
476
|
|
|
467
477
|
toDecimalPlaces(decimalPlaces?: number, rounding?: Decimal.Rounding) {
|
|
@@ -472,6 +482,14 @@ export class Numeric extends Decimal {
|
|
|
472
482
|
);
|
|
473
483
|
}
|
|
474
484
|
|
|
485
|
+
toDP(decimalPlaces?: number, rounding?: Decimal.Rounding) {
|
|
486
|
+
return new Numeric(
|
|
487
|
+
undefined !== rounding && undefined !== decimalPlaces
|
|
488
|
+
? super.toDP(decimalPlaces, rounding)
|
|
489
|
+
: super.toDP(decimalPlaces)
|
|
490
|
+
);
|
|
491
|
+
}
|
|
492
|
+
|
|
475
493
|
toFraction(maxDenominator?: NumericValue) {
|
|
476
494
|
return toNumerics(super.toFraction(undefined === maxDenominator ? undefined : new Numeric(maxDenominator)));
|
|
477
495
|
}
|
|
@@ -484,12 +502,8 @@ export class Numeric extends Decimal {
|
|
|
484
502
|
return new Numeric(super.toPower(new Numeric(value)));
|
|
485
503
|
}
|
|
486
504
|
|
|
487
|
-
|
|
488
|
-
return new Numeric(
|
|
489
|
-
undefined !== rounding && undefined !== decimalPlaces
|
|
490
|
-
? super.toSD(decimalPlaces, rounding)
|
|
491
|
-
: super.toSD(decimalPlaces)
|
|
492
|
-
);
|
|
505
|
+
pow(value: NumericValue) {
|
|
506
|
+
return new Numeric(super.pow(new Numeric(value)));
|
|
493
507
|
}
|
|
494
508
|
|
|
495
509
|
toSignificantDigits(decimalPlaces?: number, rounding?: Decimal.Rounding) {
|
|
@@ -500,18 +514,28 @@ export class Numeric extends Decimal {
|
|
|
500
514
|
);
|
|
501
515
|
}
|
|
502
516
|
|
|
503
|
-
|
|
504
|
-
return new Numeric(
|
|
517
|
+
toSD(decimalPlaces?: number, rounding?: Decimal.Rounding) {
|
|
518
|
+
return new Numeric(
|
|
519
|
+
undefined !== rounding && undefined !== decimalPlaces
|
|
520
|
+
? super.toSD(decimalPlaces, rounding)
|
|
521
|
+
: super.toSD(decimalPlaces)
|
|
522
|
+
);
|
|
505
523
|
}
|
|
506
524
|
|
|
507
525
|
truncated() {
|
|
508
526
|
return new Numeric(super.truncated());
|
|
509
527
|
}
|
|
510
528
|
|
|
529
|
+
trunc() {
|
|
530
|
+
return new Numeric(super.trunc());
|
|
531
|
+
}
|
|
532
|
+
|
|
511
533
|
inspect(depth: number, options: InspectOptionsStylized) {
|
|
512
534
|
const value = this.toFixed();
|
|
513
535
|
return isNode ? options.stylize(value, 'bigint') : value;
|
|
514
536
|
}
|
|
515
537
|
|
|
516
|
-
[inspect]
|
|
538
|
+
// [Symbol.for('nodejs.util.inspect.custom')](depth: number, options: InspectOptionsStylized) {
|
|
539
|
+
// return this.inspect(depth, options);
|
|
540
|
+
// }
|
|
517
541
|
}
|
package/lib/convert.d.ts
DELETED
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { BigNumber } from '@ethersproject/bignumber';
|
|
2
|
-
import bigInt from 'big-integer';
|
|
3
|
-
import BN from 'bn.js';
|
|
4
|
-
import { Numeric, NumericValue } from './numeric';
|
|
5
|
-
export declare const toNumeric: (value: NumericValue) => Numeric;
|
|
6
|
-
export declare const toNumerics: (values: NumericValue[]) => Numeric[];
|
|
7
|
-
export declare const toIntegerString: (value: NumericValue) => string;
|
|
8
|
-
export declare const toBigInt: (value: NumericValue) => bigint;
|
|
9
|
-
export declare const toBN: (value: NumericValue) => BN;
|
|
10
|
-
export declare const toBigInteger: (value: NumericValue) => bigInt.BigInteger;
|
|
11
|
-
export declare const toBigNumber: (value: NumericValue) => BigNumber;
|
package/lib/convert.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.toBigNumber = exports.toBigInteger = exports.toBN = exports.toBigInt = exports.toIntegerString = exports.toNumerics = exports.toNumeric = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const bignumber_1 = require("@ethersproject/bignumber");
|
|
6
|
-
const big_integer_1 = tslib_1.__importDefault(require("big-integer"));
|
|
7
|
-
const bn_js_1 = tslib_1.__importDefault(require("bn.js"));
|
|
8
|
-
const numeric_1 = require("./numeric.js");
|
|
9
|
-
const toNumeric = (value) => new numeric_1.Numeric(value);
|
|
10
|
-
exports.toNumeric = toNumeric;
|
|
11
|
-
const toNumerics = (values) => values.map(exports.toNumeric);
|
|
12
|
-
exports.toNumerics = toNumerics;
|
|
13
|
-
const toIntegerString = (value) => (0, exports.toNumeric)(value).toFixed(0);
|
|
14
|
-
exports.toIntegerString = toIntegerString;
|
|
15
|
-
const toBigInt = (value) => BigInt((0, exports.toIntegerString)(value));
|
|
16
|
-
exports.toBigInt = toBigInt;
|
|
17
|
-
const toBN = (value) => new bn_js_1.default((0, exports.toIntegerString)(value));
|
|
18
|
-
exports.toBN = toBN;
|
|
19
|
-
const toBigInteger = (value) => (0, big_integer_1.default)((0, exports.toIntegerString)(value));
|
|
20
|
-
exports.toBigInteger = toBigInteger;
|
|
21
|
-
const toBigNumber = (value) => bignumber_1.BigNumber.from((0, exports.toIntegerString)(value));
|
|
22
|
-
exports.toBigNumber = toBigNumber;
|
|
23
|
-
//# sourceMappingURL=convert.js.map
|
package/lib/convert.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"convert.js","sourceRoot":"","sources":["../src/convert.ts"],"names":[],"mappings":";;;;AAAA,wDAAqD;AACrD,sEAAiC;AACjC,0DAAuB;AACvB,0CAAkD;AAE3C,MAAM,SAAS,GAAG,CAAC,KAAmB,EAAE,EAAE,CAAC,IAAI,iBAAO,CAAC,KAAK,CAAC,CAAC;AAAxD,QAAA,SAAS,aAA+C;AAC9D,MAAM,UAAU,GAAG,CAAC,MAAsB,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,iBAAS,CAAC,CAAC;AAA/D,QAAA,UAAU,cAAqD;AACrE,MAAM,eAAe,GAAG,CAAC,KAAmB,EAAE,EAAE,CAAC,IAAA,iBAAS,EAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AAAvE,QAAA,eAAe,mBAAwD;AAC7E,MAAM,QAAQ,GAAG,CAAC,KAAmB,EAAE,EAAE,CAAC,MAAM,CAAC,IAAA,uBAAe,EAAC,KAAK,CAAC,CAAC,CAAC;AAAnE,QAAA,QAAQ,YAA2D;AACzE,MAAM,IAAI,GAAG,CAAC,KAAmB,EAAE,EAAE,CAAC,IAAI,eAAE,CAAC,IAAA,uBAAe,EAAC,KAAK,CAAC,CAAC,CAAC;AAA/D,QAAA,IAAI,QAA2D;AACrE,MAAM,YAAY,GAAG,CAAC,KAAmB,EAAE,EAAE,CAAC,IAAA,qBAAM,EAAC,IAAA,uBAAe,EAAC,KAAK,CAAC,CAAC,CAAC;AAAvE,QAAA,YAAY,gBAA2D;AAC7E,MAAM,WAAW,GAAG,CAAC,KAAmB,EAAE,EAAE,CAAC,qBAAS,CAAC,IAAI,CAAC,IAAA,uBAAe,EAAC,KAAK,CAAC,CAAC,CAAC;AAA9E,QAAA,WAAW,eAAmE"}
|
package/lib/convert.mjs
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { BigNumber } from '@ethersproject/bignumber';
|
|
2
|
-
import bigInt from 'big-integer';
|
|
3
|
-
import BN from 'bn.js';
|
|
4
|
-
import { Numeric } from "./numeric.mjs";
|
|
5
|
-
export const toNumeric = (value) => new Numeric(value);
|
|
6
|
-
export const toNumerics = (values) => values.map(toNumeric);
|
|
7
|
-
export const toIntegerString = (value) => toNumeric(value).toFixed(0);
|
|
8
|
-
export const toBigInt = (value) => BigInt(toIntegerString(value));
|
|
9
|
-
export const toBN = (value) => new BN(toIntegerString(value));
|
|
10
|
-
export const toBigInteger = (value) => bigInt(toIntegerString(value));
|
|
11
|
-
export const toBigNumber = (value) => BigNumber.from(toIntegerString(value));
|
|
12
|
-
//# sourceMappingURL=convert.mjs.map
|
package/lib/convert.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"convert.mjs","sourceRoot":"","sources":["../src/convert.ts"],"names":[],"mappings":"OAAO,EAAE,SAAS,EAAE,MAAM,0BAA0B;OAC7C,MAAM,MAAM,aAAa;OACzB,EAAE,MAAM,OAAO;OACf,EAAE,OAAO,EAAgB;AAEhC,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAmB,EAAE,EAAE,CAAC,IAAI,OAAO,CAAC,KAAK,CAAC,CAAC;AACrE,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,MAAsB,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;AAC5E,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,KAAmB,EAAE,EAAE,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AACpF,MAAM,CAAC,MAAM,QAAQ,GAAG,CAAC,KAAmB,EAAE,EAAE,CAAC,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC;AAChF,MAAM,CAAC,MAAM,IAAI,GAAG,CAAC,KAAmB,EAAE,EAAE,CAAC,IAAI,EAAE,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC;AAC5E,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAAmB,EAAE,EAAE,CAAC,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC;AACpF,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAmB,EAAE,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC,CAAC"}
|
package/src/convert.ts
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { BigNumber } from '@ethersproject/bignumber';
|
|
2
|
-
import bigInt from 'big-integer';
|
|
3
|
-
import BN from 'bn.js';
|
|
4
|
-
import { Numeric, NumericValue } from './numeric';
|
|
5
|
-
|
|
6
|
-
export const toNumeric = (value: NumericValue) => new Numeric(value);
|
|
7
|
-
export const toNumerics = (values: NumericValue[]) => values.map(toNumeric);
|
|
8
|
-
export const toIntegerString = (value: NumericValue) => toNumeric(value).toFixed(0);
|
|
9
|
-
export const toBigInt = (value: NumericValue) => BigInt(toIntegerString(value));
|
|
10
|
-
export const toBN = (value: NumericValue) => new BN(toIntegerString(value));
|
|
11
|
-
export const toBigInteger = (value: NumericValue) => bigInt(toIntegerString(value));
|
|
12
|
-
export const toBigNumber = (value: NumericValue) => BigNumber.from(toIntegerString(value));
|