@hairy/utils 1.12.0 → 1.13.1
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/dist/index.cjs +25 -15
- package/dist/index.d.ts +14 -11
- package/dist/index.global.js +19 -13
- package/dist/index.js +22 -14
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -31,6 +31,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
31
31
|
var index_exports = {};
|
|
32
32
|
__export(index_exports, {
|
|
33
33
|
BIG_INTS: () => BIG_INTS,
|
|
34
|
+
BigNum: () => BigNum,
|
|
34
35
|
Bignumber: () => import_bignumber.default,
|
|
35
36
|
Deferred: () => Deferred,
|
|
36
37
|
arange: () => arange,
|
|
@@ -110,6 +111,8 @@ __export(index_exports, {
|
|
|
110
111
|
percentage: () => percentage,
|
|
111
112
|
pipe: () => pipe,
|
|
112
113
|
plus: () => plus,
|
|
114
|
+
randomArray: () => randomArray,
|
|
115
|
+
randomNumer: () => randomNumer,
|
|
113
116
|
riposte: () => riposte,
|
|
114
117
|
sentenceCase: () => sentenceCase,
|
|
115
118
|
snakeCase: () => snakeCase,
|
|
@@ -118,7 +121,6 @@ __export(index_exports, {
|
|
|
118
121
|
uniq: () => uniq_default,
|
|
119
122
|
uniqBy: () => uniqBy_default,
|
|
120
123
|
uniqWith: () => uniqWith_default,
|
|
121
|
-
unum: () => unum,
|
|
122
124
|
unwrap: () => unwrap,
|
|
123
125
|
values: () => values_default,
|
|
124
126
|
whenever: () => whenever,
|
|
@@ -3012,40 +3014,40 @@ var BIG_INTS = {
|
|
|
3012
3014
|
m: { v: 10 ** 6, d: 7, n: "m" },
|
|
3013
3015
|
k: { v: 10 ** 3, d: 4, n: "k" }
|
|
3014
3016
|
};
|
|
3015
|
-
function
|
|
3017
|
+
function BigNum(num = "0") {
|
|
3016
3018
|
return new import_bignumber.default(numerfix(num));
|
|
3017
3019
|
}
|
|
3018
3020
|
function gte(num, n) {
|
|
3019
|
-
return
|
|
3021
|
+
return BigNum(num).gte(BigNum(n));
|
|
3020
3022
|
}
|
|
3021
3023
|
function gt(num, n) {
|
|
3022
|
-
return
|
|
3024
|
+
return BigNum(num).gt(BigNum(n));
|
|
3023
3025
|
}
|
|
3024
3026
|
function lte(num, n) {
|
|
3025
|
-
return
|
|
3027
|
+
return BigNum(num).lte(BigNum(n));
|
|
3026
3028
|
}
|
|
3027
3029
|
function lt(num, n) {
|
|
3028
|
-
return
|
|
3030
|
+
return BigNum(num).lt(BigNum(n));
|
|
3029
3031
|
}
|
|
3030
3032
|
function plus(array, options) {
|
|
3031
3033
|
const rounding = options?.r || import_bignumber.default.ROUND_DOWN;
|
|
3032
3034
|
const decimal2 = options?.d || 0;
|
|
3033
|
-
return array.filter((v) =>
|
|
3035
|
+
return array.filter((v) => BigNum(v).gt(0)).reduce((t, v) => t.plus(BigNum(v)), BigNum(0)).toFixed(decimal2, rounding);
|
|
3034
3036
|
}
|
|
3035
3037
|
function average(array, options) {
|
|
3036
3038
|
const rounding = options?.r || import_bignumber.default.ROUND_DOWN;
|
|
3037
3039
|
const decimal2 = options?.d || 0;
|
|
3038
3040
|
if (array.length === 0)
|
|
3039
3041
|
return "0";
|
|
3040
|
-
return
|
|
3042
|
+
return BigNum(plus(array)).div(array.length).toFixed(decimal2, rounding);
|
|
3041
3043
|
}
|
|
3042
3044
|
function percentage(total, count, options) {
|
|
3043
3045
|
options ??= { d: 3, r: import_bignumber.default.ROUND_DOWN };
|
|
3044
3046
|
const rounding = options?.r || import_bignumber.default.ROUND_DOWN;
|
|
3045
3047
|
const decimal2 = options?.d || 3;
|
|
3046
|
-
if (
|
|
3048
|
+
if (BigNum(total).lte(0) || BigNum(count).lte(0))
|
|
3047
3049
|
return "0";
|
|
3048
|
-
return
|
|
3050
|
+
return BigNum(count).div(BigNum(total)).times(100).toFixed(decimal2, rounding);
|
|
3049
3051
|
}
|
|
3050
3052
|
function zerofill(value, n = 2, type = "positive") {
|
|
3051
3053
|
const _value = integer(value);
|
|
@@ -3063,8 +3065,6 @@ function zeromove(value) {
|
|
|
3063
3065
|
}
|
|
3064
3066
|
function numerfix(value) {
|
|
3065
3067
|
const _isNaN = Number.isNaN(Number(value)) || value.toString() === "NaN";
|
|
3066
|
-
if (_isNaN)
|
|
3067
|
-
console.warn(`numerfix(${value}): value is not the correct value. To ensure the normal operation of the program, it will be converted to zero`);
|
|
3068
3068
|
return _isNaN ? "0" : String(value);
|
|
3069
3069
|
}
|
|
3070
3070
|
function integer(value) {
|
|
@@ -3089,7 +3089,7 @@ function parseNumeric(num, delimiters = ["t", "b", "m"]) {
|
|
|
3089
3089
|
];
|
|
3090
3090
|
let options;
|
|
3091
3091
|
for (const analy of mappings) {
|
|
3092
|
-
const opts = analy && analy(
|
|
3092
|
+
const opts = analy && analy(BigNum(num).toFixed(0));
|
|
3093
3093
|
opts && (options = opts);
|
|
3094
3094
|
}
|
|
3095
3095
|
return options || { v: 1, d: 0, n: "" };
|
|
@@ -3102,7 +3102,7 @@ function formatNumeric(value = "0", options) {
|
|
|
3102
3102
|
decimals = 2
|
|
3103
3103
|
} = options || {};
|
|
3104
3104
|
const config = parseNumeric(value, delimiters || []);
|
|
3105
|
-
let number =
|
|
3105
|
+
let number = BigNum(value).div(config.v).toFormat(decimals, rounding, {
|
|
3106
3106
|
decimalSeparator: ".",
|
|
3107
3107
|
groupSeparator: ",",
|
|
3108
3108
|
groupSize: 3,
|
|
@@ -3233,6 +3233,14 @@ function pPipe(...functions) {
|
|
|
3233
3233
|
// src/util/pipe.ts
|
|
3234
3234
|
var pipe = (...fns) => fns.reduce((v, f) => f(v));
|
|
3235
3235
|
|
|
3236
|
+
// src/util/random.ts
|
|
3237
|
+
function randomNumer(min, max) {
|
|
3238
|
+
return Math.random() * (max - min) + min;
|
|
3239
|
+
}
|
|
3240
|
+
function randomArray(array) {
|
|
3241
|
+
return array[Math.floor(Math.random() * array.length)];
|
|
3242
|
+
}
|
|
3243
|
+
|
|
3236
3244
|
// src/util/util.ts
|
|
3237
3245
|
function arange(x1, x2, stp = 1, z = [], z0 = z.length) {
|
|
3238
3246
|
if (!x2)
|
|
@@ -3264,6 +3272,7 @@ function whenever(value, callback) {
|
|
|
3264
3272
|
// Annotate the CommonJS export names for ESM import in node:
|
|
3265
3273
|
0 && (module.exports = {
|
|
3266
3274
|
BIG_INTS,
|
|
3275
|
+
BigNum,
|
|
3267
3276
|
Bignumber,
|
|
3268
3277
|
Deferred,
|
|
3269
3278
|
arange,
|
|
@@ -3343,6 +3352,8 @@ function whenever(value, callback) {
|
|
|
3343
3352
|
percentage,
|
|
3344
3353
|
pipe,
|
|
3345
3354
|
plus,
|
|
3355
|
+
randomArray,
|
|
3356
|
+
randomNumer,
|
|
3346
3357
|
riposte,
|
|
3347
3358
|
sentenceCase,
|
|
3348
3359
|
snakeCase,
|
|
@@ -3351,7 +3362,6 @@ function whenever(value, callback) {
|
|
|
3351
3362
|
uniq,
|
|
3352
3363
|
uniqBy,
|
|
3353
3364
|
uniqWith,
|
|
3354
|
-
unum,
|
|
3355
3365
|
unwrap,
|
|
3356
3366
|
values,
|
|
3357
3367
|
whenever,
|
package/dist/index.d.ts
CHANGED
|
@@ -162,19 +162,19 @@ interface FormatNumericOptions {
|
|
|
162
162
|
zeromove?: boolean;
|
|
163
163
|
format?: Bignumber.Format;
|
|
164
164
|
}
|
|
165
|
-
declare function
|
|
166
|
-
declare function gte(num:
|
|
167
|
-
declare function gt(num:
|
|
168
|
-
declare function lte(num:
|
|
169
|
-
declare function lt(num:
|
|
170
|
-
declare function plus(array:
|
|
171
|
-
declare function average(array:
|
|
165
|
+
declare function BigNum(num?: Numberish): Bignumber;
|
|
166
|
+
declare function gte(num: Numberish, n: Numberish): boolean;
|
|
167
|
+
declare function gt(num: Numberish, n: Numberish): boolean;
|
|
168
|
+
declare function lte(num: Numberish, n: Numberish): boolean;
|
|
169
|
+
declare function lt(num: Numberish, n: Numberish): boolean;
|
|
170
|
+
declare function plus(array: Numberish[], options?: DecimalOptions): string;
|
|
171
|
+
declare function average(array: Numberish[], options?: DecimalOptions): string;
|
|
172
172
|
/**
|
|
173
173
|
* calculate percentage
|
|
174
174
|
* @param total
|
|
175
175
|
* @param count
|
|
176
176
|
*/
|
|
177
|
-
declare function percentage(total:
|
|
177
|
+
declare function percentage(total: Numberish, count: Numberish, options?: DecimalOptions): string;
|
|
178
178
|
/**
|
|
179
179
|
* leading zeros
|
|
180
180
|
* @param value
|
|
@@ -195,7 +195,7 @@ declare function integer(value: Numberish): string;
|
|
|
195
195
|
* @param n
|
|
196
196
|
*/
|
|
197
197
|
declare function decimal(value: Numberish, n?: number): string;
|
|
198
|
-
declare function parseNumeric(num:
|
|
198
|
+
declare function parseNumeric(num: Numberish, delimiters?: Delimiter[]): {
|
|
199
199
|
v: number;
|
|
200
200
|
d: number;
|
|
201
201
|
n: string;
|
|
@@ -206,7 +206,7 @@ declare function parseNumeric(num: Numeric, delimiters?: Delimiter[]): {
|
|
|
206
206
|
* @param options
|
|
207
207
|
* @returns
|
|
208
208
|
*/
|
|
209
|
-
declare function formatNumeric(value?:
|
|
209
|
+
declare function formatNumeric(value?: Numberish, options?: FormatNumericOptions): string;
|
|
210
210
|
|
|
211
211
|
type Dimension = Numeric | [Numeric, Numeric] | {
|
|
212
212
|
width: Numeric;
|
|
@@ -312,10 +312,13 @@ declare function pPipe<ValueType, ResultValue1, ResultValue2, ResultValue3, Resu
|
|
|
312
312
|
|
|
313
313
|
declare const pipe: (...fns: any[]) => any;
|
|
314
314
|
|
|
315
|
+
declare function randomNumer(min: number, max: number): number;
|
|
316
|
+
declare function randomArray<T>(array: T[]): T;
|
|
317
|
+
|
|
315
318
|
declare function arange(x1: number, x2?: number, stp?: number, z?: number[], z0?: number): number[];
|
|
316
319
|
declare function loop<T = void>(fn: (next: (ms: number) => Promise<T>) => Promise<T>): Promise<T>;
|
|
317
320
|
declare function riposte<T>(...args: [cond: boolean, value: T][]): T;
|
|
318
321
|
declare function unwrap<T extends object>(value: T | (() => T)): T;
|
|
319
322
|
declare function whenever<T, C extends (value: Exclude<T, null | undefined>) => any>(value: T, callback: C): ReturnType<C> | undefined;
|
|
320
323
|
|
|
321
|
-
export { type Arrayable, type Awaitable, BIG_INTS, type BooleanLike, type DecimalOptions, type DeepKeyof, type DeepPartial, type DeepReadonly, type DeepReplace, type DeepRequired, Deferred, type Delimiter, type Dimension, type DynamicObject, type FormatGroupOptions, type FormatNumericOptions, type Key, type Noop, type NumberObject, type Numberish, type Numeric, type NumericObject, type Option, type Pipeline, type StringObject, type SymbolObject, type Typeof, type UnaryFunction, arange, average, camelCase, capitalCase, compose, constantCase, cover, decimal, delay, dotCase, formToObject, formatNumeric, formatSize, formatUnit, getTypeof, gt, gte, integer, isAndroid, isBrowser, isChrome, isEdge, isFF, isFormData, isIE, isIE11, isIE9, isIOS, isMobile, isPhantomJS, isTypeof, isWeex, isWindow, jsonTryParse, kebabCase, loop, lt, lte, noCase, noop, numerfix, objectToForm, pPipe, parseNumeric, pascalCase, pascalSnakeCase, pathCase, percentage, pipe, plus, riposte, sentenceCase, snakeCase, trainCase,
|
|
324
|
+
export { type Arrayable, type Awaitable, BIG_INTS, BigNum, type BooleanLike, type DecimalOptions, type DeepKeyof, type DeepPartial, type DeepReadonly, type DeepReplace, type DeepRequired, Deferred, type Delimiter, type Dimension, type DynamicObject, type FormatGroupOptions, type FormatNumericOptions, type Key, type Noop, type NumberObject, type Numberish, type Numeric, type NumericObject, type Option, type Pipeline, type StringObject, type SymbolObject, type Typeof, type UnaryFunction, arange, average, camelCase, capitalCase, compose, constantCase, cover, decimal, delay, dotCase, formToObject, formatNumeric, formatSize, formatUnit, getTypeof, gt, gte, integer, isAndroid, isBrowser, isChrome, isEdge, isFF, isFormData, isIE, isIE11, isIE9, isIOS, isMobile, isPhantomJS, isTypeof, isWeex, isWindow, jsonTryParse, kebabCase, loop, lt, lte, noCase, noop, numerfix, objectToForm, pPipe, parseNumeric, pascalCase, pascalSnakeCase, pathCase, percentage, pipe, plus, randomArray, randomNumer, riposte, sentenceCase, snakeCase, trainCase, unwrap, whenever, zerofill, zeromove };
|
package/dist/index.global.js
CHANGED
|
@@ -4228,40 +4228,40 @@
|
|
|
4228
4228
|
m: { v: 10 ** 6, d: 7, n: "m" },
|
|
4229
4229
|
k: { v: 10 ** 3, d: 4, n: "k" }
|
|
4230
4230
|
};
|
|
4231
|
-
function
|
|
4231
|
+
function BigNum(num = "0") {
|
|
4232
4232
|
return new bignumber_default(numerfix(num));
|
|
4233
4233
|
}
|
|
4234
4234
|
function gte(num, n) {
|
|
4235
|
-
return
|
|
4235
|
+
return BigNum(num).gte(BigNum(n));
|
|
4236
4236
|
}
|
|
4237
4237
|
function gt(num, n) {
|
|
4238
|
-
return
|
|
4238
|
+
return BigNum(num).gt(BigNum(n));
|
|
4239
4239
|
}
|
|
4240
4240
|
function lte(num, n) {
|
|
4241
|
-
return
|
|
4241
|
+
return BigNum(num).lte(BigNum(n));
|
|
4242
4242
|
}
|
|
4243
4243
|
function lt(num, n) {
|
|
4244
|
-
return
|
|
4244
|
+
return BigNum(num).lt(BigNum(n));
|
|
4245
4245
|
}
|
|
4246
4246
|
function plus(array, options) {
|
|
4247
4247
|
const rounding = options?.r || bignumber_default.ROUND_DOWN;
|
|
4248
4248
|
const decimal2 = options?.d || 0;
|
|
4249
|
-
return array.filter((v) =>
|
|
4249
|
+
return array.filter((v) => BigNum(v).gt(0)).reduce((t, v) => t.plus(BigNum(v)), BigNum(0)).toFixed(decimal2, rounding);
|
|
4250
4250
|
}
|
|
4251
4251
|
function average(array, options) {
|
|
4252
4252
|
const rounding = options?.r || bignumber_default.ROUND_DOWN;
|
|
4253
4253
|
const decimal2 = options?.d || 0;
|
|
4254
4254
|
if (array.length === 0)
|
|
4255
4255
|
return "0";
|
|
4256
|
-
return
|
|
4256
|
+
return BigNum(plus(array)).div(array.length).toFixed(decimal2, rounding);
|
|
4257
4257
|
}
|
|
4258
4258
|
function percentage(total, count, options) {
|
|
4259
4259
|
options ??= { d: 3, r: bignumber_default.ROUND_DOWN };
|
|
4260
4260
|
const rounding = options?.r || bignumber_default.ROUND_DOWN;
|
|
4261
4261
|
const decimal2 = options?.d || 3;
|
|
4262
|
-
if (
|
|
4262
|
+
if (BigNum(total).lte(0) || BigNum(count).lte(0))
|
|
4263
4263
|
return "0";
|
|
4264
|
-
return
|
|
4264
|
+
return BigNum(count).div(BigNum(total)).times(100).toFixed(decimal2, rounding);
|
|
4265
4265
|
}
|
|
4266
4266
|
function zerofill(value, n = 2, type = "positive") {
|
|
4267
4267
|
const _value = integer(value);
|
|
@@ -4279,8 +4279,6 @@
|
|
|
4279
4279
|
}
|
|
4280
4280
|
function numerfix(value) {
|
|
4281
4281
|
const _isNaN = Number.isNaN(Number(value)) || value.toString() === "NaN";
|
|
4282
|
-
if (_isNaN)
|
|
4283
|
-
console.warn(`numerfix(${value}): value is not the correct value. To ensure the normal operation of the program, it will be converted to zero`);
|
|
4284
4282
|
return _isNaN ? "0" : String(value);
|
|
4285
4283
|
}
|
|
4286
4284
|
function integer(value) {
|
|
@@ -4305,7 +4303,7 @@
|
|
|
4305
4303
|
];
|
|
4306
4304
|
let options;
|
|
4307
4305
|
for (const analy of mappings) {
|
|
4308
|
-
const opts = analy && analy(
|
|
4306
|
+
const opts = analy && analy(BigNum(num).toFixed(0));
|
|
4309
4307
|
opts && (options = opts);
|
|
4310
4308
|
}
|
|
4311
4309
|
return options || { v: 1, d: 0, n: "" };
|
|
@@ -4318,7 +4316,7 @@
|
|
|
4318
4316
|
decimals = 2
|
|
4319
4317
|
} = options || {};
|
|
4320
4318
|
const config = parseNumeric(value, delimiters || []);
|
|
4321
|
-
let number =
|
|
4319
|
+
let number = BigNum(value).div(config.v).toFormat(decimals, rounding, {
|
|
4322
4320
|
decimalSeparator: ".",
|
|
4323
4321
|
groupSeparator: ",",
|
|
4324
4322
|
groupSize: 3,
|
|
@@ -4449,6 +4447,14 @@
|
|
|
4449
4447
|
// src/util/pipe.ts
|
|
4450
4448
|
var pipe = (...fns) => fns.reduce((v, f) => f(v));
|
|
4451
4449
|
|
|
4450
|
+
// src/util/random.ts
|
|
4451
|
+
function randomNumer(min, max) {
|
|
4452
|
+
return Math.random() * (max - min) + min;
|
|
4453
|
+
}
|
|
4454
|
+
function randomArray(array) {
|
|
4455
|
+
return array[Math.floor(Math.random() * array.length)];
|
|
4456
|
+
}
|
|
4457
|
+
|
|
4452
4458
|
// src/util/util.ts
|
|
4453
4459
|
function arange(x1, x2, stp = 1, z = [], z0 = z.length) {
|
|
4454
4460
|
if (!x2)
|
package/dist/index.js
CHANGED
|
@@ -2883,40 +2883,40 @@ var BIG_INTS = {
|
|
|
2883
2883
|
m: { v: 10 ** 6, d: 7, n: "m" },
|
|
2884
2884
|
k: { v: 10 ** 3, d: 4, n: "k" }
|
|
2885
2885
|
};
|
|
2886
|
-
function
|
|
2886
|
+
function BigNum(num = "0") {
|
|
2887
2887
|
return new Bignumber(numerfix(num));
|
|
2888
2888
|
}
|
|
2889
2889
|
function gte(num, n) {
|
|
2890
|
-
return
|
|
2890
|
+
return BigNum(num).gte(BigNum(n));
|
|
2891
2891
|
}
|
|
2892
2892
|
function gt(num, n) {
|
|
2893
|
-
return
|
|
2893
|
+
return BigNum(num).gt(BigNum(n));
|
|
2894
2894
|
}
|
|
2895
2895
|
function lte(num, n) {
|
|
2896
|
-
return
|
|
2896
|
+
return BigNum(num).lte(BigNum(n));
|
|
2897
2897
|
}
|
|
2898
2898
|
function lt(num, n) {
|
|
2899
|
-
return
|
|
2899
|
+
return BigNum(num).lt(BigNum(n));
|
|
2900
2900
|
}
|
|
2901
2901
|
function plus(array, options) {
|
|
2902
2902
|
const rounding = options?.r || Bignumber.ROUND_DOWN;
|
|
2903
2903
|
const decimal2 = options?.d || 0;
|
|
2904
|
-
return array.filter((v) =>
|
|
2904
|
+
return array.filter((v) => BigNum(v).gt(0)).reduce((t, v) => t.plus(BigNum(v)), BigNum(0)).toFixed(decimal2, rounding);
|
|
2905
2905
|
}
|
|
2906
2906
|
function average(array, options) {
|
|
2907
2907
|
const rounding = options?.r || Bignumber.ROUND_DOWN;
|
|
2908
2908
|
const decimal2 = options?.d || 0;
|
|
2909
2909
|
if (array.length === 0)
|
|
2910
2910
|
return "0";
|
|
2911
|
-
return
|
|
2911
|
+
return BigNum(plus(array)).div(array.length).toFixed(decimal2, rounding);
|
|
2912
2912
|
}
|
|
2913
2913
|
function percentage(total, count, options) {
|
|
2914
2914
|
options ??= { d: 3, r: Bignumber.ROUND_DOWN };
|
|
2915
2915
|
const rounding = options?.r || Bignumber.ROUND_DOWN;
|
|
2916
2916
|
const decimal2 = options?.d || 3;
|
|
2917
|
-
if (
|
|
2917
|
+
if (BigNum(total).lte(0) || BigNum(count).lte(0))
|
|
2918
2918
|
return "0";
|
|
2919
|
-
return
|
|
2919
|
+
return BigNum(count).div(BigNum(total)).times(100).toFixed(decimal2, rounding);
|
|
2920
2920
|
}
|
|
2921
2921
|
function zerofill(value, n = 2, type = "positive") {
|
|
2922
2922
|
const _value = integer(value);
|
|
@@ -2934,8 +2934,6 @@ function zeromove(value) {
|
|
|
2934
2934
|
}
|
|
2935
2935
|
function numerfix(value) {
|
|
2936
2936
|
const _isNaN = Number.isNaN(Number(value)) || value.toString() === "NaN";
|
|
2937
|
-
if (_isNaN)
|
|
2938
|
-
console.warn(`numerfix(${value}): value is not the correct value. To ensure the normal operation of the program, it will be converted to zero`);
|
|
2939
2937
|
return _isNaN ? "0" : String(value);
|
|
2940
2938
|
}
|
|
2941
2939
|
function integer(value) {
|
|
@@ -2960,7 +2958,7 @@ function parseNumeric(num, delimiters = ["t", "b", "m"]) {
|
|
|
2960
2958
|
];
|
|
2961
2959
|
let options;
|
|
2962
2960
|
for (const analy of mappings) {
|
|
2963
|
-
const opts = analy && analy(
|
|
2961
|
+
const opts = analy && analy(BigNum(num).toFixed(0));
|
|
2964
2962
|
opts && (options = opts);
|
|
2965
2963
|
}
|
|
2966
2964
|
return options || { v: 1, d: 0, n: "" };
|
|
@@ -2973,7 +2971,7 @@ function formatNumeric(value = "0", options) {
|
|
|
2973
2971
|
decimals = 2
|
|
2974
2972
|
} = options || {};
|
|
2975
2973
|
const config = parseNumeric(value, delimiters || []);
|
|
2976
|
-
let number =
|
|
2974
|
+
let number = BigNum(value).div(config.v).toFormat(decimals, rounding, {
|
|
2977
2975
|
decimalSeparator: ".",
|
|
2978
2976
|
groupSeparator: ",",
|
|
2979
2977
|
groupSize: 3,
|
|
@@ -3104,6 +3102,14 @@ function pPipe(...functions) {
|
|
|
3104
3102
|
// src/util/pipe.ts
|
|
3105
3103
|
var pipe = (...fns) => fns.reduce((v, f) => f(v));
|
|
3106
3104
|
|
|
3105
|
+
// src/util/random.ts
|
|
3106
|
+
function randomNumer(min, max) {
|
|
3107
|
+
return Math.random() * (max - min) + min;
|
|
3108
|
+
}
|
|
3109
|
+
function randomArray(array) {
|
|
3110
|
+
return array[Math.floor(Math.random() * array.length)];
|
|
3111
|
+
}
|
|
3112
|
+
|
|
3107
3113
|
// src/util/util.ts
|
|
3108
3114
|
function arange(x1, x2, stp = 1, z = [], z0 = z.length) {
|
|
3109
3115
|
if (!x2)
|
|
@@ -3134,6 +3140,7 @@ function whenever(value, callback) {
|
|
|
3134
3140
|
}
|
|
3135
3141
|
export {
|
|
3136
3142
|
BIG_INTS,
|
|
3143
|
+
BigNum,
|
|
3137
3144
|
Bignumber,
|
|
3138
3145
|
Deferred,
|
|
3139
3146
|
arange,
|
|
@@ -3213,6 +3220,8 @@ export {
|
|
|
3213
3220
|
percentage,
|
|
3214
3221
|
pipe,
|
|
3215
3222
|
plus,
|
|
3223
|
+
randomArray,
|
|
3224
|
+
randomNumer,
|
|
3216
3225
|
riposte,
|
|
3217
3226
|
sentenceCase,
|
|
3218
3227
|
snakeCase,
|
|
@@ -3221,7 +3230,6 @@ export {
|
|
|
3221
3230
|
uniq_default as uniq,
|
|
3222
3231
|
uniqBy_default as uniqBy,
|
|
3223
3232
|
uniqWith_default as uniqWith,
|
|
3224
|
-
unum,
|
|
3225
3233
|
unwrap,
|
|
3226
3234
|
values_default as values,
|
|
3227
3235
|
whenever,
|