@heyform-inc/utils 1.0.8 → 1.0.9

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.d.mts CHANGED
@@ -1,4 +1,6 @@
1
1
  export * from 'deep-object-diff';
2
+ import { IParseOptions, IStringifyOptions } from 'qs';
3
+ export { default as qs } from 'qs';
2
4
  import dayjs, { QUnitType, OpUnitType } from 'dayjs';
3
5
  import visUUID from 'validator/lib/isUUID';
4
6
  import visFQDN from 'validator/lib/isFQDN';
@@ -29,7 +31,26 @@ declare function darken(hex: string, alpha: number): string;
29
31
  declare function invert(hex: string): string;
30
32
  declare function alphaHexToRgb(hex: string, alpha: number, backgroundHex: string): number[];
31
33
 
32
- declare function toBool(value: unknown, defaults?: boolean): boolean;
34
+ declare function toBool(value: unknown, defaults?: boolean): boolean;
35
+ declare const parseBool: typeof toBool;
36
+ declare function toInteger(value: unknown, defaults?: number, maxValue?: number): number | undefined;
37
+ declare const parseNumber: typeof toInteger;
38
+ declare const toInt: typeof toInteger;
39
+ declare function toFloat(value: unknown, defaults?: number, maxValue?: number): number | undefined;
40
+ declare function toFixed(value: number, precision?: number): string;
41
+ declare function toJSON<T extends object>(str: unknown, defaults?: T): T | undefined;
42
+ declare const parseJson: typeof toJSON;
43
+ declare function toIntlNumber(value: number): string;
44
+ interface ToDurationOptions {
45
+ hideOnZeroValue?: boolean;
46
+ padNumber?: boolean;
47
+ hourUnit?: string;
48
+ minuteUnit?: string;
49
+ secondUnit?: string;
50
+ }
51
+ declare function toDuration(value: number, options?: ToDurationOptions): string;
52
+ declare function toURLParams<T extends object>(value: string, options?: IParseOptions): T;
53
+ declare function toURLQuery(value: Record<string | number, any>, baseUri?: string, options?: IStringifyOptions): string;
33
54
 
34
55
  declare function timestamp(): number;
35
56
  declare function date(str?: string, format?: string): dayjs.Dayjs;
@@ -44,7 +65,9 @@ declare function isNumber(arg: any): boolean;
44
65
  declare function isValidArray(arg: any): boolean;
45
66
  declare function isNan(arg: any): boolean;
46
67
  declare function isSet(arg: any): boolean;
68
+ declare function isWeakSet(arg: any): boolean;
47
69
  declare function isMap(arg: any): boolean;
70
+ declare function isWeakMap(arg: any): boolean;
48
71
  declare function isSymbol(arg: any): boolean;
49
72
  declare function isObject(arg: any): boolean;
50
73
  declare function isDate(arg: any): boolean;
@@ -66,7 +89,7 @@ declare function uniqueArray(arg: any): any[];
66
89
  declare function isNumeric(arg: any, options?: IsNumericOptions): boolean;
67
90
  declare function isURL(arg: any, options?: IsURLOptions): boolean;
68
91
  declare function isEmail(arg: any, options?: IsEmailOptions): boolean;
