@hairy/utils 1.31.0 → 1.32.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
@@ -31,11 +31,12 @@ 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,
35
34
  Bignumber: () => import_bignumber.default,
36
35
  Deferred: () => Deferred,
37
36
  arange: () => arange,
38
37
  average: () => average,
38
+ bignum: () => bignum,
39
+ call: () => call,
39
40
  camelCase: () => camelCase,
40
41
  capitalCase: () => capitalCase,
41
42
  clone: () => clone_default,
@@ -59,6 +60,7 @@ __export(index_exports, {
59
60
  formatSize: () => formatSize,
60
61
  formatUnit: () => formatUnit,
61
62
  getTypeof: () => getTypeof,
63
+ groupBy: () => groupBy_default,
62
64
  gt: () => gt,
63
65
  gte: () => gte,
64
66
  integer: () => integer,
@@ -105,7 +107,7 @@ __export(index_exports, {
105
107
  mergeWith: () => mergeWith_default,
106
108
  noCase: () => noCase,
107
109
  noop: () => noop2,
108
- numerfix: () => numerfix,
110
+ numfix: () => numfix,
109
111
  objectToForm: () => objectToForm,
110
112
  off: () => off,
111
113
  on: () => on,
@@ -2527,6 +2529,17 @@ function baseIteratee(value) {
2527
2529
  }
2528
2530
  var baseIteratee_default = baseIteratee;
2529
2531
 
2532
+ // ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_arrayAggregator.js
2533
+ function arrayAggregator(array, setter, iteratee, accumulator) {
2534
+ var index = -1, length = array == null ? 0 : array.length;
2535
+ while (++index < length) {
2536
+ var value = array[index];
2537
+ setter(accumulator, value, iteratee(value), array);
2538
+ }
2539
+ return accumulator;
2540
+ }
2541
+ var arrayAggregator_default = arrayAggregator;
2542
+
2530
2543
  // ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_createBaseFor.js
2531
2544
  function createBaseFor(fromRight) {
2532
2545
  return function(object, iteratee, keysFunc) {
@@ -2546,6 +2559,54 @@ var createBaseFor_default = createBaseFor;
2546
2559
  var baseFor = createBaseFor_default();
2547
2560
  var baseFor_default = baseFor;
2548
2561
 
2562
+ // ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseForOwn.js
2563
+ function baseForOwn(object, iteratee) {
2564
+ return object && baseFor_default(object, iteratee, keys_default);
2565
+ }
2566
+ var baseForOwn_default = baseForOwn;
2567
+
2568
+ // ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_createBaseEach.js
2569
+ function createBaseEach(eachFunc, fromRight) {
2570
+ return function(collection, iteratee) {
2571
+ if (collection == null) {
2572
+ return collection;
2573
+ }
2574
+ if (!isArrayLike_default(collection)) {
2575
+ return eachFunc(collection, iteratee);
2576
+ }
2577
+ var length = collection.length, index = fromRight ? length : -1, iterable = Object(collection);
2578
+ while (fromRight ? index-- : ++index < length) {
2579
+ if (iteratee(iterable[index], index, iterable) === false) {
2580
+ break;
2581
+ }
2582
+ }
2583
+ return collection;
2584
+ };
2585
+ }
2586
+ var createBaseEach_default = createBaseEach;
2587
+
2588
+ // ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseEach.js
2589
+ var baseEach = createBaseEach_default(baseForOwn_default);
2590
+ var baseEach_default = baseEach;
2591
+
2592
+ // ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseAggregator.js
2593
+ function baseAggregator(collection, setter, iteratee, accumulator) {
2594
+ baseEach_default(collection, function(value, key, collection2) {
2595
+ setter(accumulator, value, iteratee(value), collection2);
2596
+ });
2597
+ return accumulator;
2598
+ }
2599
+ var baseAggregator_default = baseAggregator;
2600
+
2601
+ // ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_createAggregator.js
2602
+ function createAggregator(setter, initializer) {
2603
+ return function(collection, iteratee) {
2604
+ var func = isArray_default(collection) ? arrayAggregator_default : baseAggregator_default, accumulator = initializer ? initializer() : {};
2605
+ return func(collection, setter, baseIteratee_default(iteratee, 2), accumulator);
2606
+ };
2607
+ }
2608
+ var createAggregator_default = createAggregator;
2609
+
2549
2610
  // ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/now.js
2550
2611
  var now = function() {
2551
2612
  return root_default.Date.now();
@@ -2791,6 +2852,18 @@ var findIndex_default = findIndex;
2791
2852
  var find = createFind_default(findIndex_default);
2792
2853
  var find_default = find;
2793
2854
 
2855
+ // ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/groupBy.js
2856
+ var objectProto17 = Object.prototype;
2857
+ var hasOwnProperty14 = objectProto17.hasOwnProperty;
2858
+ var groupBy = createAggregator_default(function(result, value, key) {
2859
+ if (hasOwnProperty14.call(result, key)) {
2860
+ result[key].push(value);
2861
+ } else {
2862
+ baseAssignValue_default(result, key, [value]);
2863
+ }
2864
+ });
2865
+ var groupBy_default = groupBy;
2866
+
2794
2867
  // ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isString.js
2795
2868
  var stringTag5 = "[object String]";
2796
2869
  function isString(value) {
@@ -2834,8 +2907,8 @@ var isDate_default = isDate;
2834
2907
  // ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isEmpty.js
2835
2908
  var mapTag7 = "[object Map]";
2836
2909
  var setTag7 = "[object Set]";
2837
- var objectProto17 = Object.prototype;
2838
- var hasOwnProperty14 = objectProto17.hasOwnProperty;
2910
+ var objectProto18 = Object.prototype;
2911
+ var hasOwnProperty15 = objectProto18.hasOwnProperty;
2839
2912
  function isEmpty(value) {
2840
2913
  if (value == null) {
2841
2914
  return true;
@@ -2851,7 +2924,7 @@ function isEmpty(value) {
2851
2924
  return !baseKeys_default(value).length;
2852
2925
  }
2853
2926
  for (var key in value) {
2854
- if (hasOwnProperty14.call(value, key)) {
2927
+ if (hasOwnProperty15.call(value, key)) {
2855
2928
  return false;
2856
2929
  }
2857
2930
  }
@@ -3101,40 +3174,43 @@ var BIG_INTS = {
3101
3174
  m: { v: 10 ** 6, d: 7, n: "m" },
3102
3175
  k: { v: 10 ** 3, d: 4, n: "k" }
3103
3176
  };
3104
- function BigNum(num = "0") {
3105
- return new import_bignumber.default(numerfix(num));
3177
+ function bignum(n = "0") {
3178
+ return new import_bignumber.default(numfix(n));
3179
+ }
3180
+ function numfix(value) {
3181
+ return Number.isNaN(Number(value)) || value.toString() === "NaN" ? "0" : String(value);
3106
3182
  }
3107
- function gte(num, n) {
3108
- return BigNum(num).gte(BigNum(n));
3183
+ function gte(a, b) {
3184
+ return bignum(a).gte(bignum(b));
3109
3185
  }
3110
- function gt(num, n) {
3111
- return BigNum(num).gt(BigNum(n));
3186
+ function gt(a, b) {
3187
+ return bignum(a).gt(bignum(b));
3112
3188
  }
3113
- function lte(num, n) {
3114
- return BigNum(num).lte(BigNum(n));
3189
+ function lte(a, b) {
3190
+ return bignum(a).lte(bignum(b));
3115
3191
  }
3116
- function lt(num, n) {
3117
- return BigNum(num).lt(BigNum(n));
3192
+ function lt(a, b) {
3193
+ return bignum(a).lt(bignum(b));
3118
3194
  }
3119
3195
  function plus(array, options) {
3120
3196
  const rounding = options?.r || import_bignumber.default.ROUND_DOWN;
3121
3197
  const decimal2 = options?.d || 0;
3122
- return array.filter((v) => BigNum(v).gt(0)).reduce((t, v) => t.plus(BigNum(v)), BigNum(0)).toFixed(decimal2, rounding);
3198
+ return array.filter((v) => bignum(v).gt(0)).reduce((t, v) => t.plus(bignum(v)), bignum(0)).toFixed(decimal2, rounding);
3123
3199
  }
3124
3200
  function average(array, options) {
3125
3201
  const rounding = options?.r || import_bignumber.default.ROUND_DOWN;
3126
3202
  const decimal2 = options?.d || 0;
3127
3203
  if (array.length === 0)
3128
3204
  return "0";
3129
- return BigNum(plus(array)).div(array.length).toFixed(decimal2, rounding);
3205
+ return bignum(plus(array)).div(array.length).toFixed(decimal2, rounding);
3130
3206
  }
3131
3207
  function percentage(total, count, options) {
3132
3208
  options ??= { d: 3, r: import_bignumber.default.ROUND_DOWN };
3133
3209
  const rounding = options?.r || import_bignumber.default.ROUND_DOWN;
3134
3210
  const decimal2 = options?.d || 3;
3135
- if (BigNum(total).lte(0) || BigNum(count).lte(0))
3211
+ if (bignum(total).lte(0) || bignum(count).lte(0))
3136
3212
  return "0";
3137
- return BigNum(count).div(BigNum(total)).times(100).toFixed(decimal2, rounding);
3213
+ return bignum(count).div(bignum(total)).times(100).toFixed(decimal2, rounding);
3138
3214
  }
3139
3215
  function zerofill(value, n = 2, type = "positive") {
3140
3216
  const _value = integer(value);
@@ -3150,15 +3226,11 @@ function zerofill(value, n = 2, type = "positive") {
3150
3226
  function zeromove(value) {
3151
3227
  return value.toString().replace(/\.?0+$/, "");
3152
3228
  }
3153
- function numerfix(value) {
3154
- const _isNaN = Number.isNaN(Number(value)) || value.toString() === "NaN";
3155
- return _isNaN ? "0" : String(value);
3156
- }
3157
3229
  function integer(value) {
3158
- return new import_bignumber.default(numerfix(value)).toFixed(0);
3230
+ return new import_bignumber.default(numfix(value)).toFixed(0);
3159
3231
  }
3160
3232
  function decimal(value, n = 2) {
3161
- let [integer2, decimal2] = numerfix(value).split(".");
3233
+ let [integer2, decimal2] = numfix(value).split(".");
3162
3234
  if (n <= 0)
3163
3235
  return integer2;
3164
3236
  if (!decimal2)
@@ -3176,7 +3248,7 @@ function parseNumeric(num, delimiters = ["t", "b", "m"]) {
3176
3248
  ];
3177
3249
  let options;
3178
3250
  for (const analy of mappings) {
3179
- const opts = analy && analy(BigNum(num).toFixed(0));
3251
+ const opts = analy && analy(bignum(num).toFixed(0));
3180
3252
  opts && (options = opts);
3181
3253
  }
3182
3254
  return options || { v: 1, d: 0, n: "" };
@@ -3189,7 +3261,7 @@ function formatNumeric(value = "0", options) {
3189
3261
  decimals = 2
3190
3262
  } = options || {};
3191
3263
  const config = parseNumeric(value, delimiters || []);
3192
- let number = BigNum(value).div(config.v).toFormat(decimals, rounding, {
3264
+ let number = bignum(value).div(config.v).toFormat(decimals, rounding, {
3193
3265
  decimalSeparator: ".",
3194
3266
  groupSeparator: ",",
3195
3267
  groupSize: 3,
@@ -3434,14 +3506,18 @@ function unwrap(value) {
3434
3506
  function whenever(value, callback) {
3435
3507
  return value ? callback(value) : void 0;
3436
3508
  }
3509
+ function call(fn, ...args) {
3510
+ return fn(...args);
3511
+ }
3437
3512
  // Annotate the CommonJS export names for ESM import in node:
3438
3513
  0 && (module.exports = {
3439
3514
  BIG_INTS,
3440
- BigNum,
3441
3515
  Bignumber,
3442
3516
  Deferred,
3443
3517
  arange,
3444
3518
  average,
3519
+ bignum,
3520
+ call,
3445
3521
  camelCase,
3446
3522
  capitalCase,
3447
3523
  clone,
@@ -3465,6 +3541,7 @@ function whenever(value, callback) {
3465
3541
  formatSize,
3466
3542
  formatUnit,
3467
3543
  getTypeof,
3544
+ groupBy,
3468
3545
  gt,
3469
3546
  gte,
3470
3547
  integer,
@@ -3511,7 +3588,7 @@ function whenever(value, callback) {
3511
3588
  mergeWith,
3512
3589
  noCase,
3513
3590
  noop,
3514
- numerfix,
3591
+ numfix,
3515
3592
  objectToForm,
3516
3593
  off,
3517
3594
  on,
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { clone, cloneDeep, cloneDeepWith, cloneWith, concat, debounce, find, isArray, isArrayLike, isBoolean, isDate, isEmpty, isEqual, isError, isFunction, isNaN, isNative, isNull, isNumber, isObject, isPlainObject, isString, isUndefined, join, keys, merge, mergeWith, truncate, uniq, uniqBy, uniqWith, values } from 'lodash-es';
1
+ export { clone, cloneDeep, cloneDeepWith, cloneWith, concat, debounce, find, groupBy, isArray, isArrayLike, isBoolean, isDate, isEmpty, isEqual, isError, isFunction, isNaN, isNative, isNull, isNumber, isObject, isPlainObject, isString, isUndefined, join, keys, merge, mergeWith, truncate, uniq, uniqBy, uniqWith, values } from 'lodash-es';
2
2
  import Bignumber from 'bignumber.js';
3
3
  export { default as Bignumber } from 'bignumber.js';
4
4
 
@@ -230,11 +230,12 @@ interface FormatNumericOptions {
230
230
  zeromove?: boolean;
231
231
  format?: Bignumber.Format;
232
232
  }
233
- declare function BigNum(num?: Numberish): Bignumber;
234
- declare function gte(num: Numberish, n: Numberish): boolean;
235
- declare function gt(num: Numberish, n: Numberish): boolean;
236
- declare function lte(num: Numberish, n: Numberish): boolean;
237
- declare function lt(num: Numberish, n: Numberish): boolean;
233
+ declare function bignum(n?: Numberish): Bignumber;
234
+ declare function numfix(value: any): string;
235
+ declare function gte(a: Numberish, b: Numberish): boolean;
236
+ declare function gt(a: Numberish, b: Numberish): boolean;
237
+ declare function lte(a: Numberish, b: Numberish): boolean;
238
+ declare function lt(a: Numberish, b: Numberish): boolean;
238
239
  declare function plus(array: Numberish[], options?: DecimalOptions): string;
239
240
  declare function average(array: Numberish[], options?: DecimalOptions): string;
240
241
  /**
@@ -251,7 +252,6 @@ declare function percentage(total: Numberish, count: Numberish, options?: Decima
251
252
  */
252
253
  declare function zerofill(value: Numberish, n?: number, type?: 'positive' | 'reverse'): Numberish;
253
254
  declare function zeromove(value: Numberish): string;
254
- declare function numerfix(value: any): string;
255
255
  /**
256
256
  * format as a positive integer
257
257
  * @param value
@@ -527,5 +527,6 @@ declare function arange(x1: number, x2?: number, stp?: number, z?: number[], z0?
527
527
  declare function riposte<T>(...args: [cond: boolean, value: T][]): T;
528
528
  declare function unwrap<T extends object>(value: T | (() => T)): T;
529
529
  declare function whenever<T, C extends (value: Exclude<T, null | undefined>) => any>(value: T, callback: C): ReturnType<C> | undefined;
530
+ declare function call<T extends Fn$1<any>>(fn: T, ...args: Parameters<T>): ReturnType<T>;
530
531
 
531
- export { type AnyFn, type ArgumentsType, type Arrayable, type Awaitable, BIG_INTS, BigNum, 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, camelCase, capitalCase, compose, constantCase, cover, decimal, delay, dialsPhone, dotCase, downloadBlobFile, downloadNetworkFile, 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, numerfix, objectToForm, off, on, parseNumeric, pascalCase, pascalSnakeCase, pathCase, percentage, pipe, plus, proxy, randomArray, randomNumer, readFileReader, redirectTo, riposte, selectImages, sentenceCase, showOpenFilePicker, showOpenImagePicker, snakeCase, to, trainCase, unwrap, whenever, zerofill, zeromove };
532
+ 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, 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, randomNumer, readFileReader, redirectTo, riposte, selectImages, sentenceCase, showOpenFilePicker, showOpenImagePicker, snakeCase, to, trainCase, unwrap, whenever, zerofill, zeromove };
@@ -2386,6 +2386,17 @@
2386
2386
  }
2387
2387
  var baseIteratee_default = baseIteratee;
2388
2388
 
2389
+ // ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_arrayAggregator.js
2390
+ function arrayAggregator(array, setter, iteratee, accumulator) {
2391
+ var index = -1, length = array == null ? 0 : array.length;
2392
+ while (++index < length) {
2393
+ var value = array[index];
2394
+ setter(accumulator, value, iteratee(value), array);
2395
+ }
2396
+ return accumulator;
2397
+ }
2398
+ var arrayAggregator_default = arrayAggregator;
2399
+
2389
2400
  // ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_createBaseFor.js
2390
2401
  function createBaseFor(fromRight) {
2391
2402
  return function(object, iteratee, keysFunc) {
@@ -2405,6 +2416,54 @@
2405
2416
  var baseFor = createBaseFor_default();
2406
2417
  var baseFor_default = baseFor;
2407
2418
 
2419
+ // ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseForOwn.js
2420
+ function baseForOwn(object, iteratee) {
2421
+ return object && baseFor_default(object, iteratee, keys_default);
2422
+ }
2423
+ var baseForOwn_default = baseForOwn;
2424
+
2425
+ // ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_createBaseEach.js
2426
+ function createBaseEach(eachFunc, fromRight) {
2427
+ return function(collection, iteratee) {
2428
+ if (collection == null) {
2429
+ return collection;
2430
+ }
2431
+ if (!isArrayLike_default(collection)) {
2432
+ return eachFunc(collection, iteratee);
2433
+ }
2434
+ var length = collection.length, index = fromRight ? length : -1, iterable = Object(collection);
2435
+ while (fromRight ? index-- : ++index < length) {
2436
+ if (iteratee(iterable[index], index, iterable) === false) {
2437
+ break;
2438
+ }
2439
+ }
2440
+ return collection;
2441
+ };
2442
+ }
2443
+ var createBaseEach_default = createBaseEach;
2444
+
2445
+ // ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseEach.js
2446
+ var baseEach = createBaseEach_default(baseForOwn_default);
2447
+ var baseEach_default = baseEach;
2448
+
2449
+ // ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseAggregator.js
2450
+ function baseAggregator(collection, setter, iteratee, accumulator) {
2451
+ baseEach_default(collection, function(value, key, collection2) {
2452
+ setter(accumulator, value, iteratee(value), collection2);
2453
+ });
2454
+ return accumulator;
2455
+ }
2456
+ var baseAggregator_default = baseAggregator;
2457
+
2458
+ // ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_createAggregator.js
2459
+ function createAggregator(setter, initializer) {
2460
+ return function(collection, iteratee) {
2461
+ var func = isArray_default(collection) ? arrayAggregator_default : baseAggregator_default, accumulator = initializer ? initializer() : {};
2462
+ return func(collection, setter, baseIteratee_default(iteratee, 2), accumulator);
2463
+ };
2464
+ }
2465
+ var createAggregator_default = createAggregator;
2466
+
2408
2467
  // ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/now.js
2409
2468
  var now = function() {
2410
2469
  return root_default.Date.now();
@@ -2650,6 +2709,18 @@
2650
2709
  var find = createFind_default(findIndex_default);
2651
2710
  var find_default = find;
2652
2711
 
2712
+ // ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/groupBy.js
2713
+ var objectProto17 = Object.prototype;
2714
+ var hasOwnProperty14 = objectProto17.hasOwnProperty;
2715
+ var groupBy = createAggregator_default(function(result, value, key) {
2716
+ if (hasOwnProperty14.call(result, key)) {
2717
+ result[key].push(value);
2718
+ } else {
2719
+ baseAssignValue_default(result, key, [value]);
2720
+ }
2721
+ });
2722
+ var groupBy_default = groupBy;
2723
+
2653
2724
  // ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isString.js
2654
2725
  var stringTag5 = "[object String]";
2655
2726
  function isString(value) {
@@ -2693,8 +2764,8 @@
2693
2764
  // ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isEmpty.js
2694
2765
  var mapTag7 = "[object Map]";
2695
2766
  var setTag7 = "[object Set]";
2696
- var objectProto17 = Object.prototype;
2697
- var hasOwnProperty14 = objectProto17.hasOwnProperty;
2767
+ var objectProto18 = Object.prototype;
2768
+ var hasOwnProperty15 = objectProto18.hasOwnProperty;
2698
2769
  function isEmpty(value) {
2699
2770
  if (value == null) {
2700
2771
  return true;
@@ -2710,7 +2781,7 @@
2710
2781
  return !baseKeys_default(value).length;
2711
2782
  }
2712
2783
  for (var key in value) {
2713
- if (hasOwnProperty14.call(value, key)) {
2784
+ if (hasOwnProperty15.call(value, key)) {
2714
2785
  return false;
2715
2786
  }
2716
2787
  }
@@ -4303,40 +4374,43 @@
4303
4374
  m: { v: 10 ** 6, d: 7, n: "m" },
4304
4375
  k: { v: 10 ** 3, d: 4, n: "k" }
4305
4376
  };
4306
- function BigNum(num = "0") {
4307
- return new bignumber_default(numerfix(num));
4377
+ function bignum(n = "0") {
4378
+ return new bignumber_default(numfix(n));
4379
+ }
4380
+ function numfix(value) {
4381
+ return Number.isNaN(Number(value)) || value.toString() === "NaN" ? "0" : String(value);
4308
4382
  }
4309
- function gte(num, n) {
4310
- return BigNum(num).gte(BigNum(n));
4383
+ function gte(a, b) {
4384
+ return bignum(a).gte(bignum(b));
4311
4385
  }
4312
- function gt(num, n) {
4313
- return BigNum(num).gt(BigNum(n));
4386
+ function gt(a, b) {
4387
+ return bignum(a).gt(bignum(b));
4314
4388
  }
4315
- function lte(num, n) {
4316
- return BigNum(num).lte(BigNum(n));
4389
+ function lte(a, b) {
4390
+ return bignum(a).lte(bignum(b));
4317
4391
  }
4318
- function lt(num, n) {
4319
- return BigNum(num).lt(BigNum(n));
4392
+ function lt(a, b) {
4393
+ return bignum(a).lt(bignum(b));
4320
4394
  }
4321
4395
  function plus(array, options) {
4322
4396
  const rounding = options?.r || bignumber_default.ROUND_DOWN;
4323
4397
  const decimal2 = options?.d || 0;
4324
- return array.filter((v) => BigNum(v).gt(0)).reduce((t, v) => t.plus(BigNum(v)), BigNum(0)).toFixed(decimal2, rounding);
4398
+ return array.filter((v) => bignum(v).gt(0)).reduce((t, v) => t.plus(bignum(v)), bignum(0)).toFixed(decimal2, rounding);
4325
4399
  }
4326
4400
  function average(array, options) {
4327
4401
  const rounding = options?.r || bignumber_default.ROUND_DOWN;
4328
4402
  const decimal2 = options?.d || 0;
4329
4403
  if (array.length === 0)
4330
4404
  return "0";
4331
- return BigNum(plus(array)).div(array.length).toFixed(decimal2, rounding);
4405
+ return bignum(plus(array)).div(array.length).toFixed(decimal2, rounding);
4332
4406
  }
4333
4407
  function percentage(total, count, options) {
4334
4408
  options ??= { d: 3, r: bignumber_default.ROUND_DOWN };
4335
4409
  const rounding = options?.r || bignumber_default.ROUND_DOWN;
4336
4410
  const decimal2 = options?.d || 3;
4337
- if (BigNum(total).lte(0) || BigNum(count).lte(0))
4411
+ if (bignum(total).lte(0) || bignum(count).lte(0))
4338
4412
  return "0";
4339
- return BigNum(count).div(BigNum(total)).times(100).toFixed(decimal2, rounding);
4413
+ return bignum(count).div(bignum(total)).times(100).toFixed(decimal2, rounding);
4340
4414
  }
4341
4415
  function zerofill(value, n = 2, type = "positive") {
4342
4416
  const _value = integer(value);
@@ -4352,15 +4426,11 @@
4352
4426
  function zeromove(value) {
4353
4427
  return value.toString().replace(/\.?0+$/, "");
4354
4428
  }
4355
- function numerfix(value) {
4356
- const _isNaN = Number.isNaN(Number(value)) || value.toString() === "NaN";
4357
- return _isNaN ? "0" : String(value);
4358
- }
4359
4429
  function integer(value) {
4360
- return new bignumber_default(numerfix(value)).toFixed(0);
4430
+ return new bignumber_default(numfix(value)).toFixed(0);
4361
4431
  }
4362
4432
  function decimal(value, n = 2) {
4363
- let [integer2, decimal2] = numerfix(value).split(".");
4433
+ let [integer2, decimal2] = numfix(value).split(".");
4364
4434
  if (n <= 0)
4365
4435
  return integer2;
4366
4436
  if (!decimal2)
@@ -4378,7 +4448,7 @@
4378
4448
  ];
4379
4449
  let options;
4380
4450
  for (const analy of mappings) {
4381
- const opts = analy && analy(BigNum(num).toFixed(0));
4451
+ const opts = analy && analy(bignum(num).toFixed(0));
4382
4452
  opts && (options = opts);
4383
4453
  }
4384
4454
  return options || { v: 1, d: 0, n: "" };
@@ -4391,7 +4461,7 @@
4391
4461
  decimals = 2
4392
4462
  } = options || {};
4393
4463
  const config = parseNumeric(value, delimiters || []);
4394
- let number = BigNum(value).div(config.v).toFormat(decimals, rounding, {
4464
+ let number = bignum(value).div(config.v).toFormat(decimals, rounding, {
4395
4465
  decimalSeparator: ".",
4396
4466
  groupSeparator: ",",
4397
4467
  groupSize: 3,
@@ -4636,6 +4706,9 @@
4636
4706
  function whenever(value, callback) {
4637
4707
  return value ? callback(value) : void 0;
4638
4708
  }
4709
+ function call(fn, ...args) {
4710
+ return fn(...args);
4711
+ }
4639
4712
  })();
4640
4713
  /*! Bundled license information:
4641
4714
 
package/dist/index.js CHANGED
@@ -2384,6 +2384,17 @@ function baseIteratee(value) {
2384
2384
  }
2385
2385
  var baseIteratee_default = baseIteratee;
2386
2386
 
2387
+ // ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_arrayAggregator.js
2388
+ function arrayAggregator(array, setter, iteratee, accumulator) {
2389
+ var index = -1, length = array == null ? 0 : array.length;
2390
+ while (++index < length) {
2391
+ var value = array[index];
2392
+ setter(accumulator, value, iteratee(value), array);
2393
+ }
2394
+ return accumulator;
2395
+ }
2396
+ var arrayAggregator_default = arrayAggregator;
2397
+
2387
2398
  // ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_createBaseFor.js
2388
2399
  function createBaseFor(fromRight) {
2389
2400
  return function(object, iteratee, keysFunc) {
@@ -2403,6 +2414,54 @@ var createBaseFor_default = createBaseFor;
2403
2414
  var baseFor = createBaseFor_default();
2404
2415
  var baseFor_default = baseFor;
2405
2416
 
2417
+ // ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseForOwn.js
2418
+ function baseForOwn(object, iteratee) {
2419
+ return object && baseFor_default(object, iteratee, keys_default);
2420
+ }
2421
+ var baseForOwn_default = baseForOwn;
2422
+
2423
+ // ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_createBaseEach.js
2424
+ function createBaseEach(eachFunc, fromRight) {
2425
+ return function(collection, iteratee) {
2426
+ if (collection == null) {
2427
+ return collection;
2428
+ }
2429
+ if (!isArrayLike_default(collection)) {
2430
+ return eachFunc(collection, iteratee);
2431
+ }
2432
+ var length = collection.length, index = fromRight ? length : -1, iterable = Object(collection);
2433
+ while (fromRight ? index-- : ++index < length) {
2434
+ if (iteratee(iterable[index], index, iterable) === false) {
2435
+ break;
2436
+ }
2437
+ }
2438
+ return collection;
2439
+ };
2440
+ }
2441
+ var createBaseEach_default = createBaseEach;
2442
+
2443
+ // ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseEach.js
2444
+ var baseEach = createBaseEach_default(baseForOwn_default);
2445
+ var baseEach_default = baseEach;
2446
+
2447
+ // ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseAggregator.js
2448
+ function baseAggregator(collection, setter, iteratee, accumulator) {
2449
+ baseEach_default(collection, function(value, key, collection2) {
2450
+ setter(accumulator, value, iteratee(value), collection2);
2451
+ });
2452
+ return accumulator;
2453
+ }
2454
+ var baseAggregator_default = baseAggregator;
2455
+
2456
+ // ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_createAggregator.js
2457
+ function createAggregator(setter, initializer) {
2458
+ return function(collection, iteratee) {
2459
+ var func = isArray_default(collection) ? arrayAggregator_default : baseAggregator_default, accumulator = initializer ? initializer() : {};
2460
+ return func(collection, setter, baseIteratee_default(iteratee, 2), accumulator);
2461
+ };
2462
+ }
2463
+ var createAggregator_default = createAggregator;
2464
+
2406
2465
  // ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/now.js
2407
2466
  var now = function() {
2408
2467
  return root_default.Date.now();
@@ -2648,6 +2707,18 @@ var findIndex_default = findIndex;
2648
2707
  var find = createFind_default(findIndex_default);
2649
2708
  var find_default = find;
2650
2709
 
2710
+ // ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/groupBy.js
2711
+ var objectProto17 = Object.prototype;
2712
+ var hasOwnProperty14 = objectProto17.hasOwnProperty;
2713
+ var groupBy = createAggregator_default(function(result, value, key) {
2714
+ if (hasOwnProperty14.call(result, key)) {
2715
+ result[key].push(value);
2716
+ } else {
2717
+ baseAssignValue_default(result, key, [value]);
2718
+ }
2719
+ });
2720
+ var groupBy_default = groupBy;
2721
+
2651
2722
  // ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isString.js
2652
2723
  var stringTag5 = "[object String]";
2653
2724
  function isString(value) {
@@ -2691,8 +2762,8 @@ var isDate_default = isDate;
2691
2762
  // ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isEmpty.js
2692
2763
  var mapTag7 = "[object Map]";
2693
2764
  var setTag7 = "[object Set]";
2694
- var objectProto17 = Object.prototype;
2695
- var hasOwnProperty14 = objectProto17.hasOwnProperty;
2765
+ var objectProto18 = Object.prototype;
2766
+ var hasOwnProperty15 = objectProto18.hasOwnProperty;
2696
2767
  function isEmpty(value) {
2697
2768
  if (value == null) {
2698
2769
  return true;
@@ -2708,7 +2779,7 @@ function isEmpty(value) {
2708
2779
  return !baseKeys_default(value).length;
2709
2780
  }
2710
2781
  for (var key in value) {
2711
- if (hasOwnProperty14.call(value, key)) {
2782
+ if (hasOwnProperty15.call(value, key)) {
2712
2783
  return false;
2713
2784
  }
2714
2785
  }
@@ -2958,40 +3029,43 @@ var BIG_INTS = {
2958
3029
  m: { v: 10 ** 6, d: 7, n: "m" },
2959
3030
  k: { v: 10 ** 3, d: 4, n: "k" }
2960
3031
  };
2961
- function BigNum(num = "0") {
2962
- return new Bignumber(numerfix(num));
3032
+ function bignum(n = "0") {
3033
+ return new Bignumber(numfix(n));
3034
+ }
3035
+ function numfix(value) {
3036
+ return Number.isNaN(Number(value)) || value.toString() === "NaN" ? "0" : String(value);
2963
3037
  }
2964
- function gte(num, n) {
2965
- return BigNum(num).gte(BigNum(n));
3038
+ function gte(a, b) {
3039
+ return bignum(a).gte(bignum(b));
2966
3040
  }
2967
- function gt(num, n) {
2968
- return BigNum(num).gt(BigNum(n));
3041
+ function gt(a, b) {
3042
+ return bignum(a).gt(bignum(b));
2969
3043
  }
2970
- function lte(num, n) {
2971
- return BigNum(num).lte(BigNum(n));
3044
+ function lte(a, b) {
3045
+ return bignum(a).lte(bignum(b));
2972
3046
  }
2973
- function lt(num, n) {
2974
- return BigNum(num).lt(BigNum(n));
3047
+ function lt(a, b) {
3048
+ return bignum(a).lt(bignum(b));
2975
3049
  }
2976
3050
  function plus(array, options) {
2977
3051
  const rounding = options?.r || Bignumber.ROUND_DOWN;
2978
3052
  const decimal2 = options?.d || 0;
2979
- return array.filter((v) => BigNum(v).gt(0)).reduce((t, v) => t.plus(BigNum(v)), BigNum(0)).toFixed(decimal2, rounding);
3053
+ return array.filter((v) => bignum(v).gt(0)).reduce((t, v) => t.plus(bignum(v)), bignum(0)).toFixed(decimal2, rounding);
2980
3054
  }
2981
3055
  function average(array, options) {
2982
3056
  const rounding = options?.r || Bignumber.ROUND_DOWN;
2983
3057
  const decimal2 = options?.d || 0;
2984
3058
  if (array.length === 0)
2985
3059
  return "0";
2986
- return BigNum(plus(array)).div(array.length).toFixed(decimal2, rounding);
3060
+ return bignum(plus(array)).div(array.length).toFixed(decimal2, rounding);
2987
3061
  }
2988
3062
  function percentage(total, count, options) {
2989
3063
  options ??= { d: 3, r: Bignumber.ROUND_DOWN };
2990
3064
  const rounding = options?.r || Bignumber.ROUND_DOWN;
2991
3065
  const decimal2 = options?.d || 3;
2992
- if (BigNum(total).lte(0) || BigNum(count).lte(0))
3066
+ if (bignum(total).lte(0) || bignum(count).lte(0))
2993
3067
  return "0";
2994
- return BigNum(count).div(BigNum(total)).times(100).toFixed(decimal2, rounding);
3068
+ return bignum(count).div(bignum(total)).times(100).toFixed(decimal2, rounding);
2995
3069
  }
2996
3070
  function zerofill(value, n = 2, type = "positive") {
2997
3071
  const _value = integer(value);
@@ -3007,15 +3081,11 @@ function zerofill(value, n = 2, type = "positive") {
3007
3081
  function zeromove(value) {
3008
3082
  return value.toString().replace(/\.?0+$/, "");
3009
3083
  }
3010
- function numerfix(value) {
3011
- const _isNaN = Number.isNaN(Number(value)) || value.toString() === "NaN";
3012
- return _isNaN ? "0" : String(value);
3013
- }
3014
3084
  function integer(value) {
3015
- return new Bignumber(numerfix(value)).toFixed(0);
3085
+ return new Bignumber(numfix(value)).toFixed(0);
3016
3086
  }
3017
3087
  function decimal(value, n = 2) {
3018
- let [integer2, decimal2] = numerfix(value).split(".");
3088
+ let [integer2, decimal2] = numfix(value).split(".");
3019
3089
  if (n <= 0)
3020
3090
  return integer2;
3021
3091
  if (!decimal2)
@@ -3033,7 +3103,7 @@ function parseNumeric(num, delimiters = ["t", "b", "m"]) {
3033
3103
  ];
3034
3104
  let options;
3035
3105
  for (const analy of mappings) {
3036
- const opts = analy && analy(BigNum(num).toFixed(0));
3106
+ const opts = analy && analy(bignum(num).toFixed(0));
3037
3107
  opts && (options = opts);
3038
3108
  }
3039
3109
  return options || { v: 1, d: 0, n: "" };
@@ -3046,7 +3116,7 @@ function formatNumeric(value = "0", options) {
3046
3116
  decimals = 2
3047
3117
  } = options || {};
3048
3118
  const config = parseNumeric(value, delimiters || []);
3049
- let number = BigNum(value).div(config.v).toFormat(decimals, rounding, {
3119
+ let number = bignum(value).div(config.v).toFormat(decimals, rounding, {
3050
3120
  decimalSeparator: ".",
3051
3121
  groupSeparator: ",",
3052
3122
  groupSize: 3,
@@ -3291,13 +3361,17 @@ function unwrap(value) {
3291
3361
  function whenever(value, callback) {
3292
3362
  return value ? callback(value) : void 0;
3293
3363
  }
3364
+ function call(fn, ...args) {
3365
+ return fn(...args);
3366
+ }
3294
3367
  export {
3295
3368
  BIG_INTS,
3296
- BigNum,
3297
3369
  Bignumber,
3298
3370
  Deferred,
3299
3371
  arange,
3300
3372
  average,
3373
+ bignum,
3374
+ call,
3301
3375
  camelCase,
3302
3376
  capitalCase,
3303
3377
  clone_default as clone,
@@ -3321,6 +3395,7 @@ export {
3321
3395
  formatSize,
3322
3396
  formatUnit,
3323
3397
  getTypeof,
3398
+ groupBy_default as groupBy,
3324
3399
  gt,
3325
3400
  gte,
3326
3401
  integer,
@@ -3367,7 +3442,7 @@ export {
3367
3442
  mergeWith_default as mergeWith,
3368
3443
  noCase,
3369
3444
  noop2 as noop,
3370
- numerfix,
3445
+ numfix,
3371
3446
  objectToForm,
3372
3447
  off,
3373
3448
  on,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@hairy/utils",
3
3
  "type": "module",
4
- "version": "1.31.0",
4
+ "version": "1.32.0",
5
5
  "description": "Library for anywhere",
6
6
  "author": "Hairyf <wwu710632@gmail.com>",
7
7
  "license": "MIT",