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