69
- declare const _default$1: {
92
+ declare const _default: {
70
93
  isUUID: typeof visUUID;
71
94
  isFQDN: typeof visFQDN;
72
95
  isBoolean: typeof isBoolean;
@@ -78,6 +101,8 @@ declare const _default$1: {
78
101
  isNan: typeof isNan;
79
102
  isSet: typeof isSet;
80
103
  isMap: typeof isMap;
104
+ isWeakSet: typeof isWeakSet;
105
+ isWeakMap: typeof isWeakMap;
81
106
  isSymbol: typeof isSymbol;
82
107
  isObject: typeof isObject;
83
108
  isDate: typeof isDate;
@@ -101,7 +126,9 @@ declare const _default$1: {
101
126
  };
102
127
 
103
128
  declare function hs(arg: string): number | undefined;
104
- declare function ms(arg: string): number | undefined;
129
+ declare function ms(arg: string): number | undefined;
130
+ declare const toSecond: typeof hs;
131
+ declare const toMillisecond: typeof ms;
105
132
 
106
133
  declare const commonImageMimeTypes: string[];
107
134
  declare const commonFileMimeTypes: string[];
@@ -111,27 +138,13 @@ declare function nanoid(len?: number): string;
111
138
  declare function nanoidCustomAlphabet(alphabet: string, len?: number): string;
112
139
 
113
140
  declare function pickObject(target: Record<string, any>, fields: Array<string | string[]>, excludes?: Array<string>): Record<string, any>;
141
+ declare function excludeObject(target: Record<string, any>, excludes?: Array<string>): Record<string, any>;
114
142
  declare function pickValidValues<T = string | number | boolean>(target: Record<string, T>, fields: Array<string | string[]>): Record<string, T>;
115
143
  declare function removeObjectNil(target: Record<string, any>): Record<string, any>;
116
144
  declare function copyObjectValues(target: Record<string, any>, dist: Record<string, any>, keyMaps: Array<string | string[]>): void;
117
145
 
118
- declare function parseJson(str: string, defaultValue?: any): any;
119
- declare function parseBool(arg: any, defaultValue?: boolean): boolean;
120
- declare function parseNumber(arg: any, defaultValue?: number, maxValue?: number): number | undefined;
121
146
  declare function htmlToText(html: string, limit?: number): string;
122
147
 
123
- interface QsOptions {
124
- encode?: boolean;
125
- decode?: boolean;
126
- separator?: string;
127
- }
128
- declare function stringify(arg: Record<string, any>, options?: QsOptions): string;
129
- declare function parse(str: string, options?: QsOptions): Record<string, any>;
130
- declare const _default: {
131
- stringify: typeof stringify;
132
- parse: typeof parse;
133
- };
134
-
135
148
  declare enum RandomType {
136
149
  LOWER = 0,
137
150
  UPPER = 1,
@@ -155,4 +168,4 @@ declare function slugify(text: string, options?: SlugifyOptions): string;
155
168
 
156
169
  declare function type(obj: any): string;
157
170
 
158
- export { RandomType, type SlugifyOptions, alpha, alphaHexToRgb, bytes, clone, colorBrightness, commonFileMimeTypes, commonImageMimeTypes, copyObjectValues, darken, date, datePeriod, formatBytes, _default$1 as helper, hexToRgb, hs, htmlToText, invert, isDarkColor, isDateExpired, isHexColor, isLightColor, isRgb, isRgba, lighten, mime, ms, nanoid, nanoidCustomAlphabet, parseBool, parseBytes, parseJson, parseNumber, pickObject, pickValidValues, _default as qs, random, removeObjectNil, rgbToHex, slugify, timestamp, toBool, type, unixDate, unixDiff };
171
+ export { RandomType, type SlugifyOptions, alpha, alphaHexToRgb, bytes, clone, colorBrightness, commonFileMimeTypes, commonImageMimeTypes, copyObjectValues, darken, date, datePeriod, excludeObject, formatBytes, _default as helper, hexToRgb, hs, htmlToText, invert, isDarkColor, isDateExpired, isHexColor, isLightColor, isRgb, isRgba, lighten, mime, ms, nanoid, nanoidCustomAlphabet, parseBool, parseBytes, parseJson, parseNumber, pickObject, pickValidValues, random, removeObjectNil, rgbToHex, slugify, timestamp, toBool, toDuration, toFixed, toFloat, toInt, toInteger, toIntlNumber, toJSON, toMillisecond, toSecond, toURLParams, toURLQuery, type, unixDate, unixDiff };
package/dist/index.d.ts CHANGED
@@ -1,4 +1,6 @@
1
1
  export * from 'deep-object-diff';
2
+ import { IParseOptions, IStringifyOptions } from 'qs';
3
+ export { default as qs } from 'qs';
2
4
  import dayjs, { QUnitType, OpUnitType } from 'dayjs';
3
5
  import visUUID from 'validator/lib/isUUID';
4
6
  import visFQDN from 'validator/lib/isFQDN';
@@ -29,7 +31,26 @@ declare function darken(hex: string, alpha: number): string;
29
31
  declare function invert(hex: string): string;
30
32
  declare function alphaHexToRgb(hex: string, alpha: number, backgroundHex: string): number[];
31
33
 
32
- declare function toBool(value: unknown, defaults?: boolean): boolean;
34
+ declare function toBool(value: unknown, defaults?: boolean): boolean;
35
+ declare const parseBool: typeof toBool;
36
+ declare function toInteger(value: unknown, defaults?: number, maxValue?: number): number | undefined;
37
+ declare const parseNumber: typeof toInteger;
38
+ declare const toInt: typeof toInteger;
39
+ declare function toFloat(value: unknown, defaults?: number, maxValue?: number): number | undefined;
40
+ declare function toFixed(value: number, precision?: number): string;
41
+ declare function toJSON<T extends object>(str: unknown, defaults?: T): T | undefined;
42
+ declare const parseJson: typeof toJSON;
43
+ declare function toIntlNumber(value: number): string;
44
+ interface ToDurationOptions {
45
+ hideOnZeroValue?: boolean;
46
+ padNumber?: boolean;
47
+ hourUnit?: string;
48
+ minuteUnit?: string;
49
+ secondUnit?: string;
50
+ }
51
+ declare function toDuration(value: number, options?: ToDurationOptions): string;
52
+ declare function toURLParams<T extends object>(value: string, options?: IParseOptions): T;
53
+ declare function toURLQuery(value: Record<string | number, any>, baseUri?: string, options?: IStringifyOptions): string;
33
54
 
34
55
  declare function timestamp(): number;
35
56
  declare function date(str?: string, format?: string): dayjs.Dayjs;
@@ -44,7 +65,9 @@ declare function isNumber(arg: any): boolean;
44
65
  declare function isValidArray(arg: any): boolean;
45
66
  declare function isNan(arg: any): boolean;
46
67
  declare function isSet(arg: any): boolean;
68
+ declare function isWeakSet(arg: any): boolean;
47
69
  declare function isMap(arg: any): boolean;
70
+ declare function isWeakMap(arg: any): boolean;
48
71
  declare function isSymbol(arg: any): boolean;
49
72
  declare function isObject(arg: any): boolean;
50
73
  declare function isDate(arg: any): boolean;
@@ -66,7 +89,7 @@ declare function uniqueArray(arg: any): any[];
66
89
  declare function isNumeric(arg: any, options?: IsNumericOptions): boolean;
67
90
  declare function isURL(arg: any, options?: IsURLOptions): boolean;
68
91
  declare function isEmail(arg: any, options?: IsEmailOptions): boolean;
69
- declare const _default$1: {
92
+ declare const _default: {
70
93
  isUUID: typeof visUUID;
71
94
  isFQDN: typeof visFQDN;
72
95
  isBoolean: typeof isBoolean;
@@ -78,6 +101,8 @@ declare const _default$1: {
78
101
  isNan: typeof isNan;
79
102
  isSet: typeof isSet;
80
103
  isMap: typeof isMap;
104
+ isWeakSet: typeof isWeakSet;
105
+ isWeakMap: typeof isWeakMap;
81
106
  isSymbol: typeof isSymbol;
82
107
  isObject: typeof isObject;
83
108
  isDate: typeof isDate;
@@ -101,7 +126,9 @@ declare const _default$1: {
101
126
  };
102
127
 
103
128
  declare function hs(arg: string): number | undefined;
104
- declare function ms(arg: string): number | undefined;
129
+ declare function ms(arg: string): number | undefined;
130
+ declare const toSecond: typeof hs;
131
+ declare const toMillisecond: typeof ms;
105
132
 
106
133
  declare const commonImageMimeTypes: string[];
107
134
  declare const commonFileMimeTypes: string[];
@@ -111,27 +138,13 @@ declare function nanoid(len?: number): string;
111
138
  declare function nanoidCustomAlphabet(alphabet: string, len?: number): string;
112
139
 
113
140
  declare function pickObject(target: Record<string, any>, fields: Array<string | string[]>, excludes?: Array<string>): Record<string, any>;
141
+ declare function excludeObject(target: Record<string, any>, excludes?: Array<string>): Record<string, any>;
114
142
  declare function pickValidValues<T = string | number | boolean>(target: Record<string, T>, fields: Array<string | string[]>): Record<string, T>;
115
143
  declare function removeObjectNil(target: Record<string, any>): Record<string, any>;
116
144
  declare function copyObjectValues(target: Record<string, any>, dist: Record<string, any>, keyMaps: Array<string | string[]>): void;
117
145
 
118
- declare function parseJson(str: string, defaultValue?: any): any;
119
- declare function parseBool(arg: any, defaultValue?: boolean): boolean;
120
- declare function parseNumber(arg: any, defaultValue?: number, maxValue?: number): number | undefined;
121
146
  declare function htmlToText(html: string, limit?: number): string;
122
147
 
123
- interface QsOptions {
124
- encode?: boolean;
125
- decode?: boolean;
126
- separator?: string;
127
- }
128
- declare function stringify(arg: Record<string, any>, options?: QsOptions): string;
129
- declare function parse(str: string, options?: QsOptions): Record<string, any>;
130
- declare const _default: {
131
- stringify: typeof stringify;
132
- parse: typeof parse;
133
- };
134
-
135
148
  declare enum RandomType {
136
149
  LOWER = 0,
137
150
  UPPER = 1,
@@ -155,4 +168,4 @@ declare function slugify(text: string, options?: SlugifyOptions): string;
155
168
 
156
169
  declare function type(obj: any): string;
157
170
 
158
- export { RandomType, type SlugifyOptions, alpha, alphaHexToRgb, bytes, clone, colorBrightness, commonFileMimeTypes, commonImageMimeTypes, copyObjectValues, darken, date, datePeriod, formatBytes, _default$1 as helper, hexToRgb, hs, htmlToText, invert, isDarkColor, isDateExpired, isHexColor, isLightColor, isRgb, isRgba, lighten, mime, ms, nanoid, nanoidCustomAlphabet, parseBool, parseBytes, parseJson, parseNumber, pickObject, pickValidValues, _default as qs, random, removeObjectNil, rgbToHex, slugify, timestamp, toBool, type, unixDate, unixDiff };
171
+ export { RandomType, type SlugifyOptions, alpha, alphaHexToRgb, bytes, clone, colorBrightness, commonFileMimeTypes, commonImageMimeTypes, copyObjectValues, darken, date, datePeriod, excludeObject, formatBytes, _default as helper, hexToRgb, hs, htmlToText, invert, isDarkColor, isDateExpired, isHexColor, isLightColor, isRgb, isRgba, lighten, mime, ms, nanoid, nanoidCustomAlphabet, parseBool, parseBytes, parseJson, parseNumber, pickObject, pickValidValues, random, removeObjectNil, rgbToHex, slugify, timestamp, toBool, toDuration, toFixed, toFloat, toInt, toInteger, toIntlNumber, toJSON, toMillisecond, toSecond, toURLParams, toURLQuery, type, unixDate, unixDiff };
package/dist/index.js CHANGED
@@ -1,12 +1,14 @@
1
1
  'use strict';
2
2
 
3
3
  var deepObjectDiff = require('deep-object-diff');
4
+ var qs = require('qs');
4
5
  var visUUID = require('validator/lib/isUUID');
5
6
  var visFQDN = require('validator/lib/isFQDN');
6
7
  var visNumeric = require('validator/lib/isNumeric');
7
8
  var visEmail = require('validator/lib/isEmail');
8
9
  var visURL = require('validator/lib/isURL');
9
10
  var _clone = require('clone');
11
+ var vms = require('ms');
10
12
  var dayjs = require('dayjs');
11
13
  var m = require('mime-types');
12
14
  var nanoid$1 = require('nanoid');
@@ -35,12 +37,14 @@ function _interopNamespace(e) {
35
37
  return Object.freeze(n);
36
38
  }
37
39
 
40
+ var qs__default = /*#__PURE__*/_interopDefault(qs);
38
41
  var visUUID__default = /*#__PURE__*/_interopDefault(visUUID);
39
42
  var visFQDN__default = /*#__PURE__*/_interopDefault(visFQDN);
40
43
  var visNumeric__default = /*#__PURE__*/_interopDefault(visNumeric);
41
44
  var visEmail__default = /*#__PURE__*/_interopDefault(visEmail);
42
45
  var visURL__default = /*#__PURE__*/_interopDefault(visURL);
43
46
  var _clone__default = /*#__PURE__*/_interopDefault(_clone);
47
+ var vms__default = /*#__PURE__*/_interopDefault(vms);
44
48
  var dayjs__default = /*#__PURE__*/_interopDefault(dayjs);
45
49
  var m__namespace = /*#__PURE__*/_interopNamespace(m);
46
50
  var objectPath__namespace = /*#__PURE__*/_interopNamespace(objectPath);
@@ -92,9 +96,15 @@ function isNan(arg) {
92
96
  function isSet(arg) {
93
97
  return type(arg) === "set";
94
98
  }
99
+ function isWeakSet(arg) {
100
+ return type(arg) === "weakset";
101
+ }
95
102
  function isMap(arg) {
96
103
  return type(arg) === "map";
97
104
  }
105
+ function isWeakMap(arg) {
106
+ return type(arg) === "weakmap";
107
+ }
98
108
  function isSymbol(arg) {
99
109
  return type(arg) === "symbol";
100
110
  }
@@ -202,6 +212,8 @@ var helper_default = {
202
212
  isNan,
203
213
  isSet,
204
214
  isMap,
215
+ isWeakSet,
216
+ isWeakMap,
205
217
  isSymbol,
206
218
  isObject,
207
219
  isDate,
@@ -385,8 +397,6 @@ function hexToFloatAlpha(arg) {
385
397
  const max = parseInt("0xff", 16);
386
398
  return Number((num / max).toFixed(2));
387
399
  }
388
-
389
- // src/conv.ts
390
400
  function toBool(value, defaults) {
391
401
  if (isEmpty(value)) {
392
402
  return defaults || false;
@@ -396,53 +406,131 @@ function toBool(value, defaults) {
396
406
  }
397
407
  return isTrue(value);
398
408
  }
399
-
400
- // src/hs.ts
401
- var second = 1;
402
- var minute = second * 60;
403
- var hour = minute * 60;
404
- var day = hour * 24;
405
- var week = day * 7;
406
- var year = day * 365;
407
- var regx2 = /^(-?(?:\d+)?\.?\d+)(s|m|h|d|w|y)$/i;
408
- function parse(arg) {
409
- if (isEmpty(arg)) {
410
- return;
409
+ var parseBool = toBool;
410
+ function toInteger(value, defaults, maxValue) {
411
+ let val;
412
+ if (isNumber(value)) {
413
+ val = Number(value);
414
+ } else {
415
+ val = parseInt(value, 10);
411
416
  }
412
- const str = String(arg);
413
- const matches = str.match(regx2);
414
- if (!matches) {
417
+ if (!isFinite(val)) {
418
+ return defaults;
419
+ }
420
+ return maxValue ? Math.min(maxValue, val) : val;
421
+ }
422
+ var parseNumber = toInteger;
423
+ var toInt = toInteger;
424
+ function toFloat(value, defaults, maxValue) {
425
+ let val;
426
+ if (isNumber(value)) {
427
+ val = Number(value);
428
+ } else {
429
+ val = parseFloat(value);
430
+ }
431
+ if (!isFinite(val)) {
432
+ return defaults;
433
+ }
434
+ return maxValue ? Math.min(maxValue, val) : val;
435
+ }
436
+ function toFixed(value, precision = 2) {
437
+ return value.toFixed(precision).replace(/(\.\d*?)0+$/, "$1").replace(/\.$/, "");
438
+ }
439
+ function toJSON(str, defaults) {
440
+ let value;
441
+ if (isValid(str) && isString(str)) {
442
+ try {
443
+ value = JSON.parse(str);
444
+ } catch (e) {
445
+ }
446
+ }
447
+ if (!!defaults && !value) {
448
+ value = defaults;
449
+ }
450
+ return value;
451
+ }
452
+ var parseJson = toJSON;
453
+ var THOUSAND = 1e3;
454
+ var HUNDRED_THOUSAND = 1e5;
455
+ var MILLION = 1e6;
456
+ var HUNDRED_MILLION = 1e8;
457
+ var BILLION = 1e9;
458
+ var HUNDRED_BILLION = 1e11;
459
+ var TRILLION = 1e12;
460
+ function toIntlNumber(value) {
461
+ if (value >= THOUSAND && value < MILLION) {
462
+ const thousands = value / THOUSAND;
463
+ if (thousands === Math.floor(thousands) || value >= HUNDRED_THOUSAND) {
464
+ return Math.floor(thousands) + "K";
465
+ } else {
466
+ return Math.floor(thousands * 10) / 10 + "K";
467
+ }
468
+ } else if (value >= MILLION && value < BILLION) {
469
+ const millions = value / MILLION;
470
+ if (millions === Math.floor(millions) || value >= HUNDRED_MILLION) {
471
+ return Math.floor(millions) + "M";
472
+ } else {
473
+ return Math.floor(millions * 10) / 10 + "M";
474
+ }
475
+ } else if (value >= BILLION && value < TRILLION) {
476
+ const billions = value / BILLION;
477
+ if (billions === Math.floor(billions) || value >= HUNDRED_BILLION) {
478
+ return Math.floor(billions) + "B";
479
+ } else {
480
+ return Math.floor(billions * 10) / 10 + "B";
481
+ }
482
+ } else {
483
+ return `${value}`;
484
+ }
485
+ }
486
+ function durationPad(num, size) {
487
+ return ("000" + num).slice(size * -1);
488
+ }
489
+ function getDuration(num, unit, options) {
490
+ if (options?.hideOnZeroValue && num === 0) {
415
491
  return;
416
492
  }
417
- const num = parseFloat(matches[1]);
418
- const type2 = matches[2].toLowerCase();
419
- switch (type2) {
420
- case "y":
421
- return num * year;
422
- case "w":
423
- return num * week;
424
- case "d":
425
- return num * day;
426
- case "h":
427
- return num * hour;
428
- case "m":
429
- return num * minute;
430
- case "s":
431
- return num * second;
493
+ if (options?.padNumber) {
494
+ return durationPad(num, 2) + unit;
432
495
  }
496
+ return num + unit;
497
+ }
498
+ function toDuration(value, options) {
499
+ const hours = Math.floor(value / 60 / 60);
500
+ const minutes = Math.floor(value / 60) % 60;
501
+ const seconds = Math.floor(value - minutes * 60 - hours * 60 * 60);
502
+ return [
503
+ hours > 0 ? { num: hours, unit: options?.hourUnit || "h" } : null,
504
+ minutes > 0 ? { num: minutes, unit: options?.minuteUnit || "m" } : null,
505
+ { num: seconds, unit: options?.secondUnit || "s" }
506
+ ].filter(Boolean).map(
507
+ (d, i) => getDuration(d.num, d.unit, {
508
+ ...options,
509
+ hideOnZeroValue: i === 0 ? false : options?.hideOnZeroValue
510
+ })
511
+ ).filter(Boolean).join(" ");
512
+ }
513
+ function toURLParams(value, options) {
514
+ return qs.parse(value, options);
515
+ }
516
+ function toURLQuery(value, baseUri, options) {
517
+ const query = qs.stringify(value, options);
518
+ if (baseUri) {
519
+ return baseUri + (baseUri.includes("?") ? "&" : "?") + query;
520
+ }
521
+ return query;
433
522
  }
434
523
  function hs(arg) {
435
- const value = parse(arg);
524
+ const value = ms(arg);
436
525
  if (value) {
437
- return Math.round(value);
526
+ return Math.round(value / 1e3);
438
527
  }
439
528
  }
440
529
  function ms(arg) {
441
- const value = hs(arg);
442
- if (value) {
443
- return value * 1e3;
444
- }
530
+ return vms__default.default(arg);
445
531
  }
532
+ var toSecond = hs;
533
+ var toMillisecond = ms;
446
534
  function timestamp() {
447
535
  return Math.floor(Date.now() / 1e3);
448
536
  }
@@ -532,6 +620,9 @@ function pickObject(target, fields, excludes = []) {
532
620
  });
533
621
  return newObj;
534
622
  }
623
+ function excludeObject(target, excludes = []) {
624
+ return pickObject(target, [], excludes);
625
+ }
535
626
  function pickValidValues(target, fields) {
536
627
  const dist = {};
537
628
  fields.forEach((field) => {
@@ -593,42 +684,6 @@ function copyObjectValues(target, dist, keyMaps) {
593
684
  }
594
685
 
595
686
  // src/parse.ts
596
- function parseJson(str, defaultValue) {
597
- let value;
598
- try {
599
- value = JSON.parse(str);
600
- } catch (e) {
601
- }
602
- if (defaultValue && !value) {
603
- value = defaultValue;
604
- }
605
- return value;
606
- }
607
- function parseBool(arg, defaultValue) {
608
- if (isEmpty(arg)) {
609
- return defaultValue || false;
610
- }
611
- if (isBoolean(arg)) {
612
- return arg;
613
- }
614
- return isTrue(arg);
615
- }
616
- function parseNumber(arg, defaultValue, maxValue) {
617
- if (isNumber(arg)) {
618
- if (maxValue && maxValue < Number(arg)) {
619
- return maxValue;
620
- }
621
- return Number(arg);
622
- }
623
- const num = parseInt(arg, 10);
624
- if (isNaN(num)) {
625
- return defaultValue;
626
- }
627
- if (maxValue && maxValue < num) {
628
- return maxValue;
629
- }
630
- return num;
631
- }
632
687
  function htmlToText(html, limit = 100) {
633
688
  let result = html.replace(/<style[^<>]*>((?!<\/).)*<\/style>/gi, "").replace(/<script[^<>]*>((?!<\/).)*<\/script>/gi, "").replace(/<[^>]+>/g, "").replace(/\t|\r|\n|\r\n/g, "").replace(/\s+/g, "").replace(/&nbsp;/g, " ").replace(/&quot;/g, '"').replace(/&amp;/g, "&").replace(/&lt;/g, "<").replace(/&gt;/g, ">");
634
689
  if (limit > 0) {
@@ -637,48 +692,6 @@ function htmlToText(html, limit = 100) {
637
692
  return result;
638
693
  }
639
694
 
640
- // src/qs.ts
641
- function stringify(arg, options) {
642
- const arr = [];
643
- Object.keys(arg).forEach((key) => {
644
- let val = arg[key];
645
- if (isEmpty(val)) {
646
- val = "";
647
- } else {
648
- val = String(val);
649
- }
650
- if (options?.encode) {
651
- val = encodeURIComponent(val);
652
- }
653
- arr.push(`${key}=${val}`);
654
- });
655
- return arr.join("&");
656
- }
657
- function parse2(str, options) {
658
- const obj = {};
659
- if (!isString(str)) {
660
- return obj;
661
- }
662
- const arr = str.replace(/^([^?]+)?\?/, "").split("&");
663
- arr.forEach((param) => {
664
- const paramArr = param.split("=");
665
- const key = paramArr[0];
666
- if (!isEmpty(key)) {
667
- let val = paramArr[1];
668
- if (options?.decode) {
669
- val = decodeURIComponent(val);
670
- }
671
- val = options?.separator && val.includes(options?.separator) ? val.split(options?.separator) : val;
672
- obj[key] = val;
673
- }
674
- });
675
- return obj;
676
- }
677
- var qs_default = {
678
- stringify,
679
- parse: parse2
680
- };
681
-
682
695
  // src/random.ts
683
696
  var numeric = "0123456789";
684
697
  var hexic = "0123456789abcdef";
@@ -735,6 +748,10 @@ function slugify(text, options) {
735
748
  });
736
749
  }
737
750
 
751
+ Object.defineProperty(exports, "qs", {
752
+ enumerable: true,
753
+ get: function () { return qs__default.default; }
754
+ });
738
755
  Object.defineProperty(exports, "deepEqual", {
739
756
  enumerable: true,
740
757
  get: function () { return fastEquals.deepEqual; }
@@ -759,6 +776,7 @@ exports.copyObjectValues = copyObjectValues;
759
776
  exports.darken = darken;
760
777
  exports.date = date;
761
778
  exports.datePeriod = datePeriod;
779
+ exports.excludeObject = excludeObject;
762
780
  exports.formatBytes = formatBytes;
763
781
  exports.helper = helper_default;
764
782
  exports.hexToRgb = hexToRgb;
@@ -782,13 +800,23 @@ exports.parseJson = parseJson;
782
800
  exports.parseNumber = parseNumber;
783
801
  exports.pickObject = pickObject;
784
802
  exports.pickValidValues = pickValidValues;
785
- exports.qs = qs_default;
786
803
  exports.random = random;
787
804
  exports.removeObjectNil = removeObjectNil;
788
805
  exports.rgbToHex = rgbToHex;
789
806
  exports.slugify = slugify;
790
807
  exports.timestamp = timestamp;
791
808
  exports.toBool = toBool;
809
+ exports.toDuration = toDuration;
810
+ exports.toFixed = toFixed;
811
+ exports.toFloat = toFloat;
812
+ exports.toInt = toInt;
813
+ exports.toInteger = toInteger;
814
+ exports.toIntlNumber = toIntlNumber;
815
+ exports.toJSON = toJSON;
816
+ exports.toMillisecond = toMillisecond;
817
+ exports.toSecond = toSecond;
818
+ exports.toURLParams = toURLParams;
819
+ exports.toURLQuery = toURLQuery;
792
820
  exports.type = type;
793
821
  exports.unixDate = unixDate;
794
822
  exports.unixDiff = unixDiff;