@hairy/utils 1.43.0 → 1.45.0
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 +11 -4
- package/dist/index.d.ts +3 -2
- package/dist/index.global.js +11 -6
- package/dist/index.js +9 -3
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -52,7 +52,7 @@ __export(index_exports, {
|
|
|
52
52
|
decimal: () => decimal,
|
|
53
53
|
delay: () => delay,
|
|
54
54
|
dialsPhone: () => dialsPhone,
|
|
55
|
-
|
|
55
|
+
divide: () => divide,
|
|
56
56
|
dotCase: () => dotCase,
|
|
57
57
|
downloadBlobFile: () => downloadBlobFile,
|
|
58
58
|
downloadNetworkFile: () => downloadNetworkFile,
|
|
@@ -127,6 +127,7 @@ __export(index_exports, {
|
|
|
127
127
|
lte: () => lte,
|
|
128
128
|
merge: () => merge_default,
|
|
129
129
|
mergeWith: () => mergeWith_default,
|
|
130
|
+
multiply: () => multiply,
|
|
130
131
|
noCase: () => noCase,
|
|
131
132
|
nonnanable: () => nonnanable,
|
|
132
133
|
noop: () => noop2,
|
|
@@ -3569,11 +3570,16 @@ function plus(array, options) {
|
|
|
3569
3570
|
const decimal2 = options?.d || 6;
|
|
3570
3571
|
return array.filter((v) => bignumber(v).gt(0)).reduce((t, v) => t.plus(numberish(v)), bignumber(0)).toFixed(decimal2, rounding);
|
|
3571
3572
|
}
|
|
3572
|
-
function
|
|
3573
|
+
function divide(array, options) {
|
|
3573
3574
|
const rounding = options?.r || Bignumber.ROUND_DOWN;
|
|
3574
3575
|
const decimal2 = options?.d || 6;
|
|
3575
3576
|
return array.reduce((t, v) => t.div(bignumber(v)), bignumber(1)).toFixed(decimal2, rounding);
|
|
3576
3577
|
}
|
|
3578
|
+
function multiply(array, options) {
|
|
3579
|
+
const rounding = options?.r || Bignumber.ROUND_DOWN;
|
|
3580
|
+
const decimal2 = options?.d || 6;
|
|
3581
|
+
return array.reduce((t, v) => t.times(bignumber(v)), bignumber(1)).toFixed(decimal2, rounding);
|
|
3582
|
+
}
|
|
3577
3583
|
function average(array, options) {
|
|
3578
3584
|
const rounding = options?.r || Bignumber.ROUND_DOWN;
|
|
3579
3585
|
const decimal2 = options?.d || 0;
|
|
@@ -3650,7 +3656,7 @@ function formatNumeric(value = "0", options) {
|
|
|
3650
3656
|
fractionGroupSize: 0,
|
|
3651
3657
|
...format
|
|
3652
3658
|
});
|
|
3653
|
-
number = options?.decimalsZero ? zeroRemove(number, false) : number;
|
|
3659
|
+
number = options?.decimalsZero === false ? zeroRemove(number, false) : number;
|
|
3654
3660
|
return `${number}${config.n}`;
|
|
3655
3661
|
}
|
|
3656
3662
|
|
|
@@ -3754,7 +3760,7 @@ function isTypeof(target, type) {
|
|
|
3754
3760
|
decimal,
|
|
3755
3761
|
delay,
|
|
3756
3762
|
dialsPhone,
|
|
3757
|
-
|
|
3763
|
+
divide,
|
|
3758
3764
|
dotCase,
|
|
3759
3765
|
downloadBlobFile,
|
|
3760
3766
|
downloadNetworkFile,
|
|
@@ -3829,6 +3835,7 @@ function isTypeof(target, type) {
|
|
|
3829
3835
|
lte,
|
|
3830
3836
|
merge,
|
|
3831
3837
|
mergeWith,
|
|
3838
|
+
multiply,
|
|
3832
3839
|
noCase,
|
|
3833
3840
|
nonnanable,
|
|
3834
3841
|
noop,
|
package/dist/index.d.ts
CHANGED
|
@@ -282,7 +282,8 @@ declare function gt(a: Numberish, b: Numberish): boolean;
|
|
|
282
282
|
declare function lte(a: Numberish, b: Numberish): boolean;
|
|
283
283
|
declare function lt(a: Numberish, b: Numberish): boolean;
|
|
284
284
|
declare function plus(array: Numberish[], options?: DecimalOptions): string;
|
|
285
|
-
declare function
|
|
285
|
+
declare function divide(array: Numberish[], options?: DecimalOptions): string;
|
|
286
|
+
declare function multiply(array: Numberish[], options?: DecimalOptions): string;
|
|
286
287
|
declare function average(array: Numberish[], options?: DecimalOptions): string;
|
|
287
288
|
/**
|
|
288
289
|
* calculate percentage
|
|
@@ -647,4 +648,4 @@ declare function unwrap<T extends object>(value: T | (() => T)): T;
|
|
|
647
648
|
declare function whenever<T, C extends (value: Exclude<T, null | undefined>) => any>(value: T, callback: C): ReturnType<C> | undefined;
|
|
648
649
|
declare function call<T extends Fn$1<any>>(fn: T, ...args: Parameters<T>): ReturnType<T>;
|
|
649
650
|
|
|
650
|
-
export { type AnyFn, type ArgumentsType, type Arrayable, type Assign, type Awaitable, BIG_INTS, Bignumber, type BooleanLike, type BrowserNativeObject, type ConstructorType, DEFAULT_BIGNUM_CONFIG, type DecimalOptions, type DeepKeyof, type DeepMap, type DeepMerge, type DeepPartial, type DeepReadonly, type DeepReplace, type DeepRequired, Deferred, type Delimiter, type Dimension, type DynamicObject, type ElementOf, type Fn$1 as Fn, type FormatGroupOptions, type FormatNumericOptions, type IfAny, type IsAny, type Key, type Looper, type MergeInsertions, type NonUndefined, type Noop, type Nullable, type NumberObject, type Numberish, type Numeric, type NumericObject, type OmitBy, type OpenFilePickerOptions, type OpenImagePickerOptions, type Option, type Overwrite, type PickBy, type PromiseFn, type PromiseType, type Promisify, type ReaderType, type StringObject, type SymbolObject, type Typeof, arange, average, bignumber, call, camelCase, capitalCase, compose, constantCase, cover, decimal, delay, dialsPhone,
|
|
651
|
+
export { type AnyFn, type ArgumentsType, type Arrayable, type Assign, type Awaitable, BIG_INTS, Bignumber, type BooleanLike, type BrowserNativeObject, type ConstructorType, DEFAULT_BIGNUM_CONFIG, type DecimalOptions, type DeepKeyof, type DeepMap, type DeepMerge, type DeepPartial, type DeepReadonly, type DeepReplace, type DeepRequired, Deferred, type Delimiter, type Dimension, type DynamicObject, type ElementOf, type Fn$1 as Fn, type FormatGroupOptions, type FormatNumericOptions, type IfAny, type IsAny, type Key, type Looper, type MergeInsertions, type NonUndefined, type Noop, type Nullable, type NumberObject, type Numberish, type Numeric, type NumericObject, type OmitBy, type OpenFilePickerOptions, type OpenImagePickerOptions, type Option, type Overwrite, type PickBy, type PromiseFn, type PromiseType, type Promisify, type ReaderType, type StringObject, type SymbolObject, type Typeof, arange, average, bignumber, call, camelCase, capitalCase, compose, constantCase, cover, decimal, delay, dialsPhone, divide, dotCase, downloadBlobFile, downloadNetworkFile, ensurePrefix, ensureSuffix, formatNumeric, formatSize, formatUnit, formdataToObject, getTypeof, gt, gte, integer, isAndroid, isBrowser, isChrome, isEdge, isFF, isFormData, isIE, isIE11, isIE9, isIOS, isMobile, isPhantomJS, isTruthy, isTypeof, isWeex, isWindow, jsonTryParse, kebabCase, loop, lt, lte, multiply, noCase, nonnanable, noop, numberify, numberish, objectToFormdata, off, on, parseNumeric, pascalCase, pascalSnakeCase, pathCase, percentage, pipe, plus, proxy, randomArray, randomNumber, randomString, readFileReader, redirectTo, riposte, selectImages, sentenceCase, showOpenFilePicker, showOpenImagePicker, slash, snakeCase, stringify, template, to, toArray, trainCase, unindent, unwrap, whenever, zeroRemove, zerofill };
|
package/dist/index.global.js
CHANGED
|
@@ -3567,7 +3567,7 @@
|
|
|
3567
3567
|
};
|
|
3568
3568
|
}();
|
|
3569
3569
|
div = /* @__PURE__ */ function() {
|
|
3570
|
-
function
|
|
3570
|
+
function multiply2(x, k, base) {
|
|
3571
3571
|
var m, temp, xlo, xhi, carry = 0, i = x.length, klo = k % SQRT_BASE, khi = k / SQRT_BASE | 0;
|
|
3572
3572
|
for (x = x.slice(); i--; ) {
|
|
3573
3573
|
xlo = x[i] % SQRT_BASE;
|
|
@@ -3635,8 +3635,8 @@
|
|
|
3635
3635
|
s += 2;
|
|
3636
3636
|
n = mathfloor(base / (yc[0] + 1));
|
|
3637
3637
|
if (n > 1) {
|
|
3638
|
-
yc =
|
|
3639
|
-
xc =
|
|
3638
|
+
yc = multiply2(yc, n, base);
|
|
3639
|
+
xc = multiply2(xc, n, base);
|
|
3640
3640
|
yL = yc.length;
|
|
3641
3641
|
xL = xc.length;
|
|
3642
3642
|
}
|
|
@@ -3657,7 +3657,7 @@
|
|
|
3657
3657
|
n = mathfloor(rem0 / yc0);
|
|
3658
3658
|
if (n > 1) {
|
|
3659
3659
|
if (n >= base) n = base - 1;
|
|
3660
|
-
prod =
|
|
3660
|
+
prod = multiply2(yc, n, base);
|
|
3661
3661
|
prodL = prod.length;
|
|
3662
3662
|
remL = rem.length;
|
|
3663
3663
|
while (compare2(prod, rem, prodL, remL) == 1) {
|
|
@@ -4736,11 +4736,16 @@
|
|
|
4736
4736
|
const decimal2 = options?.d || 6;
|
|
4737
4737
|
return array.filter((v) => bignumber(v).gt(0)).reduce((t, v) => t.plus(numberish(v)), bignumber(0)).toFixed(decimal2, rounding);
|
|
4738
4738
|
}
|
|
4739
|
-
function
|
|
4739
|
+
function divide(array, options) {
|
|
4740
4740
|
const rounding = options?.r || Bignumber.ROUND_DOWN;
|
|
4741
4741
|
const decimal2 = options?.d || 6;
|
|
4742
4742
|
return array.reduce((t, v) => t.div(bignumber(v)), bignumber(1)).toFixed(decimal2, rounding);
|
|
4743
4743
|
}
|
|
4744
|
+
function multiply(array, options) {
|
|
4745
|
+
const rounding = options?.r || Bignumber.ROUND_DOWN;
|
|
4746
|
+
const decimal2 = options?.d || 6;
|
|
4747
|
+
return array.reduce((t, v) => t.times(bignumber(v)), bignumber(1)).toFixed(decimal2, rounding);
|
|
4748
|
+
}
|
|
4744
4749
|
function average(array, options) {
|
|
4745
4750
|
const rounding = options?.r || Bignumber.ROUND_DOWN;
|
|
4746
4751
|
const decimal2 = options?.d || 0;
|
|
@@ -4817,7 +4822,7 @@
|
|
|
4817
4822
|
fractionGroupSize: 0,
|
|
4818
4823
|
...format
|
|
4819
4824
|
});
|
|
4820
|
-
number = options?.decimalsZero ? zeroRemove(number, false) : number;
|
|
4825
|
+
number = options?.decimalsZero === false ? zeroRemove(number, false) : number;
|
|
4821
4826
|
return `${number}${config.n}`;
|
|
4822
4827
|
}
|
|
4823
4828
|
|
package/dist/index.js
CHANGED
|
@@ -3393,11 +3393,16 @@ function plus(array, options) {
|
|
|
3393
3393
|
const decimal2 = options?.d || 6;
|
|
3394
3394
|
return array.filter((v) => bignumber(v).gt(0)).reduce((t, v) => t.plus(numberish(v)), bignumber(0)).toFixed(decimal2, rounding);
|
|
3395
3395
|
}
|
|
3396
|
-
function
|
|
3396
|
+
function divide(array, options) {
|
|
3397
3397
|
const rounding = options?.r || Bignumber.ROUND_DOWN;
|
|
3398
3398
|
const decimal2 = options?.d || 6;
|
|
3399
3399
|
return array.reduce((t, v) => t.div(bignumber(v)), bignumber(1)).toFixed(decimal2, rounding);
|
|
3400
3400
|
}
|
|
3401
|
+
function multiply(array, options) {
|
|
3402
|
+
const rounding = options?.r || Bignumber.ROUND_DOWN;
|
|
3403
|
+
const decimal2 = options?.d || 6;
|
|
3404
|
+
return array.reduce((t, v) => t.times(bignumber(v)), bignumber(1)).toFixed(decimal2, rounding);
|
|
3405
|
+
}
|
|
3401
3406
|
function average(array, options) {
|
|
3402
3407
|
const rounding = options?.r || Bignumber.ROUND_DOWN;
|
|
3403
3408
|
const decimal2 = options?.d || 0;
|
|
@@ -3474,7 +3479,7 @@ function formatNumeric(value = "0", options) {
|
|
|
3474
3479
|
fractionGroupSize: 0,
|
|
3475
3480
|
...format
|
|
3476
3481
|
});
|
|
3477
|
-
number = options?.decimalsZero ? zeroRemove(number, false) : number;
|
|
3482
|
+
number = options?.decimalsZero === false ? zeroRemove(number, false) : number;
|
|
3478
3483
|
return `${number}${config.n}`;
|
|
3479
3484
|
}
|
|
3480
3485
|
|
|
@@ -3577,7 +3582,7 @@ export {
|
|
|
3577
3582
|
decimal,
|
|
3578
3583
|
delay,
|
|
3579
3584
|
dialsPhone,
|
|
3580
|
-
|
|
3585
|
+
divide,
|
|
3581
3586
|
dotCase,
|
|
3582
3587
|
downloadBlobFile,
|
|
3583
3588
|
downloadNetworkFile,
|
|
@@ -3652,6 +3657,7 @@ export {
|
|
|
3652
3657
|
lte,
|
|
3653
3658
|
merge_default as merge,
|
|
3654
3659
|
mergeWith_default as mergeWith,
|
|
3660
|
+
multiply,
|
|
3655
3661
|
noCase,
|
|
3656
3662
|
nonnanable,
|
|
3657
3663
|
noop2 as noop,
|