@hairy/utils 1.34.0 → 1.35.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 CHANGED
@@ -3394,6 +3394,8 @@ function parseNumeric(num, delimiters = ["t", "b", "m"]) {
3394
3394
  return options || { v: 1, d: 0, n: "" };
3395
3395
  }
3396
3396
  function formatNumeric(value = "0", options) {
3397
+ if (options?.default && bignum(value).isZero())
3398
+ return options?.default;
3397
3399
  const {
3398
3400
  rounding = import_bignumber.default.ROUND_DOWN,
3399
3401
  delimiters,
package/dist/index.d.ts CHANGED
@@ -108,6 +108,14 @@ type Option<L extends Key = 'label', V extends Key = 'value', C extends Key = 'c
108
108
  } & {
109
109
  [P in C]?: Option<L, V, C>[];
110
110
  };
111
+ type OmitBy<T, V> = {
112
+ [K in keyof T as T[K] extends V ? never : K]: T[K];
113
+ };
114
+ type PickBy<T, U> = {
115
+ [K in keyof T as T[K] extends U ? K : never]: T[K];
116
+ };
117
+ type Overwrite<T, U> = Pick<T, Exclude<keyof T, keyof U>> & U;
118
+ type Assign<T, U> = Omit<T, keyof U> & U;
111
119
 
112
120
  declare function redirectTo(url: string, target?: string): void;
113
121
  declare function dialsPhone(phoneNumber: string): void;
@@ -244,6 +252,7 @@ interface FormatNumericOptions {
244
252
  rounding?: Bignumber.RoundingMode;
245
253
  decimals?: number;
246
254
  zeromove?: boolean;
255
+ default?: string;
247
256
  format?: Bignumber.Format;
248
257
  }
249
258
  declare function bignum(n?: Numberish): Bignumber;
@@ -592,4 +601,4 @@ declare function unwrap<T extends object>(value: T | (() => T)): T;
592
601
  declare function whenever<T, C extends (value: Exclude<T, null | undefined>) => any>(value: T, callback: C): ReturnType<C> | undefined;
593
602
  declare function call<T extends Fn$1<any>>(fn: T, ...args: Parameters<T>): ReturnType<T>;
594
603
 
595
- export { type AnyFn, type ArgumentsType, type Arrayable, type Awaitable, BIG_INTS, type BooleanLike, type ConstructorType, type DecimalOptions, type DeepKeyof, 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 Noop, type Nullable, type NumberObject, type Numberish, type Numeric, type NumericObject, type OpenFilePickerOptions, type OpenImagePickerOptions, type Option, type PromiseFn, type PromiseType, type Promisify, type ReaderType, type StringObject, type SymbolObject, type Typeof, arange, average, bignum, call, camelCase, capitalCase, compose, constantCase, cover, decimal, delay, dialsPhone, dotCase, downloadBlobFile, downloadNetworkFile, ensurePrefix, ensureSuffix, formToObject, formatNumeric, formatSize, formatUnit, 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, noop, numfix, objectToForm, off, on, parseNumeric, pascalCase, pascalSnakeCase, pathCase, percentage, pipe, plus, proxy, randomArray, randomNumber, randomString, readFileReader, redirectTo, riposte, selectImages, sentenceCase, showOpenFilePicker, showOpenImagePicker, slash, snakeCase, template, to, trainCase, unindent, unwrap, whenever, zerofill, zeromove };
604
+ export { type AnyFn, type ArgumentsType, type Arrayable, type Assign, type Awaitable, BIG_INTS, type BooleanLike, type ConstructorType, type DecimalOptions, type DeepKeyof, 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 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, bignum, call, camelCase, capitalCase, compose, constantCase, cover, decimal, delay, dialsPhone, dotCase, downloadBlobFile, downloadNetworkFile, ensurePrefix, ensureSuffix, formToObject, formatNumeric, formatSize, formatUnit, 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, noop, numfix, objectToForm, off, on, parseNumeric, pascalCase, pascalSnakeCase, pathCase, percentage, pipe, plus, proxy, randomArray, randomNumber, randomString, readFileReader, redirectTo, riposte, selectImages, sentenceCase, showOpenFilePicker, showOpenImagePicker, slash, snakeCase, template, to, trainCase, unindent, unwrap, whenever, zerofill, zeromove };
@@ -4570,6 +4570,8 @@
4570
4570
  return options || { v: 1, d: 0, n: "" };
4571
4571
  }
4572
4572
  function formatNumeric(value = "0", options) {
4573
+ if (options?.default && bignum(value).isZero())
4574
+ return options?.default;
4573
4575
  const {
4574
4576
  rounding = bignumber_default.ROUND_DOWN,
4575
4577
  delimiters,
package/dist/index.js CHANGED
@@ -3225,6 +3225,8 @@ function parseNumeric(num, delimiters = ["t", "b", "m"]) {
3225
3225
  return options || { v: 1, d: 0, n: "" };
3226
3226
  }
3227
3227
  function formatNumeric(value = "0", options) {
3228
+ if (options?.default && bignum(value).isZero())
3229
+ return options?.default;
3228
3230
  const {
3229
3231
  rounding = Bignumber.ROUND_DOWN,
3230
3232
  delimiters,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hairy/utils",
3
3
  "type": "module",
4
- "version": "1.34.0",
4
+ "version": "1.35.0",
5
5
  "description": "Library for anywhere",
6
6
  "author": "Hairyf <wwu710632@gmail.com>",
7
7
  "license": "MIT",