@agrozyme/numeric 1.0.22 → 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 +4 -4
- package/lib/index.js +11 -11
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +3 -3
- package/lib/index.mjs.map +1 -1
- package/lib/numeric.d.ts +50 -37
- package/lib/numeric.js +127 -101
- package/lib/numeric.js.map +1 -1
- package/lib/numeric.mjs +115 -96
- package/lib/numeric.mjs.map +1 -1
- package/package.json +1 -1
- package/src/index.ts +4 -7
- package/src/numeric.ts +140 -116
- 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,13 +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
9
|
|
|
10
10
|
export type NumericValue = Numeric | Decimal.Value | bigInt.BigNumber | BigNumberish;
|
|
11
11
|
|
|
12
|
-
|
|
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
|
|
13
21
|
export class Numeric extends Decimal {
|
|
14
22
|
// private readonly toStringTag: string = 'Decimal';
|
|
15
23
|
|
|
@@ -70,14 +78,14 @@ export class Numeric extends Decimal {
|
|
|
70
78
|
return new Numeric(value).atan();
|
|
71
79
|
}
|
|
72
80
|
|
|
73
|
-
static atan2(x: NumericValue, y: NumericValue) {
|
|
74
|
-
return new Numeric(Decimal.atan2(new Numeric(x), new Numeric(y)));
|
|
75
|
-
}
|
|
76
|
-
|
|
77
81
|
static atanh(value: NumericValue) {
|
|
78
82
|
return new Numeric(value).atanh();
|
|
79
83
|
}
|
|
80
84
|
|
|
85
|
+
static atan2(x: NumericValue, y: NumericValue) {
|
|
86
|
+
return new Numeric(Decimal.atan2(new Numeric(x), new Numeric(y)));
|
|
87
|
+
}
|
|
88
|
+
|
|
81
89
|
static cbrt(value: NumericValue) {
|
|
82
90
|
return new Numeric(value).cbrt();
|
|
83
91
|
}
|
|
@@ -86,6 +94,10 @@ export class Numeric extends Decimal {
|
|
|
86
94
|
return new Numeric(value).ceil();
|
|
87
95
|
}
|
|
88
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
|
+
|
|
89
101
|
static cos(value: NumericValue) {
|
|
90
102
|
return new Numeric(value).cos();
|
|
91
103
|
}
|
|
@@ -118,14 +130,14 @@ export class Numeric extends Decimal {
|
|
|
118
130
|
return new Numeric(value).log(base);
|
|
119
131
|
}
|
|
120
132
|
|
|
121
|
-
static log10(value: NumericValue) {
|
|
122
|
-
return new Numeric(value).log(10);
|
|
123
|
-
}
|
|
124
|
-
|
|
125
133
|
static log2(value: NumericValue) {
|
|
126
134
|
return new Numeric(value).log(2);
|
|
127
135
|
}
|
|
128
136
|
|
|
137
|
+
static log10(value: NumericValue) {
|
|
138
|
+
return new Numeric(value).log(10);
|
|
139
|
+
}
|
|
140
|
+
|
|
129
141
|
static max(...values: NumericValue[]) {
|
|
130
142
|
return new Numeric(Decimal.max(...toNumerics(values)));
|
|
131
143
|
}
|
|
@@ -178,6 +190,10 @@ export class Numeric extends Decimal {
|
|
|
178
190
|
return new Numeric(x).sub(y);
|
|
179
191
|
}
|
|
180
192
|
|
|
193
|
+
static sum(...values: NumericValue[]) {
|
|
194
|
+
return new Numeric(Decimal.sum(...toNumerics(values)));
|
|
195
|
+
}
|
|
196
|
+
|
|
181
197
|
static tan(value: NumericValue) {
|
|
182
198
|
return new Numeric(value).tan();
|
|
183
199
|
}
|
|
@@ -190,100 +206,72 @@ export class Numeric extends Decimal {
|
|
|
190
206
|
return new Numeric(value).trunc();
|
|
191
207
|
}
|
|
192
208
|
|
|
193
|
-
abs() {
|
|
194
|
-
return new Numeric(super.abs());
|
|
195
|
-
}
|
|
196
|
-
|
|
197
209
|
absoluteValue() {
|
|
198
210
|
return new Numeric(super.absoluteValue());
|
|
199
211
|
}
|
|
200
212
|
|
|
201
|
-
|
|
202
|
-
return new Numeric(super.
|
|
203
|
-
}
|
|
204
|
-
|
|
205
|
-
acosh() {
|
|
206
|
-
return new Numeric(super.acosh());
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
add(value: NumericValue) {
|
|
210
|
-
return new Numeric(super.add(new Numeric(value)));
|
|
211
|
-
}
|
|
212
|
-
|
|
213
|
-
asin() {
|
|
214
|
-
return new Numeric(super.asin());
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
asinh() {
|
|
218
|
-
return new Numeric(super.asinh());
|
|
213
|
+
abs() {
|
|
214
|
+
return new Numeric(super.abs());
|
|
219
215
|
}
|
|
220
216
|
|
|
221
|
-
|
|
222
|
-
return new Numeric(super.
|
|
217
|
+
ceil() {
|
|
218
|
+
return new Numeric(super.ceil());
|
|
223
219
|
}
|
|
224
220
|
|
|
225
|
-
|
|
226
|
-
return new Numeric(super.
|
|
221
|
+
clampedTo(min: NumericValue, max: NumericValue) {
|
|
222
|
+
return new Numeric(super.clampedTo(new Numeric(min), new Numeric(max)));
|
|
227
223
|
}
|
|
228
224
|
|
|
229
|
-
|
|
230
|
-
return new Numeric(super.
|
|
225
|
+
clamp(min: NumericValue, max: NumericValue) {
|
|
226
|
+
return new Numeric(super.clamp(new Numeric(min), new Numeric(max)));
|
|
231
227
|
}
|
|
232
228
|
|
|
233
|
-
|
|
234
|
-
return new Numeric(
|
|
229
|
+
comparedTo(value: NumericValue) {
|
|
230
|
+
return super.comparedTo(new Numeric(value));
|
|
235
231
|
}
|
|
236
232
|
|
|
237
233
|
cmp(value: NumericValue) {
|
|
238
234
|
return super.cmp(new Numeric(value));
|
|
239
235
|
}
|
|
240
236
|
|
|
241
|
-
|
|
242
|
-
return
|
|
237
|
+
cosine() {
|
|
238
|
+
return new Numeric(super.cosine());
|
|
243
239
|
}
|
|
244
240
|
|
|
245
241
|
cos() {
|
|
246
242
|
return new Numeric(super.cos());
|
|
247
243
|
}
|
|
248
244
|
|
|
249
|
-
cosh() {
|
|
250
|
-
return new Numeric(super.cosh());
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
cosine() {
|
|
254
|
-
return new Numeric(super.cosine());
|
|
255
|
-
}
|
|
256
|
-
|
|
257
245
|
cubeRoot() {
|
|
258
246
|
return new Numeric(super.cubeRoot());
|
|
259
247
|
}
|
|
260
248
|
|
|
261
|
-
|
|
262
|
-
return new Numeric(super.
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
divToInt(value: NumericValue) {
|
|
266
|
-
return new Numeric(super.divToInt(new Numeric(value)));
|
|
249
|
+
cbrt() {
|
|
250
|
+
return new Numeric(super.cbrt());
|
|
267
251
|
}
|
|
268
252
|
|
|
269
253
|
dividedBy(value: NumericValue) {
|
|
270
254
|
return new Numeric(super.dividedBy(new Numeric(value)));
|
|
271
255
|
}
|
|
272
256
|
|
|
257
|
+
div(value: NumericValue) {
|
|
258
|
+
return new Numeric(super.div(new Numeric(value)));
|
|
259
|
+
}
|
|
260
|
+
|
|
273
261
|
dividedToIntegerBy(value: NumericValue) {
|
|
274
262
|
return new Numeric(super.dividedToIntegerBy(new Numeric(value)));
|
|
275
263
|
}
|
|
276
264
|
|
|
277
|
-
|
|
278
|
-
return super.
|
|
265
|
+
divToInt(value: NumericValue) {
|
|
266
|
+
return new Numeric(super.divToInt(new Numeric(value)));
|
|
279
267
|
}
|
|
280
268
|
|
|
281
269
|
equals(value: NumericValue) {
|
|
282
270
|
return super.equals(new Numeric(value));
|
|
283
271
|
}
|
|
284
272
|
|
|
285
|
-
|
|
286
|
-
return new Numeric(
|
|
273
|
+
eq(value: NumericValue) {
|
|
274
|
+
return super.eq(new Numeric(value));
|
|
287
275
|
}
|
|
288
276
|
|
|
289
277
|
floor() {
|
|
@@ -294,14 +282,14 @@ export class Numeric extends Decimal {
|
|
|
294
282
|
return super.greaterThan(new Numeric(value));
|
|
295
283
|
}
|
|
296
284
|
|
|
297
|
-
greaterThanOrEqualTo(value: NumericValue) {
|
|
298
|
-
return super.greaterThanOrEqualTo(new Numeric(value));
|
|
299
|
-
}
|
|
300
|
-
|
|
301
285
|
gt(value: NumericValue) {
|
|
302
286
|
return super.gt(new Numeric(value));
|
|
303
287
|
}
|
|
304
288
|
|
|
289
|
+
greaterThanOrEqualTo(value: NumericValue) {
|
|
290
|
+
return super.greaterThanOrEqualTo(new Numeric(value));
|
|
291
|
+
}
|
|
292
|
+
|
|
305
293
|
gte(value: NumericValue) {
|
|
306
294
|
return super.gte(new Numeric(value));
|
|
307
295
|
}
|
|
@@ -310,156 +298,180 @@ export class Numeric extends Decimal {
|
|
|
310
298
|
return new Numeric(super.hyperbolicCosine());
|
|
311
299
|
}
|
|
312
300
|
|
|
301
|
+
cosh() {
|
|
302
|
+
return new Numeric(super.cosh());
|
|
303
|
+
}
|
|
304
|
+
|
|
313
305
|
hyperbolicSine() {
|
|
314
306
|
return new Numeric(super.hyperbolicSine());
|
|
315
307
|
}
|
|
316
308
|
|
|
309
|
+
sinh() {
|
|
310
|
+
return new Numeric(super.sinh());
|
|
311
|
+
}
|
|
312
|
+
|
|
317
313
|
hyperbolicTangent() {
|
|
318
314
|
return new Numeric(super.hyperbolicTangent());
|
|
319
315
|
}
|
|
320
316
|
|
|
317
|
+
tanh() {
|
|
318
|
+
return new Numeric(super.tanh());
|
|
319
|
+
}
|
|
320
|
+
|
|
321
321
|
inverseCosine() {
|
|
322
322
|
return new Numeric(super.inverseCosine());
|
|
323
323
|
}
|
|
324
324
|
|
|
325
|
+
acos() {
|
|
326
|
+
return new Numeric(super.acos());
|
|
327
|
+
}
|
|
328
|
+
|
|
325
329
|
inverseHyperbolicCosine() {
|
|
326
330
|
return new Numeric(super.inverseHyperbolicCosine());
|
|
327
331
|
}
|
|
328
332
|
|
|
333
|
+
acosh() {
|
|
334
|
+
return new Numeric(super.acosh());
|
|
335
|
+
}
|
|
336
|
+
|
|
329
337
|
inverseHyperbolicSine() {
|
|
330
338
|
return new Numeric(super.inverseHyperbolicSine());
|
|
331
339
|
}
|
|
332
340
|
|
|
341
|
+
asinh() {
|
|
342
|
+
return new Numeric(super.asinh());
|
|
343
|
+
}
|
|
344
|
+
|
|
333
345
|
inverseHyperbolicTangent() {
|
|
334
346
|
return new Numeric(super.inverseHyperbolicTangent());
|
|
335
347
|
}
|
|
336
348
|
|
|
349
|
+
atanh() {
|
|
350
|
+
return new Numeric(super.atanh());
|
|
351
|
+
}
|
|
352
|
+
|
|
337
353
|
inverseSine() {
|
|
338
354
|
return new Numeric(super.inverseSine());
|
|
339
355
|
}
|
|
340
356
|
|
|
357
|
+
asin() {
|
|
358
|
+
return new Numeric(super.asin());
|
|
359
|
+
}
|
|
360
|
+
|
|
341
361
|
inverseTangent() {
|
|
342
362
|
return new Numeric(super.inverseTangent());
|
|
343
363
|
}
|
|
344
364
|
|
|
365
|
+
atan() {
|
|
366
|
+
return new Numeric(super.atan());
|
|
367
|
+
}
|
|
368
|
+
|
|
345
369
|
lessThan(value: NumericValue) {
|
|
346
370
|
return super.lessThan(new Numeric(value));
|
|
347
371
|
}
|
|
348
372
|
|
|
349
|
-
|
|
350
|
-
return super.
|
|
373
|
+
lt(value: NumericValue) {
|
|
374
|
+
return super.lt(new Numeric(value));
|
|
351
375
|
}
|
|
352
376
|
|
|
353
|
-
|
|
354
|
-
return new Numeric(
|
|
377
|
+
lessThanOrEqualTo(value: NumericValue) {
|
|
378
|
+
return super.lessThanOrEqualTo(new Numeric(value));
|
|
355
379
|
}
|
|
356
380
|
|
|
357
|
-
|
|
358
|
-
return
|
|
381
|
+
lte(value: NumericValue) {
|
|
382
|
+
return super.lte(new Numeric(value));
|
|
359
383
|
}
|
|
360
384
|
|
|
361
385
|
logarithm(value?: NumericValue) {
|
|
362
386
|
return new Numeric(super.logarithm(undefined === value ? undefined : new Numeric(value)));
|
|
363
387
|
}
|
|
364
388
|
|
|
365
|
-
|
|
366
|
-
return super.
|
|
367
|
-
}
|
|
368
|
-
|
|
369
|
-
lte(value: NumericValue) {
|
|
370
|
-
return super.lte(new Numeric(value));
|
|
389
|
+
log(value?: NumericValue) {
|
|
390
|
+
return new Numeric(super.log(undefined === value ? undefined : new Numeric(value)));
|
|
371
391
|
}
|
|
372
392
|
|
|
373
393
|
minus(value: NumericValue) {
|
|
374
394
|
return new Numeric(super.minus(new Numeric(value)));
|
|
375
395
|
}
|
|
376
396
|
|
|
377
|
-
|
|
378
|
-
return new Numeric(super.
|
|
397
|
+
sub(value: NumericValue) {
|
|
398
|
+
return new Numeric(super.sub(new Numeric(value)));
|
|
379
399
|
}
|
|
380
400
|
|
|
381
401
|
modulo(value: NumericValue) {
|
|
382
402
|
return new Numeric(super.modulo(new Numeric(value)));
|
|
383
403
|
}
|
|
384
404
|
|
|
385
|
-
|
|
386
|
-
return new Numeric(super.
|
|
405
|
+
mod(value: NumericValue) {
|
|
406
|
+
return new Numeric(super.mod(new Numeric(value)));
|
|
387
407
|
}
|
|
388
408
|
|
|
389
409
|
naturalExponential() {
|
|
390
410
|
return new Numeric(super.naturalExponential());
|
|
391
411
|
}
|
|
392
412
|
|
|
413
|
+
exp() {
|
|
414
|
+
return new Numeric(super.exp());
|
|
415
|
+
}
|
|
416
|
+
|
|
393
417
|
naturalLogarithm() {
|
|
394
418
|
return new Numeric(super.naturalLogarithm());
|
|
395
419
|
}
|
|
396
420
|
|
|
397
|
-
|
|
398
|
-
return new Numeric(super.
|
|
421
|
+
ln() {
|
|
422
|
+
return new Numeric(super.ln());
|
|
399
423
|
}
|
|
400
424
|
|
|
401
425
|
negated() {
|
|
402
426
|
return new Numeric(super.negated());
|
|
403
427
|
}
|
|
404
428
|
|
|
429
|
+
neg() {
|
|
430
|
+
return new Numeric(super.neg());
|
|
431
|
+
}
|
|
432
|
+
|
|
405
433
|
plus(value: NumericValue) {
|
|
406
434
|
return new Numeric(super.plus(new Numeric(value)));
|
|
407
435
|
}
|
|
408
436
|
|
|
409
|
-
|
|
410
|
-
return new Numeric(super.
|
|
437
|
+
add(value: NumericValue) {
|
|
438
|
+
return new Numeric(super.add(new Numeric(value)));
|
|
411
439
|
}
|
|
412
440
|
|
|
413
441
|
round() {
|
|
414
442
|
return new Numeric(super.round());
|
|
415
443
|
}
|
|
416
444
|
|
|
417
|
-
sin() {
|
|
418
|
-
return new Numeric(super.sin());
|
|
419
|
-
}
|
|
420
|
-
|
|
421
445
|
sine() {
|
|
422
446
|
return new Numeric(super.sine());
|
|
423
447
|
}
|
|
424
448
|
|
|
425
|
-
|
|
426
|
-
return new Numeric(super.
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
sqrt() {
|
|
430
|
-
return new Numeric(super.sqrt());
|
|
449
|
+
sin() {
|
|
450
|
+
return new Numeric(super.sin());
|
|
431
451
|
}
|
|
432
452
|
|
|
433
453
|
squareRoot() {
|
|
434
454
|
return new Numeric(super.squareRoot());
|
|
435
455
|
}
|
|
436
456
|
|
|
437
|
-
|
|
438
|
-
return new Numeric(super.
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
tan() {
|
|
442
|
-
return new Numeric(super.tan());
|
|
457
|
+
sqrt() {
|
|
458
|
+
return new Numeric(super.sqrt());
|
|
443
459
|
}
|
|
444
460
|
|
|
445
461
|
tangent() {
|
|
446
462
|
return new Numeric(super.tangent());
|
|
447
463
|
}
|
|
448
464
|
|
|
449
|
-
|
|
450
|
-
return new Numeric(super.
|
|
465
|
+
tan() {
|
|
466
|
+
return new Numeric(super.tan());
|
|
451
467
|
}
|
|
452
468
|
|
|
453
469
|
times(value: NumericValue) {
|
|
454
470
|
return new Numeric(super.times(new Numeric(value)));
|
|
455
471
|
}
|
|
456
472
|
|
|
457
|
-
|
|
458
|
-
return new Numeric(
|
|
459
|
-
undefined !== rounding && undefined !== decimalPlaces
|
|
460
|
-
? super.toDP(decimalPlaces, rounding)
|
|
461
|
-
: super.toDP(decimalPlaces)
|
|
462
|
-
);
|
|
473
|
+
mul(value: NumericValue) {
|
|
474
|
+
return new Numeric(super.mul(new Numeric(value)));
|
|
463
475
|
}
|
|
464
476
|
|
|
465
477
|
toDecimalPlaces(decimalPlaces?: number, rounding?: Decimal.Rounding) {
|
|
@@ -470,6 +482,14 @@ export class Numeric extends Decimal {
|
|
|
470
482
|
);
|
|
471
483
|
}
|
|
472
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
|
+
|
|
473
493
|
toFraction(maxDenominator?: NumericValue) {
|
|
474
494
|
return toNumerics(super.toFraction(undefined === maxDenominator ? undefined : new Numeric(maxDenominator)));
|
|
475
495
|
}
|
|
@@ -482,12 +502,8 @@ export class Numeric extends Decimal {
|
|
|
482
502
|
return new Numeric(super.toPower(new Numeric(value)));
|
|
483
503
|
}
|
|
484
504
|
|
|
485
|
-
|
|
486
|
-
return new Numeric(
|
|
487
|
-
undefined !== rounding && undefined !== decimalPlaces
|
|
488
|
-
? super.toSD(decimalPlaces, rounding)
|
|
489
|
-
: super.toSD(decimalPlaces)
|
|
490
|
-
);
|
|
505
|
+
pow(value: NumericValue) {
|
|
506
|
+
return new Numeric(super.pow(new Numeric(value)));
|
|
491
507
|
}
|
|
492
508
|
|
|
493
509
|
toSignificantDigits(decimalPlaces?: number, rounding?: Decimal.Rounding) {
|
|
@@ -498,14 +514,22 @@ export class Numeric extends Decimal {
|
|
|
498
514
|
);
|
|
499
515
|
}
|
|
500
516
|
|
|
501
|
-
|
|
502
|
-
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
|
+
);
|
|
503
523
|
}
|
|
504
524
|
|
|
505
525
|
truncated() {
|
|
506
526
|
return new Numeric(super.truncated());
|
|
507
527
|
}
|
|
508
528
|
|
|
529
|
+
trunc() {
|
|
530
|
+
return new Numeric(super.trunc());
|
|
531
|
+
}
|
|
532
|
+
|
|
509
533
|
inspect(depth: number, options: InspectOptionsStylized) {
|
|
510
534
|
const value = this.toFixed();
|
|
511
535
|
return isNode ? options.stylize(value, 'bigint') : value;
|
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));
|