@hairy/utils 1.41.0 → 1.43.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 -10
- package/dist/index.d.ts +3 -3
- package/dist/index.global.js +7 -6
- package/dist/index.js +9 -8
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -169,8 +169,8 @@ __export(index_exports, {
|
|
|
169
169
|
unwrap: () => unwrap,
|
|
170
170
|
values: () => values_default,
|
|
171
171
|
whenever: () => whenever,
|
|
172
|
-
|
|
173
|
-
|
|
172
|
+
zeroRemove: () => zeroRemove,
|
|
173
|
+
zerofill: () => zerofill
|
|
174
174
|
});
|
|
175
175
|
module.exports = __toCommonJS(index_exports);
|
|
176
176
|
|
|
@@ -3566,12 +3566,12 @@ function lt(a, b) {
|
|
|
3566
3566
|
}
|
|
3567
3567
|
function plus(array, options) {
|
|
3568
3568
|
const rounding = options?.r || Bignumber.ROUND_DOWN;
|
|
3569
|
-
const decimal2 = options?.d ||
|
|
3570
|
-
return array.filter((v) => bignumber(v).gt(0)).reduce((t, v) => t.plus(
|
|
3569
|
+
const decimal2 = options?.d || 6;
|
|
3570
|
+
return array.filter((v) => bignumber(v).gt(0)).reduce((t, v) => t.plus(numberish(v)), bignumber(0)).toFixed(decimal2, rounding);
|
|
3571
3571
|
}
|
|
3572
3572
|
function divs(array, options) {
|
|
3573
3573
|
const rounding = options?.r || Bignumber.ROUND_DOWN;
|
|
3574
|
-
const decimal2 = options?.d ||
|
|
3574
|
+
const decimal2 = options?.d || 6;
|
|
3575
3575
|
return array.reduce((t, v) => t.div(bignumber(v)), bignumber(1)).toFixed(decimal2, rounding);
|
|
3576
3576
|
}
|
|
3577
3577
|
function average(array, options) {
|
|
@@ -3600,8 +3600,9 @@ function zerofill(value, n = 2, type = "positive") {
|
|
|
3600
3600
|
return zero + value;
|
|
3601
3601
|
return "";
|
|
3602
3602
|
}
|
|
3603
|
-
function
|
|
3604
|
-
|
|
3603
|
+
function zeroRemove(value, convert = true) {
|
|
3604
|
+
const _value = convert ? numberish(value) : value || "";
|
|
3605
|
+
return _value.toString().replace(/\.?0+$/, "");
|
|
3605
3606
|
}
|
|
3606
3607
|
function integer(value) {
|
|
3607
3608
|
return new Bignumber(numberish(value)).toFixed(0);
|
|
@@ -3649,7 +3650,7 @@ function formatNumeric(value = "0", options) {
|
|
|
3649
3650
|
fractionGroupSize: 0,
|
|
3650
3651
|
...format
|
|
3651
3652
|
});
|
|
3652
|
-
number = options?.
|
|
3653
|
+
number = options?.decimalsZero ? zeroRemove(number, false) : number;
|
|
3653
3654
|
return `${number}${config.n}`;
|
|
3654
3655
|
}
|
|
3655
3656
|
|
|
@@ -3870,8 +3871,8 @@ function isTypeof(target, type) {
|
|
|
3870
3871
|
unwrap,
|
|
3871
3872
|
values,
|
|
3872
3873
|
whenever,
|
|
3873
|
-
|
|
3874
|
-
|
|
3874
|
+
zeroRemove,
|
|
3875
|
+
zerofill
|
|
3875
3876
|
});
|
|
3876
3877
|
/*! Bundled license information:
|
|
3877
3878
|
|
package/dist/index.d.ts
CHANGED
|
@@ -269,7 +269,7 @@ interface FormatNumericOptions {
|
|
|
269
269
|
delimiters?: Delimiter[] | false;
|
|
270
270
|
rounding?: Bignumber.RoundingMode;
|
|
271
271
|
decimals?: number;
|
|
272
|
-
|
|
272
|
+
decimalsZero?: boolean;
|
|
273
273
|
default?: string;
|
|
274
274
|
format?: Bignumber.Format;
|
|
275
275
|
}
|
|
@@ -297,7 +297,7 @@ declare function percentage(total: Numberish, count: Numberish, options?: Decima
|
|
|
297
297
|
* @param type
|
|
298
298
|
*/
|
|
299
299
|
declare function zerofill(value: Numberish, n?: number, type?: 'positive' | 'reverse'): Numberish;
|
|
300
|
-
declare function
|
|
300
|
+
declare function zeroRemove(value: Numberish, convert?: boolean): string;
|
|
301
301
|
/**
|
|
302
302
|
* format as a positive integer
|
|
303
303
|
* @param value
|
|
@@ -647,4 +647,4 @@ declare function unwrap<T extends object>(value: T | (() => T)): T;
|
|
|
647
647
|
declare function whenever<T, C extends (value: Exclude<T, null | undefined>) => any>(value: T, callback: C): ReturnType<C> | undefined;
|
|
648
648
|
declare function call<T extends Fn$1<any>>(fn: T, ...args: Parameters<T>): ReturnType<T>;
|
|
649
649
|
|
|
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, divs, 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, 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,
|
|
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, divs, 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, 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
|
@@ -4733,12 +4733,12 @@
|
|
|
4733
4733
|
}
|
|
4734
4734
|
function plus(array, options) {
|
|
4735
4735
|
const rounding = options?.r || Bignumber.ROUND_DOWN;
|
|
4736
|
-
const decimal2 = options?.d ||
|
|
4737
|
-
return array.filter((v) => bignumber(v).gt(0)).reduce((t, v) => t.plus(
|
|
4736
|
+
const decimal2 = options?.d || 6;
|
|
4737
|
+
return array.filter((v) => bignumber(v).gt(0)).reduce((t, v) => t.plus(numberish(v)), bignumber(0)).toFixed(decimal2, rounding);
|
|
4738
4738
|
}
|
|
4739
4739
|
function divs(array, options) {
|
|
4740
4740
|
const rounding = options?.r || Bignumber.ROUND_DOWN;
|
|
4741
|
-
const decimal2 = options?.d ||
|
|
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
4744
|
function average(array, options) {
|
|
@@ -4767,8 +4767,9 @@
|
|
|
4767
4767
|
return zero + value;
|
|
4768
4768
|
return "";
|
|
4769
4769
|
}
|
|
4770
|
-
function
|
|
4771
|
-
|
|
4770
|
+
function zeroRemove(value, convert = true) {
|
|
4771
|
+
const _value = convert ? numberish(value) : value || "";
|
|
4772
|
+
return _value.toString().replace(/\.?0+$/, "");
|
|
4772
4773
|
}
|
|
4773
4774
|
function integer(value) {
|
|
4774
4775
|
return new Bignumber(numberish(value)).toFixed(0);
|
|
@@ -4816,7 +4817,7 @@
|
|
|
4816
4817
|
fractionGroupSize: 0,
|
|
4817
4818
|
...format
|
|
4818
4819
|
});
|
|
4819
|
-
number = options?.
|
|
4820
|
+
number = options?.decimalsZero ? zeroRemove(number, false) : number;
|
|
4820
4821
|
return `${number}${config.n}`;
|
|
4821
4822
|
}
|
|
4822
4823
|
|
package/dist/index.js
CHANGED
|
@@ -3390,12 +3390,12 @@ function lt(a, b) {
|
|
|
3390
3390
|
}
|
|
3391
3391
|
function plus(array, options) {
|
|
3392
3392
|
const rounding = options?.r || Bignumber.ROUND_DOWN;
|
|
3393
|
-
const decimal2 = options?.d ||
|
|
3394
|
-
return array.filter((v) => bignumber(v).gt(0)).reduce((t, v) => t.plus(
|
|
3393
|
+
const decimal2 = options?.d || 6;
|
|
3394
|
+
return array.filter((v) => bignumber(v).gt(0)).reduce((t, v) => t.plus(numberish(v)), bignumber(0)).toFixed(decimal2, rounding);
|
|
3395
3395
|
}
|
|
3396
3396
|
function divs(array, options) {
|
|
3397
3397
|
const rounding = options?.r || Bignumber.ROUND_DOWN;
|
|
3398
|
-
const decimal2 = options?.d ||
|
|
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
3401
|
function average(array, options) {
|
|
@@ -3424,8 +3424,9 @@ function zerofill(value, n = 2, type = "positive") {
|
|
|
3424
3424
|
return zero + value;
|
|
3425
3425
|
return "";
|
|
3426
3426
|
}
|
|
3427
|
-
function
|
|
3428
|
-
|
|
3427
|
+
function zeroRemove(value, convert = true) {
|
|
3428
|
+
const _value = convert ? numberish(value) : value || "";
|
|
3429
|
+
return _value.toString().replace(/\.?0+$/, "");
|
|
3429
3430
|
}
|
|
3430
3431
|
function integer(value) {
|
|
3431
3432
|
return new Bignumber(numberish(value)).toFixed(0);
|
|
@@ -3473,7 +3474,7 @@ function formatNumeric(value = "0", options) {
|
|
|
3473
3474
|
fractionGroupSize: 0,
|
|
3474
3475
|
...format
|
|
3475
3476
|
});
|
|
3476
|
-
number = options?.
|
|
3477
|
+
number = options?.decimalsZero ? zeroRemove(number, false) : number;
|
|
3477
3478
|
return `${number}${config.n}`;
|
|
3478
3479
|
}
|
|
3479
3480
|
|
|
@@ -3693,8 +3694,8 @@ export {
|
|
|
3693
3694
|
unwrap,
|
|
3694
3695
|
values_default as values,
|
|
3695
3696
|
whenever,
|
|
3696
|
-
|
|
3697
|
-
|
|
3697
|
+
zeroRemove,
|
|
3698
|
+
zerofill
|
|
3698
3699
|
};
|
|
3699
3700
|
/*! Bundled license information:
|
|
3700
3701
|
|